Stormgrade

@GUI_CTRLID mess with my switch

6 posts in this topic

Hello,

I need some help with my gui, when I click on button 2 it call a MsgBox 2, but when I click on button 1 then button 2 it call a MsgBox 1.

I tear appart my code to minimal function then the error occur again ...

Here the script :

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version : 3.3.14.0
 Auteur:

 Fonction du Script :
    Modèle de Script AutoIt.

#ce ----------------------------------------------------------------------------

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>


Opt("GUIOnEventMode", 1);important pour gérer les fonctions et les gui

Global $GUI1
Global $GUI1_Label1, $GUI1_Label2
Global $GUI1_Input1, $GUI1_Input2
Global $GUI1_Bouton1, $GUI1_Bouton2, $GUI1_Bouton3

Global $GUI2 = 9999
Global $GUI2_Label1 = 9999, $GUI2_Label2 = 9999, $GUI2_Label3 = 9999
Global $GUI2_Input1 = 9999, $GUI2_Input2 = 9999, $GUI2_Input3 = 9999
Global $GUI2_Bouton1 = 9999
Global $GUI2_Checkbox1 = 9999

Global $GUI3 = 9998, $GUI3_Input1 = 9998, $GUI3_Label1 = 9998, $GUI3_Bouton1 = 9998

Global $GUI4 = 9997
Global $GUI4_List1 = 9997
Global $GUI4_Bouton1 = 9997, $GUI4_Bouton2 = 9997, $GUI4_Bouton3 = 9997, $GUI4_Bouton4 = 9997, $GUI4_Bouton5 = 9997, $GUI4_Bouton6 = 9997, $GUI4_Bouton7 = 9997

Global $GUI9 = 5689
Global $GUI9_Input1 = 5689, $GUI9_Input2 = 5689, $GUI9_Input3 = 5689, $GUI9_Input4 = 5689
Global $GUI9_Label1 = 5689, $GUI9_Label2 = 5689, $GUI9_Label3 = 5689, $GUI9_Label4 = 5689
Global $GUI9_Bouton1 = 5689

Global $GUI6 = 9995
Global $GUI6_Label1 = 9995, $GUI6_Label2 = 9995, $GUI6_Label3 = 9995
Global $GUI6_Input1 = 9995, $GUI6_Input2 = 9995, $GUI6_Input3 = 9995
Global $GUI6_Bouton1 = 9995
Global $GUI6_Checkbox1 = 9995

Global $GUI7 = 9994
Global $GUI7_Label1 = 9994, $GUI7_Label2 = 9994, $GUI7_Label3 = 9994
Global $GUI7_Input1 = 9994, $GUI7_Input2 = 9994, $GUI7_Input3 = 9994
Global $GUI7_Bouton1 = 9994, $GUI7_Bouton2 = 9994, $GUI7_Bouton3 = 9994
Global $GUI7_Checkbox1 = 9994


Global $MyQuery, $MyQueryRow
Global $TempDataEncryptage, $TempDataDecryptage
Global $Input1_Read, $Input2_Read, $Input3_Read, $Input4_Read
Global $aSQLResult, $iRows, $iColumns, $iRval
Global $GUI4_List1_Indice, $GUI4_List1_Item


GUI1_Principal()

Func GUI1_Principal();fenêtre principale
    $GUI1 = GUICreate("Password Manager", 266, 120, 786, 412)
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")

    $GUI1_Label1 = GUICtrlCreateLabel("Login", 24, 12, 30, 18)
    $GUI1_Label2 = GUICtrlCreateLabel("Password", 8, 44, 50, 18)

    $GUI1_Bouton1 = GUICtrlCreateButton("OUVRIR", 192, 8, 58, 58)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetOnEvent(-1, "On_Button")
    $GUI1_Bouton2 = GUICtrlCreateButton("Change Password", 144, 72, 114, 34)
    GUICtrlSetOnEvent(-1, "On_Button")
    $GUI1_Bouton3 = GUICtrlCreateButton("Change Login", 8, 72, 114, 34)
    GUICtrlSetOnEvent(-1, "On_Button")

    $GUI1_Input1 = GUICtrlCreateInput("", 64, 8, 114, 22)
    $GUI1_Input2 = GUICtrlCreateInput("", 64, 40, 114, 22)

    GUISetState()

    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>GUI1_Principal

Func GUI2_change_password();changer mot de passe
    $GUI2 = GUICreate("Change Password", 284, 152, 721, 395)
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")

    $GUI2_Label1 = GUICtrlCreateLabel("Last Password", 8, 12, 74, 18)
    $GUI2_Label2 = GUICtrlCreateLabel("New Password", 8, 44, 76, 18)
    $GUI2_Label3 = GUICtrlCreateLabel("Check Password", 8, 76, 84, 18)

    $GUI2_Input1 = GUICtrlCreateInput("", 120, 8, 154, 22)
    $GUI2_Input2 = GUICtrlCreateInput("", 120, 40, 154, 22)
    $GUI2_Input3 = GUICtrlCreateInput("", 120, 72, 154, 22)

    $GUI2_Bouton1 = GUICtrlCreateButton("VALIDATE", 136, 104, 114, 34)
    GUICtrlSetOnEvent(-1, "On_Button")

    $GUI2_Checkbox1 = GUICtrlCreateCheckbox("Display Password", 8, 112, 114, 18)
    GUICtrlSetOnEvent(-1, "On_Checkbox")

    GUISetState()
EndFunc ;=>GUI2_change_password

Func GUI3_change_login();changer login
    $GUI3 = GUICreate("Change Login", 240, 102, 674, 392)
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")

    $GUI3_Input1 = GUICtrlCreateInput("", 88, 16, 114, 22)

    $GUI3_Label1 = GUICtrlCreateLabel("New Login", 16, 20, 56, 18)

    $GUI3_Bouton1 = GUICtrlCreateButton("VALIDATE", 88, 48, 114, 34)
    GUICtrlSetOnEvent(-1, "On_Button")

    GUISetState()
EndFunc ;=>GUI3_change_login

Func GUI4_Manager();manager
    $GUI4 = GUICreate("Password Manager", 528, 282, 690, 294)
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")


    $GUI4_List1 = GUICtrlCreateListView("", 16, 16, 426, 188)

    $GUI4_Bouton1 = GUICtrlCreateButton("Add Entry", 16, 216, 98, 50)
    GUICtrlSetOnEvent(-1, "On_Button")
    $GUI4_Bouton2 = GUICtrlCreateButton("Modify Entry", 120, 216, 98, 50)
    GUICtrlSetOnEvent(-1, "On_Button")
    $GUI4_Bouton3 = GUICtrlCreateButton("Delete Entry", 232, 216, 98, 50)
    GUICtrlSetOnEvent(-1, "On_Button")
    $GUI4_Bouton4 = GUICtrlCreateButton("View", 344, 216, 98, 50)
    GUICtrlSetOnEvent(-1, "On_Button")
    $GUI4_Bouton5 = GUICtrlCreateButton("Trie A/z", 464, 16, 50, 50)
    GUICtrlSetOnEvent(-1, "On_Button")
    $GUI4_Bouton6 = GUICtrlCreateButton("Trie Z/a", 464, 152, 50, 50)
    GUICtrlSetOnEvent(-1, "On_Button")
    $GUI4_Bouton7 = GUICtrlCreateButton("PG", 464, 84, 49, 49)
    GUICtrlSetOnEvent(-1, "On_Button")

    GUISetState()
EndFunc ;=>GUI4_Manager

Func GUI5_Add();add entry
    $GUI9 = GUICreate("Add an entry", 304, 192, 666, 358)
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")

    $GUI9_Input1 = GUICtrlCreateInput("", 112, 16, 178, 22)
    $GUI9_Input2 = GUICtrlCreateInput("", 112, 48, 178, 22)
    $GUI9_Input3 = GUICtrlCreateInput("", 112, 80, 178, 22)
    $GUI9_Input4 = GUICtrlCreateInput("", 112, 112, 178, 22)

    $GUI9_Label1 = GUICtrlCreateLabel("Name", 8, 20, 32, 18)
    $GUI9_Label2 = GUICtrlCreateLabel("Login", 8, 52, 30, 18)
    $GUI9_Label3 = GUICtrlCreateLabel("Password", 8, 84, 50, 18)
    $GUI9_Label4 = GUICtrlCreateLabel("Retape Password", 8, 116, 88, 18)

    $GUI9_Bouton1 = GUICtrlCreateButton("Validate", 112, 144, 114, 34); <================== problem
    GUICtrlSetOnEvent($GUI9_Bouton1, "On_Button")

    GUISetState()
EndFunc ;=>GUI5_Add

Func GUI6_MOD();mod entry
    $GUI6 = GUICreate("Modify Entry", 288, 166, 572, 306)
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")

    $GUI6_Label1 = GUICtrlCreateLabel("Name", 8, 20, 32, 18)
    $GUI6_Label2 = GUICtrlCreateLabel("Login", 8, 52, 30, 18)
    $GUI6_Label3 = GUICtrlCreateLabel("Password", 8, 84, 50, 18)

    $GUI6_Input1 = GUICtrlCreateInput("", 80, 16, 194, 22)
    $GUI6_Input2 = GUICtrlCreateInput("", 80, 48, 194, 22)
    $GUI6_Input3 = GUICtrlCreateInput("", 80, 80, 194, 22)

    $GUI6_Bouton1 = GUICtrlCreateButton("Modify", 160, 120, 114, 34)
    GUICtrlSetOnEvent(-1, "On_Button")

    $GUI6_Checkbox1 = GUICtrlCreateCheckbox("Show Password", 40, 128, 100, 18)
    GUICtrlSetOnEvent(-1, "On_Checkbox")

    GUISetState()
EndFunc ;=>GUI6_MOD

Func GUI7_VIEW();view entry
    $GUI7 = GUICreate("View", 398, 112, 590, 298)
    GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close")

    $GUI7_Label1 = GUICtrlCreateLabel("Name", 8, 12, 32, 18)
    $GUI7_Label2 = GUICtrlCreateLabel("Login", 8, 44, 30, 18)
    $GUI7_Label3 = GUICtrlCreateLabel("Password", 8, 76, 50, 17)

    $GUI7_Input1 = GUICtrlCreateInput("", 80, 8, 218, 22)
    $GUI7_Input2 = GUICtrlCreateInput("", 80, 40, 218, 22)
    $GUI7_Input3 = GUICtrlCreateInput("", 80, 72, 218, 22)

    $GUI7_Bouton1 = GUICtrlCreateButton("Copy", 312, 40, 66, 26)
    GUICtrlSetOnEvent(-1, "On_Button")
    $GUI7_Bouton2 = GUICtrlCreateButton("Copy", 312, 72, 66, 26)
    GUICtrlSetOnEvent(-1, "On_Button")
    $GUI7_Bouton3 = GUICtrlCreateButton("GO", 312, 6, 34, 26)
    GUICtrlSetOnEvent(-1, "On_Button")

    $GUI7_Checkbox1 = GUICtrlCreateCheckbox("", 360, 12, 16, 16)
    GUICtrlSetOnEvent(-1, "On_Checkbox")

    GUISetState()
EndFunc ;=>GUI7_VIEW

Func On_Button();gestion de tout les boutons
    Switch @GUI_CTRLID

        ;### Navigation ###
        Case $GUI1_Bouton1
            GUI4_Manager()


        Case $GUI1_Bouton2
            GUI2_change_password()
        Case $GUI1_Bouton3
            GUI3_change_login()
        Case $GUI4_Bouton1
            GUI5_Add()
        Case $GUI4_Bouton2
            GUI6_MOD()
        Case $GUI4_Bouton4

                GUI7_VIEW()


        ;#################

        Case $GUI2_Bouton1

        Case $GUI3_Bouton1


        Case $GUI9_Bouton1; <================== problem

                MsgBox(64,"Erreur de sécurité 5","Les mots de passe ================================= sont différents.",5)


        Case $GUI7_Bouton1
            ;_ClipBoard_SetData($Input2_Read,$CF_TEXT)
        Case $GUI7_Bouton2
            ;_ClipBoard_SetData($Input3_Read,$CF_TEXT)
        Case $GUI7_Bouton3
            If _IsValidURL($Input1_Read) = 1 Then
                ShellExecute($Input1_Read)
            Else
                MsgBox(64,"Erreur lien","L'URL ne semble pas valide.")
            EndIf

    EndSwitch
EndFunc ;=>On_Button

Func On_Checkbox();gestion des checkbox



EndFunc ;=>On_Checkbox

Func On_Close();gestion fermeture des fenêtres
    Switch @GUI_WINHANDLE
        Case $GUI1

            Exit
        Case $GUI2
            GUIDelete($GUI2)
        Case $GUI3
            GUIDelete($GUI3)
        Case $GUI4
            GUIDelete($GUI4)
        Case $GUI9
            GUIDelete($GUI9)
        Case $GUI6
            GUIDelete($GUI6)
        Case $GUI7
            GUIDelete($GUI7)
    EndSwitch
EndFunc ;=>On_Close


Func _IsValidURL($url)
    Local $IsValid = StringRegExp($url,"^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$")
    Return ($IsValid)
EndFunc ;=>_IsValidURL

 

 The error :

Run my script, click on "OUVRIR" then click on "View" and click on "GO" you get a message : "L'URL ne semble pas valide."

Now close the view menu, click on "Add entry" , close this menu , click on "View" and click on "GO" you get another message : "Les mots de passe ================================= sont différents."

This message must only appear when you click on "Validate" in the "Add entry" menu ....

I had the same problem on another PC with AutoIT 3.3.14.0

I've changed my variable, add another button , etc... The problem occur only with this two menus and this button.

Can you test it ? If you don't have this error perhaps my AutoIT package (installer form AutoIT fr) have a problem.

Thank you.

Share this post


Link to post
Share on other sites



Stormgrade,

The problem occurs because you are constantly creating and deleting GUIs and their controls. When you delete a control (such as by deleting the GUI that holds it) you leave an empty entry in the internal array that AutoIt uses to track the controls it creates - the index of a control in this array is the ControlID that is returned by the GUICtrlCreate* function.

So when you create one of your subsidiary GUIs the controls within it use the first available open entries in this array - and these indicies will be returned as ControlIDs. When you delete the GUI these entries are cleared, when you create the next GUI the controls will also use those entries and so have those ControlIDs - but the variables holding the ControlIDs of the now-deleted controls will still hold the same value, even though the control itself has been deleted. Then when you run your Switch, the first variable to match will fire - and in this  case it is one which refers to a deleted control.

The solution? Create all the GUIs just once at the beginning of the script and hide/show as required - or set all the variables used to store ControlIDs back to their placeholder values (as you do at the beginning of the script) when you delete a GUI. I know which is the simpler solution.

Please ask if anything is still unclear.

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

Thank you !!!!!!!!!!!

I set all the variables used to store ControlID in the "On_close" function like this :

Func On_Close();gestion fermeture des fenêtres
    Switch @GUI_WINHANDLE
        Case $GUI1
            Exit
        Case $GUI2
            GUIDelete($GUI2)
            $GUI2 = 9999
            $GUI2_Label1 = 9999
            $GUI2_Label2 = 9999
            $GUI2_Label3 = 9999
            $GUI2_Input1 = 9999
            $GUI2_Input2 = 9999
            $GUI2_Input3 = 9999
            $GUI2_Bouton1 = 9999
            $GUI2_Checkbox1 = 9999
        Case $GUI3
            GUIDelete($GUI3)
            $GUI3 = 9998
            $GUI3_Input1 = 9998
            $GUI3_Label1 = 9998
            $GUI3_Bouton1 = 9998
        Case $GUI4
            GUIDelete($GUI4)
            $GUI4 = 9997
            $GUI4_List1 = 9997
            $GUI4_Bouton1 = 9997
            $GUI4_Bouton2 = 9997
            $GUI4_Bouton3 = 9997
            $GUI4_Bouton4 = 9997
            $GUI4_Bouton5 = 9997
            $GUI4_Bouton6 = 9997
            $GUI4_Bouton7 = 9997

        Case $GUI9
            GUIDelete($GUI9)
            $GUI9 = 5689
            $GUI9_Input1 = 5689
            $GUI9_Input2 = 5689
            $GUI9_Input3 = 5689
            $GUI9_Input4 = 5689
            $GUI9_Label1 = 5689
            $GUI9_Label2 = 5689
            $GUI9_Label3 = 5689
             $GUI9_Label4 = 5689
            $GUI9_Bouton1 = 5689
        Case $GUI6
            GUIDelete($GUI6)
            $GUI6 = 9995
            $GUI6_Label1 = 9995
            $GUI6_Label2 = 9995
            $GUI6_Label3 = 9995
            $GUI6_Input1 = 9995
            $GUI6_Input2 = 9995
            $GUI6_Input3 = 9995
            $GUI6_Bouton1 = 9995
            $GUI6_Checkbox1 = 9995
        Case $GUI7
            GUIDelete($GUI7)
            $GUI7 = 9994
             $GUI7_Label1 = 9994
             $GUI7_Label2 = 9994
            $GUI7_Label3 = 9994
            $GUI7_Input1 = 9994
            $GUI7_Input2 = 9994
            $GUI7_Input3 = 9994
            $GUI7_Bouton1 = 9994
            $GUI7_Bouton2 = 9994
            $GUI7_Bouton3 = 9994
            $GUI7_Checkbox1 = 9994
    EndSwitch
EndFunc ;=>On_Close

 

 Do you think I just need to do that ? It make me crazy to try to find the error but it seem to work like a charm now :)

Share this post


Link to post
Share on other sites

Stormgrade,

That should work - but I would suggest that the other method I mentioned (creating all the GUIs and then hiding/showing them as required) would be much easier.

Or you could use my GUIExtender UDF to place all the sections within the same GUI and expand/retract the correct section when needed - let me know if you would like some help getting that idea to work.

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

Thank you for your advice, I've used the AutoIt wiki to manage multiple GUI, If I use :

GUISetState(@SW_HIDE, $GUI5)

 GUISetState(@SW_SHOW, $GUI5)

I must "rethink" all I'had done with the GUis.

I've already used your UDF for a protoype, it's very useful for hiding showing GUI inside a GUI but I don't intend to make a password manager inside one GUI.

Share this post


Link to post
Share on other sites

Stormgrade,

That sounds like you have got the measure of the problem - glad I could help you get there.

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

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

  • Similar Content

    • kawliga751
      By kawliga751
      I have a workplace GUI that has a search field function that pulls up customer records to allow changes. I am attempting to 1)LOGIN 2)Enter Search field, enter a number and then {ENTER} 3)change specific field once customer record loads. I have very limited experience in GUI manipulation but I am able to login using the below:
      #include <IE.au3> Const $navOpenInNewTab = 0x0800 Dim $oIE = _IECreate('http://asag.xxxxxxx.com/ASAG/index.htm') Call ("RacksheetSignIn") Func RacksheetSignIn () Local $username = _IEGetObjByName ($oIE,"uname") Local $password = _IEGetObjByName ($oIE,"pword") $oIE.Navigate2('http://asag.xxxxxxx.com/apps/RackSheets/LogInSAG/login.asp',2048) _IEFormElementSetValue ($username, "xxxxxxx") _IEFormElementSetValue ($password, "xxxxxxx") Send('{Enter}') EndFunc However I can't seem to use the _IEGetObjByName or Mouseclick to focus on the search field to allow me to enter my search criteria. When I "inspect element" in the Search field I get the attached:
       
      Any help would be MUCH appreciated
       
       
       

    • Jibberish
      By Jibberish
      I am having difficulties getting updated results from GUICtrlCreateInput. I wrote a small script to demonstrate what I am trying to do.
      This script reads a text file into an array and displays the Name and Number from the text file.
      The user can check a name and change the number, and the results are displayed in _ArrayDisplay.
      Only the Checked names are displayed in their original position. This is necessary for future
      plumbing.
      The problem with this script is the original number is returned, not the changed number. I cannot
      figure out how to get the updated number to be displayed.
      ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; This script reads a text file into an array and displays the Name and Number from the text file. ; The user can check a name and change the number, and the results are displayed in _ArrayDisplay. ; Only the Checked names are displayed in their original position. This is necessary for future ; plumbing. ; ; The problem with this script is the original number is returned, not the changed number. I cannot ; figure out how to get the updated number to be displayed. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include-once #include <MsgBoxConstants.au3> #include <array.au3> #include <Date.au3> #include <WinAPIFiles.au3> #include <AutoItConstants.au3> #include <Misc.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Local $iMax = 6 ;Default number of Videos - 1 for the array counter Dim $aTextFile[$iMax][2] ; [start with 5 entries][Name, Number] Don't get confused! [Row][Column] Local $i = 0 Local $iLeft = 30 Local $iTop = 30 Local $sName Local $sNumber Local $aArray Local $iMaxCol = 5 Local $iRow = 0 Local $iCol = 0 Local $aNumberCount[$iMaxCol][2] $aArray1 = ReadFile() $aNamesNumbers = DisplayNames($aArray1) _ArrayDisplay($aNamesNumbers) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; ReadFile() places the contents of the NameNumber.txt file in an array ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func ReadFile() Local $sFileData = @ScriptDir & "\NameNumber.txt" Local $iStrReturn = 0 Local $aArrayFile Local $aTextFile[$iMaxCol][2] Local $aName Local $sCheckBox1 Const $iL = 10 ; Count from Left for GUI so all buttons line up Local $sFill Local $iA = 0, $iN = 0 ; Put the Names into an Array _FileReadToArray($sFileData, $aArrayFile) For $iA = 0 To $aArrayFile[0] ; Step through the array looking for Names If StringInStr($aArrayFile[$iA], "Name:") Then $aName = StringSplit($aArrayFile[$iA],":") $sFill = $aName[2] If UBound($aTextFile) <= $iRow Then ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol] EndIf $aTextFile[$iRow][$iCol] = $sFill $iRow += 1 EndIf Next $iCol = 1 $iRow = 0 $sFill = "" For $iA = 1 To $aArrayFile[0] ; Step through the array looking for Numbers If StringInStr($aArrayFile[$iA], "Number:") Then $aName = StringSplit($aArrayFile[$iA],":") $sFill = $aName[2] If UBound($aTextFile) <= $iRow Then ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol] EndIf $aTextFile[$iRow][$iCol] = $sFill $iRow += 1 EndIf Next Return $aTextFile EndFunc ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display the Name and Number ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func DisplayNames($aArray1) Local $aName[$iMax] Local $aNumbers[$iMax] $iMMCount = UBound($aArray1) $iMMCount -=1 Local $iWidth = 300 Local $iLength = 300;$iMMCount * 30 GUISetFont(12) $hGUI = GUICreate("Edit / Update Number Test", $iWidth, $iLength, -1, -1) GUICtrlCreateLabel(" Name Number",1,5) ;$iTop += 30 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display Name with a Checkbox. Only Checked Names should be saved. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For $i = 0 to $iMMCount Step 1 $sNameText = $aArray1[$i][0] $iNameLength = StringLen($sNameText) $aName[$i] = GUICtrlCreateCheckbox($sNameText,$iLeft, $iTop) $iTop += 30 Next ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display the number from the text file below each name. Allow the user to change the number and display the ; new number. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $iLeft = 60 GUIStartGroup() $iTop = 28 For $i = 0 to $iMMCount Step 1 $sNumberText = $aArray1[$i][1] $aNumberCount[$i][1] = $sNumberText $aNumberCount[$i][0] = GUICtrlCreateInput($sNumberText,$iLeft, $iTop, 50,18, $GUI_DOCKAUTO) GUICtrlSetPos($aNumberCount[$i][0],200) $iTop += 30 Next ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Read the checked names and (possibly updated) number ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $iMMCount = UBound($aNumberCount) $iMMNewCount = $iMMCount - 1 Local $aGUICheckbox[$iMMCount] Local $aCheckedNameNumber[$iMMCount][2] $iLeft = 30 Local $idCloseGUI = GUICtrlCreateButton("Close",$iLeft, $iTop) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idCloseGUI For $i = 0 To $iMMNewCount Step 1 Switch GUICtrlRead($aName[$i]) Case $GUI_CHECKED $aCheckedNameNumber[$i][0] = $aArray1[$i][0] Case $GUI_UNCHECKED EndSwitch Switch GUICtrlRead($aNumberCount[$i][0]) Case $aCheckedNameNumber[$i][1] = GUICtrlRead($aNumberCount[$i][1]) EndSwitch Next ExitLoop EndSwitch WEnd For $i = 0 to $iMMNewCount step 1 GUICtrlRead($aNumberCount[$i][0]) If $aCheckedNameNumber[$i][0] <> "" Then $aCheckedNameNumber[$i][1] = $aNumberCount[$i][1] EndIf Next GUIDelete($hGUI) Return $aCheckedNameNumber EndFunc This is the text file I am reading. If you want to try this out put the NameNumber.txt file in your script directory. It's attached to the post.
      * This is a dummy file with a Name and Number * The only purpose of this file is to read the updated Number. Name:Taggart Number:916 Name:Mongo Number:90 Name:Hedley Lamarr Number:22 Name:Bart Number:9999 Name:The Waco Kid Number:2244 If I change the number, the original number is displayed at the end, not the updated/modified number. I need the modified number to be displayed.
      Thanks in advance for any assistance!
      Jibberish
      NameNumber.txt
    • FMS
      By FMS
      Hello,
      As I was searching this forum I came along something intresting what was new to me.
      CUI/GUI hybrid.
      Whish sounds very usefull to me to compile it all into 1 script.
      So i was fideling around whit it but couldn't get it to work.
      In the real script (not this simplified version) i got a lot of functions whish i can use whan talking to it by commandline and switches.
      I could not get this to work and hope somebody could give me some pointers on how to make it work.
      Also I was hoping iff somebody could help me whit the /? function?
      (I don't know how to output the help text back to the commandline or the function that can help me do it)
      please advice and thanks in advanced.
      #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Change2CUI=y #include <Process.au3> #include <Array.au3> If $CmdLine[0] = 0 Then If _ProcessGetName(ProcessGetParent(@AutoItPID)) = "cmd.exe" Then ;ConsoleWrite("Program was started in CMD" & @CRLF) If Mod($CmdLine[0], 2) <> 0 Then Exit MsgBox(16, $sTitle, "Invalid number of parameters! has to be a multiple of 2!") If $CmdLine[0] = 0 Then Exit MsgBox(16, $sTitle, "No parameters passed!") For $i = 1 To $CmdLine[0] Step 2 If $CmdLine[$i] = "/switch" Then MsgBox(64, "Passed Parameters", "/switch is " & $CmdLine[$i+1]) If $CmdLine[$i] = "/?" Then MsgBox(64, "Passed Parameters", "/? " ) Next _ArrayDisplay($CmdLine) Else #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 239, 65, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 32, 24, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 120, 24, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 button1() Case $button2 button2() EndSwitch WEnd EndIf EndIf Exit Func button1() MsgBox(16, "title", "button1()!") EndFunc Func button2() MsgBox(16, "title", "button1()!") EndFunc Func ProcessGetParent($i_PID) ;get PID from parent process done by SmOke_N Local $TH32CS_SNAPPROCESS = 0x00000002 Local $a_tool_help = DllCall("Kernel32.dll", "long", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPPROCESS, "int", 0) If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_PID) Local $tagPROCESSENTRY32 = _ DllStructCreate( _ "dword dwsize;" & _ "dword cntUsage;" & _ "dword th32ProcessID;" & _ "uint th32DefaultHeapID;" & _ "dword th32ModuleID;" & _ "dword cntThreads;" & _ "dword th32ParentProcessID;" & _ "long pcPriClassBase;" & _ "dword dwFlags;" & _ "char szExeFile[260]" _ ) DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32)) Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32) Local $a_pfirst = DllCall("Kernel32.dll", "int", "Process32First", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32) If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_PID) Local $a_pnext, $i_return = 0 If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_PID Then $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID") DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0]) If $i_return Then Return $i_return Return $i_PID EndIf While @error = 0 $a_pnext = DllCall("Kernel32.dll", "int", "Process32Next", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32) If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_PID Then $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID") If $i_return Then ExitLoop $i_return = $i_PID ExitLoop EndIf WEnd DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0]) Return $i_return EndFunc ;==>ProcessGetParent  
    • Jibberish
      By Jibberish
      Hello,
      I have used this forum to get help many times. I thought it was time to (hopefully) help others.
      I created a script that reads a text file with a list of videos, displays the videos in a GUI with checkboxes next to the names, and displays the selected videos. This will become a part of a larger script I am creating to test a video player. The tough part for me was creating the GUI and Dynamic list of videos. I had a lot of trouble finding samples to help me, but finally found one  written by Melba23. The link is in the code, so he gets credit for helping! I also have not used arrays much and they are very picky about looping through the arrays without getting the dreaded error " Array variable has incorrect number of subscripts or subscript dimension range exceeded."  However diligence paid off!
      To run this code, take the video names commented below and create a videos.txt file in your script execution directory. You can put however many video names in this list. Thus the dynamic features of the code.
      Cheers!
      Jibberish
      #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <array.au3> #include <File.au3> #include <GUIConstantsEx.au3> Local $sMediaFile = @ScriptDir & "\videos.txt" ;~ Videos in videos.txt are: ;~ bbb_1080_60s.mp4 ;~ bbb_1080_60s_1.mp4 ;~ bbb_1080_60s_2.mp4 ;~ tos_4K_60s_HEVC.mp4 ;~ tos_4K_60s_HEVC_1.mp4 ;~ tos_4K_60s_HEVC_2.mp4 ;~ ;~ Additional videos can be added to this list. The functions are Dynamic. Dim $aMediaManifest Local $aArrayFile Local $aVideos Local $sVideoName Local $i ; MAIN ; Put the Video File Names into an Array _FileReadToArray($sMediaFile, $aArrayFile) Local $iVideoCount = UBound($aArrayFile) -1 ; Get the number of videos - 1 to prevent errors _ArrayDelete($aArrayFile, 0) ;Counter just gets in the way ; Move backwards through the array deleting the blank lines For $i = $iVideoCount - 1 To 0 Step -1 If $aArrayFile[$i] = "" Then _ArrayDelete($aArrayFile, $i) EndIf Next $aVideos = DisplayVideos($aArrayFile) $iVideoCount = UBound($aArrayFile) -1 _ArrayDisplay($aVideos) ; Display the checked videos ;~ End of MAIN ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; GUI to display Videos in checkboxes ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func DisplayVideos($aArrayFile) Local $iTop = -1 Local $iLeft = -1 Local $iWidth Local $iHeight = $iVideoCount * 30 Local $iL = 10 Local $iT = 10 Local $iRow = 0 Local $aVideo Local $iA = 0, $iB = 0 Local $sFill = "" $iMMCount = UBound($aArrayFile) $iMMNewCount = $iMMCount - 1 Local $aGUICheckbox[$iMMCount] Local $aCheckedVideos[$iMMCount] ; Put the Video File Names into an Array $hGUI = GUICreate("Video Checkbox", $iLeft, $iTop, $iWidth, $iHeight) GUICtrlCreateLabel("Videos", 180, $iT) $iT = $iT + 30 ; This is a great example of using arrays to create GUI check boxes or radio buttons For $i = 0 To $iMMNewCount Step 1 $sMP4Text = $aArrayFile[$i] $aGUICheckbox[$i] = GUICtrlCreateCheckbox($sMP4Text, 30, $iT) $iT += 30 Next $idClose1 = GUICtrlCreateButton("Start", $iL, $iT) GUISetState(@SW_SHOW) ; This section reads the checkboxes and puts the video names in an array in their original position ; in case this is important (as it is to me) ; This was the toughest part to code, and I found no samples online until I saw Melba23's sample here: ; https://www.autoitscript.com/forum/topic/119843-dynamic-gui-problem/#comment-832672 ; I got this working with only a little modification. THANK YOU MELBA23 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idClose1 For $i = 0 To $iMMNewCount Step 1 Switch GUICtrlRead($aGUICheckbox[$i]) Case $GUI_CHECKED $aCheckedVideos[$i] = $aArrayFile[$i] Case $GUI_UNCHECKED EndSwitch Next ExitLoop EndSwitch WEnd GUIDelete($hGUI) Return $aCheckedVideos EndFunc ;==>DisplayVideos  
    • thoms
      By thoms
      Hello Forum,
      As said in the title, I'm searching a way to disable all tabstops in a GUI. My GUI includes 15 buttons and 3 edit controls.
      My questions:
      - is there a way to disable all tabstops at a time
      - is there a way to list all controls of a GUI and then disable tabstops one by one
      - or should I use the following line after each button creation:
      _WinAPI_SetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE), BitNOT($WS_TABSTOP))) Thanks in advance for your valuable help!
      Thoms
      Edit: or maybe disable TAB key? I don't remember how to do!