New to autohotkey, but trying to write some code, whereby the user can read a file (which displays in a GUI), select a line, double click it, and have that print to the screen.
It's for use in a game, wherein you have to input a dirty great chunk of letters/numbers - which is a pain.
I've got it to the point where is displays the GUI and allows the user to select input, but it won't actually echo it to the screen. There are a couple of other bugs, but this one is a show stopper.
Here's the code:
Code: Select all
; Reads a file of saved hyperspace coordinates and displays it in a GUI
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#SingleInstance force
; CTRL-ALT-S
^!s::
ListBox_Text = ;initialize empty variable
Loop, Read, Hyperspace_Coordinates.txt
{
StringSplit, StringArr, A_LoopReadLine, %A_Tab%
ListBox_Text .= padstr(StringArr1,17) "`t" padstr(StringArr2,12) StringArr3 "|" ;append a line of text
}
Gui, Add, ListBox, x6 y10 w575 h200 vMyListBox gDbleClick, %ListBox_Text%
;Gui, Add, Text, x10 y15, Target system
Gui, Add, UpDown, x196 y80 w160 h-60 , UpDown
Gui, Add, Button, x250 y170 w50 h30 , Clear
Gui, Show, w575 h200, Hyperspace coordinates - DblClick to select
return
DbleClick:
; Select the coordinates
IfNotEqual A_GuiControlEvent,DoubleClick
return
else
GuiControlGet, LineContents,,MyListBox
StringSplit, StringArr, LineContents, %A_Tab%
SystemName = %StringArr1%
ScanDate = %StringArr2%
Coordinates = %StringArr3%
MsgBox, , Set coordinates, Setting coordinates for hyperspace jump to %SystemName%
MsgBox, %Coordinates%
sendinput, /setcoords %Coordinates%
return
BUTTONClear:
MsgBox, git
Gui Cancel
return
GuiClose:
Reload
PadStr(str, size)
{
loop % size-StrLen(str)
str .= A_Space
return str
}
[FILE]
Texas 15/02/18 6B00605F-773EC3C2-BE6AB0F2-01326EDE-F2D830FE-CD4F8069-34686E73
Omicron Gamma 15/02/18 A4FF0828-67C6B29A-3F4C3973-ADCD3924-CED3CBF2-66E69E6F-34652073
Galileo 15/02/18 A5FE7753-7F1BB6A8-B9AFBEF6-A9ECF85E-F03EA7A2-FB5E866E-35337726
[/FILE]
Any help gratefully accepted.
Cheers.