Page 1 of 1

Issue with sending and receiving F13 - F24

Posted: 23 Feb 2018, 19:07
by Scr1pter
Hi,

First off: This is NOT a gaming related question.

I created a script which executes specific commands whenever F13, F14 or F15 get pressed.
(These keys get pressed by external software - either by BOME MIDI Translator Pro or Logitech Gaming Software.)
Everything works perfectly.

However, I can't receive F13 commands which were sent BY AutoHotKey.
I tried this

Code: Select all

;Notepad++
#if WinActive("ahk_class Notepad++")
F12::
Send {F13}
return

F13::
ControlClick, x450 y180, Logitech Gaming Software
SplashImage, C:\Users\USER\Documents\Logitech Gaming Software\Profil-Screenshots\Notepad++-M1.png, x1920 b
return

F14::
ControlClick, x509 y180, Logitech Gaming Software
SplashImage, C:\Users\USER\Documents\Logitech Gaming Software\Profil-Screenshots\Notepad++-M2.png, x1920 b
return

F15::
ControlClick, x556 y180, Logitech Gaming Software
SplashImage, C:\Users\USER\Documents\Logitech Gaming Software\Profil-Screenshots\Notepad++-M3.png, x1920 b
return
It does not execute the F13 command if I press F12.
It executes the F13 command if it came from the other two programs, though.

In another script I made a very simple test, which worked:

Code: Select all

F12::
Send {F13}
return

F13::
Send F13 was pressed!
return
When pressing F12, the F13 command GETS executed correctly.
Why does the simple script work but not the one that I really need?

I also tried it with $F13:: instead of F13.
No chance either.

Best regards

Re: Issue with sending and receiving F13 - F24  Topic is solved

Posted: 23 Feb 2018, 19:22
by Exaskryz
You may be able to get around these limitations by using SendLevel and/or #InputLevel.

I'll do some testing to see if it is actually a problem using the #if directive, but it may not be. (But you are sure you're inside of Notepad++ when you press F12, right?)

I had an initial suspicion that the #If would be installing a keyboard hook in a similar manner to #UseHook. These two code blocks fail to produce the MsgBox when I press F12:

Code: Select all

#If WinActive("ahk_class Notepad++")

F12::Send {F13}

F13::MsgBox Hello World

Code: Select all

#UseHook

F12::Send {F13}

F13::MsgBox Hello World
But what threw me off was your comment about the $F13. Did that it work for you in your test script? You said "No chance", which is ambiguous to me. I interpreted it to be a typo and you meant "No change". Which would imply your test script worked when using $F13 still; for me, this block also failed:

Code: Select all

F12::Send {F13}

$F13::MsgBox Hello World
Given that I can come across a similar, if not the same, issue by using #If, the suggested solution of SendLevel may do it. This works for me:

Code: Select all

#If WinActive("ahk_class Notepad++")

F12::
SendLevel, 2
Send {F13}
return

F13::MsgBox Hello World

Re: Issue with sending and receiving F13 - F24

Posted: 23 Feb 2018, 20:01
by Scr1pter
Hi Exaskryz,

The answer to all your question is yes.
By "no chance" I meant "No chance to get it work."

I tested it with SendLevel, 2.
It works flawlessly!

Thank you very much!