我正在使用WorkRave休息提醒並希望在出現其他窗口時關閉我的屏幕。 我知道如何關閉它。Autohotkey窗口出現事件
在指定窗口(#IfWinActive ahk_class ...)出現時如何創建事件?
另外,我可以綁定%符號嗎? {%}不起作用,而不是其他的。
我正在使用WorkRave休息提醒並希望在出現其他窗口時關閉我的屏幕。 我知道如何關閉它。Autohotkey窗口出現事件
在指定窗口(#IfWinActive ahk_class ...)出現時如何創建事件?
另外,我可以綁定%符號嗎? {%}不起作用,而不是其他的。
要立即通知出現窗口,請使用Shell掛鉤。有時這個速度非常快,以至於在您自己看到窗戶之前,autohotkey會作出反應。
一個外殼掛鉤在AutoHotkey Forum上顯示。
與您的使用情況(幾乎是從論壇帖子逐字複製)的一個例子:
#Persistent
SetBatchLines, -1
Process, Priority,, High
Gui +LastFound
hWnd := WinExist()
DllCall("RegisterShellHookWindow", UInt,hWnd)
MsgNum := DllCall("RegisterWindowMessage", Str,"SHELLHOOK")
OnMessage(MsgNum, "ShellMessage")
Return
ShellMessage(wParam,lParam)
{
If (wParam = 1) ; HSHELL_WINDOWCREATED := 1
{
WinGetTitle, Title, ahk_id %lParam%
If (Title = "WorkRest")
WinClose, ahk_id %lParam% ; close it immideately
}
}
如果你想在命令中使用文字%符號,在AutoHotkey中的轉義字符,倒引號`轉義(與美國鍵盤上的〜相同) -
MsgBox You are 200`% awesome!
這太棒了,效果很棒!看看[這個答案](http://superuser.com/a/266240/16847)。你能設計你的腳本來做到這一點嗎?即檢測所有現有的窗口,看看以前是否看過? – Vijay 2014-04-23 09:01:37
Romale,
你可以試試這個,但因爲我不使用WorkRave,我無法測試它。
; This next line needs to be added at the top of the AHK file, so it will be started as soon as AHK starts.
; Every 120000 ms, it will launch the "WorkRave:" script to check if a window with WorkRave exists.
SetTimer, WorkRave,120000 ; Run WorkRaveTester every 2 minutes = 120000
; Somewhere else in the AHK file.....
WorkRave: ; This is the label for the WorkRave script
SetTitleMatchMode, 2 ; 2 = Matches the string WorkRave anywhere in the window title of IfWinExist
IfWinExist, WorkRave ; When WorkRave window exists
{
TrayTip, WorkRave, Started ,1 ; Or whatever you want to do here....
}
Return
Romale,當此WorkRave休息提醒處於活動狀態時,您可以打開窗戶間諜嗎?通過右鍵單擊AHK圖標打開Windows Spy。窗戶間諜將永遠在頂部。當您激活WorkRave屏幕時,您應該看到詳細信息(包括ahk_class)。我不知道你想用%符號做什麼。 – 2012-02-07 16:33:34
Romale,到目前爲止運氣如何? – 2012-02-08 17:50:33
1. Windows間諜無法抓到workrave的第一個留在最高警告。但我通過窗口列表(ahk_class)捕獲它。我怎樣才能綁定一個行動,當它出現? 2.示例,不起作用: 5 :: {%} %:: {5} – 2012-02-09 10:45:30