0

I've mapped the following keys:

ALT + Z to be equivalent to ALT + F4
ALT + X to be equivalent to ALT + F + C

With the following code:

!z::
   Send, !{F4}
!x::
   Send, !fc

However, when this code is running and I press ALT + Z , the actual keys that are being sent are:

ALT + F4 and then ALT + F + C instead of just ALT + F4

What am I doing wrong? How do get the mapping to be correct for ALT+Z?

Andreas
  • 5,393
  • 9
  • 44
  • 53
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
  • 2
    Put the commands on the same line with the hotkey definition or add `return` – wOxxOm Dec 02 '15 at 18:01
  • thanks so much make that into an answer and ill mark it correct – Alex Gordon Dec 02 '15 at 18:21
  • Possible duplicate of [Autohotkey hotkey handlers fall through/continue to lines below](http://stackoverflow.com/questions/9813484/autohotkey-hotkey-handlers-fall-through-continue-to-lines-below) – wOxxOm Dec 02 '15 at 18:22

2 Answers2

2

You need a return statement to tell the script to stop execution

!z::
   Send, !{F4}
return

!x::
   Send, !fc
return
Schneyer
  • 1,197
  • 1
  • 9
  • 27
-1

This is an AutoIt solution that works for me.

HotKeySet("!z", "sendKeys")

; Run Notepad just to have something to test with.
Run("notepad.exe", "", @SW_SHOWMAXIMIZED)

While 1
    Sleep(100)
WEnd

Func sendKeys()
    Send("!{f4}")
    Exit
EndFunc   ;==>sendKeys
MrAutoIt
  • 785
  • 6
  • 21