Jump to content
Stormgrade

@GUI_CTRLID mess with my switch

Recommended Posts

Stormgrade

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
Melba23

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
Stormgrade

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
Melba23

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
Stormgrade

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
Melba23

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

    • RHolmes
      By RHolmes
      I wrote a script a few months ago that was working at the time. When I tried it today it wouldn't retrieve any controls.  The application successfully launches, but I cannot figure out how to retrieve the control from the window that is launched. I'm on a windows 10 machine using AutoIt v3.3.14.2. The only thing I can think of that has changed is windows updates? Code is below, any help is greatly appreciated.    ; Notes: ; HandleError( handleToCheck, MsgToLogOnFailure, terminateAutoItOnFail ) : function that simply checks the handle and quits AutoIt if not present ; all of this works well FileChangeDir( $CLIENT_APPLICATION_DIR ); Run( "Client.exe" ) Local $hClient = WinWaitActive( $CLIENT_TITLE, "", 10 ) $terminateOnFail = 1 HandleError( $hClient, "LaunchClient::Error: Failed to launch client. Either timed-out or failed.", $terminateOnFail ) LogToFile( "Client launched, waiting for system to ready." ) Sleep( 5000 ) ; this part does not work ; $SYSTEM_INDICATOR is a global variable. I have tried these values: "SystemIndicatorWindow" (Text), "Qt5QWindowIcon101" (ClassNN), and ; "[CLASS:Qt5QWindowIcon; INSTANCE:101]" Local $hStatusIndicator = ControlGetHandle( $hClient, "", $SYSTEM_INDICATOR ) HandleError( $hStatusIndicator, "CheckStatus::Error: couldn't retrieve control: " & $SYSTEM_INDICATOR, $terminateOnFail ) This is what the spy reveals: 

       
      Edit: I just tried this code and it works for notepad++.
      FileChangeDir( "C:\Program Files\Notepad++\" ); Run( "notepad++.exe" ) Local $hNotePad = WinWaitActive( "new 1 - Notepad++", "", 10 ) If $hNotePad = 0 Or $hNotePad = -1 Then MsgBox( $MB_SYSTEMMODAL, "Error", "Error getting app handle." ) EndIf Sleep( 1000 ) Local $hNewFileBtn = ControlGetHandle( $hNotePad, "", "[CLASS:ToolbarWindow32; INSTANCE:1]" ) If $hNewFileBtn = 0 Or $hNewFileBtn = -1 Then MsgBox( $MB_SYSTEMMODAL, "Error", "Error getting button handle." ) EndIf MsgBox( $MB_SYSTEMMODAL, "Success", "Success." )  
    • rcmaehl
      By rcmaehl
      A UDF with Extended Functions for Window Management
       
      Notes:
      Fixes WinGetClassList's barbaric returning of a @LF separated string instead of an array.
       
      Potential Uses:
      Automating applications that change their controls' handles/classes on each launch (e.g. half of Cisco's programs)
       
      Functions:
      _WinGetClassList
      _WinGetClassNNList
      _WindowGetHandleList
      _WindowGetHandleListFromPos
       
      Download: 
      WindowEx.zip  (v0.4)
       
      Changelog:
      10/04/2016 (v0.4): _WinGetClassNNList Fixed : Not Returning an Index when using $2D_ARRAY _WinGetClassNNList Fixed : Not Properly returning $aArray[x][1] on Classes with instances > 9 when using $2D_ARRAY 10/03/2016 (v0.3): _WinGetClassList Added : Exactly the same as WinGetClassList but returns a more civilized Array _WinGetClassNNList Added : Returns Classes and their instances in either a 1D or 2D array depending on Flags _WindowGetHandleList Renamed: _WinGetHandleList SCRIPT BREAKING! _WindowGetHandleListFromPos Renamed: _WinGetHandleListFromPos SCRIPT BREAKING! 10/01/2016 (v0.2): WindowsExConstants.au3 Added : Flags in _WindowGetHandleListFromPos _WindowGetHandleListFromPos Removed: ConsoleWrite left in during debug _WindowGetHandleListFromPos Added : Flag for if part of a Control is at $X, $Y return it as well. 10/01/2016 (v0.1): _WindowGetHandleList Added : Retrieves the handles of classes from a window. _WindowGetHandleListFromPos Added : Retrieves the handles of classes at a specific position from a window. Known and Reported Bugs:
      None reported To Do:
      To Be Decided. Opinions welcome! Upcoming Changes:
      To Be Decided.
    • Reziskonh
      By Reziskonh
      Hi, everybody
      I look for GUI whose behavior similar to the message of an email client or antivirus
      In other words:
          Any PC screen able to calculate the size
          To consider the Task bar size
          To find the lower corner on the right/below and to nestle on it

      Notes:
      In GUI the GUICtrlCreateEdit field (as option) - that can be received and displayed through variable information
      Thanks a lot
      PS
      I use the translator, excuse if something is not clear
       

    • Pike
      By Pike
      Hello Everyone,
      New Guy here. This is a two-part question, hopefully easy enough though. I know it's ugly coding, this is because I have only a couple hours worth of coding experience and could really use some help.
      1) When I single click the button I want one action (like playing a sound clip) and when I double click the button I want a different action (such as opening dialogue box to ask for soundclip directory address). At the bottom of the script I made a comment which one I would like single click versus double click.
      2) I can not get the FileOpenDialogue to save the file address to the config.ini file at the 'One' position on the .ini.
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <AutoItConstants.au3> #include <Sound.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) Global $OneID _Main() Func _Main() GUICreate("Form1", 156, 86, 281, 276) $OneID = GUICtrlCreateButton("Button", 15, 17, 122, 37) GUICtrlSetOnEvent($OneID, "OnOne") GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") GUISetState() While 1 While 1 Sleep(1000) WEnd WEnd EndFunc ;---------------Functions------------- While 1 Sleep(100) WEnd Func OnOne() ; ******************Single Click for this action**************** $OneID = IniRead("config.ini", "Config", "One", $OneID) If $OneID = True Then SoundPlay($OneID, @HotKeyPressed) Else ; *******Double Click for this action*****And Help Saving File Address to config.ini 'One'*********** $OneID = FileOpenDialog("Select file", @WorkingDir, "All (*.*)") IniWrite("config.ini", "Config", "One", $OneID) $OneID = InputBox("Enter Information", "Short Name for File?", "") IniWrite("config.ini", "Config", "NameOne", $OneID) EndIf EndFunc Any help would be greatly appreciated, and if you need anymore clarity as to what exactly I'm trying to do, please do not hesitate to ask. Thanks so much!
      Pike
    • VollachR
      By VollachR
      Hi,
      I'd like to show a progress bar for an operation performed by an external program my script is running silently, I want to show it in a GUI I created using the GUICtrlCreateProgress but I have no idea how to do it.
      The important thing to point out is that there's no way of knowing how long the external program will run, as it is a file splitter and it depends on the size of file it splits and the split parts size.
      Can someone point me in the right direction or give me an example how to do so?
      This is my RunWait command:
      RunWait($MYFILES1 & '\fsplit.exe -split ' & $Size & ' mb ' & $File & " -f " & $File & "." & $extension) It uses multiple variables declared and set earlier in the script, how will I got about having the progress of that command shown using GUICtrlCreateProgress ? Is it possible?
      Thank you.
×