Author |
Topic: Ctrl/Tab in program (Read 615 times) |
|
brian658
New Member
member is offline


Gender: 
Posts: 3
|
 |
Re: Ctrl/Tab in program
« Reply #2 on: Feb 28th, 2014, 08:44am » |
|
Thanks Richard, I hadn't thought of using GET(x,y) or GET$(x,y). It works for me but I still have a real preference for stuffing the Ctrl/Tab into the keyboard buffer method. It works brilliantly when I physically press the key combination but I couldn't get it coded (a test extract using yet another of your fine examples from 2006):
CLS PRINT "ABCDEFG"
test$ = CHR$(17) + CHR$(9) + CHR$(13) FOR I% = 1 TO LEN(test$) PROCfake(ASC MID$(test$ ,I%)) NEXT
END
DEF PROCfake(C%) : LOCAL V% SYS "VkKeyScan", C% TO V% IF V% AND &100 SYS "keybd_event", 16, 0, 0, 0 IF V% AND &200 SYS "keybd_event", 17, 0, 0, 0 IF V% AND &400 SYS "keybd_event", 18, 0, 0, 0 SYS "keybd_event", V% AND &FF, 0, 0, 0 SYS "keybd_event", V% AND &FF, 0, 2, 0 IF V% AND &400 SYS "keybd_event", 18, 0, 2, 0 IF V% AND &200 SYS "keybd_event", 17, 0, 2, 0 IF V% AND &100 SYS "keybd_event", 16, 0, 2, 0 ENDPROC
I'm guessing that my codes for the Ctrl, Tab and CR respectively are incorrect.
Any thoughts?
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Ctrl/Tab in program
« Reply #3 on: Feb 28th, 2014, 4:04pm » |
|
on Feb 28th, 2014, 08:44am, brian658 wrote:| It works brilliantly when I physically press the key combination but I couldn't get it coded |
|
PROCfake isn't appropriate because it takes as a parameter the ANSI code for the character you want to send, and Ctrl+Tab does not have a corresponding character code.
Instead you can call keybd_event directly for the sequence: Ctrl Down, Tab Down, Tab Up, Ctrl Up. That should work, but bear in mind that it suffers from the fundamental weakness of faking keyboard input: you can never guarantee where the faked input will end up (it's possible that the input 'focus' may change to another window or program before or during the sequence).
Richard.
|
|
Logged
|
|
|
|
|