0
A
回答
0
你是對的。你可以用這個來代替ImgSearch。
ControlGetPos, x, y, w, h, button1, ahk_class CalcFrame
MsgBox, %x% %y% %w% %h%
return
所以,你會在每次鼠標點擊(只有當目標窗口的標題是活動的)後運行ControlGetPos,然後比較按鈕點擊區域實際鼠標座標。
這裏是計算器一些代碼:
#SingleInstance Force
#Persistent
#IfWinActive, ahk_class CalcFrame
~LButton::
MouseGetPos, MouseX, MouseY
ControlGetPos, ButtonX, ButtonY, ButtonW, ButtonH, button1, ahk_class CalcFrame
ButtonX2:=ButtonX + ButtonW
ButtonY2:=ButtonY + ButtonH
if MouseX between %ButtonX% and %ButtonX2%
{
if MouseY between %ButtonY% and %ButtonY2%
{
MsgBox, You pressed the MC button
}
}
Return
#IfWinActive
0
您是否嘗試過使用ImgSearch來「動態」查找按鈕的XY座標,然後執行if(MouseX => ImageX和MouseX = < ImageX + ImageWidth)?
僞代碼(未測試):
Settimer, FindButton, 1000
Settitlematchmode, 2
Return
FindButton:
IfWinActive, YourAppWindowTitle
ImageSearch, ImageX, ImageY, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\ButtonImage.bmp
Return
#IfWinActive, YourAppWindowTitle
~LButton::
MouseGetPos, MouseX, MouseY
if (MouseX => ImageX and MouseX =< ImageX + ImageWidth)
{
if (MouseY => ImageY and MouseY =< ImageY + ImageHeight)
{
Run your code here
}
}
Return
#IfWinActive
+0
這實際上不是一個壞主意。不過,我寧願使用該按鈕的句柄ID,因爲它更安全,不依賴座標(可能會在其他PC上更改)。 – Ismo 2013-02-28 08:57:27
+0
我明白,這可能值得尋找ID解決方案。我厭倦了用定時器「移動」按鈕(不同的屏幕,移動到屏幕上的窗口等)來解決問題。 – 2013-02-28 11:36:48
相關問題
- 1. 點擊Windows orb(菜單按鈕)時觸發AutoHotkey腳本
- 2. Javascript假點擊觸發子公司彈出窗口被阻止
- 3. 在彈出的父窗口中觸發點擊事件
- 4. 在AutoHotkey中移動窗口不會觸發Windows消息
- 5. 我的點擊DIV沒有被觸發
- 6. 單擊時觸發腳本?
- 7. 檢測前臺窗口的哪個子窗口已被點擊?
- 8. jquery-bing-maps點擊事件沒有從窗口標記觸發
- 9. 父窗口iframe元素觸發器通過簡單JavaScript點擊
- 10. 點擊更改Bootstrap彈出窗口觸發器
- 11. (窗口).scrollTop函數在第一次點擊時不會觸發
- 12. 點擊事件沒有被觸發
- 13. 骨幹當「點擊」事件被觸發
- 14. Autohotkey:從窗口擦除文本(LOTRO)
- 15. 窗口被點擊 - 然後會發生什麼?
- 16. AutoHotKey腳本SendInput
- 17. 的jQuery 1.4.2觸發點擊點擊後觸發綁定
- 18. 提交表單時觸發點擊事件按鈕被觸發
- 19. jQuery的點擊().clickable下課後仍然被觸發被刪除
- 20. AHK腳本點擊窗口程序窗口內不工作的程序中的特定按鈕?
- 21. AutoHotkey腳本在Shift + 3雙擊時發送英鎊(£)
- 22. 通過AutoHotkey的腳本
- 23. AutoHotKey:獲取mdi窗口
- 24. Autohotkey窗口出現事件
- 25. 點擊本地通知不會被觸發
- 26. 點擊窗口中的網格電話
- 27. shell窗口中的可點擊鏈接?
- 28. 虛擬鼠標點擊被另一個窗口覆蓋的窗口
- 29. 觸發ButtonBar點擊
- 30. jQuery觸發點擊
這正是我之後的事情,非常感謝! – Ismo 2013-03-01 07:54:53
不客氣! – 2013-03-01 08:07:29