Flictus Posted May 1, 2009 Posted May 1, 2009 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
will88 Posted May 1, 2009 Posted May 1, 2009 (edited) 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 May 1, 2009 by will88 Password-Keeper
Justman Posted June 12, 2022 Posted June 12, 2022 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
Moderators Melba23 Posted June 12, 2022 Moderators Posted June 12, 2022 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts