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. 從Electron主腳本中觸發點擊
- 3. Javascript假點擊觸發子公司彈出窗口被阻止
- 4. 在彈出的父窗口中觸發點擊事件
- 5. 觸發鼠標點擊通過JavaScript中的窗口偏移量
- 6. 在AutoHotkey中移動窗口不會觸發Windows消息
- 7. 如何用autohotkey點擊窗口上的特定按鈕?
- 8. 我的點擊DIV沒有被觸發
- 9. 的onClick觸發時,孩子被點擊
- 10. 單擊時觸發腳本?
- 11. 檢測前臺窗口的哪個子窗口已被點擊?
- 12. 按鈕點擊事件沒有在彈出窗口中觸發
- 13. 的AutoHotkey - ControlClick內窗口
- 14. 當彈出窗口打開時,按鈕點擊事件不會被觸發
- 15. 點擊我的圖片時,jQuery點擊事件未被觸發
- 16. 當窗口B關閉時,窗口A中的函數如何被觸發?
- 17. 觸發摺疊菜單從鏈接點擊新窗口
- 18. 谷歌地圖點擊觸發信息窗口InfoWindow
- 19. 窗口popstate後2次點擊只觸發,每兩個
- 20. jquery-bing-maps點擊事件沒有從窗口標記觸發
- 21. jQuery Waypoints只在元素點擊窗口頂部時觸發
- 22. 點擊輸入字段觸發器窗口調整大小android
- 23. 父窗口iframe元素觸發器通過簡單JavaScript點擊
- 24. 觸發點擊事件時無限新窗口循環
- 25. 點擊輸入欄觸發窗口調整大小
- 26. 點擊更改Bootstrap彈出窗口觸發器
- 27. (窗口).scrollTop函數在第一次點擊時不會觸發
- 28. 點擊事件沒有被觸發
- 29. 骨幹當「點擊」事件被觸發
- 30. Jquery mobile點擊事件未被觸發
這正是我之後的事情,非常感謝! – Ismo 2013-03-01 07:54:53
不客氣! – 2013-03-01 08:07:29