これは、AutoHotkey.dll (COM インターフェイスを持つ) からアクセスできます。
このライブラリをダウンロードする必要があります。移動しc:\Windows\System32
ます。
そして、システムに登録します (Run, % "regsvr32.exe AutoHotkey.dll"
, % "c:\Windows\System32")
.
次に、VS でコンソール アプリケーション プロジェクトを作成し、[プロジェクト] タブ/[参照の追加] を選択します。
開いたウィンドウで AutoHotkey ライブラリを見つけ、[追加] ボタンをクリックしてウィンドウを閉じます
。このライブラリをプロジェクトに接続すると、これが参照フォルダーに表示されます.
Program.cs ですべてを選択し、このコードを置き換えます:
using System.Threading;
using AutoHotkey;
namespace work_with_AHK_object
{
class Program
{
static void Main()
{
/// write content for ahk script (thread)
string scriptContent=""
//+"#NoTrayIcon\n"
+"#KeyHistory, 0\n"
+"#NoEnv\n"
//+"ListLines, Off\n"
//+"DetectHiddenWindows, On\n"
//+"Process, Priority,, High\n"
+"SetBatchLines, -1\n"
+"SetMouseDelay, 25\n"
//+"Menu, Tray, Icon, % \"shell32.dll\", -153\n"
//+"WinSet, AlwaysOnTop, On, % \"ahk_id\"A_ScriptHwnd\n"
//+"WinSet, Style, -0xC00000, % \"ahk_id\"A_ScriptHwnd\n"
//+"WinMove, % \"ahk_id\"A_ScriptHwnd,, 888, 110, 914, 812\n"
//+"ListLines\n"
//+"ListLines, On\n"
+"TrayTip,, % \"Ready to use!\"\n" /// some notice
+""
+"Ins::\n"
+" Suspend\n"
+" Loop, % A_IsSuspended ? 1:2\n"
+" SoundBeep, 12500, 50\n"
+" KeyWait, % A_ThisHotkey\n"
+" Return\n"
+""
+"LButton::\n"
+" Loop\n"
+" Send, {Click}\n"
+" Until, !GetKeyState(\"LButton\", \"P\")\n"
+" Return\n"
+""
+"Space::\n"
+" Suspend, Off\n"
+" ExitApp";
/// initialize instance
CoCOMServer ahkThread=new CoCOMServer();
/// launch a script in a separate thread
ahkThread.ahktextdll(scriptContent);
/// wait for exit
while (ahkThread.ahkReady()!=0) Thread.Sleep(1000);
}
}
}
プロジェクト プロパティを開き、[アプリケーション] タブで [出力タイプ] を [Windows アプリケーション] に変更します。