Jump to content
Sign in to follow this  
Flictus

Making Left Shift key toggle the Left Shift key

Recommended Posts

Flictus

I am trying to set up a macro that will run in the background so that when I press the Shift key once it will use the Shift Down command. When I press the shift key a second time I'd like to call the Shift Up command. Basically, I want to toggle the shift key to be up or down by pressing the shift key. I am trying to use it for games that require holding down the shift key to run. I'd like to press shift once to run and then again to stop running.

I can't get the left shift key to call the function. It works with other keys though like 1 or F12. But, even when the function gets called, it will send "lshift down" when I press the hotkey once but not "lshift up" when I press it again. Any ideas?

Here is my code:

CODE
#include <Misc.au3>

HotKeySet("lshift", "TogRun")

Global $paused = true

Func TogRun()

$paused = false

$dll = DllOpen("user32.dll")

While 1

If _IsPressed("12", $dll) Then

Send("{lshift up}")

ExitLoop

Else

Send("{lshift down}")

ExitLoop

EndIf

WEnd

DllClose($dll)

$paused = true

EndFunc

While $paused = true

Sleep(500)

WEnd

Share this post


Link to post
Share on other sites
will88

This what you trying to do?:

#include <Misc.au3>
Global $Shift = "", $dll = DllOpen("user32.dll")
While 1
    If _IsPressed("10", $dll) Then
        If $Shift = "" Or $Shift = 0 Then
            Send("{lshift up}")
            $Shift = 1
        ElseIf $Shift = 1 Then
            Send("{lshift down}")
            $Shift = 0    
        EndIf
    EndIf
WEnd
DllClose($dll)
Edited by will88

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.