Sign in to follow this  
Followers 0
udac

WinClose with AutoItSetOption ( "GUICloseOnESC", 0)

3 posts in this topic

Hello!

I am having trouble using WinClose with AutoItSetOption ( "GUICloseOnESC", 0), is this expected?

I have searched the docs, forum and uncle google, i didn't find any info.

@AutoItVersion says 3.2.10.0 and i'm on XP SP2.

I have tried with 3.2.8.1 and i get the same result.

Thanks

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
Global $Form3 = GUICreate("Form3", 409, 301, 303, 219)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form3Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form3Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form3Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form3Restore")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

AutoItSetOption ( "GUICloseOnESC", 0); If this is set to 0 the WinClose() function does not work for me
AutoItSetOption("WinTitleMatchMode", 4)
$handle = WinGetHandle("[TITLE:Form3; CLASS:AutoIt v3 GUI]", "")
ToolTip("Handle is " & $handle, Default, Default, "AutoItVersion " & @AutoItVersion)
Sleep(3000)
ToolTip("WinClose returned " & WinClose($handle), Default, Default, "AutoItVersion " & @AutoItVersion)
Sleep(3000)
ToolTip("Window still open, trying again with GUICloseOnESC=1", Default, Default, "AutoItVersion " & @AutoItVersion)
Sleep(3000)
AutoItSetOption ( "GUICloseOnESC", 1); If this is set to 1 it works for me
WinClose($handle)

While 1
    Sleep(100)
WEnd

Func Form3Close()
    Exit
EndFunc
Func Form3Maximize()

EndFunc
Func Form3Minimize()

EndFunc
Func Form3Restore()

EndFunc

Share this post


Link to post
Share on other sites



I think you only want to mess with that if you are using a GuiGetMsg() loop, not for GuiOnEventMode.

:P


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 tried with GUIGetMsg() and i seem to get the same result with both 3.2.10.0 and 3.2.8.1.

Start App1 and App2.

When you click WinClose in App1 then App2 should receive $GUI_EVENT_CLOSE.

It only works for me when i have App2 set to AutoItSetOption ( "GUICloseOnESC", 1).

Thanks

**App1**

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 0)
$App1 = GUICreate("App1", 400, 300, -1, -1)
GUISetState(@SW_SHOW)
$AButton1 = GUICtrlCreateButton("WinClose",100, 250, 75, 25)
$ALabel1 = GUICtrlCreateLabel ("",  100, 100,200,20)
$ALabel2 = GUICtrlCreateLabel ("",  100, 150,200,20)
AutoItSetOption("WinTitleMatchMode", 4)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $AButton1
            TryClose()
    EndSelect
WEnd 
Func TryClose()
    $handle = WinGetHandle("[TITLE:App2; CLASS:AutoIt v3 GUI]", "")
    GUICtrlSetData($ALabel1,"Handle [" & $handle & "] " & @HOUR & ":" & @MIN & ":" & @SEC)
    $WCret = WinClose($handle)
    GUICtrlSetData($ALabel2,"WinClose Return Value [" & $WCret & "] " & @HOUR & ":" & @MIN & ":" & @SEC)
EndFuncoÝ÷ Ø
iÙ«­¢+Ø¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì)=ÁÐ ÅÕ½ÐíU%=¹Ù¹Ñ5½ÅÕ½Ðì°À¤(ÀÌØíÁÀÈôU%
ÉÑ ÅÕ½ÐíÁÀÈÅÕ½Ðì°ÐÀÀ°ÌÀÀ°´Ä°´Ä¤)U%MÑMÑÑ¡M]}M!=¤(ÀÌØí ÕÑѽ¸ÄôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½ÐíQ½±ÅÕ½Ðì°ÄÀÀ°ÈÔÀ°ÜÔ°ÈÔ¤(ÀÌØí ÕÑѽ¸ÈôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí
±½ÍÅÕ½Ðì°ÈÀÀ°ÈÔÀ°ÜÔ°ÈÔ¤(ÀÌØí1°ÄôU%
Ñɱ
ÉÑ1° ÅÕ½ÐìÅÕ½Ðì°ÄÀÀ°ÄÀÀ°ÈÀÀ°ÈÀ¤(ÀÌØí1°ÈôU%
Ñɱ
ÉÑ1° ÅÕ½ÐìÅÕ½Ðì°ÄÀÀ°ÄÔÀ°ÈÀÀ°ÈÀ¤)¥´ÀÌØí¤ôÀ)Õѽ%ÑMÑ=ÁÑ¥½¸ ÅÕ½ÐíU%
±½Í=¹MÅÕ½Ðì°ÀÌØí¤¤)U%
ÑɱMÑÑ ÀÌØí1°Ä°ÅÕ½ÐíÕѽ%ÑMÑ=ÁÑ¥½¸ ÅÕ½ÐìÅÕ½ÐíU%
±½Í=¹MÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìµÀìÀÌØí¤µÀìÅÕ½Ðì¤ÅÕ½Ðì¤)]¡¥±Ä($ÀÌØíµÍôU%Ñ5Í ¤(%M±Ð($%
ÍÀÌØíµÍôÀÌØíU%}Y9Q}
1=M($$%U%
ÑɱMÑÑ ÀÌØí1°È°ÅÕ½ÐìÀÌØíU%}Y9Q}
1=MÉ¥ÙÅÕ½ÐìµÀì!=UHµÀìÅÕ½ÐìèÅÕ½ÐìµÀì5%8µÀìÅÕ½ÐìèÅÕ½ÐìµÀìM¤($%
ÍÀÌØíµÍôÀÌØí    ÕÑѽ¸Ä($$%
¡¹=ÁÐ ¤($%
ÍÀÌØíµÍôÀÌØí    ÕÑѽ¸È($$%á¥Ð(%¹M±Ð)]¹)Õ¹
¡¹=ÁÐ ¤($ÀÌØí¤ôµ½ ÀÌØí¤¬Ä°È¤(%Õѽ%ÑMÑ=ÁÑ¥½¸ ÅÕ½ÐíU%
±½Í=¹MÅÕ½Ðì°ÀÌØí¤¤(%U%
ÑɱMÑÑ ÀÌØí1°Ä°ÅÕ½ÐíÕѽ%ÑMÑ=ÁÑ¥½¸ ÅÕ½ÐìÅÕ½ÐíU%
±½Í=¹MÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìµÀìÀÌØí¤µÀìÅÕ½Ðì¤ÅÕ½Ðì¤(%U%
ÑɱMÑÑ ÀÌØí1°È°ÅÕ½ÐìÅÕ½Ðì¤)¹Õ¹

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