Jump to content

Disable ESK key close window


mike2003
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

mike2003,

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

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

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?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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.

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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