input a word and replace it's letters as output

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
way2000
Posts: 58
Joined: 15 Jul 2016, 08:57

input a word and replace it's letters as output

18 Sep 2017, 08:32

i'm trying to create a program that let's the user type a word in an input field (gui) and when a button is pressed the letters of the word are replaced by 1 word each from a list of words in a text file

each letter of a word should be replaced by a word from a text file
the text file is a source for replacing letters is a file with 2 columns separated by tab that contains the entire alphabet (26 rows)
Attachments
Screenshot_1.png
Screenshot_1.png (4.99 KiB) Viewed 3068 times
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: input a word and replace it's letters as output

18 Sep 2017, 08:41

Nice to know. Support your supporters, ask a question! 8-)
Guest

Re: input a word and replace it's letters as output

18 Sep 2017, 10:18

sorry i wasn't clear

i need help to create it, the screenshot is not a finished program it's an example of how the program could look

please help if possible

post some code to begin with, thanks in advance
way2000
Posts: 58
Joined: 15 Jul 2016, 08:57

Re: input a word and replace it's letters as output

19 Sep 2017, 18:52

please help

if someone can help me create this program i would be really grateful
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: input a word and replace it's letters as output

19 Sep 2017, 19:13

I would do a StringSplit on the submitted word to break it into each letter.

Then just parse those letters (Loop them) to construct a new string with either If=letter statements or having loaded up your text file into an array and using those values. For the array (see Object; associative array), if you did something like array:={"a":"airplane","b":"boy"} then you could do string.=array[letter%A_Index%] in a loop with the pseudo-array prefix letter from the StringSplit. The .= is the concatenate-assign operator.
way2000
Posts: 58
Joined: 15 Jul 2016, 08:57

Re: input a word and replace it's letters as output

09 Oct 2017, 13:20

i have this code so far for the gui:

Code: Select all

Gui,Add,Edit,x9 y5 w500 h21,TestString
Gui,Add,Edit,x9 y30 w500 h350
Gui,Add,Button,x424 y386 w86 h23,Find
Gui,Show
return
please i would be really thankful if someone can post a working example with all the options and added code source

please help if possible
Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: input a word and replace it's letters as output

09 Oct 2017, 13:54

Since I've been looking for something to code today...

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance Force
SetBatchLines, -1

Letters := []
Loop, Read, Word_List.txt
{
	IF (A_LoopReadLine) {
		temp := StrSplit(A_LoopReadLine, "`t")
		Letters[temp[1]] := []
		Loop, Parse, % temp[2], `,
			Letters[temp[1]].Push(A_LoopField)
	}
}

Gui,Add,Edit,x9 y5 w500 h21 vTestString
Gui,Add,Edit,x9 y30 w500 h350 vDisplay
Gui,Add,Button,x424 y386 w86 h23 gFind Default,Find
Gui,Show
return

Find:
Gui, Submit, NoHide
output := ""
Loop, Parse, TestString
{
	IF (isObject(Letters[A_LoopField])) {
		Random,r,1,% Letters[A_LoopField].MaxIndex()
		output .= Letters[A_LoopField][r] . " "
	}
}
Display .= output . "`n"
GUIControl,,Display, %Display%
GUIControl,,TestString,
Return
Word_List.txt: - Comma separate each random word you'd like to choose from, only put one word if you don't want it to be random.

Code: Select all

A	Apple,Always
B	Ball
C	Cat
D	Dog
E	Elephant
F	Frog
G	Goat
H	House
I	Ice
J	Jogging
K	Kitten
L	Long
M	Mouse
N	Net
O	Oxen
P	People
Q	Quick
R	Right
S	Stupid
T	This
U	Unknown
V	Vertical
W	West
X	Xylophone
Y	Yes
Z	Zebra
way2000
Posts: 58
Joined: 15 Jul 2016, 08:57

Re: input a word and replace it's letters as output

09 Oct 2017, 15:44

thank you so much

it works


thanks again
way2000
Posts: 58
Joined: 15 Jul 2016, 08:57

Re: input a word and replace it's letters as output

19 Apr 2018, 20:11

hi

can anyone modify this script above from Nightwolf85 and make it so the program replaces words to words instead of letters to words?

please help if possible

it has to replace words with words with a text list of words
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: input a word and replace it's letters as output

20 Apr 2018, 12:07

You could change the word list so the left column isn't just letters. Then you just need to change Loop, Parse, TestString under the Find: label to use the delimiters you like (probably a space; I'd denote it as Loop, Parse, TestString, %A_Space% myself.

I have not run Night's code, and of course not any modifications I suggested. So apologies if that doesn't resolve it. I may have overlooked some logic in the original code that also needs to be changed to accommodate word->word.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, Google [Bot], vysmaty and 243 guests