Have a program simulate a Hotkey press

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
HBinswanger
Posts: 17
Joined: 14 Feb 2016, 00:45

Have a program simulate a Hotkey press

Post by HBinswanger » 14 Feb 2016, 00:54

I have an AHK script that does a RegExReplace, and I want to have it called at a certain point in another script (a macro in XyWrite, an ancient word processing program). That other script can send text to the screen, and AHK can intercept actual key hits and be triggered that way, of course. But how do I get the AHK module to be triggered automatically in the script? In other words, AHK can recognize when a key has been pressed, but is there something else that it can recognize which would set the RegExReplace into operation?

lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: Have a program simulate a Hotkey press

Post by lexikos » 14 Feb 2016, 01:59

Déjà vu... Make AHK think a key has been pressed that it can respond to

I have no idea what XyWrite is capable of. If it's a 16-bit program, there's probably very little a macro can do that could be seen outside of the program. If it's a console app, you can monitor what characters are on screen via console functions like ReadConsoleOutputCharacter (maybe LibCon will help). However, that would mean constantly watching the window/polling the contents of the window.

HBinswanger
Posts: 17
Joined: 14 Feb 2016, 00:45

Re: Have a program simulate a Hotkey press

Post by HBinswanger » 14 Feb 2016, 15:13

XyWrite is a DOS program that runs under NTVDM in Win7 32-bit. XyWrite is 16bit AT BEST (could even be, shudder, 8bit). So my workaround is to have the XyWrite macro prompt me to hit the key that cues AHK: alt-t. (I have disabled alt-t in XyWrite, so nothing will be passed to it).

Since I don't know how long it will take AHK to do its process, I hit upon the idea of using GetKeyState, state, Shift--to see if the shift key is down, so that I can use that to Break out of the loop AHK will be in. That might not be necessary, because I can simply do a Sleep inside XyWrite for 1 or more seconds, which should be more than enough time for super-swift AHK to do its thing.

If this call to AHK from within XyWrite works, it will solve a major problem I'm having. And preliminary results are good. Thanks for your reply.

Post Reply

Return to “Ask for Help (v1)”