0

Is there a way to tell an autohotkey action (subroutine) to release the Alt key despite its trigger is Alt + X ?? here is my code...

!x::
sleep 100
it does some clicks and drags here (work fine)
return

but despite the sleep 100 in my code, sometimes when I press the Alt + X if I manually let the alt pressed the script will do an Alt Click, instead of only a Click which does a completely different thing.

I know I could increase the delay (sleep 100), or set AHK to wait until the alt key is realeased, but none of these would help cuz this script will be run several times continuously, so I prefer to hold down the Alt and press down/up the x several times in order to run it multiple times continuosly.

So I need a way to block temporarily the keyboard, or set the script to release the alt key, so autohotkey won't recognize my finger is still pressing the Alt key while executing the script several times.

I need something similar to this...

BlockInput, MouseMove
BlockInput, On

btw I have tried both, they don't work.

EDIT>>>>>

This is my function to click and drag...

AR4clickDnABmoveClickUpCDfn(ParamA, ParamB, ParamC, ParamD)
{
    If AR4togWorkbMode
    {
        AR4workbModeFn()    ;   Since this fn is used to click n drag panels, after disabling AR4workbMode I won't enable it back, cuz is supposed I need to see the Panel I'm draging afterward
        AR4togWorkbMode := !AR4togWorkbMode ;   So AR4retWorkbMode doesn't need to be set, but AR4togWorkbMode does
        Sleep 200
    }

        MouseGetPos X, Y
        BlockInput, On
        ;   BlockInput, MouseMove
        Sleep 50

        MouseMove, ParamA, ParamB
        Click down
        Sleep 50

        Loop 10
        {
            MouseMove, -1, 1, 100, R
        }

        Sleep 40
        MouseMove, ParamC, ParamD, 100
        Click Up

        BlockInput, Off
        ;   BlockInput, MouseMoveOff
        MouseMove %X%, %Y%
}

Then I in other subroutine !x run a subroutine which will click on a panel and call the click and drag function, in order to drag the panel, this is it..

#If WinActive("ahk_class ArtRage 3") or WinActive("ahk_class ToolWindow")

<!x::
;   Lalt & x::
If !AR4togToolSetsNear  ;   will run the first time the hotkey is pressed cuz the toggle var is not set yet
{
    Sleep 220
    AR4clickDnABmoveClickUpCDfn(AR4toolSetsX0 + AR4toolSetsSetGapXX, AR4toolSetsY0 + 10, AR4toolSetsNearX, AR4toolSetsNearY)
    AR4togToolSetsNear := !AR4togToolSetsNear
    Sleep 20
    WinActivate, ahk_class ArtRage 3
}
Else
{
    Sleep 220
    AR4clickDnABmoveClickUpCDfn(AR4toolSetsNearX, AR4toolSetsNearY, AR4toolSetsX0 + AR4toolSetsFarDifXX, AR4toolSetsY0 + AR4toolSetsFarDifYY)
    AR4togToolSetsNear := !AR4togToolSetsNear
    Sleep 20
    WinActivate, ahk_class ArtRage 3
}
Return

#If

BUT, since this subroutine trigger contains Lalt if I press and hold down Alt while pressing and releasing X multiple times in order to call the subroutine multiple times. Then AHK sript will send Alt Click and Drag and not only Click and Drag the former will actually rotate de panel, while the later will move it, I want to move it, not to rotate it, but on the other hand I need to press and hold ALT in order to run the subroutine multiple times, How can I do??

How can I make AHK to see the Alt keyboard as release while is been pressed manually by me?

Hope some super user could help me out, thanks advanced.

1
; Trigger an action (subroutine) by releasing the left Alt key, 
; without losing its native function as modifier key:

LAlt up:: 
if (A_PriorKey = "LAlt")
    Send a               ; do sth
return


; Trigger another action by releasing the left Alt key 
; in a key combination:

LAlt & x:: Send b       ; do sth else
; or:
; <!x:: Send b          ; <! means LAlt 
| improve this answer | |
  • This may be better as a comment – Dave M Dec 3 '16 at 22:06
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review – Dave M Dec 3 '16 at 22:06
  • I put my answer that way, because I wanted to make sure that I undestood the question correctly. As a comment, is the above code difficult to understand. Of course I'll modify it, giving more details, if it answers the question, or remove it, in case it doesn't. – user3419297 Dec 3 '16 at 22:35
  • @user3419297 - Answers should be not be used to "make sure you understand the question". You should ask a comment, which answers and provides, the clarification you need to answer the question – Ramhound Dec 4 '16 at 0:02
  • OK, I've modified my answer. Thanks for the correction. – user3419297 Dec 4 '16 at 1:03
0

here's an example of how to use the blockinput

https://autohotkey.com/docs/commands/BlockInput.htm

^!p::
KeyWait Control  ; Wait for the key to be released.  Use one KeyWait for each of the hotkey's modifiers.
KeyWait Alt
BlockInput On
; ... send keystrokes and mouse clicks ...
BlockInput Off
return

I just had to add, KeyWait Alt

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.