Slythfox Posted October 18, 2006 Share Posted October 18, 2006 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.") EndIfObviously 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. Link to comment Share on other sites More sharing options...
Paulie Posted October 18, 2006 Share Posted October 18, 2006 (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.") EndIfObviously 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®Øfr§ÚÂ)Ý£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 October 18, 2006 by Paulie Link to comment Share on other sites More sharing options...
MHz Posted October 18, 2006 Share Posted October 18, 2006 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 Link to comment Share on other sites More sharing options...
Slythfox Posted October 18, 2006 Author Share Posted October 18, 2006 Opt('WintitleMatchmode',2)oÝ÷ Ù©e£¢ºZ®Øfr§ÚÂ)Ý£b¶W¬£*.r¥vƲjëh×6 Opt('WintitleMatchmode',2) While 1 If WinActive("- Mozilla Firefox") Then MsgBox(0, "", "Firefox is active.") EndIf WEndYes 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now