Gui help

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
inseption86
Posts: 202
Joined: 19 Apr 2018, 00:24

Gui help

13 Jul 2018, 09:09

Hi guys, please help. I have:

Code: Select all

Inputbox test1, test
Run %test1% ,,hide
return
Esc::ExitApp
How to make gui instead of inputbox, but without a button? i have QR scaner, and when the barcode is scanned,

Code: Select all

Run %test1% ,,hide
was automatic
Qysh
Posts: 143
Joined: 24 Apr 2018, 09:16

Re: Gui help

13 Jul 2018, 12:27

Do you mean something like this?

Code: Select all

var := sendInputBox()
MsgBox, %var%

sendInputBox()
{
	global editfield
	Gui, 99:Add, Edit, x2 y9 w270 h20 veditfield, 
	Gui, 99:Show, w278 h36, InputBox
	while(!GetKeyState("Enter", "p"))
		continue
	Gui, 99:Submit, nohide
	Gui, 99:Destroy
	return editfield
}
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: Gui help

13 Jul 2018, 12:45

Nice idea to use while(!GetKeyState("Enter", "p")). But at least add 1 milliseconds to it, otherwise the script will take up a lot of CPU, 8% for me.

Code: Select all

while(!GetKeyState("Enter", "p"))
		sleep 1
Qysh
Posts: 143
Joined: 24 Apr 2018, 09:16

Re: Gui help

13 Jul 2018, 13:05

tmplinshi wrote:Nice idea to use while(!GetKeyState("Enter", "p")). But at least add 1 milliseconds to it, otherwise the script will take up a lot of CPU, 8% for me.

Code: Select all

while(!GetKeyState("Enter", "p"))
		sleep 1
True. i didnt thought about that :)

Code: Select all

var := sendInputBox()
MsgBox, %var%
return


sendInputBox()
{
	global editfield
	Gui, 99:Add, Edit, x2 y9 w270 h20 veditfield, 
	Gui, 99:Show, w278 h36, InputBox
	while(!GetKeyState("Enter", "p"))
		Sleep, 100
	Gui, 99:Submit, nohide
	Gui, 99:Destroy
	return editfield
}
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: Gui help

13 Jul 2018, 13:55

Or KeyWait, Enter, Down.
However there is a problem here, pressing Enter key in another window will also close the input GUI.

Improved code:

Code: Select all

MsgBox, % sendInputBox()
MsgBox, % sendInputBox2()
return

sendInputBox()
{
	static
	Gui, 99:+HWNDhGUI
	Gui, 99:Add, Edit, x2 y9 w270 h20 veditfield +HWNDhEdit, 
	Gui, 99:Show, w278 h36, InputBox
	while !( GetKeyState("Enter", "p") && WinActive("ahk_id " hGUI) )
		Sleep, 100
	Gui, 99:Submit
	Gui, 99:Destroy
	return editfield
}

sendInputBox2()
{
	static
	Gui, 99:+HwndHGUI
	Gui, 99:Add, Edit, x2 y9 w270 h20 veditfield, 
	Gui, 99:Add, Button, Default Hidden, OK
	Gui, 99:Show, w278 h36, InputBox
	WinWaitClose, ahk_id %HGUI%
	return editfield

	99ButtonOK:
		Gui, 99:Submit
		Gui, 99:Destroy
	return
}
inseption86
Posts: 202
Joined: 19 Apr 2018, 00:24

Re: Gui help

17 Jul 2018, 02:23

Hi guys, sorry I have not answered so long, I'm using:

Code: Select all

q::
SendMessage, 0x50,, 0x4090409,, A ; English

Gui, +AlwaysOnTop +Caption +LastFound +ToolWindow +Owner
Gui, Add, Edit, x2 y9 w270 h20 vtest1
gui, add, button, Default,GO
Gui, Show, w278 h36, InputBox 
WinSet, TransColor, %CustomColor% 50
return
ButtonGO:
gui, submit, nohide
Run %test1% ,,hide
Gui, Destroy
return

Esc::ExitApp

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], inseption86, jomaweb, KruschenZ, mikeyww, Rohwedder, Swiftly9767 and 297 guests