Jump to content

Making Left Shift key toggle the Left Shift key


Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 13 years later...
On 5/1/2009 at 7:47 AM, will88 said:

 

 

#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)

This is not working. At least on Win10

Link to comment
Share on other sites

  • Moderators

Justman,

Did you notice that the last post in this thread dates from over 13 years ago and that the OP has not been online since then?

Please do not necro-post like this again - just open a new thread and link to the old one if it is absolutely necessary for understanding the problem. We ask you to do this for two main reasons:

- 1. The language advances and the functionality might well be included in core or UDF code by now

- 2. The changes in language syntax mean that it is likely that code from more than a couple of years ago may well not run under the current release interpreter without significant modification.

Thanks for your cooperation.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...