Sign in to follow this  
Followers 0
eyc

Activating Windows with States 31 or 5

5 posts in this topic

I discovered some interesting things when I tried activating a window using AutoIt.

There are two cases when a window will not appear after executing a WinActivate command. The first is when a window has a state of 31 and the other is when a window has a state of 5.

Use the WinGetState command to find the state of a window.

According to the help file, a state of 31 indicates that the window is active but minimized. Since the window is already active, the WinActivate command has no effect. To make the window appear though, you must maximize the window by using the WinSetState command.

Getting a window with a state of 5 to appear is a little more difficult. The only method I found to work is to script Alt-Shift-Tab until the window you're looking for appears.

I hope this helps people reliably activate windows in your scripts.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Normally when a Window is minimized the State = 7, but occassionally you will find windows that report a Sate = 5 after a minimize command. What is happening is the Window is being hidden, not minimized.

State = 5 means the Window Exists (1) and is Enabled (4) and is not Visible (2)

A WinSetState(@SW_RESTORE) will restore a window with State = 7

A WinSetState(@SW_SHOW) will restore a window with State = 5

Once restored the State=5 window can then be activated using WinActivate

I was debugging such a situation last week.

Hope that helps.

Edited by cits

.... GOTOs? We don't need no stinkin' GOTOs! ....

Share this post


Link to post
Share on other sites

that didn't seem to work for me. i did a WinSetState(@SW_SHOW) which changed State from 5 to 7. Then i did a WinSetState(@SW_RESTORE) which didn't have any effect on State. Then i did a WinActivate which failed to activate the window. the window i'm trying to activate is microsoft outlook 2010. here's my code:

Opt("WinTitleMatchMode", 2)  ;1=start, 2=subStr
   If @error Then
      MsgBox (0, "error", "setting win title match mode failed")
      Return
   EndIf
 
   $state = WinGetState ("Microsoft Outlook")
   If Not $state Then
     MsgBox (0, "error", "couldn't get state of outlook window")
   EndIf

   If $state = 5 Then
 
      $returnVal = WinSetState ("Microsoft Outlook", "", @SW_SHOW)
      If $returnVal = 0 Then
         MsgBox (0, "error", "couldn't show outlook window")
      EndIf

      $returnVal = WinSetState ("Microsoft Outlook", "", @SW_RESTORE)
      If $returnVal = 0 Then
         MsgBox (0, "error", "couldn't restore outlook window")
      EndIf

      $newstate = WinGetState ("Microsoft Outlook")
      If Not $newstate Then
         MsgBox (0, "error", "couldn't get state of outlook window")
      EndIf

      MsgBox (0, "info", "after SHOW and RESTORE, state is " & $newstate)
   EndIf

   WinActivate("Microsoft Outlook")

Loz,

could you post your fix so i can try it out?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

is window minimized? or the outlook is hidden to tray next to clock?

if its hidden to tray then maybe this can help

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

the outlook window is minimized to the task bar, not tray.

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