AHK与按键精灵内存通信.ahk
#NoEnv #KeyHistory 0 #MaxThreads 255 #SingleInstance Force ; 修改A_ScriptHwnd后,此失效 SetBatchLines -1 ListLines Off SetWorkingDir %A_ScriptDir% if !(A_IsAdmin || InStr(DllCall("GetCommandLine", "Str"), ".exe /r")) RunWait % "*RunAs " (_:=A_IsCompiled ? """" : A_AhkPath " /r """) A_ScriptFullPath (_ ? """" : """ /r") VarSetCapacity(box1, 4, 0) NumPut(0, box1, 0, "int") ; 写入一个初始值 RegWrite, REG_SZ, HKCU\Software\ahkajjl, MemoryGet1, % Format("{:X}", &box1) VarSetCapacity(box2, 4, 0) NumPut(0, box2, 0, "int") RegWrite, REG_SZ, HKCU\Software\ahkajjl, MemoryGet2, % Format("{:X}", &box2) /* VarSetCapacity(box3, 4, 0) NumPut(333, box3, 0, "int") RegWrite, REG_SZ, HKCU\Software\ahkajjl, MemoryGet3, % Format("{:X}", &box3) VarSetCapacity(box4, 4, 0) NumPut(444, box4, 0, "int") RegWrite, REG_SZ, HKCU\Software\ahkajjl, MemoryGet4, % Format("{:X}", &box4) */ DetectHiddenWindows % ("On", DHW:=A_DetectHiddenWindows) WinSetTitle, ahk_id %A_ScriptHwnd%, , 修改ahk隐藏窗口标题与按键精灵通信 DetectHiddenWindows %DHW% ; MsgBox % "内存地址已存到剪贴板:" Clipboard := Format("{:X}", &box1) Run %A_ScriptDir%\超级模拟小精灵.exe, , Hide, 小精灵PID WinWait, ahk_class #32770 ahk_pid %小精灵PID% WinHide, ahk_class #32770 ahk_pid %小精灵PID% ; 隐藏托盘图标用TrayIcon库 OnExit("退出脚本时同步关闭小精灵") Return ; 按住F1填入随机数到此内存地址中,观察变化 F1:: Random, 随机数生成1, 1, 999 Random, 随机数生成2, 1, 999 MouseTo(随机数生成1, 随机数生成2) ; ToolTip % 随机数生成1 " - " 随机数生成2 Return MouseTo(x, y) { Global NumPut(x, box1, 0, "int") NumPut(y, box2, 0, "int") } 退出脚本时同步关闭小精灵() { Loop 10 Process, Close, 超级模拟小精灵.exe } F3::MsgBox % NumGet(box)
超级模拟小精灵源码.Q
Set OMG=CreateObject("WScript.Shell") Dim Read_Key1 Read_Key1 = OMG.RegRead("HKCU\Software\ahkajjl\MemoryGet1") //TracePrint "位置为:"& Read_Key1 post1 = "&h" & Read_Key1 Dim Read_Key2 Read_Key2 = OMG.RegRead("HKCU\Software\ahkajjl\MemoryGet2") //TracePrint "位置为:"& Read_Key2 post2 = "&h" & Read_Key2 Dim Read_Key3 Read_Key3 = OMG.RegRead("HKCU\Software\ahkajjl\MemoryGet3") //TracePrint "位置为:"& Read_Key3 post3 = "&h" & Read_Key3 Dim Read_Key4 Read_Key4 = OMG.RegRead("HKCU\Software\ahkajjl\MemoryGet4") //TracePrint "位置为:"& Read_Key4 post4 = "&h" & Read_Key4 hwnd = Plugin.Window.Find(0, "修改ahk隐藏窗口标题与按键精灵通信") //TracePrint "ahk进程隐藏A_ScriptHwnd:" & hwnd If hwnd = 0 Then ExitScript End If //切换按键精灵超级模拟,3是硬件模拟 SetSimMode 2 //KeyPress 67, 3 //TracePrint "ahk随机数内容1:" & ahkX //TracePrint "ahk随机数内容2:" & ahkY //临时赋值,避免启动时鼠标位移 ahkX=Plugin.Memory.Read32Bit(hwnd,post1) ahkY=Plugin.Memory.Read32Bit(hwnd,post2) TempAHKX = ahkX TempAHKY = ahkY Do ahkX=Plugin.Memory.Read32Bit(hwnd,post1) ahkY=Plugin.Memory.Read32Bit(hwnd,post2) //ahk3=Plugin.Memory.Read32Bit(hwnd,post3) //ahk4=Plugin.Memory.Read32Bit(hwnd,post4) If ahkX <> TempAHKX or ahkY <> TempAHKY Then MoveTo ahkX,ahkY TempAHKX = ahkX TempAHKY = ahkY //lahk3 = ahk3 //lahk4 = ahk4 End If Loop
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)