Jump to content

Can you disable hotkeys?


Recommended Posts

HotKeySet("E", "EKey")

Func EKey()
Send("{BACKSPACE}")
Send("=")
Send("7")
Send("-")
EndFunc

This is helpful except when I want to type. I don't want to have to start and restart the script since it requires tabbing into autoit script editor and hitting f5 again.

Is there a way to disable/enable hotkeys?

I tried putting in something like

Func EKey()
if $blah = 1 Then
Send("{BACKSPACE}")
Send("=")
Send("7")
Send("-")
Elseif $blah = 2 Then
Send ("e")
EndIf

EndFunc

Of course that just causes an infinite loop when I hit the e key.

I'm thinking of doing something like this:

HotKeySet("E", "EKey")
$count = 0
$blah = 1

Func EKey()
if $count = 0 Then

   if $blah = 1 Then
      Send("{BACKSPACE}")
      Send("=")
      Send("7")
      Send("-")
   Elseif $blah = 2 Then
      Send ("E")
      $count = 1
   EndIf
else
   $count = 0
EndIf

EndFunc

Is there a better way to do this? Would this even work?

Edited by Aro2220
Link to comment
Share on other sites

Did you read the documentation of HotKeySet?

function[optional] The name of the function to call when the key is pressed. Not specifying this parameter will unset a previous hotkey.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Maybe you could make a Hotkey to disable the others, something like this:

Global $hotkeys=0 ;By default hotkeys are disabled

HotKeySet("^!m","_EnableDisable") ;We use ctrl+alt+m to activate/deactivate HotKeys

While 1
    Sleep(250)
WEnd

Func _EnableDisable()
If $hotkeys=0 Then ;Hotkeys are disabled so we enable them
    HotKeySet("E","_Ekey")
    $hotkeys=1 ;We know now Hotkeys are enabled
Else
    HotKeySet("E") ;Disable HotKey "E"
    $hotkeys=0 ;We know now Hotkeys are disabled
EndIf
EndFunc

Func _Ekey()
MsgBox(0,"","_Ekey activated")
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...