Macro's with IF commands

Have something you would like to say? let us know.
Post Reply
Jonovision
Posts: 12
Joined: Mon Mar 16, 2015 5:16 pm

Macro's with IF commands

Post by Jonovision »

I am far more familiar with the use of IF and ELSE IF commands in things like VBA and AUTOIT than I am with the macro activation triggers you have created for your macros. Personally I have not yet wrapped my head around the whole triggers thing, I don't even know where to start. I have an idea to help with the use of LSHIFT for running in games like COD Advanced Warfare, personally my little finger gets really tired and sore from the unnatural position is has to assume in order to play these games effectively, sometimes I hit the CAPS LOCK key instead. I was thinking that because I am almost always running in game and that I love the new dash feature of COD:AW that I would like to use triggers to improve my movement capabilities, without straining my little finger. This is what I had in mind with the use of IF commands:
(Bind in config file IJKL to movement) (I don't want the trigger LSHIFT when holding down the forward key and tapping A or D, only at the release of W do I want the other macros to become active)
IF MACRO KEYDOWN W then
KEYDOWN I
KEY LSHIFT <-Run or tap to dash forward after jumping
ELSE IF MACRO KEYDOWN A then
KEYDOWN J
KEY LSHIFT <-Dash Left
ELSE IF MACRO KEYDOWN S then
KEYDOWN K
KEY LSHIFT <-Dash Back
ELSE IF MACRO KEYDOWN D then
KEYDOWN L
KEY LSHIFT <-Dash Right
ENDIF

MACRO KEYUP W
KEYUP I
MACRO KEYUP A
KEYUP J
MACRO KEYUP S
KEYUP K
MACRO KEYUP D
KEYUP L

Or if this is not possible with triggers, could you possibly make it possible with the macro code to use IF and ELSE IF commands?
User avatar
Matlo
Posts: 5768
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Macro's with IF commands

Post by Matlo »

If I understand well you want to trigger a LSHIFT key press when w is not pressed and a or d is pressed?
I think it should work with the following definitions:

Code: Select all

#wasd is bound to movement

MACRO KEYDOWN a
TRIGGER KEYDOWN m
INIT ON
TOGGLE YES
KEYDOWN LSHIFT
#you may want to adjust this delay
DELAY 50
KEYUP LSHIFT

MACRO KEYDOWN d
TRIGGER KEYDOWN m
INIT ON
TOGGLE YES
KEYDOWN LSHIFT
#you may want to adjust this delay
DELAY 50
KEYUP LSHIFT

#when the state of w changes, generate a KEYDOWN m event, so as to toggle above macros

MACRO KEYDOWN w
KEYDOWN m

MACRO KEYUP w
KEYDOWN m
GIMX creator
Jonovision
Posts: 12
Joined: Mon Mar 16, 2015 5:16 pm

Re: Macro's with IF commands

Post by Jonovision »

Okay so from what I can see in the code, a key that is bound in a config.xml can have a macro assigned to it and a keyup macro is not required unless it is a looping macro, but then again looping macros shouldn't be triggered by a key bound in a config.xml file. What would changing toggle to NO do to the macros? Would that alter the code to a hold only state so that the key must be held down to trigger the macro? If so then could the last bit of code be writen as follows:

MACRO KEYDOWN w
KEYUP m

MACRO KEYUP w
KEYDOWN m

And how would I have the auto run coded? Would this work with the existing code?

MACRO KEYDOWN w
TRIGGER KEYUP m
TOGGLE OFF
KEYDOWN LSHIFT
DELAY 100
KEYUP LSHIFT
User avatar
Matlo
Posts: 5768
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Macro's with IF commands

Post by Matlo »

Jonovision wrote:What would changing toggle to NO do to the macros?
TOGGLE YES means that pressing the activation trigger (defined by TRIGGER <DEVICE EVENT> <ID>) will enable or disable the macro. TOGGLE NO means that pressing the activation trigger will enable the macro and disable the macros that have a different activation trigger and TOGGLE set to NO (or no TOGGLE defined). Macros without activation trigger are not affected.

To automatically run when pressing w just modify the last macros as following:

Code: Select all

MACRO KEYDOWN w
KEYDOWN LSHIFT
KEYDOWN m

MACRO KEYUP w
KEYUP LSHIFT
KEYDOWN m
GIMX creator
Jonovision
Posts: 12
Joined: Mon Mar 16, 2015 5:16 pm

Re: Macro's with IF commands

Post by Jonovision »

I am learning so much from this, the macro wiki should really be updated, but thanks for all the input on the subject and I will be certain to do some more testing given the new knowledge I have acquired, and I will definitely share my experiences on the subject.
Jonovision
Posts: 12
Joined: Mon Mar 16, 2015 5:16 pm

Re: Macro's with IF commands

Post by Jonovision »

That macro did some weird things, haha. I changed things up a little and got it working, this is what I wrote:

#Always active macro, no trigger
MACRO KEYDOWN w
KEYDOWN LSHIFT
DELAY 200
KEYUP LSHIFT

#Active only when not using auto run macro
MACRO KEYDOWN a
TRIGGER KEYUP w
KEYDOWN LSHIFT
DELAY 200
KEYUP LSHIFT

MACRO KEYDOWN d
TRIGGER KEYUP w
KEYDOWN LSHIFT
DELAY 200
KEYUP LSHIFT

As of right now, I cannot think of a good way to use TOGGLE except to turn off a macro with INIT ON, like if I wanted to use a key to prevent the auto run and dash strafing for situations involving sneaking. But I did notice that upon using this macro the aim got shaky when using faster mouse movements, but small mouse movements were smooth. The problem didn't go away until I restarted my laptop, which makes me think that something was stuck in memory that was causing the shaky aim that couldn't be cleared by restarting gimx or changing the macro or config file. I deleted all the macros as I have a backup and changed all the key bindings to the original and the aim continued to be a problem, it was rather strange. I am going to test the macros again but this time without a keyboard and see if it was the macros or the keyboard that triggered the problem.
User avatar
Matlo
Posts: 5768
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Macro's with IF commands

Post by Matlo »

Jonovision wrote:The problem didn't go away until I restarted my laptop
An explanation could be that some other program running on your laptop was doing CPU-intensive tasks...
It is a good practice to close all other apps when running GIMX.
GIMX creator
Jonovision
Posts: 12
Joined: Mon Mar 16, 2015 5:16 pm

Re: Macro's with IF commands

Post by Jonovision »

I never run other programs, I thought that was a problem before so I always made certain to shut down every unnecessary program including my WiFi adapter, just in case the system cannot manage those resources effectively. I will send you my results when I test, and I have removed the toggle off from my code so it just has a trigger of keyup w. When it comes to my coding I always try my best to trim it down to the most simple form while still getting the job done, that is why I tried using a keyup as a trigger instead of using toggle with a different key. And I have been thinking on this for some time, I would like to help on the project, how do I become a contributor?
User avatar
Matlo
Posts: 5768
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Macro's with IF commands

Post by Matlo »

There are several ways to contribute, they all are listed on the wiki: http://gimx.fr/wiki/index.php?title=Contribute
GIMX creator
Post Reply