Jump to content
Sign in to follow this  

WinSetState not working

Recommended Posts

Hi Guys,

I am trying to maximise a Citrix Application window.

However, although the script "confirms" that the window has been maximised, it remains unchanged.

Using WinMove was also unsuccessful.

$citrix_window  = "Citrix : "                   ; Start of Citrix Window Title
$citrix_handle  = WinActivate($citrix_window,"")        ; Bring Citrix window to the front and make it active

$hide = WinSetState($citrix_handle,"",@SW_HIDE) ; ***** THIS WORKS *****
$show = WinSetState($citrix_handle,"",@SW_SHOW) ; ***** THIS WORKS *****
$min = WinSetState($citrix_handle,"",@SW_MINIMIZE)  ; ***** THIS WORKS *****
$max = WinSetState($citrix_handle,"",@SW_MAXIMIZE)  ; ***** NOPE *****
$win1 = WinMove($citrix_handle,0,0,@DesktopWidth,@DesktopHeight) ; ***** NOPE *****
$win2 = WinMove("[active]",0,0,@DesktopWidth,@DesktopHeight) ; ***** NOPE *****

MsgBox(262144,"Results","Hide=" & $hide & @crlf & "Show=" & $show & @crlf & "Min =" & $hide & @crlf & "Max =" & $max & @crlf & "Win1=" & $win1 & @crlf & "Win2=" & $win2 & @crlf)

The resultant message box returned "1" for all of the WinSetState commands, indicating success. The WinMove commands returned the correct window handle.

I did also try a  WinGetState after the @SW_MAXIMIZE command, and it returned a value of 47

32 = Window is maximized  ***** This is incorrect. The window is unchanged *****

 8 = Window is active [Correct]

 4 = Window is enabled [Correct]

 2 = Window is enabled [Correct]

 1 = Window exists [Correct]

Likewise, WinMove had zero effect on the active window. Didn't move it or resize it.

Any gurus out there with any ideas as to why it is failing and more importantly a possible solution?

Thanks in advance






Edited by pete_wilde

Share this post

Link to post
Share on other sites
3 minutes ago, orbs said:

can you maximize that window manually?

Yes.  I can manually click on the maximize icon at the top right of the screen or use ALT + Space then scroll down to the Maximize option in the menu.


Share this post

Link to post
Share on other sites

1) when you maximize it, does it look maximized or full-screen? i.e. the title bar still exists?

2) what if, instead of attaching to an existing window, you let your AutoIt script launch the Citrix application?

3) what if there was another hidden window running about? can you WinList() the Citrix window before and after trying to maximize?

4) what if you use _SendMessage() to maximize the window?

Edited by orbs

Share this post

Link to post
Share on other sites
@SW_RESTORE = Undoes a window minimization or maximization


Restore from the minimized or maximized state, and then set your new state.


You also missed a variable in your winmove:

$citrix_handle = GUICreate("my test app")
GUISetState(@SW_SHOW, $citrix_handle)

$hide = WinSetState($citrix_handle,"",@SW_HIDE)
$show = WinSetState($citrix_handle,"",@SW_SHOW)
$min = WinSetState($citrix_handle,"",@SW_MINIMIZE)
$max = WinSetState($citrix_handle,"",@SW_MAXIMIZE)
$win1 = WinMove($citrix_handle,"",0,0,@DesktopWidth,@DesktopHeight)
MsgBox(262144,"Results","Hide=" & $hide & @crlf & "Show=" & $show & @crlf & "Min =" & $hide & @crlf & "Max =" & $max & @crlf & "Win1=" & $win1 & @crlf & @crlf)


Just saw your question with WinGetState as well...that returns the sum of ALL states on the window.  So if a window exists, is visible and is enabled and that is all, the win state is: 7

Use BitAnd to determine if a particular state is present...such as this checking to see if the window is enabled:

If BitAND(WinGetState($win), 4) Then
    ; Is Enabled

If Not BitAND(WinGetState($win), 4) Then
    ; Is Disabled

Everything is working as expected, you just have those first few hurdles of determining what is what.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post

Link to post
Share on other sites

Hi Guys,

Apparently the problem is "Citrix" as it uses a cut-down version of IE6 as an interface, which excludes certain functionality.

AutoIT sends the correct command to Citrix, but as the IE6 has been stripped down it doesn't include that functionality any more.

The workaround is to use send({LWINDOWN}{UP}{LWINUP})  which does the trick.

Thanks to everyone who helped.

Hopefully one day I will as knowledgable as you peeps 🙂


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...