Sign in to follow this  
Followers 0
RadovanJ

Problem with @SW_MAXIMIZE

12 posts in this topic

Hi All,

I am having a small problem with the @SW_MAXIMIZE setting.

If I use this switch with the 'WinSetState' command, the window is maximized correctly, but if I then click (manually, haven't tried it in a script) the minimize button, it does nothing. I can use the button to switch between maximized and not maximized, but I can't minimize the window when it's maximized. Even when script is finished.

I think this is true only with some type of third party applications.

Have anyone same experience with this problem ?

Is this a bug in AutoIt, or something else?

Thanks

RadovanJ

Share this post


Link to post
Share on other sites

Hi All,

I am having a small problem with the @SW_MAXIMIZE setting.

If I use this switch with the 'WinSetState' command, the window is maximized correctly, but if I then click (manually, haven't tried it in a script) the minimize button, it does nothing. I can use the button to switch between maximized and not maximized, but I can't minimize the window when it's maximized. Even when script is finished.

I think this is true only with some type of third party applications.

Have anyone same experience with this problem ?

Is this a bug in AutoIt, or something else?

Thanks

RadovanJ

You'll have to post something that reproduces the symptoms. If you can't, it's hardly an AutoIt issue...

; Open notepad to monitor test
Run("notepad.exe")
WinWait("Untitled - Notepad")
$hWin = WinGetHandle("Untitled - Notepad")
If Not WinActive($hWin) Then WinActivate($hWin)
WinWaitActive($hWin)

WinSetState($hWin, "", @SW_MAXIMIZE)

MsgBox(64, "Test", "Manually minimize the notepad window then click OK...")
Sleep(1000)

WinSetState($hWin, "", @SW_MAXIMIZE)
MsgBox(64, "Test", "One more time: Manually minimize the notepad window then click OK...")

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Hi,

yes, I know.

I can reproduce this problem on CSVed 1.4.4 application. When i modify your example test script for this apps, second attempt to minimize apps will be failed. And minimize the window is blocked until apps is restarted.

You can download test apps on this web page: http://csved.sjfrancke.nl/index.html

My example:

; Open CSVed to monitor test

Run("C:\Program Files\CSVed\CSVed.exe")

WinWait("CSVed 1.4.4")

$hWin = WinGetHandle("CSVed 1.4.4")

If Not WinActive($hWin) Then WinActivate($hWin)

WinWaitActive($hWin)

WinSetState($hWin, "", @SW_MAXIMIZE)

MsgBox(64, "Test", "Manually minimize the CSVed window then click OK...")

Sleep(1000)

WinSetState($hWin, "", @SW_MAXIMIZE)

MsgBox(64, "Test", "One more time: Manually minimize the CSVed window then click OK...")

Thank you for your help ...

RadovanJ

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi,

yes, I know.

I can reproduce this problem on CSVed 1.4.4 application. When i modify your example test script for this apps, second attempt to minimize apps will be failed. And minimize the window is blocked until apps is restarted.

You can download test apps on this web page: http://csved.sjfrancke.nl/index.html

My example:

; Open CSVed to monitor test

Run("C:\Program Files\CSVed\CSVed.exe")

WinWait("CSVed 1.4.4")

$hWin = WinGetHandle("CSVed 1.4.4")

If Not WinActive($hWin) Then WinActivate($hWin)

WinWaitActive($hWin)

WinSetState($hWin, "", @SW_MAXIMIZE)

MsgBox(64, "Test", "Manually minimize the CSVed window then click OK...")

Sleep(1000)

WinSetState($hWin, "", @SW_MAXIMIZE)

MsgBox(64, "Test", "One more time: Manually minimize the CSVed window then click OK...")

Thank you for your help ...

RadovanJ

Hmm... interesting effect. Switching between normal-max-min-max-min changes the bits in WinGetState:

Run("notepad.exe")
WinWait("Untitled - Notepad")
$hWin = WinGetHandle("Untitled - Notepad")
If Not WinActive($hWin) Then WinActivate($hWin)
WinWaitActive($hWin)
$iState = WinGetState($hWin)
ConsoleWrite("Debug: $iState Before = " & $iState & @LF)

WinSetState($hWin, "", @SW_MAXIMIZE)
$iState = WinGetState($hWin)
ConsoleWrite("Debug: $iState first maximized = " & $iState & @LF)

MsgBox(64, "Test", "Manually minimize the notepad window then click OK...")
Sleep(1000)
$iState = WinGetState($hWin)
ConsoleWrite("Debug: $iState first minimized = " & $iState & @LF)

WinSetState($hWin, "", @SW_MAXIMIZE)
$iState = WinGetState($hWin)
ConsoleWrite("Debug: $iState second maximize = " & $iState & @LF)

MsgBox(64, "Test", "One more time: Manually minimize the notepad window then click OK...")
$iState = WinGetState($hWin)
ConsoleWrite("Debug: $iState second minimize = " & $iState & @LF)oÝ÷ Øë­¦ëb±Ê{­ºyâ|ãMö×M8×çÍ=Ù7¦§OvMë-ÓÝzËují÷à7º|Ó~¢JÖ­x¢·

Maybe that will make the difference for your app also.

:D

P.S. Oops -- brain fart -- just use @SW_RESTORE to return from minimized, works better.

:P

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Hi all,

my problem still exist, but i discover some details about it.

1. It is important use CSVed 1.4.4 as test application for reproduce my problem

2. There is difference between situation when apps is already runing in time of start AutoIt script or not running

If it is not running and test AutoIt script will run CSVed, then windows control block does not occur. But If I run CSVed manually before AutoIt script then after window is blocked until apps is restarted !!!

You can download test apps on this web page: http://csved.sjfrancke.nl/index.html

Example 1 - CSVed is manually run and minimized

$hWin = WinGetHandle("CSVed 1.4.4")
WinActivate($hWin)
Sleep(1000)
WinSetState($hWin, "", @SW_MAXIMIZE)
Sleep(1000)
WinSetState($hWin, "", @SW_RESTORE)
exit

Example 2 - CSVed will be run by script

Run("C:\Program Files\CSVed\CSVed.exe")
$hWin = WinGetHandle("CSVed 1.4.4")
WinActivate($hWin)
Sleep(1000)
WinSetState($hWin, "", @SW_MAXIMIZE)
Sleep(1000)
WinSetState($hWin, "", @SW_RESTORE)
exit

Thank you very much for your help

Radovan J

Share this post


Link to post
Share on other sites

Hi all,

my problem still exist, but i discover some details about it.

1. It is important use CSVed 1.4.4 as test application for reproduce my problem

2. There is difference between situation when apps is already runing in time of start AutoIt script or not running

If it is not running and test AutoIt script will run CSVed, then windows control block does not occur. But If I run CSVed manually before AutoIt script then after window is blocked until apps is restarted !!!

You can download test apps on this web page: http://csved.sjfrancke.nl/index.html

Example 1 - CSVed is manually run and minimized

$hWin = WinGetHandle("CSVed 1.4.4")
WinActivate($hWin)
Sleep(1000)
WinSetState($hWin, "", @SW_MAXIMIZE)
Sleep(1000)
WinSetState($hWin, "", @SW_RESTORE)
exit

Example 2 - CSVed will be run by script

Run("C:\Program Files\CSVed\CSVed.exe")
$hWin = WinGetHandle("CSVed 1.4.4")
WinActivate($hWin)
Sleep(1000)
WinSetState($hWin, "", @SW_MAXIMIZE)
Sleep(1000)
WinSetState($hWin, "", @SW_RESTORE)
exit

Thank you very much for your help

Radovan J

Are you sure in your second example that you are getting a valid handle to the window? A few milliseconds after Run(), you are trying to get the window handle by title. It may not exist yet. Put this line right before the WinGetHandle():

WinWait("CSVed 1.4.4")

You could also test your handle for error checking with: If IsHWnd($hWin) Then ...

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

i'd try this

Opt("WinTitleMatchMode", 2) 
Run("C:\Program Files\CSVed\CSVed.exe")
$hWin = WinGetHandle(WinGetTitle("CVSed")) 
WinActivate($hWin)
Sleep(1000)
WinSetState($hWin, "", @SW_MAXIMIZE)
Sleep(1000)
WinSetState($hWin, "", @SW_RESTORE)
exit

it's case sensitive, so make sure you get the wingettitles characters right, it should give you the full title if you do.


---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites

Thank you PsaltyDS and blademonkey,

but my primary problem is with manually minimize CSVed window (Example 1) after AutoIT script is finished.

When i have CSVed running and after some time I want maximize CSVed window by AutoIt and do other things and then finish AutoIT script then after AutoIt script maximize and restore CSVed window, yet is not possible minimize CSVed window manually.

Thanks

RadovanJ

Share this post


Link to post
Share on other sites

Thank you PsaltyDS and blademonkey,

but my primary problem is with manually minimize CSVed window (Example 1) after AutoIT script is finished.

When i have CSVed running and after some time I want maximize CSVed window by AutoIt and do other things and then finish AutoIT script then after AutoIt script maximize and restore CSVed window, yet is not possible minimize CSVed window manually.

Thanks

RadovanJ

Try this (untested)

Opt("WinTitleMatchMode", 2) 
If NOT WinExists ("CVSed") Then
   Run("C:\Program Files\CSVed\CSVed.exe")
EndIf
WinWaitActive("CVSed")
$hWin = WinGetHandle(WinGetTitle("CVSed")) 
;WinActivate($hWin)
;Sleep(1000)
WinSetState($hWin, "", @SW_MAXIMIZE)
Sleep(1000)
WinSetState($hWin, "", @SW_RESTORE)
exit

Comment out the following 3 lines to see if you can now Minimize with the button click.

Sleep(1000)
WinSetState($hWin, "", @SW_RESTORE)
exit

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Hi GEOSoft,

Yes I can use minimize button, but I do not want run CSVed by AutoIt script, even if it is not running !!! And this is core of my problem.

If AutoIt will run CSVed then after script i can not use minimize button !!!

Thank you

Radovan J

Share this post


Link to post
Share on other sites

Maybe running through a use case would help. what do you ultimately want your script to automate?


---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites

Hi,

I use easy available and small CSVed application only as example (in this forum is often used Notepad as example, but with it i have not this problem) and i have this problem also with some else applications. My script example is only fragment of my complex script, but is fully sufficient for demonstrate this problem with CSVed (is it artificial construction). It is possible to test this problem on this example. And application which I really want to automate is always running on my desktop, thus there's no need to run it.

You can download freeware CSVed (only 0,9 MB) on this page:

http://home.hccnet.nl/s.j.francke/software/software.htm

Once again example:

Opt("WinTitleMatchMode", 2) 
WinWait("CSVed")
$hWin = WinGetHandle(WinGetTitle("CSVed")) 
WinActivate($hWin)
Sleep(1000)
WinSetState($hWin, "", @SW_MAXIMIZE)
Sleep(1000)
WinSetState($hWin, "", @SW_RESTORE)
exit

Thank you

RadovanJ

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