BBC BASIC for Windows
« Ctrl/Tab in program »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:49pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Ctrl/Tab in program  (Read 611 times)
brian658
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 3
xx Ctrl/Tab in program
« Thread started on: Feb 27th, 2014, 08:32am »

I need to copy the output window to the clipboard (as text using Ctrl/Tab). How can I do this from within the program? I've tried 'faking' the keyboard input with Ctrl/Tab with no success. Can it be done?
Kind regards......
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Ctrl/Tab in program
« Reply #1 on: Feb 27th, 2014, 3:19pm »

on Feb 27th, 2014, 08:32am, brian658 wrote:
I need to copy the output window to the clipboard (as text using Ctrl/Tab). How can I do this from within the program? I've tried 'faking' the keyboard input with Ctrl/Tab with no success. Can it be done?

Instead of faking keyboard input, which should work but is a bit messy, you can loop through the characters yourself using GET(x,y) or GET$(x,y) and assemble them back into a string, which you can then put on the clipboard.

But since you have presumably output whatever is displayed yourself, it might be easier to use *SPOOL to copy the output to a file at the same time as you display it, saving you the trouble of reading the screen at all.

Richard.
User IP Logged

brian658
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 3
xx 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?

User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx 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.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls