2013-07-22 66 views
0

我試圖使用autohotkey來確認網站的超時消息,並保持會話自動生效。 Winwait似乎是這個理想的功能,但由於某種原因,它沒有做我認爲應該做的事情。winwait沒有捕捉到「來自網頁的消息」

這裏是我寫的是不工作的功能:

DetectHiddenWindows, On 
    SetTitleMatchMode 2 
    winwait, Message from webpage, Your TrackWise session is expiring 
    ControlClick, Button1, Message from webpage, Your TrackWise session is expiring 
    return 

窗口是由Internet Explorer中的彈出窗口。下面是窗口的間諜告訴我關於我要自動檢測並點擊OK窗口:

>>>>>>>>>>(Window Title & Class)<<<<<<<<<<< 
Message from webpage 
ahk_class #32770 

>>>>>>>>>>>>(Mouse Position)<<<<<<<<<<<<< 
On Screen: 1503, 692 (less often used) 
In Active Window: 1219, 259 

>>>>>>>>>(Now Under Mouse Cursor)<<<<<<<< 

Color: 0xF0F0F0 (Blue=F0 Green=F0 Red=F0) 

>>>>>>>>>>(Active Window Position)<<<<<<<<<< 
left: 284  top: 433  width: 484  height: 174 


>>>>>>>>>>>(Status Bar Text)<<<<<<<<<< 

>>>>>>>>>>>(Visible Window Text)<<<<<<<<<<< 
OK 
Cancel 
Your TrackWise session is expiring in 15 minute(s). 
If you would like to continue click OK, otherwise you will be logged off TrackWise. 

>>>>>>>>>>>(Hidden Window Text)<<<<<<<<<<< 

>>>>(TitleMatchMode=slow Visible Text)<<<< 

>>>>(TitleMatchMode=slow Hidden Text)<<<< 

無論出於何種原因,winwait沒有得到它。如果我使用這樣的熱鍵:

#k::ControlClick , Button1, Message from webpage, Your TrackWise session is expiring 

然後贏得+ K點擊鼠標右鍵,保存網頁會話的生命是我想要的,只是沒有自動像我想要的。

有什麼建議嗎?謝謝!!!

+0

我無法用IE10重現這一點。我測試了一個[示例頁面](http://jsfiddle.net/9zxhG/)模擬彈出窗口和代碼(只是'WinWait')。它立即找到創建窗口。 WinWait是否檢測到您機器上的彈出窗口? – MCL

回答

0
titleOption:="ahk_exe iexplore.exe ahk_class #32770", GW_OWNER:=4 
Loop 
{ 
    WinWait, % titleOption 
    WinGet, procName, ProcessName 
     , % "ahk_id "DllCall("GetWindow", "Ptr", hWnd:=WinExist(titleOption) 
             , "UInt", GW_OWNER 
             , "Ptr") 
    If % procName=="IEXPLORE.EXE" 
     ControlClick, % "Button1", % "ahk_id "hWnd 
    Sleep, 250 
}