Jump to content

GUICtrlRead edit box to multiline variables


jgq85
 Share

Recommended Posts

I've got a working GUI with script but I'm trying to change from a single input to a multiline input

What's a good way to to take multi lines in the box, say I have three lines in the input box:

12345

23456

34567

Then I want AUtoIt to type out into a box (I switch to the box in another piece of code from a button function), but want it to Send a string, such as the Bing URL search then at the end of the URL it will insert the Asset numbers I put in. Since there are 3 asset numbers it will send three Bing search URL's total, each containing the next asset number I have in the input box...

(typed in notepad, for example):

http://www.bing.com/search?q=12345

http://www.bing.com/search?q=23456

http://www.bing.com/search?q=34567

GUI:

$Assets = GUICtrlCreateEdit("", 0, 56, 105, 81)

Related code within script:

$AssetNumbersText = GUICtrlRead($Assets, 1) ; reads the text of the edit box
Send("Asset <a href=" & chr(34) & "http://www.bing.com/search?q=") ; Types out "Asset" and then the html hyperlink text for a Bing search
Send($AssetNumbersText & chr(34) & ">" & $AssetNumbersText & "</a>") ; Types out Asset # from each line and completes the html hyperlink tag
Link to comment
Share on other sites

  • Moderators

jgq85,

Read the contents of your edit control and split it into lines with StringSplit. Then loop through the array and concatenate the prefix with the contents of each line: ;)

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$cEdit = GUICtrlCreateEdit("", 10, 10, 200, 200)
GUICtrlSetData($cEdit, "12345" & @CRLF & "23456" & @CRLF & "34567")

$cButton = GUICtrlCreateButton("Read", 10, 300, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton
            $sText = GUICtrlRead($cEdit)
            $aText = StringSplit($sText, @CRLF, 1)
            For $i =1 To $aText[0]
                ConsoleWrite("http://www.bing.com/search?q=" & $aText[$i] & @CRLF)
            Next
    EndSwitch

WEnd

All clear? :)

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 comment
Share on other sites

  • 4 weeks later...

Thanks so much, it works great.

I need to figure out how to add a text box, or a drag bag, and use it to establish a Number figure. Then, the script will loop based on that number, instead of reading how many lines I have in the text box.

So far I just have:

Local $i = 0
Do
WinActivate("Custom Window 2013", "")
Send("http://oursearch.domain.com/assetid=" & "^v")
    $i = $i + 1
 Until $i = 20

So my other GUI field would have to be something readable to set a number for "until" that $i could become equal to?

Link to comment
Share on other sites

  • Moderators

jgq85,

To get a simple user-selectable number I would use an input with an updown - look in the Help file to see how to code them. :)

And I would suggest using a For...Next loop - why not let AutoIt look after the counting for you. ;)

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 comment
Share on other sites

  • 2 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...