blahdaze Posted November 7, 2007 Share Posted November 7, 2007 Longtime AutoIt-er, first time poster. I'd like to add a feature to a larger app that I have, using the WinGetState function. To "play" with the functionality of the function I wrote the following applet <more>: CODE Opt("WinTitleMatchMode",4) $WindowToObserveTitle = InputBox("Window title to observe:","Please enter the beginning of the window title to observe:") While 1 $SCState = WinGetState($WindowToObserveTitle,"") Select Case $SCState = 1 ;Window exists ToolTip($WindowToObserveTitle & " window exists",1,1) Case $SCState = 2 ;Window is visible ToolTip($WindowToObserveTitle & " window is visible",1,1) Case $SCState = 4 ;Window is enabled ToolTip($WindowToObserveTitle & " window is currently enabled",1,1) Case $SCState = 8 ;Window is active ToolTip($WindowToObserveTitle & " window active",1,1) Case $SCState = 16 ;Window is minimized ToolTip($WindowToObserveTitle & " window minimized",1,1) Case $SCState = 32 ;Window is maximized ToolTip($WindowToObserveTitle & " window maximized",1,1) Case Else ToolTip($WindowToObserveTitle & " window status unknown",1,1) EndSelect WEnd What I don't get is that in the larger application I do stuff with window titles all the time. I've tried changing the WinTitleMatchMode to all four settings. So what am I missing? If I can get this working, I can begin working on getting my larger toolbar app to follow around the window of the application it's used with. Perhaps someone has a better idea altogether on how to accomplish this? Hugs, Blah Link to comment Share on other sites More sharing options...
Nahuel Posted November 7, 2007 Share Posted November 7, 2007 Help file:WinGetState()Returns a value indicating the state of the window. Multiple values are added together so use BitAND() to examine the part you are interested in Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 7, 2007 Moderators Share Posted November 7, 2007 Your code doesn't move on past the Input box code until you've actually pressed ok/cancel, so getting its state from one script isn't going to happen like this. An alternative could be to do the InputBox separate with something like /AutoIt3ExecuteLine, or if you need the value from InputBox then /AutoIt3ExecuteScript Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Bowmore Posted November 7, 2007 Share Posted November 7, 2007 (edited) Longtime AutoIt-er, first time poster. I'd like to add a feature to a larger app that I have, using the WinGetState function. To "play" with the functionality of the function I wrote the following applet <more>: CODE Opt("WinTitleMatchMode",4) $WindowToObserveTitle = InputBox("Window title to observe:","Please enter the beginning of the window title to observe:") While 1 $SCState = WinGetState($WindowToObserveTitle,"") Select Case $SCState = 1 ;Window exists ToolTip($WindowToObserveTitle & " window exists",1,1) Case $SCState = 2 ;Window is visible ToolTip($WindowToObserveTitle & " window is visible",1,1) Case $SCState = 4 ;Window is enabled ToolTip($WindowToObserveTitle & " window is currently enabled",1,1) Case $SCState = 8 ;Window is active ToolTip($WindowToObserveTitle & " window active",1,1) Case $SCState = 16 ;Window is minimized ToolTip($WindowToObserveTitle & " window minimized",1,1) Case $SCState = 32 ;Window is maximized ToolTip($WindowToObserveTitle & " window maximized",1,1) Case Else ToolTip($WindowToObserveTitle & " window status unknown",1,1) EndSelect WEnd What I don't get is that in the larger application I do stuff with window titles all the time. I've tried changing the WinTitleMatchMode to all four settings. So what am I missing? If I can get this working, I can begin working on getting my larger toolbar app to follow around the window of the application it's used with. Perhaps someone has a better idea altogether on how to accomplish this? A couple of points. The value returned by WinGetState() is a combination of the available values you need to BitAnd() it to check which states are current Calling WinGetState() when the tooltip is visible seems to always return a value of 7 Exist, Visible and Active? One thing that does not seem to work correctly is the minimised is not set when a window is minimised to the taskbar in Win XP I've ammended your code I now works for me Opt("WinTitleMatchMode", 4) $WindowToObserveTitle = InputBox("Window title to observe:", "Please enter the beginning of the window title to observe:") While 1 ToolTip("") $SCState = WinGetState($WindowToObserveTitle, "") Select Case BitAND($SCState,32) = 32 ;Window is maximized ToolTip($WindowToObserveTitle & " window maximized", 1, 1) Case BitAND($SCState,16) = 16 ;Window is minimized ToolTip($WindowToObserveTitle & " window is minimized", 1, 1) Case BitAND($SCState,8) = 8 ;Window is enabled ToolTip($WindowToObserveTitle & " window is currently enabled", 1, 1) Case BitAND($SCState,4) = 4 ;Window is active ToolTip($WindowToObserveTitle & " Window is active", 1, 1) Case BitAND($SCState,2) = 2 ;Window is visible ToolTip($WindowToObserveTitle & " window is visible", 1, 1) Case BitAND($SCState,1) = 1 ;Window exists ToolTip($WindowToObserveTitle & " window exists", 1, 1) Case Else ToolTip($WindowToObserveTitle & " window status unknown", 1, 1) EndSelect Sleep(200) WEnd Edited November 7, 2007 by Bowmore "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 7, 2007 Moderators Share Posted November 7, 2007 (edited) A couple of points. The value returned by WinGetState() is a combination of the available values you need to BitAnd() it to check which states are current Calling WinGetState() when the tooltip is visible seems to always return a value of 7 Exist, Visible and Active? One thing that does not seem to work correctly is the minimised is not set when a window is minimised to the taskbar in Win XP I've ammended your code I now works for me Opt("WinTitleMatchMode", 4) $WindowToObserveTitle = InputBox("Window title to observe:", "Please enter the beginning of the window title to observe:") While 1 ToolTip("") $SCState = WinGetState($WindowToObserveTitle, "") Select Case BitAND($SCState,32) = 32 ;Window is maximized ToolTip($WindowToObserveTitle & " window maximized", 1, 1) Case BitAND($SCState,16) = 16 ;Window is minimized ToolTip($WindowToObserveTitle & " window is minimized", 1, 1) Case BitAND($SCState,8) = 8 ;Window is enabled ToolTip($WindowToObserveTitle & " window is currently enabled", 1, 1) Case BitAND($SCState,4) = 4 ;Window is active ToolTip($WindowToObserveTitle & " Window is active", 1, 1) Case BitAND($SCState,2) = 2 ;Window is visible ToolTip($WindowToObserveTitle & " window is visible", 1, 1) Case BitAND($SCState,1) = 1 ;Window exists ToolTip($WindowToObserveTitle & " window exists", 1, 1) Case Else ToolTip($WindowToObserveTitle & " window status unknown", 1, 1) EndSelect Sleep(200) WEndWhat do you mean it works for you? Since when does the return value of InputBox() give you a handle? Edit: I see what you are saying now... I saw that and totally got thrown off (Using the input info to get the title ) Edited November 7, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
NomadRJ Posted November 9, 2007 Share Posted November 9, 2007 A couple of points. The value returned by WinGetState() is a combination of the available values you need to BitAnd() it to check which states are current Calling WinGetState() when the tooltip is visible seems to always return a value of 7 Exist, Visible and Active? One thing that does not seem to work correctly is the minimised is not set when a window is minimised to the taskbar in Win XP I've ammended your code I now works for me Opt("WinTitleMatchMode", 4) $WindowToObserveTitle = InputBox("Window title to observe:", "Please enter the beginning of the window title to observe:") While 1 ToolTip("") $SCState = WinGetState($WindowToObserveTitle, "") Select Case BitAND($SCState,32) = 32 ;Window is maximized ToolTip($WindowToObserveTitle & " window maximized", 1, 1) Case BitAND($SCState,16) = 16 ;Window is minimized ToolTip($WindowToObserveTitle & " window is minimized", 1, 1) Case BitAND($SCState,8) = 8 ;Window is enabled ToolTip($WindowToObserveTitle & " window is currently enabled", 1, 1) Case BitAND($SCState,4) = 4 ;Window is active ToolTip($WindowToObserveTitle & " Window is active", 1, 1) Case BitAND($SCState,2) = 2 ;Window is visible ToolTip($WindowToObserveTitle & " window is visible", 1, 1) Case BitAND($SCState,1) = 1 ;Window exists ToolTip($WindowToObserveTitle & " window exists", 1, 1) Case Else ToolTip($WindowToObserveTitle & " window status unknown", 1, 1) EndSelect Sleep(200) WEnd Bowmore, it doesn't work for me, saying that the window is always active.... [ ]s NomadRJ Link to comment Share on other sites More sharing options...
Bowmore Posted November 10, 2007 Share Posted November 10, 2007 Bowmore, it doesn't work for me, saying that the window is always active.... [ ]s NomadRJ It's working for me although I did have active and enabled transposed. Maybe it was not the best script to demonstrate how WinGetState() works so I've rewriten the code so that the tooltip displays ALL the states of the window with the title specified in the input box. Try running this and playing around with the window. Opt("WinTitleMatchMode", 4) $WindowToObserveTitle = InputBox("Window title to observe:", "Please enter the beginning of the window title to observe the status of:") Dim $Msg = "" While 1 ToolTip("") $SCState = WinGetState($WindowToObserveTitle, "") $Msg = " window " If BitAND($SCState,1) = 0 Then $Msg &= " does not exist" If BitAND($SCState,1) = 1 Then $Msg &= " exists" If BitAND($SCState,2) = 2 Then $Msg &= " and is visible" If BitAND($SCState,4) = 4 Then $Msg &= " and is enabled" If BitAND($SCState,8) = 8 Then $Msg &= " and is active" If BitAND($SCState,16) = 16 Then $Msg &= " and is minimized" If BitAND($SCState,32) = 32 Then $Msg &= " and is maximized" If $Msg = " window " Then $Msg = " window status is unknown" ToolTip($WindowToObserveTitle & $Msg, 1, 1) Sleep(500) WEnd "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook 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