Jump to content
Sign in to follow this  
MikahS

Parent child problem; Child case in while loop running before called

Recommended Posts

MikahS

I am having problem. I have script that has a main GUI window that allows you to select which kind of encryption you'd like to use. When I go to start the script, for some reason the case statement for the:

$iSubmit
button for the child GUI runs right away and tried to read the data from the input on the child window, which hasn't been created yet, and then pops up the MsgBox.

 

I have been scouring the forums for something of similar nature, but unsuccessful. I have checked helpfile and it seems I am doing this correct. Here is my script:

; includes
 
#include <GUIConstantsEx.au3>
#include <Crypt.au3>
 
; vars
Local $hGUI, $msg = 0, $hInput, $iButton, $hDecode, $dButton
Local $aChkBx[8], $cValue, $iChild, $iMsg, $iPswd, $iMsgBox
Local $iPswdBox, $iSubmit
;main line
 
GUI()
 
While 1
    $msg = GUIGetMsg(1)
    Switch $msg[1]
        Case $hGUI
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    Quit()
                Case $iButton
                    getCheckbox()
                    inputChild()
                    ;Crypt(, $cValue)
                Case $dButton
                    getCheckbox()
             EndSwitch
        Case $iChild
            Switch $msg[0]
                  Case $GUI_EVENT_CLOSE
                      GUIDelete($iChild)
                  Case $iSubmit
                      $iMsg = GUICtrlRead($iMsgBox)
                      $iPswd = GUICtrlRead($iPswdBox)
                      MsgBox(0, "title", "msg:" & $iMsg & " paswrd:" & $iPswd)
            EndSwitch
    EndSwitch
WEnd
 
;functions
 
Func GUI()
    $hGUI = GUICreate("Short-Order Encrypter", 300, 200)
    GUICtrlCreateLabel("Encrypt a Message!", 95, 15)
    GUICtrlCreateLabel("This is a simple input and output encryption program.", 25, 35)
    GUICtrlCreateLabel("You will select which method of encryption, then", 30, 48)
    GUICtrlCreateLabel("input your text by pressing the Input button,", 40, 61)
    GUICtrlCreateLabel("or you will press the Decode button to", 55, 74)
    GUICtrlCreateLabel("decode an encrypted message.", 65, 87)
    $iButton = GUICtrlCreateButton("Input", 50, 160, 70, 30)
    $dButton = GUICtrlCreateButton("Decode", 160, 160, 70, 30)
    $aChkBx[0] = GUICtrlCreateCheckbox("Text", 15, 105)
    $aChkBx[1] = GUICtrlCreateCheckbox("3DES", 67, 105)
    $aChkBx[2] = GUICtrlCreateCheckbox("AES (128bit)", 122, 105)
    $aChkBx[3] = GUICtrlCreateCheckbox("AES (192bit)", 208, 105)
    $aChkBx[4] = GUICtrlCreateCheckbox("AES (256bit)", 32, 130)
    $aChkBx[5] = GUICtrlCreateCheckbox("DES", 121, 130)
    $aChkBx[6] = GUICtrlCreateCheckbox("RC2", 172, 130)
    $aChkBx[7] = GUICtrlCreateCheckbox("RC4", 224, 130)
    GUISetState(@SW_SHOW)
EndFunc ;==>GUI
 
Func getCheckbox()
    Local $i, $readArray, $cCounter = 0
    For $i = 0 To UBound($aChkBx) - 1 Step 1
        $readArray = GUICtrlRead($aChkBx[$i])
        If $readArray = 1 Then
             $cCounter += 1
             $cValue &= $i
        EndIf
    Next
    If $cCounter > 1 Then
        MsgBox(0, "Encryption Type", "Could not specify encryption type due to multiple selections. Please make sure you have only selected on type of encryption")
        $cValue = ""
        Return
    ElseIf $cCounter = 0 Then
         MsgBox(0, "Encryption Type", "You must select an encryption type in the Short-Order Encrypter window")
         Return
    EndIf
EndFunc ;==>getCheckbox
 
Func inputChild()
    If $cValue = "" Then
         Return
    EndIf
    $iChild = GUICreate("Input Message", 386, 120, -1, -1, -1, -1, $hGUI)
    GUICtrlCreateLabel("Message", 5, 10)
    GUICtrlCreateLabel("Password", 200, 10)
    $iMsgBox = GUICtrlCreateInput("", 5, 25, 180, 60)
    $iPswdBox = GUICtrlCreateInput("", 200, 25, 180, 60)
    $iSubmit = GUICtrlCreateButton("Encrypt", 172, 90)
    GUISetState()
EndFunc ;==>inputChild
 
#cs
Func Crypt($iMsg, $iPass, $iflag)
    Local $mFlag[8]
    $mFlag[0] = "TEXT"
    $mFlag[1] = $CALG_3DES
    $mFlag[2] = $CALG_AES_128
    $mFlag[3] = $CALG_AES_192
    $mFlag[4] = $CALG_AES_256
    $mFlag[5] = $CALG_DES
    $mFlag[6] = $CALG_RC2
    $mFlag[7] = $CALG_RC4
EndFunc ;==>Crypt
#ce
 
Func Quit()
    GUIDelete($hGUI)
    Exit
EndFunc ;==>Quit

 


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
careca

This works for me.

; includes

#include <GUIConstantsEx.au3>
#include <Crypt.au3>
Opt("TrayMenuMode", 1)
Opt("TrayIconHide", 0)
Opt("GUICoordMode", 1)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
Opt("GUIEventOptions", 0)
Opt("TrayOnEventMode", 1)
Opt("ExpandEnvStrings", 1)
Opt("WinDetectHiddenText", 1)
; vars
Local $hGUI, $msg = 0, $hInput, $iButton, $hDecode, $dButton
Local $aChkBx[8], $cValue, $iChild, $iMsg, $iPswd, $iMsgBox
Local $iPswdBox, $iSubmit
;main line

GUI()

;functions

Func GUI()
    $hGUI = GUICreate("Short-Order Encrypter", 300, 200)
    GUICtrlCreateLabel("Encrypt a Message!", 95, 15)
    GUICtrlCreateLabel("This is a simple input and output encryption program.", 25, 35)
    GUICtrlCreateLabel("You will select which method of encryption, then", 30, 48)
    GUICtrlCreateLabel("input your text by pressing the Input button,", 40, 61)
    GUICtrlCreateLabel("or you will press the Decode button to", 55, 74)
    GUICtrlCreateLabel("decode an encrypted message.", 65, 87)
    $iButton = GUICtrlCreateButton("Input", 50, 160, 70, 30)
    GUICtrlSetOnEvent(-1, "iButton")
    $dButton = GUICtrlCreateButton("Decode", 160, 160, 70, 30)
    GUICtrlSetOnEvent(-1, "getCheckbox")
    $aChkBx[0] = GUICtrlCreateCheckbox("Text", 15, 105)
    $aChkBx[1] = GUICtrlCreateCheckbox("3DES", 67, 105)
    $aChkBx[2] = GUICtrlCreateCheckbox("AES (128bit)", 122, 105)
    $aChkBx[3] = GUICtrlCreateCheckbox("AES (192bit)", 208, 105)
    $aChkBx[4] = GUICtrlCreateCheckbox("AES (256bit)", 32, 130)
    $aChkBx[5] = GUICtrlCreateCheckbox("DES", 121, 130)
    $aChkBx[6] = GUICtrlCreateCheckbox("RC2", 172, 130)
    $aChkBx[7] = GUICtrlCreateCheckbox("RC4", 224, 130)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
    GUISetState(@SW_SHOW)
EndFunc ;==>GUI

Func iButton()
    getCheckbox()
    inputChild()
EndFunc

Func getCheckbox()
    Local $i, $readArray, $cCounter = 0
    For $i = 0 To UBound($aChkBx) - 1 Step 1
        $readArray = GUICtrlRead($aChkBx[$i])
        If $readArray = 1 Then
             $cCounter += 1
             $cValue &= $i
        EndIf
    Next
    If $cCounter > 1 Then
        MsgBox(0, "Encryption Type", "Could not specify encryption type due to multiple selections. Please make sure you have only selected on type of encryption")
        $cValue = ""
        Return
    ElseIf $cCounter = 0 Then
         MsgBox(0, "Encryption Type", "You must select an encryption type in the Short-Order Encrypter window")
         Return
    EndIf
EndFunc ;==>getCheckbox

Func inputChild()
    If $cValue = "" Then
         Return
    EndIf
    $iChild = GUICreate("Input Message", 386, 120, -1, -1, -1, -1, $hGUI)
    GUICtrlCreateLabel("Message", 5, 10)
    GUICtrlCreateLabel("Password", 200, 10)
    $iMsgBox = GUICtrlCreateInput("", 5, 25, 180, 60)
    $iPswdBox = GUICtrlCreateInput("", 200, 25, 180, 60)
    $iSubmit = GUICtrlCreateButton("Encrypt", 172, 90)
    GUICtrlSetOnEvent($iSubmit, "Encrypt")
    GUISetOnEvent($GUI_EVENT_CLOSE, "QuitChild")
    GUISetState()
EndFunc ;==>inputChild

#cs
Func Crypt($iMsg, $iPass, $iflag)
    Local $mFlag[8]
    $mFlag[0] = "TEXT"
    $mFlag[1] = $CALG_3DES
    $mFlag[2] = $CALG_AES_128
    $mFlag[3] = $CALG_AES_192
    $mFlag[4] = $CALG_AES_256
    $mFlag[5] = $CALG_DES
    $mFlag[6] = $CALG_RC2
    $mFlag[7] = $CALG_RC4
EndFunc ;==>Crypt
#ce

Func Quit()
    GUIDelete($hGUI)
    Exit
EndFunc ;==>Quit

Func QuitChild()
    GUIDelete($iChild)
EndFunc ;==>Quit

Func Encrypt()
    $iMsg = GUICtrlRead($iMsgBox)
    $iPswd = GUICtrlRead($iPswdBox)
    MsgBox(0, "title", "msg:" & $iMsg & " paswrd:" & $iPswd)
EndFunc

While 1
Sleep(100)
WEnd

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
BrewManNH

All you need to do is change your declarations for the child gui and the controls on it.

; vars
Local $hGUI, $msg = 0, $hInput, $iButton, $hDecode, $dButton
Local $aChkBx[8], $cValue, $iChild=9999, $iMsg, $iPswd, $iMsgBox ; <<<<<<<<<<<<<<<<<<<<<<
Local $iPswdBox, $iSubmit=9999 ; <<<<<<<<<<<<<<<<<<<<<<<<
;main line

Because you haven't created the child GUI yet, the gui handle and all controls will equal zero. In a MessageLoop, GUIGetMsg returns 0 whenever nothing is happening in the GUI, so the child GUI handle will match and the $iSubmit id will match because both are zero. Set them to something that probably won't be a control ID, 9999 in my example above, and this won't happen. When the controls and the GUI are created, the default 9999 will be overwritten.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
MikahS

@careca Thank you for that solution, as it's something to think about :)

@BrewManNH Thank you, I really wanted to figure out what was going on and not change around the way I poll for events on the GUI. With this solution (tested) it worked :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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  

  • Similar Content

    • jdegraff
      By jdegraff
      I created a quick script to set/clear the topmost status of a window. It works like
          top <title> /on | /off
          
      I want the title match to be case insensitive and to work on partial strings. For example, if the window of note is titled "APLX for Windows" I want
          top apl /on
          
      to work. The AutoIt manual says that for WinTitleMatchMode
          Mode -1 to -4
              Force lower case match according to other type of match.
      so I assumed that by
          aut.Opt "WinTitleMatchMode",-1
          
      I would be doing a lower case match on existing windows. As long as I lcase(title) for the comparison it should match on "APLX for Windows" but it does not Is this a bug or am I misreading the docs?    
    • Skysnake
      By Skysnake
      From From here, bottom of the post
      I am not arguing the logic of this, merely would like to point out that if there is such a rule, it is not documented...  Are there other such rules?
      Skysnake
    • damon
      By damon
      @JLogan3o13 I apologize, I did not think of it that way.  I have attached all the code and the Ini File information.  Please let me know if I need to add anything else to help understand what is happening.  thank you.
       
       
       
      Guys, I apologize in advance as I did not search for my answer before posting.  I just could not figure out a way to search that made since so I decided to go ahead and post my question.
       
      Getting to it.
      Background: this is being used to validate file names before moving to a new location.  though i have not included all the code, below is what i am having a problem with.
       I have an ini file that i am reading values from. Func ConfigDefineVars() -- I read the value of $ValidationRDA and everything is good then I set 
      $CaseRDALocationCheck = '$SplitFile[$ValidationRDALocation]' <> $ValidationRDA
      the code that will be used in the select case in Func FileSplitCount().  The problem i have is that even though the numbers = each other they are not recognizing as =.  
      This is what i am getting in my log file i create.
      2017-12-04 14:09:53 : RDA was 2403 should have been 2403:
      If I move $SplitFile[$ValidationRDALocation] <> $ValidationRDA to the Case line under the function it works correctly.
       
      I think this has to do with my use of ' ' around the '$SplitFile[$ValidationRDALocation]' but  i don't know what option i have in Func ConfigDefineVars I am not ready to define $SplitFile.  I have tried adding it to my Global Vars at the top of my script but that did not seem to help.
      There will be more fail this is just the first one in the select case.
       
      Any help or ideas would be greatly appreciated.
       
      thanks,
      Damon
      Example of a filename used.
      DWRSSD-37087-95-026.%-064.00-Tatum Family %-%-1230 Academy Rd-%-PERM-TRUE-2403.pdf
      This file will fail on the 95, it should be 095.  The problem i am getting is with the 2403 it fails even though the ini file value ValidationRDA = 2403 
       
       
      Ini File:
      [SSD_FolderPaths]
      pendingFolder=C:\Users\bg01152\Desktop\SSD Test\pending
      reviewFolder=C:\Users\bg01152\Desktop\SSD Test\review
      completedFolder=C:\Users\bg01152\Desktop\SSD Test\Completed
      FileNetProperties=DocumentTitle,ZipCode,County,MapAndGroupID,ParcelID,PropertyOwner,Subdivision,StreetAddress,LotNumber,DocumentType,Approved,RDANumber
      ValidationDocumentTitle=DWRSSD
      ValidationDocumentTitleLocation=1
      ValidationCountyCodeLocation=3
      ValidationRDA=2403
      ValidationRDALocation=12
      Validation3=TRUE
      Validation3Location=11
      Validation4=PERM
      Validation4Location=10
       
       
      #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ;------------Global Vars --------------------- Global $SplitFile, $aFileList, $FileLog, $dFolder, $sFolder, $cFolder, $ConfigFile, $t Global $ValidationDocumentTitle, $ValidationDocumentTitleLocation, $ValidationCountyCodeLocation, $ValidationRDA Global $ValidationRDALocation, $Validation3, $Validation3Location, $Validation4, $Validation4Location, $FileNetPropertiesSplit Global $CaseCountyCheck, $CaseRDALocationCheck, $CaseValidation3LocationCheck, $CaseValidation4LocationCheck, $SplitFile ;;--------------------------------Check and Read Config files-------------------------------- $SysConfigFile = @ScriptDir & "\SysConfig.ini" ;----------------PreCheck for Config File-------------- If FileExists ($SysConfigFile) <> 1 Then Exit EndIf ;----------------End PreCheck-------------------------- $FileNetEXE = @ScriptDir & "\" & IniRead ($SysConfigFile, "FileNetUploader","FileName","") $delimiter = IniRead ($SysConfigFile, "FileInformation", "Delimiter","") $Filter = IniRead ($SysConfigFile, "FileInformation", "Filter", "") $ConfigFile = @ScriptDir & "\Config.ini" ;----------------PreCheck for Config File-------------- If FileExists ($ConfigFile) <> 1 Then Exit EndIf ;----------------End PreCheck-------------------------- ;;-------------------------------------------------------------------------------------------- $Sections = IniReadSectionNames ($ConfigFile) ;MsgBox (0,"test", $Sections[0] & @CRLF & $Sections[1] & @CRLF & $Sections[2] & @CRLF & $Sections[3] & @CRLF & $Sections[4]);TESTING ONLY - DELETE WHEN DONE $p = 0 Do $t = 0 ;used for precheck $p = $p + 1 ConfigDefineVars($Sections[$p]) ;MsgBox(0,"ConfigDefineVars", $sFolder & @CRLF & $dFolder & @CRLF & $cFolder);TESTING ONLY - DELETE WHEN DONE PreCheck($dFolder, $sFolder, $cFolder) ;Runs a Pre-check to make sure folder structure exists before running the program If $t = 0 Then ;MsgBox(0,"PreCheck Run", "Running next functions");TESTING ONLY - DELETE WHEN DONE ListArray($sFolder, $Filter) ;Puts File Names in String Array ;_ArrayDisplay ($aFileList, $Sections[$p]) If $t = 0 Then FileSplitCount($dFolder, $aFileList) ;Takes filename String Array and splits by $delimiter ;MsgBox(0,"PreCheck Run2", "Running split function");TESTING ONLY - DELETE WHEN DONE Else ;MsgBox(0,"PreCheck Run2", "Skipping split function");TESTING ONLY - DELETE WHEN DONE EndIf Else ;MsgBox(0,"PreCheck Run", "Skipping next functions");TESTING ONLY - DELETE WHEN DONE EndIf Until $p = $Sections[0] ExitScript() ;Exit script Function Func ConfigDefineVars($SectionsNum);Defines Variables from config file Sections $sFolder = IniRead ($ConfigFile, $SectionsNum, "pendingFolder","") ;Pending Folder, Folder that is awaiting the process $dFolder = IniRead ($ConfigFile, $SectionsNum, "reviewFolder","") ;Review Folder, Files that did not pass validation check and division needs to review $cFolder = IniRead ($ConfigFile, $SectionsNum, "completedFolder","") ;Completed Folder, Once process is completed this would be location files get moved to $FileNetProperties = IniRead ($ConfigFile, $SectionsNum, "FileNetProperties","") $FileNetPropertiesSplit = StringSplit ($FileNetProperties,",") $ValidationDocumentTitle = IniRead ($ConfigFile, $SectionsNum, "ValidationDocumentTitle","") $ValidationDocumentTitleLocation = IniRead ($ConfigFile, $SectionsNum, "ValidationDocumentTitleLocation","") $ValidationCountyCodeLocation = IniRead ($ConfigFile, $SectionsNum, "ValidationCountyCodeLocation","") $ValidationRDA = IniRead ($ConfigFile, $SectionsNum, "ValidationRDA","") $ValidationRDALocation = IniRead ($ConfigFile, $SectionsNum, "ValidationRDALocation","") $Validation3 = IniRead ($ConfigFile, $SectionsNum, "Validation3","") $Validation3Location = IniRead ($ConfigFile, $SectionsNum, "Validation3Location","") $Validation4 = IniRead ($ConfigFile, $SectionsNum, "Validation4","") $Validation4Location = IniRead ($ConfigFile, $SectionsNum, "Validation4Location","") If $ValidationCountyCodeLocation = 999 Then $CaseCountyCheck = 1 <> 1 Else ;MsgBox (0,"test of county code", "location = " &$ValidationCountyCodeLocation) $CaseCountyCheck = StringLen('$SplitFile[$ValidationCountyCodeLocation]') <> 3 ; Checks for 3 digit County Code EndIf If $ValidationRDALocation = 999 Then $CaseRDALocationCheck = 1 <> 1 Else $CaseRDALocationCheck = '$SplitFile[$ValidationRDALocation]' <> $ValidationRDA ; Checks for 4 Digit RDA EndIf If $Validation3Location = 999 Then $CaseValidation3LocationCheck = 1 <> 1 Else $CaseValidation3LocationCheck = '$SplitFile[$Validation3Location]' <> $Validation3 ; Checks that Approved = True EndIf If $Validation4Location = 999 Then $CaseValidation4LocationCheck = 1 <> 1 Else $CaseValidation3LocationCheck = '$SplitFile[$Validation4Location]' <> $Validation4 ; Checks that Document Type = PERM EndIf EndFunc Func ValidationCheck ($check1) $blank = StringLen ($check1) If $check1 Then EndIf EndFunc Func PreCheck($dFolder, $sFolder, $cFolder) ;----------------PreCheck for Destination Folder-------------- If FileExists ($dFolder) <> 1 Then $t = 1 Return Else $FileLog = FileOpen($dFolder & "\FileLog.log", 1) EndIf ;----------------End PreCheck-------------------------- ;----------------PreCheck for Source Folder-------------- If FileExists ($sFolder) <> 1 Then _FileWriteLog($FileLog, "Path to Pending Folder -- " & $sFolder & " -- does not exist") $t = 1 Return EndIf ;----------------End PreCheck-------------------------- ;----------------PreCheck for Completed Folder--------- If FileExists ($cFolder) <> 1 Then _FileWriteLog($FileLog, "Path to Completed Folder -- " & $cFolder & " -- does not exist") $t = 1 Return EndIf ;----------------End PreCheck-------------------------- EndFunc Func ListArray($sFolder, $Filter) $aFileList = _FileListToArray($sFolder, $Filter, 1) ;Create an array of files from the source folder filtering by filetype ;in the config.ini files for the specified section If @error = 1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") _FileWriteLog($FileLog, "Path to File(s) is Invalid") $t = 1 Return EndIf If @error = 4 Then ;MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") _FileWriteLog($FileLog, "No File(s) were found, exiting.") $t = 1 Return EndIf EndFunc ;==>ListArray  
       
       
       
    • Miliardsto
      By Miliardsto
      Hello Im using Metro UDF and there is a code when menu panel is shown by clicking on menu button.
       
      And what I want I want make instead  Case $GUI_MENU_BUTTON, this $MenuSelect[1].. Case
      While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $GUI_CLOSE_BUTTON _Metro_GUIDelete($Form1) ;Delete GUI/release resources, make sure you use this when working with multiple GUIs! Exit Case $GUI_MINIMIZE_BUTTON GUISetState(@SW_MINIMIZE, $Form1) Case $GUI_MENU_BUTTON ;Create an Array containing menu button names Local $MenuButtonsArray[5] = ["Themes Demo", "Settings", "About", "Contact", "Exit"] ; Open the metro Menu. See decleration of $MenuButtonsArray above. Local $MenuSelect = _Metro_MenuStart($Form1, 150, $MenuButtonsArray) Switch $MenuSelect ;Above function returns the index number of the selected button from the provided buttons array. Case "0" ConsoleWrite("Returned 0 = Starting themes demo. Please note that the window border colors are not updated during this demo." & @CRLF) ;_ThemesDemo() Case "1" ConsoleWrite("Returned 1 = Settings button clicked." & @CRLF) Case "2" ConsoleWrite("Returned 2 = About button clicked." & @CRLF) Case "3" ConsoleWrite("Returned 3 = Contact button clicked." & @CRLF) Case "4" ConsoleWrite("Returned 4 = Exit button clicked." & @CRLF) _Metro_GUIDelete($Form1) Exit EndSwitch WEnd I tried something like this what I found on forum but not work
      ;~ Case Else ;~ For $i = 0 To $MenuSelect ;~ ;MsgBox("","",$liczba) ;~ ;MsgBox("","",$MenuSelect) ;~ If $MenuSelect == "1" Then ;~ ;If $MenuSelect[$i] = "0" Then ;~ ConsoleWrite("Returned 1 = Settings button clicked." & @CRLF) ;~ ;EndIf ;~ Elseif $MenuSelect == "2" Then ;~ ConsoleWrite("Returned 2" & @CRLF) ;~ ExitLoop ;~ EndIf ;~ Next  
×