Hotkey not working Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
leofabian
Posts: 12
Joined: 25 Jan 2022, 10:17

Hotkey not working

Post by leofabian » 17 Aug 2022, 10:11

Hello there ;)

I have this code:

Code: Select all

#SingleInstance, Force
^j::

ThisIsMyFunction()
{
}

WinActivate ahk_exe Excel.exe

Sleep, 200
Send, ^c
Sleep, 200
Send, {Up}
Sleep, 200
Send, ^v
Sleep, 200
Send, {Enter}

return

Exit
My defined Hotkey only works when I comment out the function.
On another computer the script is working as supposed.
What am I missing out?
Even when I close aöö other programs so that only the script is running.
Bthw. it`s Version SciTE4AutoHotkey Version 3.1.00 SciTE:5.2.2 Scintilla:5.2.2 Lexilla:5.1.6 Built on May 2 2022 14:12:35

Thanks in advance

gregster
Posts: 9014
Joined: 30 Sep 2013, 06:48

Re: Hotkey not working  Topic is solved

Post by gregster » 17 Aug 2022, 10:17

Function definitions usually don't belong into hotkey subroutines.

Exception: Function hotkeys which exist since AHK v1.1.20+. But then the rest of the hotkey subroutine wouldn't be executed anymore, afaik. Which seems to be exactly what you are seeing.
Hence, pull the function definition out of the hotkey subroutine, if you plan to actually put smth into it and to call it some time. Otherwise, just remove it.

Perhaps there are running very old AHK versions on the computers on which this code still works.
SciTE4AHK's version shouldn't matter - that's just the editor.

leofabian
Posts: 12
Joined: 25 Jan 2022, 10:17

Re: Hotkey not working

Post by leofabian » 18 Aug 2022, 07:11

Thank you gregster!

Post Reply

Return to “Ask for Help (v1)”