Hold key for 8 seconds

Post Reply
Zathras
Posts: 70
Joined: Thu May 21, 2015 4:09 pm
Location: NY

Hold key for 8 seconds

Post by Zathras »

How can I make a macro that holds a key for 8 seconds. Shouldn't this do it..

Code: Select all

<MACRO id="E_KeyHold8">
    <START></START>
    <MAIN repeat="1">
      <KEYINPUT behaviour="PRESS" type="VIRTUAL_CODE" code="0x45"/>
      <WAIT time="8000"/>
      <KEYINPUT behaviour="RELEASE" type="VIRTUAL_CODE" code="0x45"/>
    </MAIN>
    <END></END>
  </MACRO>
Does "Stop macro on deactivation" have to be unchecked? Also, how do you know when to put code in the start or end sections of the macro?

We really could use a manual or a little tutorial on macros. I usually just get frustrated with it and end up using autohotkey instead.
User avatar
Xcessity
Site Admin
Posts: 286
Joined: Sat May 16, 2015 2:23 pm
Location: Graz
Contact:

Re: Hold key for 8 seconds

Post by Xcessity »

Hi,
Does "Stop macro on deactivation" have to be unchecked?
Depends on what you want to achieve with the macro. If you set this checkmark the macro will be advanced to it's <END> section as soon as you stop doing the expression you bound the macro to. If you leave the checkbox empty the macro execution will remain active.
So in this example if you leave the box unchecked the macro will always take 8sec until it finishes no matter how long you do the expression. If you check this box for this macro the key will only release if you hold the expression for 8sec.
Also, how do you know when to put code in the start or end sections of the macro?
The sections of a macro are just for refinement. A macro that runs from start to finish has to execute it's <START>, <MAIN> and <END> section. There are a few reasons where these sections can become handy:
  1. use the <START> section to initialize the key/mouse button state you want during your macro.
  2. take advantage of the "repeat=x" argument to repeat a certain section several times
  3. use the <END> section to reset any mouse/kb states after the macro execution

As an example I once created a macro to use the mouse to rotate my character in World of Warcraft. This is done by holding the right mouse button and moving the mouse in the direction you want to turn to. So I put the RMB-down in the <START> section. Created a <MAIN repeat="x"> section that repeats infinite times and moves the mouse cursor to the left/right for a few pixels every 20ms. And finally we need an <END> section that releases the mouse cursor when the macro is stopped. Of course we would need to check the box "Stop macro on deactivation", otherwhise the macro would run infinitely.

Hope this explains the purpose of macro sections.
Zathras
Posts: 70
Joined: Thu May 21, 2015 4:09 pm
Location: NY

Re: Hold key for 8 seconds

Post by Zathras »

Yeah, that clears it up a bit. So is the above code correct... it's not working in my game.

I'm playing Dishonored and the q and e button lean your character left or right to peek around corners. I'm using Iris and I want to glance over at the interacter and have the character lean for moment while I refocus back on the game window.
Post Reply