Jump to content

Recommended Posts

Hello,

I would like to ask if there is any way to avoid pause loop when we click on Menu in AutoIt GUI?

* without using _Timer_SetTimer.

[Edit 2021-02-14 20:45] Solved! Big thanks for @MrCreatoR, below solution:

#include <GuiMenu.au3>

; Create GUI.
$hGUI = GUICreate("Autoit GUI", 200, 100)

; Create menu and item.
Local $menu = GUICtrlCreateMenu("&Click here")
GUICtrlCreateMenuItem("none", $menu)
$hMenu = _GUICtrlMenu_GetMenu($hGUI)
_GUICtrlMenu_SetMenuStyle($hMenu, $MNS_MODELESS)

; Crate label to control progress.
Local $label = GUICtrlCreateLabel("Working: ", 60, 30, 160)

; Set start time point script.
Local $startPoint = 0

; Show GUI.
GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1
    ; Set new time to label.
    GUICtrlSetData($label, "Working: " & $startPoint & "%")
    
    ; add point
    $startPoint += 1
    
    ; When point is above 100 reset
    If $startPoint >= 100 Then $startPoint = 0
    
    ; Listen signal from GUI.
    Switch GUIGetMsg()
        Case -3
            Exit
    EndSwitch
WEnd

 

Edited by Ascer
Link to post
Share on other sites

If one of my scripts would need a menu, which is not blocking, i would use a ComboBoX with disabled input, then after an item is selected, i would remove the focus from it , to prevent the combo box scrolling with the mouse wheel.

The other solution would be to open a  custom popup gui, which displays menu options in a listbox or as buttons (with changed borders). 

The handling of the items would, then, be in the loop, in which the pause should be avoided. 

Edited by Dan_555
Link to post
Share on other sites

You do it this way:

#include <GuiMenu.au3>

; Create GUI.
$hGui = GUICreate("Autoit GUI", 200, 100)

$hMenu = _GUICtrlMenu_CreateMenu()
_GUICtrlMenu_InsertMenuItem( $hMenu, 0, "none" )
 $hMain = _GUICtrlMenu_CreateMenu( $MNS_MODELESS )
_GUICtrlMenu_InsertMenuItem( $hMain, 0, "none", 0, $hMenu )
_GUICtrlMenu_SetMenu( $hGui, $hMain )

; Crate label to control progress.
$label = GUICtrlCreateLabel("Working: " , 60, 30, 160)

; Set start time point script.
$startPoint = 0

; Show GUI.
GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1
  ; Set new time to label.
  GUICtrlSetData($label, "Working: " & $startPoint & "%")

  ; add point
  $startPoint += 1

  ; When point is above 100 reset
  If $startPoint >= 100 Then $startPoint = 0

  ; Listen signal from GUI.
  Switch GUIGetMsg()
    Case -3
      Exit
  EndSwitch
WEnd

 

Link to post
Share on other sites
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <WinAPIConv.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hStyle, $g_sStyle
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idMNS_CHECKORBMP, $e_idMNS_AUTODISMISS, $e_idMNS_MODELESS, $e_idMNS_NOCHECK, $e_idAbout

Example()

Func Example() ; based on https://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlMenu_CreateMenu.htm
    Local $hGUI, $hFile, $hHelp, $hMain, $idTimeLabel
    Local $iStyle = StylesFromCmdLine() ; 1st call to get the styles from command line

    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu($iStyle)
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $g_hStyle = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($g_hStyle, 0, "MNS_CHECKORBMP", $e_idMNS_CHECKORBMP)
    _GUICtrlMenu_InsertMenuItem($g_hStyle, 1, "MNS_AUTODISMISS", $e_idMNS_AUTODISMISS)
    _GUICtrlMenu_InsertMenuItem($g_hStyle, 2, "MNS_MODELESS", $e_idMNS_MODELESS)
    _GUICtrlMenu_InsertMenuItem($g_hStyle, 3, "MNS_NOCHECK", $e_idMNS_NOCHECK)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu($iStyle)
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu($iStyle) ; ..for MNS_MODELESS, only this "main menu" is needed.
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Style", 0, $g_hStyle)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    $idTimeLabel = GUICtrlCreateLabel("Time:  ???", 200, 2, 160)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 30 + 2, 396, 276 - 30, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    StylesFromCmdLine() ; 2nd call to set the checkboxes
    GUISetState(@SW_SHOW)
    MemoWrite("starting with styles: " & @CRLF & @TAB & $g_sStyle)

    ; Register Windows Message ID
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Loop until the user exits.
    Do
        ; Set new time to label.
        GUICtrlSetData($idTimeLabel, "Time:   " & @HOUR & " : " & @MIN & " : " & @SEC & " . " & @MSEC)

    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Handle menu commands
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Switch _WinAPI_LoWord($wParam)
        Case $e_idNew
            MemoWrite("New")
        Case $e_idOpen
            MemoWrite("Open")
        Case $e_idSave
            MemoWrite("Save")
        Case $e_idExit
            GUIDelete()
            Exit
        Case $e_idMNS_CHECKORBMP
            RestartWithStyles("MNS_CHECKORBMP")
        Case $e_idMNS_AUTODISMISS
            RestartWithStyles("MNS_AUTODISMISS")
        Case $e_idMNS_MODELESS
            RestartWithStyles("MNS_MODELESS")
        Case $e_idMNS_NOCHECK
            RestartWithStyles("MNS_NOCHECK")
        Case $e_idAbout
            MemoWrite("About")
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func RestartWithStyles($sStyle)
    If StringInStr($g_sStyle, $sStyle) Then
        $g_sStyle = StringStripWS(StringReplace($g_sStyle, $sStyle, ""), $STR_STRIPSPACES)
    Else
        $g_sStyle &= " " & $sStyle
    EndIf
    MemoWrite("restarting with styles: " & @CRLF & @TAB & $g_sStyle)
    ShellExecute(@AutoItExe, '"' & @ScriptFullPath & '" ' & $g_sStyle)
    GUIDelete()
    Exit
EndFunc   ;==>RestartWithStyles

Func StylesFromCmdLine()
    Local $iStyle = 0
    $g_sStyle = ""
    For $n = 1 To $CmdLine[0]
        Switch Eval($CmdLine[$n])
            Case $MNS_CHECKORBMP
                $iStyle += Eval($CmdLine[$n])
                $g_sStyle &= " MNS_CHECKORBMP"
                _GUICtrlMenu_SetItemState($g_hStyle, $e_idMNS_CHECKORBMP, $MFS_CHECKED, True, False)
            Case $MNS_AUTODISMISS
                $g_sStyle &= " MNS_AUTODISMISS"
                $iStyle += Eval($CmdLine[$n])
                _GUICtrlMenu_SetItemState($g_hStyle, $e_idMNS_AUTODISMISS, $MFS_CHECKED, True, False)
            Case $MNS_MODELESS
                $g_sStyle &= " MNS_MODELESS"
                $iStyle += Eval($CmdLine[$n])
                _GUICtrlMenu_SetItemState($g_hStyle, $e_idMNS_MODELESS, $MFS_CHECKED, True, False)
            Case $MNS_NOCHECK
                $g_sStyle &= " MNS_NOCHECK"
                $iStyle += Eval($CmdLine[$n])
                _GUICtrlMenu_SetItemState($g_hStyle, $e_idMNS_NOCHECK, $MFS_CHECKED, True, False)
        EndSwitch
    Next
    If $iStyle = 0 Then
        $iStyle = $MNS_CHECKORBMP ; default mode
        $g_sStyle = " MNS_CHECKORBMP"
        _GUICtrlMenu_SetItemState($g_hStyle, $e_idMNS_CHECKORBMP, $MFS_CHECKED, True, False)
    EndIf
    Return $iStyle
EndFunc   ;==>StylesFromCmdLine

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

..did this the other day and left it aside. But might as well post it :) 

Edit: the code below is 20 lines of code less but may be less explicit for a help file :huh2:

Spoiler
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <WinAPIConv.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hStyle, $g_sStyle, $g_hMain
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idMNS_CHECKORBMP, $e_idMNS_AUTODISMISS, $e_idMNS_MODELESS, $e_idMNS_NOCHECK, $e_idAbout

Example()

Func Example() ; based on https://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlMenu_CreateMenu.htm
    Local $hGUI, $hFile, $hHelp, $idTimeLabel
    Local $iStyle = StylesFromCmdLine() ; 1st call to get the styles from command line

    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu($iStyle)
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $g_hStyle = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($g_hStyle, 0, "MNS_CHECKORBMP", $e_idMNS_CHECKORBMP)
    _GUICtrlMenu_InsertMenuItem($g_hStyle, 1, "MNS_AUTODISMISS", $e_idMNS_AUTODISMISS)
    _GUICtrlMenu_InsertMenuItem($g_hStyle, 2, "MNS_MODELESS", $e_idMNS_MODELESS)
    _GUICtrlMenu_InsertMenuItem($g_hStyle, 3, "MNS_NOCHECK", $e_idMNS_NOCHECK)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu($iStyle)
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $g_hMain = _GUICtrlMenu_CreateMenu($iStyle) ; ..for MNS_MODELESS, only this "main menu" is needed.
    _GUICtrlMenu_InsertMenuItem($g_hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($g_hMain, 1, "&Style", 0, $g_hStyle)
    _GUICtrlMenu_InsertMenuItem($g_hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $g_hMain)

    $idTimeLabel = GUICtrlCreateLabel("Time:  ???", 200, 2, 160)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 30 + 2, 396, 276 - 30, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    StylesFromCmdLine() ; 2nd call to set the checkboxes
    GUISetState(@SW_SHOW)
    MemoWrite("starting with styles: " & @CRLF & @TAB & $g_sStyle)

    ; Register Windows Message ID
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Loop until the user exits.
    Do
        ; Set new time to label.
        GUICtrlSetData($idTimeLabel, "Time:   " & @HOUR & " : " & @MIN & " : " & @SEC & " . " & @MSEC)

    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Handle menu commands
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Switch _WinAPI_LoWord($wParam)
        Case $e_idNew
            MemoWrite("New")
        Case $e_idOpen
            MemoWrite("Open")
        Case $e_idSave
            MemoWrite("Save")
        Case $e_idExit
            GUIDelete()
            Exit
        Case $e_idMNS_CHECKORBMP, $e_idMNS_AUTODISMISS, $e_idMNS_MODELESS, $e_idMNS_NOCHECK
            RestartWithStyles(_GUICtrlMenu_GetItemText($g_hMain, _WinAPI_LoWord($wParam), False))
        Case $e_idAbout
            MemoWrite("About")
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func RestartWithStyles($sStyle)
    If StringInStr($g_sStyle, $sStyle) Then
        $g_sStyle = StringStripWS(StringReplace($g_sStyle, $sStyle, ""), $STR_STRIPSPACES)
    Else
        $g_sStyle &= " " & $sStyle
    EndIf
    MemoWrite("restarting with styles: " & @CRLF & @TAB & $g_sStyle)
    ShellExecute(@AutoItExe, '"' & @ScriptFullPath & '" ' & $g_sStyle)
    GUIDelete()
    Exit
EndFunc   ;==>RestartWithStyles

Func StylesFromCmdLine()
    Local $iStyle = 0
    $g_sStyle = ""
    For $n = 1 To $CmdLine[0]
        Switch Eval($CmdLine[$n])
            Case $MNS_CHECKORBMP, $MNS_AUTODISMISS, $MNS_MODELESS, $MNS_NOCHECK
                $iStyle += Eval($CmdLine[$n])
                $g_sStyle &= " " & $CmdLine[$n]
                _GUICtrlMenu_SetItemState($g_hStyle, Eval("e_id" & $CmdLine[$n]), $MFS_CHECKED, True, False)
        EndSwitch
    Next
    If $iStyle = 0 Then
        $iStyle = $MNS_CHECKORBMP ; default mode
        $g_sStyle = " MNS_CHECKORBMP"
        _GUICtrlMenu_SetItemState($g_hStyle, $e_idMNS_CHECKORBMP, $MFS_CHECKED, True, False)
    EndIf
    Return $iStyle
EndFunc   ;==>StylesFromCmdLine

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

 

 

Edited by argumentum
OCD got the best of me :D
Link to post
Share on other sites

Hi argumentum,
Instead of this "looping way" which lauches again the script as soon as an option is checked/unchecked, wasn't it possible to do it with a simple _GUICtrlMenu_SetMenuStyle ?

Just curious here. Maybe you tried it and it wasn't possible to dynamically modify the menu styles, you'll tell us :)

Link to post
Share on other sites
2 hours ago, pixelsearch said:

Maybe you tried it and it wasn't possible to dynamically modify the menu styles, you'll tell us

I did it !
But it does not behave reliably on every style in my testing :(  ( the code is hidden so no-one can see it :P )

Spoiler
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <WinAPIConv.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hStyle, $g_sStyle, $g_hMain, $g_iStyle = $MNS_CHECKORBMP, $g_hHelp, $g_hFile
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idMNS_CHECKORBMP, $e_idMNS_AUTODISMISS, $e_idMNS_MODELESS, $e_idMNS_NOCHECK, $e_idAbout

Example()

Func Example() ; based on https://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlMenu_CreateMenu.htm
    Local $hGUI, $idTimeLabel

    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $g_hFile = _GUICtrlMenu_CreateMenu($g_iStyle)
    _GUICtrlMenu_InsertMenuItem($g_hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($g_hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($g_hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($g_hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($g_hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $g_hStyle = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($g_hStyle, 0, "MNS_CHECKORBMP", $e_idMNS_CHECKORBMP)
    _GUICtrlMenu_InsertMenuItem($g_hStyle, 1, "MNS_AUTODISMISS", $e_idMNS_AUTODISMISS)
    _GUICtrlMenu_InsertMenuItem($g_hStyle, 2, "MNS_MODELESS", $e_idMNS_MODELESS)
    _GUICtrlMenu_InsertMenuItem($g_hStyle, 3, "MNS_NOCHECK", $e_idMNS_NOCHECK)

    ; Create Help menu
    $g_hHelp = _GUICtrlMenu_CreateMenu($g_iStyle)
    _GUICtrlMenu_InsertMenuItem($g_hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $g_hMain = _GUICtrlMenu_CreateMenu($g_iStyle) ; ..for MNS_MODELESS, only this "main menu" is needed.
    _GUICtrlMenu_InsertMenuItem($g_hMain, 0, "&File", 0, $g_hFile)
    _GUICtrlMenu_InsertMenuItem($g_hMain, 1, "&Style", 0, $g_hStyle)
    _GUICtrlMenu_InsertMenuItem($g_hMain, 2, "&Help", 0, $g_hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $g_hMain)

    $idTimeLabel = GUICtrlCreateLabel("Time:  ???", 200, 2, 160)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 30 + 2, 396, 276 - 30, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    _GUICtrlMenu_SetItemState($g_hStyle, $e_idMNS_CHECKORBMP, $MFS_CHECKED, True, False)
    GUISetState(@SW_SHOW)
    MemoWrite("starting with styles: " & @CRLF & @TAB & $g_sStyle)

    ; Register Windows Message ID
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")


    ; Loop until the user exits.
    Do
        ; Set new time to label.
        GUICtrlSetData($idTimeLabel, "Time:   " & @HOUR & " : " & @MIN & " : " & @SEC & " . " & @MSEC)

    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Handle menu commands
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Switch _WinAPI_LoWord($wParam)
        Case $e_idNew
            MemoWrite("New")
        Case $e_idOpen
            MemoWrite("Open")
        Case $e_idSave
            MemoWrite("Save")
        Case $e_idExit
            GUIDelete()
            Exit
        Case $e_idMNS_CHECKORBMP, $e_idMNS_AUTODISMISS, $e_idMNS_MODELESS, $e_idMNS_NOCHECK
            GUICtrlMenu_StyleChange(_WinAPI_LoWord($wParam))
        Case $e_idAbout
            MemoWrite("About")
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func GUICtrlMenu_StyleChange( $id )
    Local $iStyle = "0x" & Hex(Eval(_GUICtrlMenu_GetItemText($g_hMain, $id, False)))
;~  If Int($iStyle) = $MNS_NOCHECK Then _GUICtrlMenu_SetItemDisabled($g_hMain, $id , True , False )
    If BitAND($g_iStyle, $iStyle) Then
        $g_iStyle = BitAND($g_iStyle, BitNOT($iStyle))
    Else
        $g_iStyle = BitOR($g_iStyle, $iStyle)
    EndIf
    _GUICtrlMenu_SetItemChecked($g_hMain, $id, BitAND($g_iStyle, $iStyle) ? True : False, False)
    MemoWrite(Hex($g_iStyle) & " - Style " & _GUICtrlMenu_GetItemText($g_hMain, $id, False) & " " & (BitAND($g_iStyle, $iStyle) ? "added" : "removed") )
    _GUICtrlMenu_SetMenuStyle($g_hMain, $g_iStyle)
    _GUICtrlMenu_SetMenuStyle($g_hHelp, $g_iStyle)
    _GUICtrlMenu_SetMenuStyle($g_hFile, $g_iStyle)
EndFunc

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

 

...but it was a good idea I did not think of  :)

Edit: MNS_NOCHECK would not remove the style ( recreating the checkmark area ) :wacko2:

Edited by argumentum
Link to post
Share on other sites

@argumentum : adding 1 line should fix it. Instead of :

_GUICtrlMenu_SetMenuStyle($g_hMain, $g_iStyle)
_GUICtrlMenu_SetMenuStyle($g_hHelp, $g_iStyle)
_GUICtrlMenu_SetMenuStyle($g_hFile, $g_iStyle)

Then :

_GUICtrlMenu_SetMenuStyle($g_hMain, $g_iStyle)
_GUICtrlMenu_SetMenuStyle($g_hHelp, $g_iStyle)
_GUICtrlMenu_SetMenuStyle($g_hFile, $g_iStyle)
_GUICtrlMenu_SetMenuStyle($g_hStyle, $g_iStyle)

 

Edited by pixelsearch
Link to post
Share on other sites
7 hours ago, pixelsearch said:

1 line should fix it.

...the idea is to leave $g_hStyle out of the MNS_NOCHECK, as to keep a marker.
But you can see in the about and file menu, what _GUICtrlMenu_SetMenuStyle( ,MNS_NOCHECK) did.

In any case, the idea is to better the _GUICtrlMenu_CreateMenu() example showcase. ( well, my idea is to have the "loop" example replace the current one )

In _GUICtrlMenu_SetMenuStyle(), the example uses an external GUI to add the style.
For what I come to believe, once a menu got painted, MNS_NOCHECK does not apply reliably back and forth.

Link to post
Share on other sites

@Ascer, the example posted above is the best I can think of. Going from that, to the built in GuiCtrlCreate*(), ...no clue.
In my testing, it did not fail even once. If you can post something that could replicate the problem, then I'd have something to work on.

Edited by argumentum
Link to post
Share on other sites
On 2/13/2021 at 3:03 PM, Ascer said:

The only way is modify style of already created Menu by GUICtrlCreateMenu("&File") if even possible.

#include <GuiMenu.au3>

; Create GUI.
$hGUI = GUICreate("Autoit GUI", 200, 100)

; Create menu and item.
Local $menu = GUICtrlCreateMenu("&Click here")
GUICtrlCreateMenuItem("none", $menu)
$hMenu = _GUICtrlMenu_GetMenu($hGUI)
_GUICtrlMenu_SetMenuStyle($hMenu, $MNS_MODELESS)

; Crate label to control progress.
Local $label = GUICtrlCreateLabel("Working: ", 60, 30, 160)

; Set start time point script.
Local $startPoint = 0

; Show GUI.
GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1
    ; Set new time to label.
    GUICtrlSetData($label, "Working: " & $startPoint & "%")
    
    ; add point
    $startPoint += 1
    
    ; When point is above 100 reset
    If $startPoint >= 100 Then $startPoint = 0
    
    ; Listen signal from GUI.
    Switch GUIGetMsg()
        Case -3
            Exit
    EndSwitch
WEnd

 

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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

    No registered users viewing this page.

×
×
  • Create New...