2011年4月9日 星期六

AutoHotKey + VS2010

最近在找把 AutoHotKey 放入 VS2010 來開發, 方便結合當辨識某手勢來觸發對應事件.
建置步驟如下:
1.下載 AutoHotKey.dll, 按此連結.
2.加入以下程式碼


typedef int (*ahkdll)(wchar_t *, wchar_t *, wchar_t *);
typedef int (*ahktextdll)(wchar_t *, wchar_t *, wchar_t *);
typedef int (*ahkReady)();
typedef int (*ahkExec)(wchar_t *);


HINSTANCE hinstLib = LoadLibrary(L"AutoHotkey.dll");
if(hinstLib == NULL)
return -2;

ahkdll ahkdll_ = (ahkdll)GetProcAddress(hinstLib, "ahkdll");
if(ahkdll_ == 0)
return -3;
ahktextdll ahktextdll_ = (ahktextdll)GetProcAddress(hinstLib, "ahktextdll");
if(ahktextdll_ == 0)
return -4;
ahkReady ahkReady_ = (ahkReady)GetProcAddress(hinstLib, "ahkReady");
if(ahkReady_ == 0)
return -5;
ahkExec ahkExec_ = (ahkExec)GetProcAddress(hinstLib, "ahkExec");
if(ahkExec_ == NULL)
return -6;

//移動滑鼠
ahktextdll_(L"MouseMove, 20, 30, 50", L"", L"");
//顯示訊息視窗
ahktextdll_(L"MsgBox % A_ScriptDir", L"", L"");
//定義函式
ahktextdll_(L"#persistent \necho(x){\ny := x . \" hello\"\nMsgBox % y\nreturn x\n}", L"", L"");
//呼叫函式(可傳參數)
ahkExec_(L"echo(\"ervis\")");

沒有留言:

張貼留言