Autohotkey event appears

I am using a WorkRave reminder reminder and want to turn off the screen when the stop window appears. I know how to disable it.

How to create an event when the specified window (#IfWinActive ahk_class ...) appears?

Also, can I associate the% character? {%} does not work, not others.

+6
source share
2 answers

To get instant notification of a window, use the Shell Hook. It is sometimes so fast that an autohotkey can react before you even see the window yourself.

The shell of the shell is shown on the AutoHotkey forum .

An example with your use (almost copied verbatim from a forum post):

#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 } } 

If you want to use the literal character% in a command, output it using the AutoHotkey escape character, the back of `(on the same key as ~ on the US keyboard), for example:

 MsgBox You are 200`% awesome! 
+8
source

Romale,

You can try this, but since I am not using WorkRave, I cannot test it.

 ; 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 
0
source

Source: https://habr.com/ru/post/907850/


All Articles