Jump to content

Recommended Posts

Hello World!!!, please I need help I wanted to read the GUICreateInput, I don't know whats wrong with my script.

 

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <GUIListViewEx.au3>


GUICreate("My GUI", 300, 100)
GUISetState(@SW_SHOW)

Local $sInput = GUICtrlCreateInput("", 150, 50, 50, 20)
Local $sRead = GUICtrlRead($sInput,0)
Local $sAdd = GUICtrlCreateButton("Read", 80, 50, 50, 20)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

        Case $iAdd
            MsgBox(0, "Input!!!", $sRead)

    EndSwitch

WEnd

 

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to post
Share on other sites

Should be:

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <GUIListViewEx.au3>

GUICreate("My GUI", 300, 100)
Local $sInput = GUICtrlCreateInput("", 150, 50, 50, 20)
Local $sAdd = GUICtrlCreateButton("Read", 80, 50, 50, 20)
GUISetState(@SW_SHOW)
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $sAdd
            $sRead = GUICtrlRead($sInput, 0)
            MsgBox(0, "Input!!!", $sRead)
    EndSwitch
WEnd

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites
  • Moderators

232showtime,

You need to read the input after the button has been pressed - at the moment you are doing so as it is created, when it will always be empty.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By DigiBox
      Hello!
      Please help me with this small problem I've encountered while learning to make GUI.
      I'm not able to get the set slider values out of sliders and I can't figure out why.
      The slider value in the example is preset to 1, but whatever I set the slider to, it returns the value 3 when I click Apply and I havn't set any value to 3.
      Where is that 3 coming from?
       
      #include <SliderConstants.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> Global $LRSlider Opt("GUIOnEventMode", 1) Global $Form1 = GUICreate("test slider", 200, 200, -1, -1) Global $LRSlider = GUICtrlCreateSlider(50, 50, 100, 20, $TBS_TOOLTIPS) GUICtrlSetLimit($LRSlider, 50, 1) GUICtrlSetData($LRSlider, 1) GUISetOnEvent($GUI_EVENT_CLOSE, "Exit1") Global $ApplyButton = GUICtrlCreateButton("APPLY", 100, 150, 89, 17) GUICtrlSetOnEvent($ApplyButton, "Apply") GUISetState(@SW_SHOW) Func Apply() GUICtrlRead($LRSlider) MsgBox(0, 0, $LRSlider) GUICtrlSetData($LRSlider, $LRSlider) EndFunc ;==>Apply Func Exit1() Exit EndFunc ;==>Exit1 While 1 Sleep(200) WEnd  
    • By fopetesl
      One statement of GUICtrlRead() fails. Result is always "Long/Short" in written file.
      The other GUICtrlRead() calls work as expected
      Func GetScanSettings() ; Read User Input for scan Local $collectusername, $collectlot, $collectsample $UserFile = "Sample.dat" ; Global $UserFile = save this scan's parameters $datafile = FileOpen($UserFile) If( $datafile <> -1) Then $collectusername = FileReadLine($datafile, 1) EndIf FileClose($datafile) ; now open a new 'clean' file.. $datafile = FileOpen($UserFile,$FO_OVERWRITE ) ;Create GUI $Main = GUICreate('Enter Sample Detail', 500, 500) Opt("GUICoordMode",1) If( $collectusername <> "") Then $username = GUICtrlCreateInput($collectusername,100,20,100,20) Else $username = GUICtrlCreateInput('',100,20,100,20) EndIf $usernamelabel = GUICtrlCreateLabel('Username',30,22) $FileName = GUICtrlCreateInput("",100,45,100,0) $FileNamelabel = GUICtrlCreateLabel('File Name',30,47) $BatchNum = GUICtrlCreateInput("",100,65,100,0) $BatchNumlabel = GUICtrlCreateLabel('Lot',30,72) $SampleNum = GUICtrlCreateInput("",100,85,100,0) $SampleNumlabel = GUICtrlCreateLabel('Sample',30,97) $SampleLS = GUICtrlCreateInput("",100,105,100,0) $SampleNumLS = GUICtrlCreateLabel('Long/Short',30,117) $Button_1 = GUICtrlCreateButton ("OK", 190, 170, 0, 0, 0x0001) GUISetState (); Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() ; complete data entries Select Case $msg = $Button_1 $collectusername = GUICtrlRead($username) WinSetState('Collect Username','',@SW_HIDE) $collectfilename = GUICtrlRead($FileName) $collectlot = GUICtrlRead($BatchNum) $collectsample = GUICtrlRead($SampleNum) $collectLS = GUICtrlRead($SampleNumLS) ; Do ; $collectLS = GUICtrlRead($SampleNumLS) ; If $collectLS <> 'Long' And $collectLS <> 'Short' Then ; Soundplay("Windows XP Error.wav", 1) ; $collectLS = "" ; EndIf ; Until $collectLS = 'Long' Or $collectLS = 'Short' ExitLoop EndSelect Wend GUIDelete($Main) FileWrite($datafile,$collectusername & @CRLF & $collectfilename & @CRLF & $collectlot _ & @CRLF & $collectsample & @CRLF & 'Long' & @CRLF ) ; $collectLS & @CRLF) FileClose($datafile) EndFunc ;<=== GetScanSettings ================== I also tried to force user to enter either 'Short' or 'Long' but I got that wrong also
      The final FileWrite() edited so I do have a correct result.
      sample.dat
      Pete FilenamePete Num1 Samp2 Long/Short  
    • By 232showtime
      im getting strange output in array display,$split_[1] is not properly aligned to other arrays and why guictrlsetdata is not writting any data if i put comma(,) at the end of the text in $Input1???
       
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form=C:\Users\user\Desktop\Script\StringSplit.kxf $Form1 = GUICreate("Form1", 623, 449, 192, 114) $Input1 = GUICtrlCreateInput("50UGITQ421X, 50UGITQ422X, 50UGITQ423X, 50UGITQ427X, 50UGITQ431X, 50UGITQ435X, 50UGITQ436X, 50UGITQ437X, 50UGITQ441X, 50UGITQ445X, 50UGITQ449X, 50UGITQ453X, 50UGITQ454X, 50UGITQ455X, 50UGITQ459X", 24, 16, 553, 21) $Split = GUICtrlCreateButton("Split", 24, 48, 75, 25) $List1 = GUICtrlCreateList("", 24, 96, 553, 97) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Split $read = GUICtrlRead($Input1) $split_ = StringSplit($read, ",") $Max = UBound($split_, 1) For $i = 1 To UBound($split_) - 1 ConsoleWrite($split_[$i] & @CRLF) ;~ ControlSetText($Form1, "", $List1, $split_[$i]) GUICtrlSetData($List1, $split_[$i]) ;~ GUICtrlSetData($List1, $split_[$i]) ;~ GUICtrlSetData($List1, $i) Next _ArrayDisplay($split_) EndSwitch WEnd  
    • By Skysnake
      Hi
      Wiki has this entry: https://www.autoitscript.com/wiki/Label, which differs from the actual Help file.
      I can not READ the value of a LABEL.  Code
      GuiCtrlRead($myLabel) returns "False". Help appreciated.
    • By iresolver
      Hi guys When I run this part of my script     If GUICtrlRead(Input1) = "" Then on_Close()      it closes that gui window but still sends 0
      I want it to send nothing if the user don't type anything
      anyone know how to fix this?
      thanks
      this is my full script       the   GUICtrlRead(input1) = "" Then on_Close()    is near the bottom of the script
      #RequireAdmin #include <IE.au3> #include <ComboConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <AutoEmail.au3> Opt("GUIOnEventMode", 1) AutoItSetOption ( "TrayIconDebug", 1 ) Global $AutoEmail, $AutoReplace_GUI = 9999, $Gmail_Button, $Hotmail_Button, $AutoReplace_Button = 9999 ; Predeclare the variables with dummy values to prevent firing the Case statements Global $Gmail1_Button, $Gmail2_Button, $Hotmail1_Button, $Hotmail2_Button, $Input1, $Input2, $Input3, $Input4 Global $Gmail, $Hotmail, $cCombo, $cCombo2 Global $sFilename = @ScriptFullPath Global $DataFromUser GUI_AutoEmail() Func GUI_AutoEmail() $AutoEmail = GUICreate("Auto Email", 339, 125, @DesktopWidth, @DesktopHeight) $aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd]", "") $aWin = WinGetPos($AutoEmail) WinMove($AutoEmail, "", @DesktopWidth - $aWin[2] - 4, @DesktopHeight - $aWin[3] - $aTaskbar[3] - 4) GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function $Gmail_Button = GUICtrlCreateButton("Gmail", 64, 16, 49, 41, $BS_ICON) GUICtrlSetImage(-1, "C:\Program Files\AutoEmail\gmail_icon.ico", 1) $Hotmail_Button = GUICtrlCreateButton("Hotmail", 223, 16, 49, 41, $BS_ICON) GUICtrlSetImage(-1, "C:\Program Files\AutoEmail\MSMail_icon.ico", 1) Global $cCombo = GUICtrlCreateCombo("", 16, 72, 145, 25) GUICtrlSetData(-1, "YourAccount1@gmail.com|YourAccount2@gmail.com", "YourAccount1@gmail.com") $cCombo2 = GUICtrlCreateCombo("", 176, 72, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "YourAccount1@hotmail.com|YourAccount2@hotmail.com", "YourAccount1@hotmail.com") Global $msg GUICtrlSetOnEvent(3, "On_Button") GUICtrlSetOnEvent(4, "On_Button") GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function $AutoReplace_Button = GUICtrlCreateButton("Add Your Email", 10, 100, 80, 30) GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function GUISetState() EndFunc Func On_Button() Switch @GUI_CTRLID ; See which button sent the message Case $Gmail_Button Gmail() Case $Hotmail_Button Hotmail() Case $AutoReplace_Button GUICtrlSetState($AutoReplace_Button, $GUI_DISABLE) GUI_AutoReplace() Case $Gmail1_Button AddEmail1() Case $Gmail2_Button AddEmail2() Case $Hotmail1_Button AddEmail3() Case $Hotmail2_Button AddEmail4() EndSwitch EndFunc ;--------------------------------------- This is the Main App Read Combos --------------------------------------------------------------------- While 1 Sleep(10) WEnd Func Gmail() $DataFromUser = GUICtrlRead($cCombo) If $DataFromUser = "YourAccount1@gmail.com" Then gmail_login1() EndIf $DataFromUser = GUICtrlRead($cCombo) If $DataFromUser = "YourAccount2@gmail.com" Then gmail_login2() EndIf EndFunc Func Hotmail() $DataFromUser = GUICtrlRead($cCombo2) If $DataFromUser = "YourAccount1@hotmail.com" Then hotmail_login1() EndIf $DataFromUser = GUICtrlRead($cCombo2) If $DataFromUser = "YourAccount2@hotmail.com" Then hotmail_login2() EndIf EndFunc ;----------------------------------------------------- This sends account info to web Browser & Logs in ------------------------------------------------------------ Func gmail_login1() Sleep (60) Global $oIE =_IECreate ("https://accounts.google.com/ServiceLogin?sacu=1&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fpc%3Dtopnav-about-en&hl=en&service=mail") local $username = _IEGetObjByName ($oIE, "Email") Local $password = _IEGetObjByName ($oIE, "Passwd") Local $Email_button = _IEGetObjByName ($oIE, "Email") Local $Signin_button = _IEGetObjByName ($oIE,"signIn") _IEFormElementSetValue ($username, "YourAccount1@gmail.com") ;<===== Here you put your Gmail Account Name _IEFormElementSetValue ($password, "Your Password") ;<===== Here you put your Gmail Account Password _IEAction ($Email_button, "click") _IEAction ($Signin_button, "click") EndFunc Func gmail_login2() Sleep(60) Global $oIE =_IECreate ("https://accounts.google.com/ServiceLogin?sacu=1&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fpc%3Dtopnav-about-en&hl=en&service=mail") local $username = _IEGetObjByName ($oIE, "Email") Local $password = _IEGetObjByName ($oIE, "Passwd") Local $Email_button = _IEGetObjByName ($oIE, "account-email") Local $Signin_button = _IEGetObjByName ($oIE,"signIn") _IEFormElementSetValue ($username, "YourAccount2@gmail.com") ;<===== Here you put your 2nd Gmail Account Name _IEFormElementSetValue ($password, "Your Password") ;<===== Here you put your 2nd Gmail Account Password _IEAction ($Email_button, "click") _IEAction ($Signin_button, "click") EndFunc Func hotmail_login1() Sleep(60) Global $oIE =_IECreate ("http://www.live.com") local $username = _IEGetObjByName ($oIE, "login") Local $password = _IEGetObjByName ($oIE, "passwd") Local $Signin_button = _IEGetObjByName ($oIE,"SI") _IEFormElementSetValue ($username, "YourAccount1@hotmail.com") ;<===== Here you put your Hotmail Account Name _IEFormElementSetValue ($password, "Your Password") ;<===== Here you put your Hotmail Account Password _IEAction ($Signin_button, "click") EndFunc Func hotmail_login2() Sleep(60) Global $oIE =_IECreate ("http://www.live.com") local $username = _IEGetObjByName ($oIE, "login") Local $password = _IEGetObjByName ($oIE, "passwd") Local $Signin_button = _IEGetObjByName ($oIE,"SI") _IEFormElementSetValue ($username, "YourAccount2@hotmail.com") ;<===== Here you put your Hotmail Account Name _IEFormElementSetValue ($password, "Your Password") ;<===== Here you put your Hotmail Account Password _IEAction ($Signin_button, "click") EndFunc Func On_Close() Switch @GUI_WINHANDLE ; See which GUI sent the CLOSE message Case $AutoEmail Exit ; If it was this GUI - we exit <<<<<<<<<<<<<<< Case $AutoReplace_GUI GUIDelete($AutoReplace_GUI) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<< GUICtrlSetState($AutoReplace_Button, $GUI_ENABLE) EndSwitch EndFunc Func GUI_AutoReplace() $AutoReplace_GUI = GUICreate("Auto Add Email", 474, 324, 969, 306) $Input1 = GUICtrlCreateInput("", 24, 32, 329, 21) $Gmail1_Button = GUICtrlCreateButton("Add Gmail", 360, 30, 89, 25) $Label_AddGmail1 = GUICtrlCreateLabel("Type Your Gmail Account1", 24, 8, 131, 17) $Input2 = GUICtrlCreateInput("", 24, 106, 329, 21) $Gmail2_Button = GUICtrlCreateButton("Add Gmail", 360, 104, 89, 25) $Label_AddGmail2 = GUICtrlCreateLabel("Type Your Gmail Account2", 24, 82, 131, 17) $Input3 = GUICtrlCreateInput("", 24, 183, 329, 21) $Hotmail1_Button = GUICtrlCreateButton("Add Hotmail", 360, 181, 89, 25) $Label1 = GUICtrlCreateLabel("Type Your Hotmail Account1", 21, 159, 140, 17) $Input4 = GUICtrlCreateInput("", 24, 257, 329, 21) $Hotmail2_Button = GUICtrlCreateButton("Add Hotmail", 360, 255, 89, 25) $Label2 = GUICtrlCreateLabel("Type Your Homail Account2", 21, 233, 137, 17) GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function GUICtrlSetOnEvent(9, "On_Button") GUICtrlSetOnEvent(12, "On_Button") GUICtrlSetOnEvent(15, "On_Button") GUICtrlSetOnEvent(18, "On_Button") GUICtrlSetOnEvent(3, "On_Button") GUICtrlSetOnEvent(4, "On_Button") GUISetState() EndFunc Func AddEmail1() If GUICtrlRead($Input1) = "" Then On_Close() $DataFromUser = GUICtrlRead($Input1) _ReplaceStringInFile ($sFilename, $sFindg1, $DataFromUser) ;FileSaveDialog("Save File", @ScriptDir, "Au3 Files (*.au3)", 16) EndFunc Func AddEmail2() If GUICtrlRead($Input2) = "" Then On_Close() $DataFromUser = GUICtrlRead($Input2) _ReplaceStringInFile ($sFilename, $sFindg2, $DataFromUser) ;FileSaveDialog("Save File", @ScriptDir, "Au3 Files (*.au3)", 16) EndFunc Func AddEmail3() If GUICtrlRead($Input3) = "" Then On_Close() $DataFromUser = GUICtrlRead($Input3) _ReplaceStringInFile ($sFilename, $sFindh1, $DataFromUser) ;FileSaveDialog("Save File", @ScriptDir, "Au3 Files (*.au3)", 16) EndFunc Func AddEmail4() If GUICtrlRead($Input4) = "" Then On_Close() $DataFromUser = GUICtrlRead($Input4) _ReplaceStringInFile ($sFilename, $sFindh2, $DataFromUser) ;FileSaveDialog("Save File", @ScriptDir, "Au3 Files (*.au3)", 16) EndFunc
×
×
  • Create New...