Page 1 of 1

Gui help

Posted: 13 Jul 2018, 09:09
by inseption86
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

Re: Gui help

Posted: 13 Jul 2018, 12:27
by Qysh
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
}

Re: Gui help

Posted: 13 Jul 2018, 12:45
by tmplinshi
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

Re: Gui help

Posted: 13 Jul 2018, 13:05
by Qysh
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
}

Re: Gui help

Posted: 13 Jul 2018, 13:55
by tmplinshi
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
}

Re: Gui help

Posted: 17 Jul 2018, 02:23
by inseption86
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