2016-04-26 81 views
0

我一直在試圖讓一個窗口,在軟件安裝過程中的焦點。該窗口沒有標題。該腳本保持失敗。有人可以告訴我,如果有什麼我可以改變我的腳本?autohotkey焦點沒有標題

這應該共同努力,單擊確定按鈕:

Sleep, 4000. 
Send, {control down} 
MouseClick, Left, 300, 185, 
Send, {Control up} 

的結果是,它會打開谷歌瀏覽器旁邊的Windows的開始菜單,而不是點擊打開的窗口中所確定的點在中間桌面。

我完整的腳本如下:

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. 
;#Warn ; Enable warnings to assist with detecting common errors. 
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. 
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. 

Sleep, 1000 ;language selection and next. 
Send, {tab} 
Sleep, 500 
Send, {tab} 
Sleep, 500 
Send, {tab} 
Sleep, 500 
Sleep, 2000 
Send, {Enter} 

Sleep, 1000 ;directory and installation. 
Send, {tab} 
Sleep, 500 
Send, {tab} 
Sleep, 500 
Send, {tab} 
Sleep, 500 
Send, {tab} 
Sleep, 500 
Send, {tab} 
Sleep, 5000 
Send, {Enter} 
Sleep, 500 
Send, {tab} 
Sleep, 5000 ;for installation wait time. 
Send, {Enter} ;finish. 

Sleep, 7000 
Run "myexecutable.exe" 

Sleep, 4000 ;focus attempt 2. 
Send, {control down} 
MouseClick, Left, 300, 185, 
Send, {Control up} ;for association OK. 

回答

0

你可以用鼠標點擊在相對模式:

CoordMode, Mouse, Window 

這將使點擊相對座標到活動窗口代替屏幕。

因此,計算窗口上需要點擊的位置的新座標,並確保該窗口處於活動狀態。

要獲得窗口句柄,請使用程序的可執行文件名稱。例如,要激活窗口,而不是參數WinTitle使用ahk_exe和進程名稱:

WinActivate, ahk_exe myexecutable.exe 
+0

感謝您的答覆。實際的問題是該窗口沒有「關注」焦點。它不顯示標題,也沒有「隱藏」標題。 我確實嘗試了不同的方法來關注彈出窗口,但都沒有成功。有趣的是,嘗試使用SCREEN的相對座標有時有效,但在97%的時間內失敗(使用完全相同的編碼)。 此外,當我將它作爲一個單獨的片段進行測試時,它的工作成功率更高(50%),繪製精確編碼的座標(空白窗口標題選項)。 –

+0

˙@ JDoe查看更新。 – 2501