QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: Richard on November 14, 2020, 10:50:09 pm
-
I thought I saw somewhere how to insert key strokes actually simulated by a program (not a person) into the keyboard buffer and then continue from the buffer as if a person just did the keystrokes.
Similarly to "insert" mouse movements and "click".
Anyone have any relevant references?
-
_SCREENCLICK will punch the mouse anywhere on the screen, even outside your window.
I'm using it to click the minimize button. I needed _SCREENX, _SCREENY, and_WIDTH
to compute where to click. Some situations may need the use of _HEIGHT, _DESKTOPWIDTH,
or _DESKTOPHEIGHT.
I have no clue how to stuff the keyboard buffer, tho clearly you can change the focus
to some other program with the above.
-
_SCREENPRINT will simulate keypresses for you.
-
@ Richard
Thanks - _SCREENCLICK (etc) sounds like exactly all that I need for the mice side of things (hope it will also work with "TouchPads" (built in "mouse" (sort of) as supplied with many laptops).
-
@ Steve
Thanks for reply.
In using _SCREEENPRINT, I assume that only standard 7-bit ASCII (above CHR$(&h20)) can be used - such as A-Z 0-9 +-=-() etc and the Ctrl +A (etc) for control codes as mentioned in the IDE help Screen.
How to (if possible) simulate say CTRL +, Ctrl -, Fn Alt Ctrl Shift WindowsKey F1-F12 numeric keypad etc etc which may be used as SINGLE, DOUBLE TRIPLE etc key combos?
-
For anything deeper related to screen macros I recommend using AutoHotKey: https://www.autohotkey.com/
-
One note about _SCREENCLICK, you may want to consider _DELAY .05 to separate clicks. Also, be careful what you want on the desktop is there, before you click. This can be accomplished by running a check routine if you are using SHELL _DONTWAIT to open a third party app. If the app doesn't open before the _SCREENCLICK initiates, you're screwed.
In regard to simulating key input, if you are using a Windows system, you can fiddle around with the API. The Wiki has some examples of this, by Dav. I believe the API uses SendInput(). Anyway, here are a couple of off-site references...
https://www.codeproject.com/tips/506147/easy-way-to-simulate-keyboard-press-and-release-ke
https://stackoverflow.com/questions/5607849/how-to-simulate-a-key-press-in-c
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput
Pete
-
OK You can use DOS interrupt 16h
INT 16 - AH = 05h KEYBOARD - WRITE TO KEYBOARD BUFFER (AT model 339,XT2,XT286,PS)
CH = scan code
CL = character
Return: AL = 1 if buffer full
Ok the ENTER key is 13(decimal) (carriage return)
-
@ NOVARSEG
Thanks for your reply.
I will give your method a try.
Its been a long time since I did anything with Interrupts - when I did do so, it was using MS PDS 7.1 (an upgrade to MS QB45), and being 16 bit environment - one could do "all sorts of things". Nowadays with Windows 10 I think there are very strict restrictions on interrupt calls and although I have not read deeply into QB64 Wiki - the QB64 emulation for interrupts is very limited (maybe bare-bones Mouse related only I think - I hope that I am wrong).
So I hope that I can form a list of ALL the keys scan codes (including WindowsKey, Fn and F1-F12 etc etc - my hard copy list from DOS 3 is not detailed enough). My HP laptop has i7 processor and I have no idea on any of the keyboard details.
-
Richard
Ya I did a strange thing with that interrupt once.. I managed to use the DIR command from within a Quick Basic program.
If you got XP you can still run the 16 bit programs. Dont know how QB64 would compile that.