Problem using Timers Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Lem2001
Posts: 127
Joined: 27 Jun 2017, 17:59

Problem using Timers

23 Jun 2019, 16:08

I have a script with the following code in it (see below).

It contains only 2 timers, and one hotkey.

However, only one of the timers will work at a time (whichever one is written first in the script). I may have been a bit over-enthusiastic with my 'returns', but I just can't seem to find the problem that's stopping the two timers from working together in the same script.

Can anyone spot the problem?


Code: Select all

ListaryTimer:													
SetTimer, HideListarySearchBar, 100						
Return																		
HideListarySearchBar:
IF !WinActive("ahk_class #32770")							
Return
IF WinActive("ahk_class #32770")							
	{
	SetTitleMatchMode, RegEx									
	WinHide ^$ ahk_class Listary_WidgetWin_*		 
	Sleep 5																
	WinHide ^$ ahk_class Listary_WidgetWin_*		; the command repeated to prevent visible flash of the Listary search bar.
	return
	}
Return



#IfWinActive ahk_class #32770

^'::								; Ctrl + '   (i.e Ctrl + @ key)   toggles the Listary File Dialog search bar on and off.
{									; Retains last used on/off state. Works fine with the auto-hide timer function above. 
	SetTitleMatchMode, RegEx									
	SetTimer, HideListarySearchBar, Off					
	DetectHiddenWindows, Off								
	IfWinExist, ^$ ahk_class Listary_WidgetWin_*	
	GoSub, ListaryTimer											
	Else																		
	WinShow, ^$ ahk_class Listary_WidgetWin_*
	return
}
#If



SetTimer, illustratorChecker, 3000
illustratorChecker:
Process, Exist , illustrator.exe
IF !ErrorLevel
	Return
Sleep 500
;MsgBox, illustrator running		; Test line for visually checking when the command is being triggered.
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, Adobe.Illustrator.18\shell, , View
Sleep 2000
SetTimer, illustratorChecker, Off
WinWaitClose, ahk_exe illustrator.exe
SetTimer, illustratorChecker, On
Return

wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Problem using Timers  Topic is solved

23 Jun 2019, 16:13

this line is unreachable:

Code: Select all

SetTimer, illustratorChecker, 3000
Move it into the auto-execute section of the script.
Lem2001
Posts: 127
Joined: 27 Jun 2017, 17:59

Re: Problem using Timers

23 Jun 2019, 17:37

Thank you.

That fixed it. They both work at the same time now.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Darkmaster006, OrangeCat and 149 guests