Jump to content

Recommended Posts

Posted (edited)

Hello Peoples!!

Firstly let me say thanks in advance for any assistance rendered.

Sorry if the title is a bit misleading, best I could come up with at the time.

Here is the problem, as I understand it anyway....

I have been developing (mainly learning from) scripts "B", "C" & "D" over quite a long period of time for daily use at work. I have got all three to the point where they are almost finished and decided that I would create script "A" as kind of launcher and active GUI management bar with some additional goodies that don't really fit with any of the others.

Launching, minimising, hiding etc were quite straight forward using "Run" , "WinExists", "WinSetState" and the like and all was going well until it came to actually closing out of everything. This is where I found that script "D" would not close like the others.

I narrowed it down to script "D" using:

Opt("GUICloseOnESC", 0) ;1=ESC  closes, 0=ESC won't close

Once this option was set to 1 or commented out the problem went away.

It really handy set to 1 for script "D" due to the annoying web-based app that it deal with so the solution I have used is combining all the scripts into one (and to my suprise it is all still working as far as I can tell) but with 15000 lines of code it has become confusing for a beginner like me to work on, even when I seperated the functions into there own include.

So what I would really like to know is if there is a way to WinKill another script set to not close on ESC?

EDIT: Wow I really screwed up the thread title, it should say "Opt("GUICloseOnESC", 0)" as it does in the body.

Edited by Woongjinn
Posted

Interesting! I confirmed it with both WinKill() and WinClose(). Neither works on windows with GUICloseOnEsc = 0.

#include <GuiConstantsEx.au3>

If Not @Compiled Then
    MsgBox(16, "Must run compiled", "Must run compiled")
    Exit
EndIf

; Create four windows then try to close them

If $CmdLine[0] Then
    ; Instance called to create window

    $n = Number($CmdLine[1])
    Opt("GuiCloseOnEsc", Mod($n, 2)) ; Odd = 1, Even = 0

    $hGUI = GUICreate("GUI_" & $n, 200, 200, $n * 200, $n * 200)
    $ctrlExit = GUICtrlCreateButton("Exit", 50, 85, 100, 30)
    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $ctrlExit
                Exit
        EndSwitch
    WEnd
Else
    ; Run test

    ; Open four windows
    For $n = 1 To 4
        ShellExecute(@ScriptFullPath, $n)
        Sleep(2000)
    Next

    ; Close four windows
    For $n = 1 To 4
        WinClose("GUI_" & $n, "")
        TrayTip("Test", "Closed: GUI_" & $n, 5)
        Sleep(3000)
    Next
EndIf

Hmm...

;)

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
Posted

  On 1/7/2010 at 10:19 PM, 'PsaltyDS said:

Interesting! I confirmed it with both WinKill() and WinClose(). Neither works on windows with GUICloseOnEsc = 0.

#include <GuiConstantsEx.au3>

If Not @Compiled Then
    MsgBox(16, "Must run compiled", "Must run compiled")
    Exit
EndIf

; Create four windows then try to close them

If $CmdLine[0] Then
    ; Instance called to create window

    $n = Number($CmdLine[1])
    Opt("GuiCloseOnEsc", Mod($n, 2)) ; Odd = 1, Even = 0

    $hGUI = GUICreate("GUI_" & $n, 200, 200, $n * 200, $n * 200)
    $ctrlExit = GUICtrlCreateButton("Exit", 50, 85, 100, 30)
    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $ctrlExit
                Exit
        EndSwitch
    WEnd
Else
    ; Run test

    ; Open four windows
    For $n = 1 To 4
        ShellExecute(@ScriptFullPath, $n)
        Sleep(2000)
    Next

    ; Close four windows
    For $n = 1 To 4
        WinClose("GUI_" & $n, "")
        TrayTip("Test", "Closed: GUI_" & $n, 5)
        Sleep(3000)
    Next
EndIf

Hmm...

;)

Well thanks for confirming that it is not something I am doing wrong!!

At the moment I have combined it all into two seperate scripts which is manageable for me and allowing me to set GUICloseOnEsc = 0 on the two that need it the most. However the more I think about the amount of stray 'esc' key presses being thrown around (by me) the more practical it would be to have it on anything I use at work.

I was kind of expecting complications when they released the "new web-based system" that they have been working on for 5 years and will only work properly with IE6. They even managed to somehow totally fail at auto-complete to the point it took longer everytime you did anything.

The old system was telnet based and we got along fine!!

Anyway do you think there would be any value in posting this as a possible bug? or is it less than obvious design intention?

Thanks

Posted

Give it a day to see if some of the smarter people see something in this topic we missed. Else, it's worth a BugTrack to see.

Any time you post a possible bug, however, make your demo script as short, simple and to the point as possible. Demonstrate the specific AutoIt symptom, without reference to any irrelevant specifics about your environment. If you show some effort at isolating the problem down to the basic issue and it's not a bug, you'll get a simple "No Bug" result.

;)

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
Posted (edited)

Same problem if not compiled. Expected, but just in case. Same problem for WinKill.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=esc0.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GuiConstantsEx.au3>
$AutoItProdexePath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir");installDir for production


; Create four windows then try to close them

If $CmdLine[0] Then
    ; Instance called to create window

    $n = Number($CmdLine[1])
    Opt("GuiCloseOnEsc", Mod($n, 2)) ; Odd = 1, Even = 0

    $hGUI = GUICreate("GUI_" & $n, 200, 200, $n * 200, $n * 200)
    $ctrlExit = GUICtrlCreateButton("Exit", 50, 85, 100, 30)
    GUISetState()

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE, $ctrlExit
    Exit
    EndSwitch
    WEnd
Else
    ; Run test

    ; Open four windows
    For $n = 1 To 4
    If Not @Compiled Then
    ;create the script to run from the original; we will pretend we're running the original script
    $ToRun = '"' & $AutoItProdexePath & '\AutoIt3.exe "' & ' "' & @ScriptFullPath & '" ' & $n
    Run($ToRun)
    Else
    ShellExecute(@ScriptFullPath, $n)
    EndIf
    ;Sleep(2000)
    Next
 Sleep(2000)
    ; Close four windows
    For $n = 1 To 4
    WinClose("GUI_" & $n, "")
    TrayTip("Test", "Closed: GUI_" & $n, 5)
    Sleep(1000)
    Next

    For $n = 1 To 4
    If WinExists("GUI_" $ $n) then WinKill("GUI_" & $n, "")
    TrayTip("Test", "Closed: GUI_" & $n, 5)
    Sleep(1000)
    Next
EndIf

Behaves as when you register WM_CLOSE and do not return $GUI_RUNDEFMSG.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
  • 2 weeks later...
Posted

It can be reproduced without external process:

#include <GUIConstantsEx.au3>

Opt("GUICloseOnESC", 0)

$hGUI = GUICreate("Test Script", 300, 200)

GUISetState(@SW_SHOW, $hGUI)

WinClose($hGUI)
WinKill($hGUI)

While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd

And BTW, we can workaround this by sending Alt+F4 to the window:

ControlSend($hGUI, "", "", "!{F4}")

Or by cathing the WM_CLOSE message (wich is the best solution, it will cover up all the external attempts to close the window):

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUICloseOnESC", 0)

$hGUI = GUICreate("Test Script", 300, 200)

GUISetState(@SW_SHOW, $hGUI)
GUIRegisterMsg($WM_CLOSE, "WM_CLOSE")

WinClose($hGUI)

While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Func WM_CLOSE($hWnd, $nMsg, $lParam, $wParam)
    Exit
EndFunc

P.S

As we can see here, when we set GUICloseOnESC = 0, the WM_CLOSE message is still recieved, so the problem is in the GUIGetMsg() (in the event handler actualy, because with OnEvent mode it's the same).

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...