Wednesday, January 24, 2024

一个学习通定位输入法批注的ahk代码

#NoEnv  
#Warn
SendMode Input
SetWorkingDir %A_ScriptDir%
SysGet, VirtualWidth, 78
SysGet, VirtualHeight, 79

!s::
count=0
loop, 2
{
if count=0
{__ImageFilePath:="D:\Office\AHKFiles\pizhu.png"
}
else if count=1
{__ImageFilePath:="D:\Office\AHKFiles\wenben.png"
}
else exit
gui,add,picture,hwnd__mypic,%__ImageFilePath%
controlgetpos,,,__img_w,__img_h,,ahk_id %__mypic%
CoordMode, Pixel, Screen
ImageSearch, __FoundX, __FoundY, VirtualWidth*0.2, VirtualHeight*0.8, VirtualWidth, VirtualHeight, *50, %__ImageFilePath%
PicX:=__FoundX + __img_w/2
PicY:=__FoundY + __img_h/2
CoordMode, Mouse, Screen
__ClickX:=PicX
__ClickY:=PicY
__ClickTimes:=1
Click %__ClickX%, %__ClickY%, %__ClickTimes%
count++
sleep 500
}
Return

!w::
__ImageFilePath:="D:\Office\AHKFiles\wancheng.png"
gui,add,picture,hwnd__mypic,%__ImageFilePath%
controlgetpos,,,__img_w,__img_h,,ahk_id %__mypic%
CoordMode, Pixel, Screen
ImageSearch, __FoundX, __FoundY, VirtualWidth*0.5, 0, VirtualWidth, VirtualHeight*0.5,*150, %__ImageFilePath%
PicX:=__FoundX + __img_w/2
PicY:=__FoundY + __img_h/2
CoordMode, Mouse, Screen
__ClickX:=PicX
__ClickY:=PicY
__ClickTimes:=1
Click %__ClickX%, %__ClickY%, %__ClickTimes%
Return

No comments: