Sign in to follow this  
Followers 0
Slythfox

WinActive & ProcessExists

4 posts in this topic

I'm trying to set an if case so that if the window of an exe is the active window, then... [insert code here].

Basically something like this, but of course, this doesn't work:

If WinActive("firefox.exe") Then
MsgBox(0, "", "Firefox is active.")
EndIf
Obviously the title of many programs, like firefox, changes. Thus you see my problem.

Yes, I know I could set WinActive to wait for a match any substring in the title, in this case "Mozilla Firefox," but I need this to work with programs that don't necessarily have an identifier like "Notepad" or "Mozilla Firefox" attached to the end of their titles.

Any ideas? Thanks.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm trying to set an if case so that if the window of an exe is the active window, then... [insert code here].

Basically something like this, but of course, this doesn't work:

If WinActive("firefox.exe") Then
MsgBox(0, "", "Firefox is active.")
EndIf
Obviously the title of many programs, like firefox, changes. Thus you see my problem.

Yes, I know I could set WinActive to wait for a match any substring in the title, in this case "Mozilla Firefox," but I need this to work with programs that don't necessarily have an identifier like "Notepad" or "Mozilla Firefox" attached to the end of their titles.

Any ideas? Thanks.

Opt('WintitleMatchmode',2)oÝ÷ Ù©e£¢ºZ®Øf­r§ÚÂ)Ý£b¶W¬£*.r¥vƲjëh×6
Opt('WintitleMatchmode',2)
While 1
    If WinActive("- Mozilla Firefox") Then
        MsgBox(0, "", "Firefox is active.")
    EndIf
WEnd
Edited by Paulie

Share this post


Link to post
Share on other sites

Another option is using Classname for the title.

Opt('WintitleMatchmode', 4)
While 1
    If WinActive("classname=MozillaUIWindowClass") Then
        MsgBox(0, "", "Firefox is active.")
    EndIf
WEnd

:lmao:

Share this post


Link to post
Share on other sites

Opt('WintitleMatchmode',2)oÝ÷ Ù©e£¢ºZ®Øf­r§ÚÂ)Ý£b¶W¬£*.r¥vƲjëh×6
Opt('WintitleMatchmode',2)
While 1
    If WinActive("- Mozilla Firefox") Then
        MsgBox(0, "", "Firefox is active.")
    EndIf
WEnd
Yes I know I can do that, which is what I meant by "Yes, I know I could set WinActive to wait for a match any substring in the title..."

I'm using this method for now. I guess I should probably make a request for WinActive to also be by .exe

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0