1

我有 4 个 AutoHotKey 程序,现在有没有办法将自动热键代码转换为 Visual Studio 代码?我需要这个,因为我正在制作一个 Visual Studio 程序,并且需要一个可以做某事的代码,所以我可以用 autohotkey 来做,但不能用 Visual Studio。也许有一个网站可以转换它或什么的?

其中一个代码是:

    #SingleInstance force
#Persistent

OnExit, ExitRoutine
xpos := A_ScreenWidth/2
ypos := A_ScreenHeight/2
hDrwArea := DllCall("GetDC", "uint", Null)
SetTimer, SetPixel, 1


SetPixel:

DllCall("SetPixel", "uint", hDrwArea, "int", xpos, "int", ypos, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos, "int", ypos - 2, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos, "int", ypos + 2, "uint", 255, "uint", 0, "uint", 0)


DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 2, "int", ypos, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 2, "int", ypos, "uint", 255, "uint", 0, "uint", 0)

; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 6, "int", ypos - 6, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 6, "int", ypos - 6, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 6, "int", ypos + 6, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 6, "int", ypos + 6, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 6, "int", ypos + 6, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 6, "int", ypos - 6, "uint", 255, "uint", 0, "uint", 0)
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 9, "int", ypos - 9, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 9, "int", ypos - 9, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 9, "int", ypos + 9, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 9, "int", ypos + 9, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 9, "int", ypos + 9, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 9, "int", ypos - 9, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos, "int", ypos, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos, "int", ypos - 2, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos, "int", ypos + 2, "uint", 255, "uint", 0, "uint", 0)


DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 2, "int", ypos, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 2, "int", ypos, "uint", 255, "uint", 0, "uint", 0)

; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 6, "int", ypos - 6, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 6, "int", ypos - 6, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 6, "int", ypos + 6, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 6, "int", ypos + 6, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 6, "int", ypos + 6, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 6, "int", ypos - 6, "uint", 255, "uint", 0, "uint", 0)
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 9, "int", ypos - 9, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 9, "int", ypos - 9, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 9, "int", ypos + 9, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 9, "int", ypos + 9, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 9, "int", ypos + 9, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 9, "int", ypos - 9, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos, "int", ypos, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos, "int", ypos - 2, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos, "int", ypos + 2, "uint", 255, "uint", 0, "uint", 0)


DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 2, "int", ypos, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 2, "int", ypos, "uint", 255, "uint", 0, "uint", 0)

; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 6, "int", ypos - 6, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 6, "int", ypos - 6, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 6, "int", ypos + 6, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 6, "int", ypos + 6, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 6, "int", ypos + 6, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 6, "int", ypos - 6, "uint", 255, "uint", 0, "uint", 0)
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 9, "int", ypos - 9, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 9, "int", ypos - 9, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 9, "int", ypos + 9, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 9, "int", ypos + 9, "uint", 255, "uint", 0, "uint", 0)

DllCall("SetPixel", "uint", hDrwArea, "int", xpos - 9, "int", ypos + 9, "uint", 255, "uint", 0, "uint", 0)
DllCall("SetPixel", "uint", hDrwArea, "int", xpos + 9, "int", ypos - 9, "uint", 255, "uint", 0, "uint", 0)

Return

ExitRoutine:

ExitApp
4

1 回答 1

0

与其将 Autohotkey 代码转换为 C# 或 VB.NET,不如尝试使您的 AHK 脚本可从另一个程序调用。将 AHK 脚本编译为 exe 可能是一个很好的解决方案。来回传递数据可能很棘手,但它可能比转换代码更容易。

于 2013-10-31T02:19:03.640 回答