Best way to check if process and win exists in one line

Get help with using AutoHotkey and its commands and hotkeys
Yanush Kartov

Best way to check if process and win exists in one line

22 Apr 2018, 10:13

What am I doing wrong here?? I want to check if my game is running and if the window is not exists,

Code: [Select all] [Download] GeSHi © Codebox Plus

If ProcessExist("spongeball.exe")  && !WinExist ("ahk_exe spongeball.exe")
MsgBox Remember to turn off


ProcessExist(Name){
Process,Exist,%Name%
return Errorlevel
}
swagfag
Posts: 1090
Joined: 11 Jan 2017, 17:59

Re: Best way to check if process and win exists in one line

22 Apr 2018, 11:30

since Porcess, Exist and WinExist when used with "ahk_exe" are effectively the same, u got this going on:

Code: [Select all] [Download] GeSHi © Codebox Plus

A | (A ∧ ¬A)
--|---------
F | F
T | F

unreachable code, what are contradictions for 200, alex?
Last edited by swagfag on 22 Apr 2018, 13:59, edited 1 time in total.
Yanush Kartov

Re: Best way to check if process and win exists in one line

22 Apr 2018, 12:19

swagfag wrote:since Porcess, Exist and WinExist when used with "ahk_exe" are effectively the same, u got this going on:

Code: [Select all] [Download] GeSHi © Codebox Plus

A | (A ∧ ¬A)
--|---------
F | F
T | F

unreachable code, what are contradictions for 200, alex?


a process can exist without its window being shown. So back to my question - how can I check if a process exists BUT its window is not exist
swagfag
Posts: 1090
Joined: 11 Jan 2017, 17:59

Re: Best way to check if process and win exists in one line

22 Apr 2018, 14:00

youre right i overlooked that

Code: [Select all] [Download] GeSHi © Codebox Plus

If ProcessExist("svchost.exe")  && !WinExist("ahk_exe svchost.exe")
MsgBox Remember to turn off


ProcessExist(Name){
Process,Exist,%Name%
return Errorlevel
}


the following works for me, the only thing ive modified from your original script was deleting the space between WinExist (), this is a syntax error and doesnt call the function
Yanush Kartov

Re: Best way to check if process and win exists in one line

22 Apr 2018, 18:11

swagfag wrote:youre right i overlooked that

Code: [Select all] [Download] GeSHi © Codebox Plus

If ProcessExist("svchost.exe")  && !WinExist("ahk_exe svchost.exe")
MsgBox Remember to turn off


ProcessExist(Name){
Process,Exist,%Name%
return Errorlevel
}


the following works for me, the only thing ive modified from your original script was deleting the space between WinExist (), this is a syntax error and doesnt call the function


i see it works with svchost, however, with my game and even iexplore.exe it does not work, for example, if i have the process hidden (winhide) it will still see it as winexist :headwall:
User avatar
jeeswg
Posts: 4977
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Best way to check if process and win exists in one line

23 Apr 2018, 01:41

I hid Internet Explorer, but still found a window with class 'Alternate Owner'. I set SetTitleMatchMode to RegEx, to make it look for a window that had a window title of at least one character, and then it didn't find any windows.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Yanush Kartov

Re: Best way to check if process and win exists in one line

23 Apr 2018, 03:06

jeeswg wrote:I hid Internet Explorer, but still found a window with class 'Alternate Owner'. I set SetTitleMatchMode to RegEx, to make it look for a window that had a window title of at least one character, and then it didn't find any windows.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



I used your code to try to build a test. When I run the script it launched hidden IE. Now when I hit q I would like for it to tell me if there IE hidden or not.

Can you help me fix the code for that please?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
jeeswg
Posts: 4977
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Best way to check if process and win exists in one line

23 Apr 2018, 06:58

Here's some example code.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], blue83 and 73 guests