我正在使用WorkRave休息提醒,并希望在其余窗口出现时关闭我的屏幕。 我知道如何关闭它。
如何在指定窗口(#IfWinActive ahk_class ...)出现时创建活动?
另外,我可以绑定%符号吗? {%}不起作用,而不是其他的。
答案 0 :(得分:11)
要显示窗口的即时通知,请使用Shell Hook。这有时是如此之快,以至于autohotkey在你甚至自己看到窗户之前就会做出反应。
AutoHotkey Forum上展示了一个shell挂钩。
您的使用示例(几乎从论坛帖子逐字复制):
#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!
答案 1 :(得分:0)
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