mike2003

Disable ESK key close window

11 posts in this topic

#1 ·  Posted (edited)

i have some code

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = ....

When i press ESC - window close

IF i delete

Case $msg = $GUI_EVENT_CLOSE
            ExitLoop

i cant close window even with mouse click

 

How disable ESC button??

Edited by mike2003

Share this post


Link to post
Share on other sites



mike2003,

Opt("GUICloseOnESC", 0) should do the trick.

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Yes. Thanks

Share this post


Link to post
Share on other sites

Can i reprogram the button for minimize window? :)

Share this post


Link to post
Share on other sites

Define "reprogram". Are you looking to remove it, ignore it,  or change the behavior? And if the last, what are you looking for that behavior to be?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Maybe you can use $GUI_EVENT_MINIMIZE in your main loop, or use GUIRegisterMsg with WM_SYSCOMMAND, for example :

#Include <GUIConstantsEx.au3>
#Include <WindowsConstants.au3>
#Include <MenuConstants.au3>

Opt("GUICloseOnESC", 0) 
Local $hGui = GUICreate("My GUI")
GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")

GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd


Func WM_SYSCOMMAND($hWndGUI, $MsgID, $WParam, $LParam)
    Switch $WParam
        Case $SC_MINIMIZE
            MsgBox(0, "", "Minimize button was clicked", 0, $hGui)
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

 

Share this post


Link to post
Share on other sites

mike2003,

Perhaps this is close to what you require:

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

Opt("GUICloseOnESC", 0)
Opt("GUIEventOptions", 1)

Opt("TrayMenuMode", 3)

$cTrayShow = TrayCreateItem("Restore GUI")
TrayItemSetState($cTrayShow, $TRAY_DISABLE)
TrayCreateItem("")
$cTrayExit = TrayCreateItem("Exit")

Local $hGui = GUICreate("My GUI", 500, 500, Default, Default, BitOr($WS_SYSMENU, $WS_CAPTION))
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            WinSetState($hGui, "", @SW_MINIMIZE)
            TrayItemSetState($cTrayShow, $TRAY_ENABLE)
    EndSwitch

    Switch TrayGetMsg()
        Case $cTrayExit
            Exit
        Case $cTrayShow
            WinSetState($hGui, "", @SW_RESTORE)
            TrayItemSetState($cTrayShow, $TRAY_DISABLE)
    EndSwitch
WEnd

The [X] minimises the GUI and the tray menu restores it. Please ask if you have any questions.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@Melba23 I always liked programs that use that feature (minimize to systray) and additionally hide the taskbar icon as well.  This can be achieved by changing @SW_MINIMIZED to @SW_HIDE in your demo script.  I'm sure you knew that...just wanted to point it out for other readers.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I think you misunderstood me. Now button ESC does not close the window, but I want to make it minimized when ESC press.

Something like

$GUI_EVENT_CLOSE

but for minimize for ESC )

 

Edited by mike2003

Share this post


Link to post
Share on other sites

mike2003,

To do that I would use an Accelerator key - like this:

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

Local $hGui = GUICreate("My GUI", 500, 500, Default, Default, BitOR($WS_SYSMENU, $WS_CAPTION))

$cMinimiseDummy = GUICtrlCreateDummy()

Local $aAccelKeys[1][2] = [["{ESC}", $cMinimiseDummy]]
GUISetAccelerators($aAccelKeys)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cMinimiseDummy
            WinSetState($hGui, "", @SW_MINIMIZE)
    EndSwitch
WEnd

spudw2k,

I did know about @SW_HIDE removing the icon from the taskbar, but thanks for reminding others.

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

that's what I need

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