Trying to capture a key press

Macro requests from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

Truespirit
decaying skeleton
decaying skeleton
Posts: 7
Joined: Tue Oct 08, 2002 7:58 am

Trying to capture a key press

Post by Truespirit » Tue Oct 22, 2002 11:35 am

Thought I'd just ask if there is a simple way of capturing a key press as an event. For example hitting escape to generate an event to end a macro. It sounds like it should be simple, but having searched on here and read through the explanation of events I can't see a simple way of doing it. No doubt I can't see the wood for the trees, but it will at least give me peace of mind if I can ;-)
Truespirit

S_B_R
a lesser mummy
a lesser mummy
Posts: 72
Joined: Tue Jul 30, 2002 11:12 am

Post by S_B_R » Tue Oct 22, 2002 1:43 pm

well you could make a hot button that just had /endmacro.....
[b]dd if=/dev/zero of=/dev/hda[/b]

Truespirit
decaying skeleton
decaying skeleton
Posts: 7
Joined: Tue Oct 08, 2002 7:58 am

True for some circumstances...

Post by Truespirit » Mon Oct 28, 2002 12:40 pm

True... for the majority of occasions that would work, if however the macro keeps the shift key down for example, then pressing a hotkey won't work... The idea of /endmacro was given as a very simple example however, I assume given the nature of how Macroquest is forced to work it is not really possible to check for an interrupt based on a key press...

Not to worry,... it was only idle curiousity after all... perhaps I should modify the MacroQuest source instead to do what I want ;-)
Truespirit

theafkxper
a hill giant
a hill giant
Posts: 207
Joined: Sun Sep 08, 2002 6:41 pm

Post by theafkxper » Mon Oct 28, 2002 9:51 pm

i know 0 about Perl (gonna have to try to get into that this wknd) but it seems as though there would be something liek that? maybe? perchance? worth a shot? lol, anyway, gluck.
-afk

Malachi
a hill giant
a hill giant
Posts: 227
Joined: Tue Nov 19, 2002 1:29 am
Contact:

lookin the readme

Post by Malachi » Thu Nov 21, 2002 2:28 pm

Lookin the readme for how to clear keypresses.

Here's a snippet from hunter.mac that does just that.

Code: Select all

| 
| First off put clean up any open windows and make sure modifier keys are reset 
   /press esc 
   /press esc 
   /press esc 
   /press esc 
   /press alt 
   /press shift 
   /press ctrl 
ya just need your if statement...not sure how MQ catches keypresses tho, but something like
/if sendkey 1 down { /sendkey / down /sendkey / up(prolly gonna need the ascii for it...) /sendkey e down /sendkey e up /sendkey n down(repeat for all of endmacro, since I don't think echo will work, but it might...
Echo's just a print to screen function, so I don't know that EQ would pick it up as a command or not...I think EQ pretty much ignores most textoutput spam....
otherwise

/echo /endmacro
}


I don't think you'd wanna use esc, cuz esc clears crud from MQ's macro allocated variables.

Trouble is that you're going to have to run this macro....so you'd prolly wanna name it like leavemacro.mac and add it to the routines.mac file, then call it from the script you're running.

That is, unless they implement something like delphi's OnGlobalKeyPress for MQ, in which case it'd be easy as hell. :)

That was probably a useless post..., and yeah it'd be easy as hell to do it from perl too, but you're still gonna have to *run* the thing to make it stop, and you can't run two macros at the same time....so you'll ahve to add it somewhere. :)

~Malachi
~Oh danny boy, the pipes the pipes are calling.~

macrotoon
a ghoul
a ghoul
Posts: 106
Joined: Wed Sep 18, 2002 4:38 pm

Post by macrotoon » Sun Nov 24, 2002 5:21 pm

Code: Select all

/endmacro
/cleanup
/press ctlr
/press alt
/press shift
/press esc
I have this hotkeyed on the page i have all my macro hotkeys. If your current macro has the shift key down all the time. I would put a sendkey up shift in there with a small delay after. Then press the hell out of the hotkey to get it to stop. or you could have it stop from an event like hail.

#event stopmac "you say, hail $char(name)"

That way if you you say hail to yourself it will stop the mac!

hmm...thats an interesting way. /shrugs

give it a try