help: Detecting keystokes?

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

User avatar
Jon100
a hill giant
a hill giant
Posts: 161
Joined: Mon Sep 22, 2003 6:15 am
Location: UK

help: Detecting keystokes?

Post by Jon100 » Sun Dec 28, 2003 4:19 pm

Is there a way to detect if a particular key is pressed down?

Id like to pause one macro if the alt key is being pressed, but i dont see any way to detect that.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Sun Dec 28, 2003 4:21 pm

Not that I know of. I typically just create a hotkey with /mqpause in it and use that.

User avatar
Jon100
a hill giant
a hill giant
Posts: 161
Joined: Mon Sep 22, 2003 6:15 am
Location: UK

Post by Jon100 » Sun Dec 28, 2003 4:30 pm

unfortunately that would be too slow and cumbersome. I typically need to 'pause' the macro for a second.

What im trying to do is stop a macro that is moving me so I can cast a spell without interupt. using $char(casting) is too late - by then I have already started to cast the spell and have interupted myself.

What I could like ideally is

Code: Select all

/if $pressed(alt) /goto :mainloop
so I can stop the movement before the spell casting starts.

Any ideas how I can check if a key is pressed?

User avatar
wilso132
Contributing Member
Contributing Member
Posts: 106
Joined: Thu Oct 17, 2002 11:53 am

Post by wilso132 » Sun Dec 28, 2003 4:39 pm

It might be possible to add an event where you send yourself a /tell and put that text as the event itself.... then if the event is detected you /pause 10s (or however long you need).

Then hotkey a /tell myself blah... that may work??? (Crappy workaround I know, but it should work.)

Edit: To clarify, put "Talking to yourself again?" as the event.

Here's the code:

Code: Select all

#event talking_to_self "Talking to yourself again?"

Sub Main
	:LOOP
	/doevents
	/goto :LOOP
/return
/end macro

Sub Event_talking_to_self
	/delay 5s
/return

User avatar
Jon100
a hill giant
a hill giant
Posts: 161
Joined: Mon Sep 22, 2003 6:15 am
Location: UK

Post by Jon100 » Sun Dec 28, 2003 4:55 pm

Thats an interesting idea.

I would have to make a hotkey and send myself a tell every time i want to pause the macro and cast a spell. That would work, but it's a bit messy (and finding another page 1 hotkey would be a problem).

Any other ideas how I might do this? :/

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Sun Dec 28, 2003 5:02 pm

Only thing I can think of is to maybe press d to duck. Then d to resume.

Something like the code below would work.

Code: Select all

:WaitLoop
/delay 1s
/if $char(state)==DUCK  /goto :WaitLoop

User avatar
Jon100
a hill giant
a hill giant
Posts: 161
Joined: Mon Sep 22, 2003 6:15 am
Location: UK

Post by Jon100 » Sun Dec 28, 2003 8:12 pm

except you cant cast while ducked. lol

I suppose you could trap the duck, then wait for you to stand and then stop the movement for 2s while the spell casting starts. then use $char(casting) to stop movement until it ends.

still a clumsy solution tho :(

Any other ideas please?

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Sun Dec 28, 2003 8:25 pm

Oh I guess I should have read your later comments. You simply need to do this:

Code: Select all

Sub Main
/call CastSpell
/return

Sub CastSpell
[color=red]:Loop
/delay 1
/if $char(ismoving)==TRUE  /goto :Loop[/color]
/cast "Spellname"
:Loop2
/delay 1
/if $char(casting)==TRUE /goto :Loop2
/return
The portion marked in red will make it wait til you stop to cast.