2023-06-03|閱讀時間 ‧ 約 8 分鐘

AHK-偵圖點擊-視窗更名-腳本

^+Z::
Loop,1{
CoordMode, Menu, Screen
CoordMode, Mouse, Screen
Menu,MyMenu,Add,O__________[當前滑鼠座標並存記事本],開啟_當前滑鼠座標並存記事本
Menu,MyMenu,Add,P____[偵測圖片左上角座標],開啟_偵測圖片左上角座標
Menu,MyMenu,Add,Q__[移動至目標座標並點擊],開啟_移動到目標座標並點擊
Menu,MyMenu,Add,C__________[當前視窗名稱],開啟_當前視窗名稱
Menu,MyMenu,Add,V__________[當前滑鼠座標],開啟_當前滑鼠座標
Menu,MyMenu,Add,B______[更改當前視窗名稱],開啟_更改當前視窗名稱
MouseGetPos,MX,MY
Menu,MyMenu,Show,% MX,% MY
Menu,MyMenu,DeleteAll
return
開啟_當前滑鼠座標並存記事本:
WinSet, AlwaysOnTop, Off, 新分頁 - Google Chrome
WinActivate, 新分頁 - Google Chrome
WinWaitActive, 新分頁 - Google Chrome
CoordMode, Mouse, Screen
MouseGetPos, X0, Y0
FileDelete, D:\AutoHotkeyPortable\App\AutoHotkey\gotpost_X0.txt
FileDelete, D:\AutoHotkeyPortable\App\AutoHotkey\gotpost_Y0.txt
FileAppend, %X0%, D:\AutoHotkeyPortable\App\AutoHotkey\gotpost_X0.txt
FileAppend, %Y0%, D:\AutoHotkeyPortable\App\AutoHotkey\gotpost_Y0.txt
return
開啟_偵測圖片左上角座標:
WinSet, AlwaysOnTop, Off, 新分頁 - Google Chrome
WinActivate, 新分頁 - Google Chrome
WinWaitActive, 新分頁 - Google Chrome
CoordMode, Pixel, Screen
ImageSearch, X1, Y1, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Users\jason\Desktop\U2-01.PNG
If ErrorLevel = 0
{
MsgBox, 成功取得圖片座標
FileRead, X0, D:\AutoHotkeyPortable\App\AutoHotkey\gotpost_X0.txt
FileRead, Y0, D:\AutoHotkeyPortable\App\AutoHotkey\gotpost_Y0.txt
W0 := X0 - X1
H0 := Y0 - Y1
FileDelete, D:\AutoHotkeyPortable\App\AutoHotkey\gotpost_W0.txt
FileDelete, D:\AutoHotkeyPortable\App\AutoHotkey\gotpost_H0.txt
FileAppend, %W0%, D:\AutoHotkeyPortable\App\AutoHotkey\gotpost_W0.txt
FileAppend, %H0%, D:\AutoHotkeyPortable\App\AutoHotkey\gotpost_H0.txt
}
else if ErrorLevel = 1
{
MsgBox, 依來源圖片比對,沒有找到圖片
}
else
{
MsgBox, 沒有找到來源圖片
}
return
開啟_移動到目標座標並點擊:
WinSet, AlwaysOnTop, Off, 新分頁 - Google Chrome
WinActivate, 新分頁 - Google Chrome
WinWaitActive, 新分頁 - Google Chrome
CoordMode, Pixel, Window
ImageSearch, X3, Y3, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Users\jason\Desktop\U2-01.PNG
If ErrorLevel = 0
{
FileRead, W0, D:\AutoHotkeyPortable\App\AutoHotkey\gotpost_W0.txt
FileRead, H0, D:\AutoHotkeyPortable\App\AutoHotkey\gotpost_H0.txt
X4 := X3 + W0
Y4 := Y3 + H0
MouseMove, X4, Y4, 0
Click
}
else if ErrorLevel = 1
{
MsgBox, 依來源圖片比對,沒有找到圖片
}
else
{
MsgBox, 沒有找到來源圖片
}
return
開啟_當前視窗名稱:
WinGetActiveTitle,WinTitle
Msgbox,%WinTitle%
return
開啟_當前滑鼠座標:
CoordMode, Mouse, Screen
MouseGetPos, posX, posY
Msgbox,(%posX%`,%posY%)
return
開啟_更改當前視窗名稱:
InputBox, NewWindowTitle, 視窗名稱修改, 請輸入新的視窗名稱:
If ErrorLevel
{
MsgBox, 使用者取消了操作.
return
}
WinGet, ActiveWindow, ID, A
WinSetTitle, ahk_id %ActiveWindow%, , %NewWindowTitle%
MsgBox, 視窗名稱已修改為:%NewWindowTitle%
return
}
Return
分享至
成為作者繼續創作的動力吧!
© 2024 vocus All rights reserved.