How to loop through characters in an edit-box?

Get help with using AutoHotkey and its commands and hotkeys
Posts: 4
Joined: 24 Dec 2015, 04:57

How to loop through characters in an edit-box?

27 Jun 2017, 23:15

I want to loop through characters in an edit box and push all those characters into an array. How can I do this? I just don't get all of this and I've been looking up the syntax. Just don't get it.

Here's my current script:

Code: Select all

#SingleInstance Force
SetWorkingDir %A_ScriptDir%
Status := 1
Keys := []

Gui Add, CheckBox, x534 y257 w120 h23, CheckBox
Gui Font, s20 cRed, Georgia
Gui Add, Text, x1 y-4 w306 h36 +0x200, Test
Gui Font
Gui Add, Edit, x3 y31 w474 h150
Gui Add, Button, x2 y188 w210 h37 vSb1 gSub1, Execute [F5]
Gui Show, w481 h231, Test and learn

F5:: gosub, Sub1

    if (Status = 1){
    GuiControl Text, Sb1, Executing [F5]
    Status := 0
    GuiControl Text, Sb1, Execute [F5]
    Status := 1


; Do not edit above this line
When I press F5 the script should read all the characters that are in the edit-box and push them into the array. The array is called "Keys" so any ideas?
Posts: 12
Joined: 02 Dec 2015, 12:32

Re: How to loop through characters in an edit-box?

28 Jun 2017, 00:58

First you need to assign a variable to you edit control :

Gui Add, Edit, x3 y31 w474 h150 vMyEdit

alt1 :
Add [ Gui,Submit,Nohide ] to top of your Sub1 so content of editcontrol is saved to variable.
The contens of %MyEdit% contain the text as a string

[ GuiControlGet, OutputVar , Edit, MyEdit, ]" added to top of your sub1
The variable %Outputvar% contain contents of the editcontrol

use some variation of this code to split string into array:

StringSplit, OutputArray, InputVar [, Delimiters, OmitChars]
Array := StrSplit(String [, Delimiters, OmitChars])

and remember to clear editcontrol so it only add latest contents to the array

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], CluelessHotKeyUser, mikeyww, omareg94, songdg, yumuffin and 41 guests