Type "Tab" on PC keyboard (Win7) --> RTS line on serial port pulses - Page 1
Forum section: electronics / general

author: Jester
author_rank: Frequent Contributor
timestamp: April 16, 2018, 11:11:30 pm
content: Can a PC programmer explain roughly how they would approach this; in what language, how much code would be required?EDIT: Original thought was to use the parallel port, it would actually be better if I use the serial port RTS signal.

author: rstofer
author_rank: Super Contributor
timestamp: April 16, 2018, 11:34:20 pm
content: I would probably do it in Visual Basic because I am more familiar with the IO libraries.https://www.aaroncake.net/electronics/vblpt.htmReading the keyboard should be pretty simplehttps://docs.microsoft.com/en-us/dotnet/framework/winforms/how-keyboard-input-worksMaybe a couple of dozen lines of code, maybe less.

author: Distelzombie
author_rank: Frequent Contributor
timestamp: April 16, 2018, 11:56:21 pm
content: Typing "tab":What do you mean"type tab"? Do you mean a hotkey, like CTRL+ALT+DEL? That would be a global hotkey. Meaning it works everywhere, in every program. You can program global hotkeys. Using probably any programming language, or even easier: autohotkey, which is like a scripting language. But if you just want to type "tab" randomly and then your PC does a thing, that's a very, very bad idea. even T+A+B is very bad. Because, just use CTRL or ALT and some key.Pressing tab button:Also a very bad idea. Tab is a global button, used by the OS itself for navigation purposes.Just come up with a good hotkey using CTRL or ALT; whereas CTRL would make more sense since you want control something, won't you?Required code, like 10 to 20 lines, mostly library calls and variables.

author: Jester
author_rank: Frequent Contributor
timestamp: April 17, 2018, 12:26:40 am
content: Quote from: Distelzombie on April 16, 2018, 11:56:21 pmWhen I say Tab, I mean pressing the tab button on the keyboard. It has to be the Tab button.

author: Distelzombie
author_rank: Frequent Contributor
timestamp: April 17, 2018, 12:37:40 am
content: Ok yes, I answered on that too. ("type 'tab'" means pressing the keys t, a to write the word "tab", btw. I wonder why I have to tell you that, considering our country flags.)Why does it have to be this key? WHERE do you want it to do that? Inside your own program? Everywhere? I said "tab" can be problematic. Just press it anywhere and see what it already does. Can you not choose a different key?

author: rstofer
author_rank: Super Contributor
timestamp: April 17, 2018, 12:56:25 am
content: You may also have to change the port type to EPP in the BIOS.http://janaxelson.com/files/ppc1.pdfYou will almost certainly need a resistor in series with the LED. For a conventional LED, try 470 Ohms to start.

author: Jester
author_rank: Frequent Contributor
timestamp: April 17, 2018, 01:02:44 am
content: Quote from: Distelzombie on April 17, 2018, 12:37:40 amI'm using a CNC program called mach3. It uses Tab (ASCII 9) to invoke a particular display mode. I need to signal that this display mode is active to another piece of hardware. I have tried numerous methods from within the Mach program to detect this display mode, however none of the methods have worked, I tried some VB code GetPage(), that correctly returns the page number for every display page except this particular page. I have tried numerous methods, none of which work. I think the only thing that is going to work is capturing the keystroke independently. Changing the command key is not a viable option for me.

author: Distelzombie
author_rank: Frequent Contributor
timestamp: April 17, 2018, 01:21:00 am
content: I see. I think easiest solution would be autohotkey:https://autohotkey.com/board/topic/57216-check-if-window-is-open/(With any key)https://autohotkey.com/board/topic/59161-parallel-port-library/orhttps://autohotkey.com/board/topic/78998-lpt-port-io-control-32-in-12-out-leds-relays-switches/Otherwise I could give you hints for C++, like, making a background task that waits for "tab" and sends/ -or sends a command over parallel port, if a certain window with a certain NAME, if it has one - probably not, is open upon hotkey press (any).You practically don't need any knowledge of autohotkey or C++ to realize this in a few hours. But it's like much to read, you know. Better don't take the easy route and train ya brain.

author: Ampera
author_rank: Super Contributor
timestamp: April 17, 2018, 02:09:58 am
content: Honestly, I believe the easiest method would be not using Windows at all. I could probably run a PC booting program in Assembly that can do exactly that. Would be even easier in DOS, because then I could use C.

author: Distelzombie
author_rank: Frequent Contributor
timestamp: April 17, 2018, 02:22:16 am
content: So the easiest way is writing an OS that runs his Mach3 CNC software just to make a simple 10 line program run ... easier? I don't think that makes any sense at all.

author: Stray Electron
author_rank: Super Contributor
timestamp: April 17, 2018, 02:42:45 am
content: Quote from: Jester on April 17, 2018, 12:26:40 amIn MS-DOS you could use the Ansi.sys file to redefine any of the keyboard keys to send any string that you wanted and it would child's play to write a string to the serial port. But I don't think that will work in Win 7.

author: AndersJ
author_rank: Frequent Contributor
timestamp: April 17, 2018, 02:49:20 am
content: If all that is needed is a 5V pulse,why not skip the PC and use a physically separate pushbutton,possibly with a monostable and/or schmitt trigger, or a 555 timer?

author: Distelzombie
author_rank: Frequent Contributor
timestamp: April 17, 2018, 02:59:14 am
content: Quote from: Stray Electron on April 17, 2018, 02:42:45 amThat sounds like it would be a "global hotkey" then, rendering the tab key useless btw.I understand that he wants the Tab to do two things at once: The usual stuff and then it should send a command over parallel. Also his Mach3 software probably doesn't run under MS-DOS. [Nope: Desktop or Laptop with Windows 2000, Windows XP, Windows Vista, Windows 7, or Windows 8]Do I miss something or why does that keep coming up?Edit: No seriously. And no offense.

author: Jester
author_rank: Frequent Contributor
timestamp: April 18, 2018, 12:56:03 pm
content: Quote from: Distelzombie on April 17, 2018, 02:59:14 amThanks to all for the ideas, I have solved this problemDistelzombie, Big thanks the key translator turned out to be part of the solution.I'm using a Pokeys57 board as part of this system and it allows me to share data between it and Mach3. I already had some programmable logic in the Pokeys device that toggled the desired screen on and off based on some hard buttons on a custom control panel.So I used the key translator to effectively block the Tab key from getting to Mach and instead send an alternate unused hotkey Alt-B, I added a custom button (software button) in Mach that gets pressed when ever it receives Alt-B. I then shared the data from that button with pokeys and OR'd the input to the existing logic that controls the desired display. Works like a charm.No parallel or serial port required.

author: Distelzombie
author_rank: Frequent Contributor
timestamp: April 18, 2018, 01:36:01 pm
content: Quote from: Jester on April 18, 2018, 12:56:03 pmI didn't even know that works with such an important key as tab. Doesn't that result in issues?Well, good to know I could help with practically just writing the word "Autohotkey".