Jump to content

Any Key


Recommended Posts

Hi there,

I'm trying to create a small tool that inserts text blocks (broadly speaking) into an editor window after a hotkey is pressed.

In order not to collide with predefined shortcuts, I use {pause] as an hotkey to activate all hotkeys, so that I can e.g., press {pause} "a".

My problem is that I wan't to delete the hotkeys for any key pressed (after {pause}) regardless if the key is a hotkey or not ...

Any suggestions?

Global $hKeyArray[4][2] = [ _
   ["c", "_addControl"], _
   ["i", "_addIf"], _
   ["e", "_addEndrep"], _
   ["n", "_neueFrage"] _
]
HotKeySet("{PAUSE}", "_toggleHotkeys")

Func _toggleHotkeys()
   If ($awaitingShortut) Then
      _deactivateHotkeys()
   Else
      _activateHotkeys()
   EndIf
EndFunc

Func _activateHotkeys()
   For $i = 0 To (UBound($hKeyArray) - 1) Step 1
      HotKeySet($hKeyArray[$i][0],$hKeyArray[$i][1])
   Next
   $awaitingShortut=true
   ConsoleWrite("waiting for hotkey" & @CRLF)
EndFunc

Func _deactivateHotkeys()
   For $i = 0 To (UBound($hKeyArray) - 1) Step 1
      HotKeySet($hKeyArray[$i][0])
   Next
   $awaitingShortut=false
   ConsoleWrite("disable hotkeys" & @CRLF)
EndFunc

Best 

Thorsten

Link to comment
Share on other sites

Seems alright to me, you just need to initialise $awaitingShortcut = True, and make a [While 1 sleep (100) WEnd] loop so the script doesn't exit immediately. You may also want to define a hotkey to exit your script.  Of course, the 4 hotkey functions need to be included in the script :)

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...