Check if script is running

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
langben
Posts: 52
Joined: 20 Apr 2016, 00:06

Check if script is running

02 Jun 2017, 03:05

I want to make a script something like this:

Run c:.\hello.ahk
If winexist hello.ahk
Run c:\goodbye.ahk

I understand that i somehow need to use showhiddenwindow and settitlematchmode.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check if script is running

02 Jun 2017, 03:41

Try this:

Code: Select all

F11:: Run, c:.\hello.ahk

F12::
    SetTitleMatchMode, 2
    DetectHiddenWindows, On
    If WinExist("hello.ahk" . " ahk_class AutoHotkey")
        Run, c:\goodbye.ahk
Return
I hope that helps.
langben
Posts: 52
Joined: 20 Apr 2016, 00:06

Re: Check if script is running

02 Jun 2017, 03:59

Nothing happens :/
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check if script is running

02 Jun 2017, 04:42

Please check your system tray for the number of AHK icons. Also consider to post an example for hello.ahk and an example for goodbye.ahk.
I have made up my own examples and it works.

Another way to go from here is you explain what you expect to happen. A statement like yours is not enough information.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Check if script is running

02 Jun 2017, 04:57

wolf_II wrote:Please check your system tray for the number of AHK icons. Also consider to post an example for hello.ahk and an example for goodbye.ahk.
I have made up my own examples and it works.
There's a reason why I always leave a comment like ...

Code: Select all

F12:: ; press F12 to start the script
:lol:
User avatar
Jamjize
Posts: 12
Joined: 16 Apr 2017, 05:17

Re: Check if script is running

18 Apr 2022, 16:04

Code: Select all

#a::
    SetTitleMatchMode, 2
    DetectHiddenWindows, On
	ide := WinExist("Asistente") ;ide=ID in Spanish
	if (ide=="0xe0632") or (ide=="0x0"){
		Run, D:\Programas\Scripts\AHK\Asistente\Asistente.ahk
		MsgBox, Se abrió el asistente ;Opening assistant
	}
	else
	{
		MsgBox, El asistente ya está abierto ;Already open
	}
	;0xe0632/0x0 ← es lo que devuelve WinExist("Asistente") cuando no está abierto
	;Those values are the ones that WinExist("Asistente") returns when "the assistant" is not open
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], bobstoner289 and 207 guests