Enter as tab in GUI Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Enter as tab in GUI

23 Aug 2017, 04:14

Hi,

I'm trying to build a gui with some edit controls. I'm also using a barcode scanner which after
the scan automatically presses the enter key.

After this enter, I would like to move to the next edit control automatically.
Any ideas ?

Here's what I have so far:

Code: Select all

Gui, Font, S12 CDefault Bold, Verdana
Gui, Add, Text, x12 y12 w120 h20 , TSI automatisch
Gui, Font, S8 CDefault Bold, Verdana
Gui, Add, Text, x12 y42 w80 h20 , Inpaktafel:
Gui, Add, Edit, x93 y40 w39 h20 , 1
Gui, Add, Text, x33 y72 w50 h20 , PickID
Gui, Add, Text, x93 y72 w80 h20 , Vervoerder
Gui, Add, Text, x183 y72 w50 h20 , Aantal
Gui, Add, Text, x243 y72 w52 h20 , Eenheid
Gui, Add, Edit, x33 y92 w50 h20 gMyPickID vPickID,  ; <---------- When an enter is pressed move to next edit control

Gui, Add, Edit, x93 y92 w80 h20 , DHL
Gui, Add, Edit, x193 y92 w20 h20 +Center, 1
Gui, Add, Edit, x243 y92 w50 h20 , Collo
; Generated using SmartGUI Creator 4.0
Gui, Show, x127 y87 h687 w479, New GUI Window
Return

GuiClose:
ExitApp

MyPickID:                                     ; <------- I was thinking something like this as an alternative sollution, but it doesn't work.
If (StrLen(PickID) > 4)
	Send {tab}
return
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Enter as tab in GUI

23 Aug 2017, 05:13

Now I tried this, but it doesn't wait for the ENTER, it fires with every keypress in the editbox, why is that ?

Code: Select all

MyPickID:
Gui, submit, nohide
KeyWait, Enter
    send {tab}
edit
...Because I forgot to add the ,D option :crazy:

working code:

Code: Select all

Gui, Font, S12 CDefault Bold, Verdana
Gui, Add, Text, x12 y12 w120 h20 , TSI automatisch
Gui, Font, S8 CDefault Bold, Verdana
Gui, Add, Text, x12 y42 w80 h20 , Inpaktafel:
Gui, Add, Edit, x93 y40 w39 h20 , 1
Gui, Add, Text, x33 y72 w50 h20 , PickID
Gui, Add, Text, x93 y72 w80 h20 , Vervoerder
Gui, Add, Text, x183 y72 w50 h20 , Aantal
Gui, Add, Text, x243 y72 w52 h20 , Eenheid
Gui, Add, Edit, x33 y92 w50 h20 gMyPickID vPickID, 

Gui, Add, Edit, x93 y92 w80 h20 , DHL
Gui, Add, Edit, x193 y92 w20 h20 +Center, 1
Gui, Add, Edit, x243 y92 w50 h20 , Collo
; Generated using SmartGUI Creator 4.0
Gui, Show, x127 y87 h687 w479, New GUI Window
Return

GuiClose:
ExitApp

MyPickID:
KeyWait, Enter, D
    send {tab}
return
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Enter as tab in GUI

23 Aug 2017, 09:12

:(
Unfortunately this is waaay to slow. If I something manually and press enter it work fine, but
when I use the scanner it's to fast I get duplicate scans in the same edit control.

Any other ideas ?

Code: Select all

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <[email protected]>
;
; Script Function:
;	Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetBatchLines, -1
No := 5
LeftPos := 33 ;links
TopPos  := 93 ;boven


Gui, Font, S12 CDefault Bold, Verdana
Gui, Add, Text, x12 y12 h20 , TSI automatisch
Gui, Font, S8 CDefault Bold, Verdana
Gui, Add, Text, x12 y42 w80 h20 , Inpaktafel:
Gui, Add, Edit, x93 y40 w39 h20 , 1
Gui, Add, Text, x33 y72 w50 h20 , PickID
Gui, Add, Text, x93 y72 w80 h20 , Vervoerder
Gui, Add, Text, x183 y72 w50 h20 , Aantal
Gui, Add, Text, x243 y72 w52 h20 , Eenheid

Loop, 25
{
	Gui, Add, Edit, Number x%LeftPos% y%TopPos% w50 h20 vPickID%A_Index% gMyPickID
	TopPos := TopPos+24
}

Gui, Add, Edit, x93 y92 w80 h20 vVervoerder, DHL
Gui, Add, Edit, x193 y92 w20 h20 +Center, 1
Gui, Add, Edit, x243 y92 w50 h20 , Collo
; Generated using SmartGUI Creator 4.0
Gui, Show, x127 y87 h700 w479, New GUI Window
Return

MyPickID:           <-------------- Here I want to wait for an enter, OR if the editbox data is bigger than 4 characters I want TAB to be send
Gui, Submit, NoHide
send {tab}
return


GuiClose:
ExitApp
Nightwolf85
Posts: 302
Joined: 05 Feb 2017, 00:03

Re: Enter as tab in GUI  Topic is solved

23 Aug 2017, 10:21

Does this work? and is it faster for you?

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetBatchLines, -1
No := 5
LeftPos := 33 ;links
TopPos  := 93 ;boven


Gui, Font, S12 CDefault Bold, Verdana
Gui, Add, Text, x12 y12 h20 , TSI automatisch
Gui, Font, S8 CDefault Bold, Verdana
Gui, Add, Text, x12 y42 w80 h20 , Inpaktafel:
Gui, Add, Edit, x93 y40 w39 h20 , 1
Gui, Add, Text, x33 y72 w50 h20 , PickID
Gui, Add, Text, x93 y72 w80 h20 , Vervoerder
Gui, Add, Text, x183 y72 w50 h20 , Aantal
Gui, Add, Text, x243 y72 w52 h20 , Eenheid

Loop, 25
{
	Gui, Add, Edit, Number x%LeftPos% y%TopPos% w50 h20 vPickID%A_Index% gMyPickID Multi -0x200000 ; Multi to allow enter key to be pressed, -0x200000 so the vertical scroll isn't shown
	TopPos := TopPos+24
}

Gui, Add, Edit, x93 y92 w80 h20 vVervoerder, DHL
Gui, Add, Edit, x193 y92 w20 h20 +Center, 1
Gui, Add, Edit, x243 y92 w50 h20 , Collo
; Generated using SmartGUI Creator 4.0
Gui, Show, x127 y87 h700 w479, New GUI Window
Return

MyPickID:        ;   <-------------- Here I want to wait for an enter, OR if the editbox data is bigger than 4 characters I want TAB to be send
Gui, Submit, NoHide
GuiControlGet, temp,, %A_GuiControl% ; Get the text every time a character is entered
IF (InStr(temp, "`n") OR StrLen(temp) > 4) { ; if it contains a new line (Enter Pressed), OR is longer than 4 digits.
	temp := RTrim(temp, "`n") ; Remove the new line
	temp := SubStr(temp, 1, 4) ; Use only the first 4 characters
	GuiControl,,%A_GuiControl%, %temp% ; Set the text to the trimmed value
	Send, {Tab} ; send Tab
}
Return

GuiClose:
ExitApp
Edit:
Added check for second case of being longer than 4 characters long, while still working in the case where there are only 3 digits then {Enter}
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Enter as tab in GUI

24 Aug 2017, 01:22

Yes ! That works perfectly. Thanks so much.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Google [Bot], jameswrightesq, mikeyww, wpulford and 329 guests