Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Toggle Holding Down the Shift Key


  • Please log in to reply
7 replies to this topic
zackyang
  • Members
  • 13 posts
  • Last active: Jan 05 2010 02:10 AM
  • Joined: 04 Jan 2009
Hi,
I'm a semi-decent coder who has been having a lot of trouble trying to create both a toggle to hold down the shift key, as well as a simple trigger to engage holding down the shift key. The specific scenario is that I want to be able to sometimes sprint, in combat, in the MMO Age of Conan, and I'd like to be able to do so by a simple toggle switch, OR if I've hit a certain key (not a toggle, though, because it'll always activate, but the toggle switch will turn it off).

The problem is, if you do something like:
send +w (since I am using WASD keyboard), it will glitch out and not let you run.

w::+w would work, except that I couldn't toggle it, and I can't use reload, or my other macros will get messed up, and pause is just a big mess.

Help!

Thanks,

Zack

PS: and no, using capslock doesn't work, lol.

animeaime
  • Members
  • 1045 posts
  • Last active: Jun 18 2011 04:44 AM
  • Joined: 04 Nov 2008
What is it that you want from us? I know, bad start, but let's move past that.

It seems that "w" will walk and "shift + w" will sprint, or reverse, right? You then want to have a key to be the toggle. If I'm going way out on left field, please tell me, because I'm lost.

Please elaborate on what you want the code to do.
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.

Slanter
  • Members
  • 739 posts
  • Last active: Jul 08 2011 05:26 AM
  • Joined: 28 May 2008
maybe something like
Shift::Send, % "{Shift " ((SToggle := !SToggle) ? "Down" : "Up") "}"
:?:
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.

zackyang
  • Members
  • 13 posts
  • Last active: Jan 05 2010 02:10 AM
  • Joined: 04 Jan 2009

What is it that you want from us? I know, bad start, but let's move past that.

It seems that "w" will walk and "shift + w" will sprint, or reverse, right? You then want to have a key to be the toggle. If I'm going way out on left field, please tell me, because I'm lost.

Please elaborate on what you want the code to do.


What I'd like to do is:

If you hit ctrl, all WASD keystrokes will now be +w, +a, +s, +d, in other words, they will have a shift in front of them. If you hit ctrl again, they will be normal.

animeaime
  • Members
  • 1045 posts
  • Last active: Jun 18 2011 04:44 AM
  • Joined: 04 Nov 2008
I think this is what you want.

<Shifted> controls whether shift + key is sent or just key. <Shifted> starts off false, so pressing "awsd" will send "awsd". Press control and <shifted> will toggle. Then, pressing "aswd" will send "ASWD".

Hope it does what you want. If not, or if you have any questions, you know where to find me.

#SingleInstance Force
#NoEnv

Shifted := false
return

;Toggle <Shifted>
Control::Shifted := !Shifted

;Sends wasd
$w::Send("w")
$a::Send("a")
$s::Send("s")
$d::Send("d")

Send(Key)
{
    ;if <Shifted>, sends +%Key%
    ;else, sends %Key%

    global Shifted
    
    if Shifted
        Send, +%Key%
    else
        Send, %Key%
}

As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.

helpme123k89122
  • Guests
  • Last active:
  • Joined: --
doesn't work in-game, only works in Word. Try it!

zackyang
  • Members
  • 13 posts
  • Last active: Jan 05 2010 02:10 AM
  • Joined: 04 Jan 2009
Yeah, it doesn't :(

Basically, if you do it in-game, you can't move at all :(

The WASD keys no longer work. It's weird because it seems fine outside of the game.

animeaime
  • Members
  • 1045 posts
  • Last active: Jun 18 2011 04:44 AM
  • Joined: 04 Nov 2008
That's because that game must have a block for Send, try SendPlay instead (or another Send mode).
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.