Author Topic: Perform action when caps-lock is activated and button is pressed?  (Read 4083 times)

Xariez

  • Guest
Heyyo,

Title. So I have gotten into games such as ETS2, ATS, Elite Dangerous etc again, and for driving/trucking was specifically wonder if there is a way to only execute a certain command whenever a button is pressed, AND caps lock is detected as toggled? So something like this:

-- if caps lock is pressed
   -- if key is pressed
      -- perform action

My idea would be, specifically in ETS2 and ATS, to be able to double (or triple) shift (basically hit the shift key twice) without the hassle of actually hitting it twice/thrice?

Thanks in advance!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: Perform action when caps-lock is activated and button is pressed?
« Reply #1 on: January 23, 2018, 03:09:33 PM »
I'm not sure what you're looking for, is this it?:

Code: [Select]
Begin Text Compare : [{CAPSLOCKON}] Equals '1'
    Write '[Blue] Caps lock is on, do the thing' to log
Else
    Write '[Blue] Caps lock is off, do the other thing' to log
End Condition

You'd use the "When I press keys :" option to trigger the command with a keypress, and the state of the caps lock feature would determine which branch is executed.

Xariez

  • Guest
Re: Perform action when caps-lock is activated and button is pressed?
« Reply #2 on: January 23, 2018, 04:32:14 PM »
I feel like that should work (or atleast, it's the correct principle), but it isn't.

If we take the CapsLock-part out of it, the command looks like this:

When I press LEFT SHIFT:
Code: [Select]
Pause 0,1 seconds
Press Left Shift key and hold for 1 second and release

This will basically make sure I shift up each time I hit shift, as of right now, in ETS2.

However, my request is to make this work ONLY when CapsLock is toggled. Hopefully that cleared it up if anything was unclear? Thanks either way!


Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2826
Re: Perform action when caps-lock is activated and button is pressed?
« Reply #3 on: January 23, 2018, 09:17:47 PM »
What Pfeil described works here.  I have it with a command that executes when I press x.  When caps lock is on, it does one thing.  If caps lock is not on it does another thing.

If you are wanting the Shift key to come BEFORE the key press, you're going to need to do two things.  First, you'll need to set your, 'when i press key' to no allow the key to be passed through.  Next, you'll want to put the key you want to press in the macro itself.  Otherwise the key will be either be not handled and passed through (as a lower-cased letter) or, not passed through at all:

Begin Text Compare : [{CAPSLOCKON}] Equals '1'
    Press X key and hold for 0.1 seconds and release
Else
    Press Left Shift+X keys and hold for 0.1 seconds and release
End Condition

Either way, it makes sure, 'X' is capitalized.




Xariez

  • Guest
Re: Perform action when caps-lock is activated and button is pressed?
« Reply #4 on: January 24, 2018, 04:44:04 AM »
Alright, thanks to both of you! This is now fixed. Apparently I had to update VoiceAttack, remove my old profile and create a new one for it to work - but now it does just that! Thanks again!