Jump to content

Recommended Posts

Posted (edited)

Hello
I have a problem with how to get the text from GuiCtrlInput field into a string variable. Has tested and tested but has not got it working. I hope there is someone here who can help me with this problem.

 

#NoTrayIcon
;#include <GUIConstantsEx.au3>
Global Const $gui_focus = 256
Global Const $gui_disable = 128
Global Const $gui_event_close = -3

If NOT IsDeclared("WS_CAPTION") Then Local Const $ws_caption = 12582912
If NOT IsDeclared("WS_SYSMENU") Then Local Const $ws_sysmenu = 524288




menu()

;Global $_a3c_path = @ScriptDir & "\A3C.exe", $_a3c_dir


Func menu()
    

    
    $run = FileOpenDialog("Select a file!",  @homedrive, "Run (*.exe)",1,"",GUICreate("",-1,-1,360,-1))
    ;SoundPlay("m6.wav", 0)
    
    $gui = GUICreate("Add data. ", 400, 158, -1, -1, 12582912, BitOR(262144, 256))
    GUISetBkColor(14745599)
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 262160)
    GUISetIcon(@TempDir & "\3.ico")
    
    $groupbox1 = GUICtrlCreateGroup("", 8, 1, 383, 150) ;235 $groupbox1 = GUICtrlCreateGroup("", 8, 1, 383, 235)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
        
    GUICtrlCreateLabel("   Path/Exe fil:  ", 9, 30, 125, 25, 1)
    GUICtrlSetFont(-1, 8, 700, 2, "verdana")                     
    GUICtrlSetColor(-1, 255)
    
    $Run1 = GUICtrlCreateInput($Run, 117, 25, 260, 20)
    GUICtrlSetFont(-1, 9, 700, 2, "verdana")
    GUICtrlSetColor(-1, 0x773C3C);4194304)
        
    GUICtrlCreateLabel("   Key Name:   ", 9, 58, 125, 35, 1)
    GUICtrlSetFont(-1, 8, 700, 2, "verdana")                      
    GUICtrlSetColor(-1, 255)
    
    $Key = GUICtrlCreateInput("", 117, 55, 230, 20)
    GUICtrlSetFont(-1, 9, 700, 2, "verdana")
    GUICtrlSetColor(-1, 0x773C3C);4194304)
        
    GUICtrlCreateLabel("      Menu Text: ", 9, 88, 125, 35, 1)
    GUICtrlSetFont(-1, 8, 700, 2, "verdana")                      
    GUICtrlSetColor(-1, 255)
    
    $Text = GUICtrlCreateInput("", 117, 85, 230, 20)
    GUICtrlSetFont(-1, 9, 700, 2, "verdana")
    GUICtrlSetColor(-1, 0x773C3C);4194304)  
        
    $04 = GUICtrlCreateButton("OK", 117, 115, 75, 25)
    GUICtrlSetFont(-1, 9, 400, 2, "verdana")
    ;GUICtrlSetState(-1, $gui_disable)
    
    $05 = GUICtrlCreateButton("Close", 215, 115, 75, 25) ;225
    GUICtrlSetFont(-1, 9, 400, 2, "verdana")
    GUISetState(@SW_SHOW)
    ;Send("{TAB}")
    
    
    While 1
        
        $nmsg = GUIGetMsg()
        Switch $nmsg
            Case $gui_event_close
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
                GUIDelete($gui)
            Case $04                                                                                     
                    close()                                                                            
                            
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
                    
                    Exit                    
            Case $05                                                                                                                      
                
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)   
                GUIDelete($gui)
                Return 
        EndSwitch
    WEnd
    
        
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
    GUIDelete($gui)
    
       Exit
EndFunc

Func close() 
        Exit
EndFunc

 

Edited by Borje
Posted

Your code doesn't show where you're trying to read from the Input controls.

Use GUICtrlRead to read the contents of the input control.

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

Posted

Hi BreManNh

 

I have already test that and that not works perhaps i have done som wrong, when I type in some data in the inputs and all is empty after it passed the loop

can you give some exaple what I must do.. I would like to have all the inputs string when i click on on button...

Posted

Show the code where you're reading from the input controls, because what you posted doesn't show that. We can't tell you what you're doing wrong if we don't know what you're doing and how.

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

Posted

Hi

When I use this code in case $04 That works perfekt but if I copy that to the _intregate function that no works msg box present run ok but the 2 other present 0 0

also strings are gone what i am doing wrong?

 

 

Func _integrate() 
    
                Local $Run1,$Nyckel1,$Nyckel,$Text,$text1
                
                $Run1 = GUICtrlRead($run,1)
                $Nyckel1 = GUICtrlRead($Nyckel,1)
                $Text1 = GUICtrlRead($Text,1)
                
                MsgBox(4096, "Reading Info.................  ",$Run & " "& $Nyckel1 & " " & $Text1)     
    Exit
EndFunc

 

Posted

Ok, last chance.

Show your code that YOU ARE USING, in its entirety, so that I can see what you are doing and where. That code you just posted isn't even referenced in the first script, so I don't know how you're calling it or where. Post a full runnable script, even if just a reproducer, that shows exactly how you're reading from the controls.

BTW, none of the control ID variables in your first script are able to be seen by any other function in your script because they're all local variables in it.

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

Posted

I have solved this problem now that was when I use the func that been problem but when I exitloop and inserted this after the wend command all works but why it not worked in a func it produces only 00.

Posted

Is there anybody that can answer my question why it not works in the func process? And why it works outside the loop?

 

 

  • Moderators
Posted
8 minutes ago, Borje said:

Is there anybody that can answer my question

Not without seeing complete and runnable code, as has been asked of you a couple of times.

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

How to get your question answered on this forum!

Posted

This is the whole code so far and as long as I do not get it working in the func process but under Button1 it works hoping for help.

 

 

NoTrayIcon
Global Const $gui_focus = 256
Global Const $gui_disable = 128
Global Const $gui_event_close = -3

If NOT IsDeclared("WS_CAPTION") Then Local Const $ws_caption = 12582912
If NOT IsDeclared("WS_SYSMENU") Then Local Const $ws_sysmenu = 524288

menu()


Func menu()
    

    
    $Run = FileOpenDialog("Select a file!",  @homedrive, "Run (*.exe)",1,"",GUICreate("",-1,-1,360,-1))
    ;SoundPlay("m6.wav", 0)
    
    $gui = GUICreate("Add data. ", 400, 158, -1, -1, 12582912, BitOR(262144, 256))
    GUISetBkColor(14745599)
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 262160)
    GUISetIcon(@TempDir & "\3.ico")
    
    $groupbox1 = GUICtrlCreateGroup("", 8, 1, 383, 150) ;235 $groupbox1 = GUICtrlCreateGroup("", 8, 1, 383, 235)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
        
    GUICtrlCreateLabel("   Path/Exe fil:  ", 9, 30, 125, 25, 1)
    GUICtrlSetFont(-1, 8, 700, 2, "verdana")                     
    GUICtrlSetColor(-1, 255)
    
    $Run1 = GUICtrlCreateInput($Run, 117, 25, 260, 20)
    GUICtrlSetFont(-1, 9, 700, 2, "verdana")
    GUICtrlSetColor(-1, 0x773C3C);4194304)
        
    GUICtrlCreateLabel("   Key Name:   ", 9, 58, 125, 35, 1)
    GUICtrlSetFont(-1, 8, 700, 2, "verdana")                      
    GUICtrlSetColor(-1, 255)
    
    $Nyckel = GUICtrlCreateInput("", 117, 55, 230, 20)
    GUICtrlSetFont(-1, 9, 700, 2, "verdana")
    GUICtrlSetColor(-1, 0x773C3C);4194304)
        
    GUICtrlCreateLabel("      Menu Text: ", 9, 88, 125, 35, 1)
    GUICtrlSetFont(-1, 8, 700, 2, "verdana")                      
    GUICtrlSetColor(-1, 255)
    
    $Text = GUICtrlCreateInput("", 117, 85, 230, 20)
    GUICtrlSetFont(-1, 9, 700, 2, "verdana")
    GUICtrlSetColor(-1, 0x773C3C);4194304)  
        
    $Button1 = GUICtrlCreateButton("OK", 117, 115, 75, 25)
    GUICtrlSetFont(-1, 9, 400, 2, "verdana")
    ;GUICtrlSetState(-1, $gui_disable)
    
    $Button2 = GUICtrlCreateButton("Close", 215, 115, 75, 25) ;225
    GUICtrlSetFont(-1, 9, 400, 2, "verdana")
    GUISetState(@SW_SHOW)
    Send("{TAB}")
    
    
    While 1
        
        $nmsg = GUIGetMsg()
        Switch $nmsg
            Case $gui_event_close
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
                GUIDelete($gui)
            
            Case $Button1                                                                                     
                                                                                            
                            
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
                    
                ;Local $Run,$Run1,$Nyckel1,$Nyckel,$Text,$text1
            
                 ;$Nyckel1 = GUICtrlRead($Nyckel,1)
                 ;$Text1 = GUICtrlRead($Text,1)
                
                 ;MsgBox(4096, "Read inputs ............  ",$Run & " "& $Nyckel1 & " " & $text1)
                    
                                        
                    show()    
                    Exit                    
            Case $Button2                                                                                                                      
                
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)   
                GUIDelete($gui)
                Return 
        EndSwitch
    WEnd
    
        
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
    GUIDelete($gui)
    
       Exit
EndFunc

Func show() 
        
                 Local $Run,$Run1,$Nyckel1,$Nyckel,$Text,$text1
            
                 $Nyckel1 = GUICtrlRead($Nyckel,1)
                 $Text1 = GUICtrlRead($Text,1)
                
                MsgBox(4096, "Read inputs ............  ",$Run1 & " "& $Nyckel1 & " " & $text1)
                Exit
                
        
EndFunc

 

Posted

Like I stated earlier, none of the control IDs from the menu() function can be seen in the show() function because they are in the local scope of the menu function. Redeclaring them as Local in the show function does nothing to help your script. You need to make them Global variables so that they can be used in other functions, or pass them as parameters to the function you're calling.

; ++++++++++++++
; Using Global variables
; ++++++++++++++

#NoTrayIcon
#include <GUIConstants.au3>
Global $Nyckel, $Text ; <<<<<<<<<< Add this line

menu()
Func menu()
    $Run = FileOpenDialog("Select a file!", @HomeDrive, "Run (*.exe)", 1, "", GUICreate("", -1, -1, 360, -1))
    ;SoundPlay("m6.wav", 0)
    $gui = GUICreate("Add data. ", 400, 158, -1, -1, 12582912, BitOR(262144, 256))
    GUISetBkColor(14745599)
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 262160)
    GUISetIcon(@TempDir & "\3.ico")
    $groupbox1 = GUICtrlCreateGroup("", 8, 1, 383, 150) ;235 $groupbox1 = GUICtrlCreateGroup("", 8, 1, 383, 235)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateLabel("   Path/Exe fil:  ", 9, 30, 125, 25, 1)
    GUICtrlSetFont(-1, 8, 700, 2, "verdana")
    GUICtrlSetColor(-1, 255)
    $Run1 = GUICtrlCreateInput($Run, 117, 25, 260, 20)
    GUICtrlSetFont(-1, 9, 700, 2, "verdana")
    GUICtrlSetColor(-1, 0x773C3C) ;4194304)
    GUICtrlCreateLabel("   Key Name:   ", 9, 58, 125, 35, 1)
    GUICtrlSetFont(-1, 8, 700, 2, "verdana")
    GUICtrlSetColor(-1, 255)
    $Nyckel = GUICtrlCreateInput("", 117, 55, 230, 20)
    GUICtrlSetFont(-1, 9, 700, 2, "verdana")
    GUICtrlSetColor(-1, 0x773C3C) ;4194304)
    GUICtrlCreateLabel("      Menu Text: ", 9, 88, 125, 35, 1)
    GUICtrlSetFont(-1, 8, 700, 2, "verdana")
    GUICtrlSetColor(-1, 255)
    $Text = GUICtrlCreateInput("", 117, 85, 230, 20)
    GUICtrlSetFont(-1, 9, 700, 2, "verdana")
    GUICtrlSetColor(-1, 0x773C3C) ;4194304)
    $Button1 = GUICtrlCreateButton("OK", 117, 115, 75, 25)
    GUICtrlSetFont(-1, 9, 400, 2, "verdana")
    ;GUICtrlSetState(-1, $gui_disable)
    $Button2 = GUICtrlCreateButton("Close", 215, 115, 75, 25) ;225
    GUICtrlSetFont(-1, 9, 400, 2, "verdana")
    GUISetState(@SW_SHOW)
    Send("{TAB}")
    While 1
        $nmsg = GUIGetMsg()
        Switch $nmsg
            Case $gui_event_close
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
                GUIDelete($gui)
            Case $Button1
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
                show()
                Exit
            Case $Button2
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
                GUIDelete($gui)
                Return
        EndSwitch
    WEnd
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
    GUIDelete($gui)
    Exit
EndFunc   ;==>menu
Func show()
    Local $Run, $Run1, $Nyckel1, $text1 ; <<<<<<<<<< Don't redeclare what should be Global variables as local and expect them to work
    $Nyckel1 = GUICtrlRead($Nyckel, 1)
    $text1 = GUICtrlRead($Text, 1)
    MsgBox(4096, "Read inputs ............  ", $Run1 & " " & $Nyckel1 & " " & $text1)
    Exit
EndFunc   ;==>show
; ++++++++++++
; Using Local variables and passing them to the function
; ++++++++++++
#NoTrayIcon
#include <GUIConstants.au3>

menu()
Func menu()
    $Run = FileOpenDialog("Select a file!", @HomeDrive, "Run (*.exe)", 1, "", GUICreate("", -1, -1, 360, -1))
    ;SoundPlay("m6.wav", 0)
    $gui = GUICreate("Add data. ", 400, 158, -1, -1, 12582912, BitOR(262144, 256))
    GUISetBkColor(14745599)
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 262160)
    GUISetIcon(@TempDir & "\3.ico")
    $groupbox1 = GUICtrlCreateGroup("", 8, 1, 383, 150) ;235 $groupbox1 = GUICtrlCreateGroup("", 8, 1, 383, 235)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateLabel("   Path/Exe fil:  ", 9, 30, 125, 25, 1)
    GUICtrlSetFont(-1, 8, 700, 2, "verdana")
    GUICtrlSetColor(-1, 255)
    $Run1 = GUICtrlCreateInput($Run, 117, 25, 260, 20)
    GUICtrlSetFont(-1, 9, 700, 2, "verdana")
    GUICtrlSetColor(-1, 0x773C3C) ;4194304)
    GUICtrlCreateLabel("   Key Name:   ", 9, 58, 125, 35, 1)
    GUICtrlSetFont(-1, 8, 700, 2, "verdana")
    GUICtrlSetColor(-1, 255)
    $Nyckel = GUICtrlCreateInput("", 117, 55, 230, 20)
    GUICtrlSetFont(-1, 9, 700, 2, "verdana")
    GUICtrlSetColor(-1, 0x773C3C) ;4194304)
    GUICtrlCreateLabel("      Menu Text: ", 9, 88, 125, 35, 1)
    GUICtrlSetFont(-1, 8, 700, 2, "verdana")
    GUICtrlSetColor(-1, 255)
    $Text = GUICtrlCreateInput("", 117, 85, 230, 20)
    GUICtrlSetFont(-1, 9, 700, 2, "verdana")
    GUICtrlSetColor(-1, 0x773C3C) ;4194304)
    $Button1 = GUICtrlCreateButton("OK", 117, 115, 75, 25)
    GUICtrlSetFont(-1, 9, 400, 2, "verdana")
    ;GUICtrlSetState(-1, $gui_disable)
    $Button2 = GUICtrlCreateButton("Close", 215, 115, 75, 25) ;225
    GUICtrlSetFont(-1, 9, 400, 2, "verdana")
    GUISetState(@SW_SHOW)
    Send("{TAB}")
    While 1
        $nmsg = GUIGetMsg()
        Switch $nmsg
            Case $gui_event_close
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
                GUIDelete($gui)
            Case $Button1
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
                show($Nyckel, $Text)
                Exit
            Case $Button2
                DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
                GUIDelete($gui)
                Return
        EndSwitch
    WEnd
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 327696)
    GUIDelete($gui)
    Exit
EndFunc   ;==>menu
Func show($input1, $input2)
    Local $Run, $Run1, $Nyckel1, $text1 ; <<<<<<<<<< Don't redeclare what should be Global or passed variables as local and expect them to work
    $Nyckel1 = GUICtrlRead($input1)
    $text1 = GUICtrlRead($input2)
    MsgBox(4096, "Read inputs ............  ", $Run1 & " " & $Nyckel1 & " " & $text1)
    Exit
EndFunc   ;==>show

 

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

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
×
×
  • Create New...