How to loop through characters in an edit-box?

Get help with using AutoHotkey and its commands and hotkeys
EnderInside1739
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

#NoEnv
#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
Return

F5:: gosub, Sub1

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

GuiEscape:
GuiClose:
    ExitApp

; 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?
Peared
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

alt2:
[ 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: ader5429, AHKStudent, brotherS, btonasse, dreamery16, Google [Bot], kczx3, Lem2001, Visioneer and 53 guests