Jump to content

Disabling keys temporarily


Recommended Posts

Hello, I am writing a program that must hold down alt at all times but must let go of alt whenever I press s, or left click. I am not sure how to accomplish this, please help. I can't think of a way to use hotkeyset to do this.

EDIT FOR SECOND QUESTION: Ok I just tested the other part of my program and it disables keys that are hotkeyed, can I fix this? This program is just supposed to make my tyghv and b keys substitute for my corresponding 78451 and 2 keys on my numpad for warcraft 3 hotkeys.

$toggle=0

$exit=0

$x=1

hotkeyset ("_","kill")

hotkeyset ("+","reset")

hotkeyset ("{ENTER}","toggle")

hotkeyset ("t","send7")

hotkeyset ("y","send8")

hotkeyset ("g","send4")

hotkeyset ("h","send5")

hotkeyset ("b","send1")

hotkeyset ("n","send2")

func toggle()

if $toggle=1 Then

$toggle=0

else

$toggle=1

EndIf

EndFunc

func send7()

if $toggle=1 Then

send ("{NUMPAD7}")

EndIf

EndFunc

func send8()

if $toggle=1 Then

send ("{NUMPAD8}")

EndIf

EndFunc

func send4()

if $toggle=1 Then

send ("{NUMPAD4}")

EndIf

EndFunc

func send5()

if $toggle=1 Then

send ("{NUMPAD5}")

EndIf

EndFunc

func send1()

if $toggle=1 Then

send ("{NUMPAD1}")

EndIf

EndFunc

func send2()

if $toggle=1 Then

send ("{NUMPAD2}")

EndIf

EndFunc

func reset()

$toggle=0

EndFunc

func kill()

$exit=1

EndFunc

do

sleep (1000)

if $exit=1 Then

Exit

EndIf

until $x=0

Edited by Ipooptoomuch
Link to comment
Share on other sites

  • Moderators

You should lay off the ex-lax :D

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Hello, I am writing a program that must hold down alt at all times but must let go of alt whenever I press s, or left click. I am not sure how to accomplish this, please help. I can't think of a way to use hotkeyset to do this.

EDIT FOR SECOND QUESTION: Ok I just tested the other part of my program and it disables keys that are hotkeyed, can I fix this? This program is just supposed to make my tyghv and b keys substitute for my corresponding 78451 and 2 keys on my numpad for warcraft 3 hotkeys.

One thing to do is change your Do/Until loop you have at the bottom into a While/Wend loop, its just more reliable for a default action, not that yours was incorrect

HotKeySet Steals keys for other uses, look into "_IsPressed" in the helpfile (I think its there)

Edited by Paulie
Link to comment
Share on other sites

  • 1 month later...

Hello, I am writing a program that must hold down alt at all times but must let go of alt whenever I press s, or left click. I am not sure how to accomplish this, please help. I can't think of a way to use hotkeyset to do this.

For Q#1.

#Include <Misc.au3>

Opt("OnExitFunc","OnAutoItExit")

Send("{LALT DOWN}")

While 1
    
    If _IsPressed(53) Or _IsPressed(01) Then
    
        Send("{LALT UP}")
        
        Do
            Sleep(10)
        Until _IsPressed(53) = 0 And _IsPressed(01) = 0
        
        Send("{LALT DOWN}")

EndIf

WEnd

Func OnAutoItExit()
    Send("{LALT UP}")
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

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