Sign in to follow this  
Followers 0
grimmlock

send String output

13 posts in this topic

What I am trying to do is take the output from $Split which should be just test and display it in $Input2. However when I open this all I get in #Input2 is 0.

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#Include <String.au3>

GuiCreate("test", 400, 400)
GuiSetState(@SW_SHOW)

Local $Input1 = GUICtrlCreateList("test.test.test", 10, 10, 100, 20)

Local $Split = StringTrimRight(GUICtrlRead($Input1), 12)

Local $Input2 = GUICtrlCreateEdit(GUICtrlRead($Split), 10, 50, 100, 20)


Sleep(30000)

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites



$Split isn't a control handle. so guess it should be:

Local $Input1 = GUICtrlCreateList("test.test.test", 10, 10, 100, 20)\
Local $Split = StringTrimRight(GUICtrlRead($Input1), 12)
Local $Input2 = GUICtrlCreateEdit($Split, 10, 50, 100, 20)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Ok, I will change the $Split to something else, my next question is If I want to send the "output" of $Input3 ($Split) would the code be Send($Input3)?

I have tried Send($Input3) and it does not send anything.

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites

Not sure I understand your question, but just have a try as test ...

Post some code snippet when it doesn't work.


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I know why this is failing however I am not sure how to fix it.

The reason it is failing is because in the txt file I am reading from each "line" is seperated by a | .

Here is a simple gui I created that will allow you to see what I am running into.

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#Include <String.au3>

GuiCreate("test", 400, 400)
GuiSetState(@SW_SHOW)
$list1 = Fileread("c:\test.txt")

Local $Combo1 = GUICtrlCreateCombo("", 10, 10, 100, 20)
GUICtrlSetData(-1, "test")
Local $Input1 = GUICtrlCreateList("", 10, 50, 100, 50)
Local $Input3 = StringTrimRight(GUICtrlRead($Input1), 12)
Local $button1 = GUICtrlCreateButton("Notepad", 200, 50, 100, 100)
;~ Local $Input2 = Send($Split, 10, 50, 100, 20)

;~ Local $Input1 = GUICtrlCreateList("", 150, 20

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
Case $combo1
Switch GUICtrlRead($Combo1)
Case "Branch Servers"
GUICtrlSetData($Input1, "|" & $List1)
EndSwitch

Case $button1
Run("Notepad.exe")
Sleep(1000)
Send($Input3)
Sleep(1000)

EndSwitch
WEnd

In the test.txt file all I have is one line test.test1.test1|test1.test1.test1

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You are not really making much sense yet with the posted snippet but tried something to see if that is what you are looking for:

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <String.au3>

GUICreate("test", 400, 400)
GUISetState(@SW_SHOW)
$list1text = FileRead("test.txt")

Local $Combo1 = GUICtrlCreateCombo("", 10, 10, 100, 20)
GUICtrlSetData(-1, "test")
Local $list1 = GUICtrlCreateList("", 10, 50, 100, 50)
GUICtrlSetData($list1,$list1text)
Local $button1 = GUICtrlCreateButton("Notepad", 200, 50, 100, 100)
;~ Local $Input2 = Send($Split, 10, 50, 100, 20)

;~ Local $Input1 = GUICtrlCreateList("", 150, 20

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            Run("Notepad.exe")
            Sleep(1000)
            Send(GUICtrlRead($list1))
            Sleep(1000)
    EndSwitch
WEnd
Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

grimmlock,

You really are going to have to give us more info when you post questions - at the moment it is very difficult to work out exactly what you are trying to do. ;)

Does this script act more like you want:

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <String.au3>

GUICreate("test", 400, 400)
GUISetState(@SW_SHOW)
$list1 = FileRead(@ScriptDir & "\test.txt")

Local $Combo1 = GUICtrlCreateCombo("", 10, 10, 100, 20)
GUICtrlSetData(-1, "test|Branch Servers")
Local $Input1 = GUICtrlCreateList("", 10, 50, 100, 50)
;Local $Input3 = StringTrimRight(GUICtrlRead($Input1), 12) ; Here there is nothing in the control so this variable is always empty <<<<<<<<<<<<<<<<<<<<<
Local $button1 = GUICtrlCreateButton("Notepad", 200, 50, 100, 100)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            Switch GUICtrlRead($Combo1)
                Case "Branch Servers"
                    ConsoleWrite("Hit" & @CRLF)
                    GUICtrlSetData($Input1, "|" & $list1)
            EndSwitch

        Case $button1
            ; Here there is perhaps some thing in the control! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            ; But have you selected an item in the list? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            ; Because what does GUICtrlRead do for a List control? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Local $Input3 = StringTrimRight(GUICtrlRead($Input1), 12)
            ; So check here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            If $Input3 = "" Then
                MsgBox(0,"Error", "No selection")
            Else
                Run("Notepad.exe")
                Sleep(1000)
                Send($Input3)
                Sleep(1000)
            EndIf

    EndSwitch
WEnd

Well, does it? :huh:

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

#8 ·  Posted (edited)

I tried your script but it still does not want to "send" the correct data. My apologizes if I am not making much sense. For the input I am using test.test1.test1|test1.test1.test1. The reason for this is because I have several remote locations that are only pingable by typing in the whole domain name (test.test1.test1). I can ping them just fine, however the next step is to open an app and remote into the PC's at the remote location using just the first part of their name. Test or Test1. That is why I wanted to do a split and remove all characters .test1.test1.

Thanks

Grimm

Edited by grimmlock

Thanks

Grimm

Share this post


Link to post
Share on other sites

Thank you M23 you are the best that was exactly what I needed.

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites

grimmlock,

Which is exactly what the script I posted does when I run it - I get either "test" or "test1" in the Notepad instance. ;)

Are you selecting an item in the list before pressing the button? :huh:

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

#11 ·  Posted (edited)

I modified your script because I am going to merging this with another script I am working on. In the modified script it seems to work except for $Input4 which opens Notepad however sends all the data I selected in the Input box then waits 1 sec and adds the correct entry.

So for instance when I select Branch Servers from the drop down, and select test.test1.test1 and press the button, Notepad opens then types out test.test1.test1 followed by a pause then types in correct response of test. It looks like this (test.test1.test1test)

To answer your question...I am selecting an item in the list before pressing the button

This is what I have:

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <String.au3>

GUICreate("test", 400, 400)
GUISetState(@SW_SHOW)
$list1 = FileRead("C:\test.txt") ; <<<<<< file contains test.test1.test1|test1.test1.test1
$list2 = FileRead("c:\test2.txt") ; <<<<<<<< file contains just test123

Local $Combo1 = GUICtrlCreateCombo("", 10, 10, 100, 20)
GUICtrlSetData(-1, "test|Branch Servers")
Local $Input1 = GUICtrlCreateList("", 10, 50, 100, 50)
Local $button1 = GUICtrlCreateButton("Notepad", 200, 50, 100, 100)


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

Case $Combo1
            Switch GUICtrlRead($Combo1)
Case "Branch Servers"
;~                   ConsoleWrite("Hit" & @CRLF)
                    GUICtrlSetData($Input1, "|" & $list1)
Case "test"
;~  ConsoleWrite("Hit" & @CRLF)
GUICtrlSetData($Input1, "|" & $list2)

            EndSwitch

        Case $button1
Local $Input3 = StringTrimRight(GUICtrlRead($Input1), 0)
Local $Input4 = StringTrimRight(GUICtrlRead($Input1), 12)

If $Input3 = "" Then
                MsgBox(0,"Error", "No selection")
            Else
                Run("Notepad.exe")
                Sleep(1000)
                Send($Input3)
                Sleep(1000)
EndIf

If $Input4 = "" Then
                MsgBox(0,"Error", "No selection")
            Else
                Run("Notepad.exe")
                Sleep(1000)
                Send($Input4)
                Sleep(1000)
EndIf
    EndSwitch
WEnd

Thanks

Grimm

Edited by grimmlock

Thanks

Grimm

Share this post


Link to post
Share on other sites

grimmlock,

when I select Branch Servers from the drop down, and select test.test1.test1 and press the button, Notepad opens then types out test.test1.test1 followed by a pause then types in correct response of test. It looks like this (test.test1.test1test)

Which is exactly what you are telling the script to do: ;)

Case $button1
    Local $Input3 = StringTrimRight(GUICtrlRead($Input1), 0)  ; This will read "test.test1.test1" 
    Local $Input4 = StringTrimRight(GUICtrlRead($Input1), 12) ; This will read "test"

    If $Input3 = "" Then ; Was something selected?
        MsgBox(0, "Error", "No selection")
    Else
        Run("Notepad.exe")
        Sleep(1000)
        Send($Input3) ; Send the contents "test.test1.test1" to Notepad <<<<<<<<<<<<<<<<<<<<<
        Sleep(1000)
    EndIf

    If $Input4 = "" Then ; But here you check again and then.......
        MsgBox(0, "Error", "No selection")
    Else
        Run("Notepad.exe")
        Sleep(1000)
        Send($Input4) ; Send "test" to Notepad <<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Sleep(1000)
    EndIf

I think you would be better served by rearranging the code like this:

Case $button1
    Local $Input3 = StringTrimRight(GUICtrlRead($Input1), 0)  ; This will read "test.test1.test1" 
    Local $Input4 = StringTrimRight($Input3, 12) ; This will read "test" - and why read the control again ;)

    If $Input3 = "" Then ; Was something selected?  Check the first input to see if there was a selection
        MsgBox(0, "Error", "No selection")
    Else
        Run("Notepad.exe")
        Sleep(1000)
        Send($Input4) ; Send the contents of the second input "test" to Notepad
        Sleep(1000)
    EndIf

It seems more logical to me but as I have mentioned many times before, unless you explain clearly what is you are trying to get as a result we are really just whistling int eh dark trying to get your code to work as you want. ;)

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 again M23, however it did not work the way I wanted it.

After coming back from a weekend break, I was able to put this together

Case $button1
Local $Input3 = GUICtrlRead($Input1)
Local $Input4 = StringTrimRight(GUICtrlRead($Input1), 12)

If StringInStr(GuiCtrlRead($Input1), ".local") Then
                Run("Notepad.exe")
                Sleep(1000)
                Send($Input4)
                Sleep(1000)
Else
Run("Notepad.exe")
                Sleep(1000)
                Send($Input3)
                Sleep(1000)
EndIf

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

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

Create an account

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


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • cheeroke
      By cheeroke
      Hi all,
      I got this code and would like to be able to change Baud Rate and instead of sending character by character i would like to be able (if possible) to send whole string. But i don't know how to change it.
      I am taking input from file and processing whole line (this is done in FilesHandling.au3).
      To execute this i am just calling SendData("FileName", int) in "main" script.
      Any help very appreciated.
      #include <WinAPI.au3> #include <Array.au3> #include "FilesHandling.au3" ;init DLL function, we need handle to call the function $h = DllCall("Kernel32.dll", "hwnd", "CreateFile", "str", "\\.\COM19", "int", BitOR($GENERIC_READ,$GENERIC_WRITE), "int", 0, "ptr", 0, "int", $OPEN_EXISTING, "int", $FILE_ATTRIBUTE_NORMAL, "int", 0) $handle=$h[0] Func SendData($FileName, $LineNumber) ;string to be send $c = readFile($FileName, $LineNumber) $cLenght = StringLen($c) $aArray = StringSplit($c, "") ;_ArrayDisplay($aArray, "", Default, 64) For $i = 1 To $cLenght writeChar($handle, $aArray[$i], $cLenght) Next ;move to next line writeChar($handle, @CR,1) EndFunc ;write a single char func writeChar($handle,$c,) $stString = DLLStructCreate("char str") $lpNumberOfBytesWritten = 0 DllStructSetData($stString, 1, $c) $res = _WinAPI_WriteFile($handle, DllStructGetPtr($stString, "str"), 1,$lpNumberOfBytesWritten) if ($res<>true) then ConsoleWrite ( _WinAPI_GetLastErrorMessage() & @LF) EndIf EndFunc  
    • 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
       
       
       

    • FroVN
      By FroVN
      Hi, i have a problem :" can't set the name of file with a special character like: \;/;";|;...  have anyway to short the StringInSrt and Stringreplace? i am using this code but too long
      $title=InputBox(0,'','','')
         if StringInStr($title,'\') or StringInStr($title,'/') or StringInStr($title,':') or StringInStr($title,'*') or StringInStr($title,'?') or StringInStr($title,'"') or StringInStr($title,'<') or StringInStr($title,'>') or StringInStr($title,'|') Then
             $title=StringReplace($title,'\','-')
              $title=StringReplace($title,'/','-')
               $title=StringReplace($title,':','-')
                $title=StringReplace($title,'*','-')
                 $title=StringReplace($title,'?','-')
                  $title=StringReplace($title,'"','-')
                   $title=StringReplace($title,'<','-')
                    $title=StringReplace($title,'>','-')
                     $title=StringReplace($title,'|','-')
         EndIf
       
    • 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