Onevent or Waitkeyboard

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
nodochau
Junior Coder
Posts: 22
Joined: Wed Jan 16, 2019 12:59 pm

Onevent or Waitkeyboard

Post by nodochau » Wed Jun 26, 2019 12:31 pm

Hello All,
I have a touch screen and I want to touch the screen (at anywhere on screen) and it will activate my program.
Do you have any ideas?
Thanks a lot

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

Re: Onevent or Waitkeyboard

Post by JRL » Thu Jun 27, 2019 3:13 pm

Code: Select all

OnEvent>key_down,VK1,0,srtStart

Label>lblStart
  Wait>0.01
Goto>lblStart

SRT>srtStart
Dialog>Dialog1
object Dialog1: TForm
  Left = 317
  Top = 198
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'Enter your password'
  ClientHeight = 113
  ClientWidth = 340
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  Position = poScreenCenter
  TextHeight = 13
  object Label1: TLabel
    Left = 272
    Top = 24
    Width = 32
    Height = 13
    Caption = 'VIEW'
  end
  object Edit1: TEdit
    Left = 39
    Top = 15
    Width = 218
    Height = 21
    PasswordChar = '*'
    TabOrder = 0
    Text = 'PasswordChar is *'
  end
  object MSButton1: tMSButton
    Left = 133
    Top = 78
    Width = 75
    Height = 25
    Caption = 'Ok'
    TabOrder = 9
    Default = True
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSButton1,OnClick,srtProcess
AddDialogHandler>Dialog1,Label1,OnMouseDown,srtDisplayChars
AddDialogHandler>Dialog1,Label1,OnMouseUp,srtHideChars
AddDialogHandler>Dialog1,,OnClose,Quit

Show>Dialog1,

SRT>srtProcess
  GetDialogProperty>Dialog1,Edit1,Text,vPWStr
  MDL>vPWStr
  Exit>0
END>srtProcess

SRT>srtDisplayChars
    SetDialogProperty>Dialog1,Edit1,PasswordChar,nullchar
END>srtDisplayChars

SRT>srtHideChars
    SetDialogProperty>Dialog1,Edit1,PasswordChar,*
END>srtHideChars

SRT>Quit
  Exit>0
END>Quit

END>srtStart

nodochau
Junior Coder
Posts: 22
Joined: Wed Jan 16, 2019 12:59 pm

Re: Onevent or Waitkeyboard

Post by nodochau » Fri Jun 28, 2019 10:20 am

Thanks a lot JRL. This code for WaitKeyDown. Do you have any idea of touching on the screen instead of using the keyboard? :)
I greatly appreciate your help.

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

Re: Onevent or Waitkeyboard

Post by JRL » Fri Jun 28, 2019 1:24 pm

nodochau wrote:This code for WaitKeyDown.
Technically, since WaitKeyDown is a Macro Scheduler function and what I provided is an OnEvent function with a key_down parameter, the code is not for WaitKeyDown. In my testing, using a mouse click, the OnEvent worked reliably where the WaitKeyDown function did not.

In any case, I do not have a touch screen to test with. Used to have them and paid like $800 per monitor for 30 of them. Then when they started dying off we polled our users and found that of 90 people only 2 preferred the touchscreen over the mouse.

Searching the web for VK code and touchscreen I found only one reference that said a Windows CE touchscreen would produce a Virtual Code of 1 (one). Since VK1 is the Virtual Code for a mouse selection which is also essentially what happens when you touch a touchscreen I hoped the OnEvent would detect a VK1 when you touched your screen.

You can see ALL VK codes HERE. Try them all (There's only 254 of them). Or try the ones that might make sense. In the code I provided, you would substitute the number you want to try after the VK. So, OnEvent>key_down,VK1,0,srtStart would become OnEvent>key_down,VK235,0,srtStart or whatever number you want to test.

If none of the VK codes work, then I have one other possibility for you. Create a dialog that completely covers the screen. A touch on the dialog will certainly be detected. The dialog can be opaque or visibly transparent and will work either way. On detection of the touch, close the dialog and proceed with the rest of the script.

nodochau
Junior Coder
Posts: 22
Joined: Wed Jan 16, 2019 12:59 pm

Re: Onevent or Waitkeyboard

Post by nodochau » Fri Jun 28, 2019 3:40 pm

Yeah, good idea.
I will try it. There is no mouse in my place. :)
Thanks

Post Reply