Jump to content
Sign in to follow this  
Sparrowlord

WinSetState

Recommended Posts

Sparrowlord

Hi, I'm trying to use "WinSetState($title, "", @SW_MAXIMIZE)" in my script to make IE8 maximize, however this just creates a blank IE shell window.. and doesn't actually make the window I want bigger.

Edit:

After some more failed attempts I finally realized the problem.

Using WinSetState only works on the 64 bit version of Windows Internet Explorer (Default _IECreate), however I have to use the 32-bit version of Windows Internet Explorer because I have to work with a flash application.

Here's the code I'm trying to use on the 32-bit browser:

#include <IE.au3>
Opt("WinTitleMatchMode", 2)

Run("C:\Program Files (x86)\Internet Explorer\iexplore.exe")
WinWait("- Windows Internet Explorer")
WinSetState("Windows Internet Explorer", "", @SW_MAXIMIZE)

Attached is a screenshot of what happens to the browser window.

post-9779-12643959102843_thumb.jpg

Edited by Sparrowlord

Share this post


Link to post
Share on other sites
natthehe
an alternative solution could be: WinMove($title,'',0,0,@desktopwidth,@desktopheight,0)

Share this post


Link to post
Share on other sites
somdcomputerguy

I just ran this code and it works. Maybe there is an issue with $title. Try changing the TitleMatchMode in your script. Also, I am running this under Vista, so the problem might be with Win7.

Opt("WinTitleMatchMode", 2)
WinSetState("Windows Internet Explorer", "", @SW_MAXIMIZE)

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
Sparrowlord

After some more failed attempts I finally realized the problem.

Using WinSetState only works on the 64 bit version of Windows Internet Explorer (Default _IECreate), however I have to use the 32-bit version of Windows Internet Explorer because I have to work with a flash application.

Here's the code I'm trying to use on the 32-bit browser:

#include <IE.au3>
Opt("WinTitleMatchMode", 2)

Run("C:\Program Files (x86)\Internet Explorer\iexplore.exe")
WinWait("- Windows Internet Explorer")
WinSetState("Windows Internet Explorer", "", @SW_MAXIMIZE)

Attached is a screenshot of what happens to the browser window.

post-9779-12643902473909_thumb.jpg

Share this post


Link to post
Share on other sites
Sparrowlord

updated first post so everybody don't have to read the whole thread to figure out the problem

Share this post


Link to post
Share on other sites
KaFu

If you open IE via run() you don't have to include IE.au3. Additionally you can set @SW_MAXIMIZE in the run() command.

$sPathIE = StringReplace(StringReplace(RegRead("HKEY_CLASSES_ROOT\Applications\iexplore.exe\shell\open\command", ""), " %1", ""), """", "")
If Not FileExists($sPathIE) Then $sPathIE = @ProgramFilesDir & "\Internet Explorer\iexplore.exe"
If Not FileExists($sPathIE) Then
    MsgBox(16, "Error", "Location of iexplore.exe not found")
    Exit
EndIf
$iPID = Run($sPathIE, "", @SW_MAXIMIZE)
Edited by KaFu

Share this post


Link to post
Share on other sites
JerryD

How strange. I haven't written a script in well over a year, and haven't been on the forums for longer, and just yesterday I sat down and wrote a script that does just this! Little did I know I was doing something that couldn't be done. The thing is, the title of the window I was dealing with changed, so what I ended up doing was using the Windows handle like this:

$obj_IE = _IECreate ( 'about:blank', $IECreate_NoAttach, $IECreate_NoVisible, $IECreate_Wait, $IECreate_TakeFocus )
_IENavigate ( $obj_IE, $VPNURL )
_IEAction ( $obj_IE, 'visible' )
_IEAction ( $obj_IE, 'focus' )
$hwnd_IE = _IEPropertyGet ( $obj_IE, 'hwnd' )
WinWait ( 'vpn', '', 1 )
WinActivate ( 'vpn' )
Do     ; Wait for the title of the window to have the word Home in it
    $Ret = WinGetTitle ( $hwnd_IE )
    If $Ret = '' Then Exit
    If StringInStr ( $Ret, 'Home' ) Then
        ExitLoop
    EndIf
    Sleep ( 100 )
Until 1=2
Do     ; Now wait for the window to be minimized by another process
    $Ret = WinGetState ( $hwnd_IE )
    If @error Then Exit
    If $Ret >= 16 Then
        ExitLoop
    EndIf
    Sleep ( 100 )
Until 1=2
WinSetState ( $hwnd_IE, '', @SW_HIDE )
Do     ; Now hide the window and wait for the word Home to NOT be in the title!
    $Ret = WinGetTitle ( $hwnd_IE )
    If $Ret = '' Then Exit
    If NOT StringInStr ( $Ret, 'Home' ) Then
        WinSetState ( $hwnd_IE, '', @SW_SHOW )
        WinSetState ( $hwnd_IE, '', @SW_RESTORE )
        ExitLoop
    EndIf
    Sleep ( 500 )
Until 1=2

This script works exactly as I wanted it to under XP/IE6, Vista/IE7, and Windows 7/IE8 (all 32 bit). Was I just lucky?

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.