barcode scanner TAB suffix

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
donparlee
Newbie
Posts: 7
Joined: Wed Oct 13, 2010 2:04 pm

barcode scanner TAB suffix

Post by donparlee » Wed Oct 13, 2010 2:18 pm

Hi, some of our barcode scanners are configured so that they return the data [read from the barcode] plus, in addition, a TAB character (ascii 008). We also have barcode scanners that return the data plus a CR character (ascii 013). Barcode scanning into Edit boxes of a Dialog works great with the scanners that are configured with a CR suffix (ie. clicks an OK button), however, the scanners configured with a TAB suffix do not automatically click the OK button. Is there a way to get the TAB character to be recognized and behave like the CR character does within the Edit boxes of a Dialog?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Oct 13, 2010 2:29 pm

Use OnEvent. In the following sample, when tab is pressed, Onevent and its subroutine then press enter.

Code: Select all

OnEvent>key_down,VK9,0,PressEnter

SRT>PressEnter
  Press Enter
  Exit>0
END>PressEnter

Label>Loop
  Wait>0.01
Goto>Loop

donparlee
Newbie
Posts: 7
Joined: Wed Oct 13, 2010 2:04 pm

Can't get MS to recognize the KEY_DOWN event

Post by donparlee » Wed Oct 13, 2010 3:43 pm

I setup the OnEvent and subroutine as you outlined, and thank you very much b-t-w for the immediate resposne, however, using different keystrokes, none are firing the various OnEvent>KEY_DOWN... characters within the EDIT box of the Dialog... Am I missing something?

Here is your code and my dialog but using the space key to try to get the message displayed... but no message... Is it because I am Showing the dialog modally? Is there a way to accomplish when the dialog is displayed modal? Thanks!


Dialog>DeliveryNumber
object DeliveryNumber: TForm
Left = 255
Top = 126
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'Enter The Delivery#'
ClientHeight = 187
ClientWidth = 397
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 16
object Label1: TLabel
Left = 24
Top = 8
Width = 158
Height = 20
Caption = 'Enter The Delivery#'
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ParentFont = False
end
object Label3: TLabel
Left = 232
Top = 104
Width = 48
Height = 16
Caption = 'Column:'
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
object Edit1: TEdit
Left = 46
Top = 34
Width = 307
Height = 28
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ParentFont = False
TabOrder = 0
end
object MSButton1: tMSButton
Left = 66
Top = 139
Width = 127
Height = 38
Caption = 'Process'
Default = True
DoubleBuffered = True
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ModalResult = 3
ParentDoubleBuffered = False
ParentFont = False
TabOrder = 4
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton2: tMSButton
Left = 221
Top = 139
Width = 108
Height = 38
Cancel = True
Caption = 'Quit'
DoubleBuffered = True
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ModalResult = 2
ParentDoubleBuffered = False
ParentFont = False
TabOrder = 5
DoBrowse = False
BrowseStyle = fbOpen
end
object CheckBox1: TCheckBox
Left = 184
Top = 75
Width = 97
Height = 17
Caption = 'Restart Row:'
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 1
end
object Edit2: TEdit
Left = 288
Top = 72
Width = 65
Height = 24
Alignment = taCenter
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
NumbersOnly = True
ParentFont = False
TabOrder = 2
Text = '1'
end
object Edit3: TEdit
Left = 288
Top = 103
Width = 65
Height = 24
Alignment = taCenter
NumbersOnly = True
TabOrder = 3
Text = '1'
end
end
EndDialog>DeliveryNumber

OnEvent>KEY_DOWN,VK32,0,KeyPress

SRT>KeyPress
MessageModal>Space was pressed
END>KeyPress

Show>DeliveryNumber,r

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Oct 13, 2010 4:04 pm

Yes the dialog must be modeless. Put controls into a subroutine to accomplish whatever you would do when the dialog closes. Then call that subroutine using AddDialogHandler> with an onclick on the process or quit buttons

Code: Select all

Dialog>DeliveryNumber
object DeliveryNumber: TForm
Left = 255
Top = 126
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'Enter The Delivery#'
ClientHeight = 187
ClientWidth = 397
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 16
object Label1: TLabel
Left = 24
Top = 8
Width = 158
Height = 20
Caption = 'Enter The Delivery#'
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ParentFont = False
end
object Label3: TLabel
Left = 232
Top = 104
Width = 48
Height = 16
Caption = 'Column:'
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
object Edit1: TEdit
Left = 46
Top = 34
Width = 307
Height = 28
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ParentFont = False
TabOrder = 0
end
object MSButton1: tMSButton
Left = 66
Top = 139
Width = 127
Height = 38
Caption = 'Process'
Default = True
DoubleBuffered = True
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ModalResult = 3
ParentDoubleBuffered = False
ParentFont = False
TabOrder = 4
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton2: tMSButton
Left = 221
Top = 139
Width = 108
Height = 38
Cancel = True
Caption = 'Quit'
DoubleBuffered = True
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -16
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
ModalResult = 2
ParentDoubleBuffered = False
ParentFont = False
TabOrder = 5
DoBrowse = False
BrowseStyle = fbOpen
end
object CheckBox1: TCheckBox
Left = 184
Top = 75
Width = 97
Height = 17
Caption = 'Restart Row:'
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
TabOrder = 1
end
object Edit2: TEdit
Left = 288
Top = 72
Width = 65
Height = 24
Alignment = taCenter
Font.Charset = DEFAULT_CHARSET
Font.Color = clNavy
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
NumbersOnly = True
ParentFont = False
TabOrder = 2
Text = '1'
end
object Edit3: TEdit
Left = 288
Top = 103
Width = 65
Height = 24
Alignment = taCenter
NumbersOnly = True
TabOrder = 3
Text = '1'
end
end
EndDialog>DeliveryNumber

AddDialogHandler>DeliveryNumber,,OnClose,Quit
AddDialogHandler>DeliveryNumber,msButton2,OnClick,Quit
AddDialogHandler>DeliveryNumber,msButton1,OnClick,Process

SRT>Quit
  Exit>0
END>Quit

SRT>Process
  MDL>Doing Stuff
END>Process

OnEvent>KEY_DOWN,VK32,0,KeyPress
SRT>KeyPress
 MessageModal>Space was pressed
END>KeyPress
Show>DeliveryNumber

Label>Loop
  Wait>0.01
Goto>Loop


donparlee
Newbie
Posts: 7
Joined: Wed Oct 13, 2010 2:04 pm

Thanks!

Post by donparlee » Wed Oct 13, 2010 4:34 pm

The modeless Show and AddHandler's work perfectly! Thanks very much!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts