How to assign PF13 thru PF24 as Shift+PF1-12?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
michaeljohara
Posts: 29
Joined: 01 Jan 2019, 12:41

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

02 Jan 2019, 21:29

Scr1pter...

I stumbled across the Window Spy tool by right-clicking the taskbar icon. Eureka! It seems to display window title, ahk_class, ahk_exe, ahk_pid. So, I was able to better grasp what you had in mind with:

ControlSend, , +{F1}, ahk_class CLASSNAME and, later,
ControlSend, , +{F1}, ahk_exe youremulator.exe

So I feel I should back up to your earlier messages and review in light of some better understanding.

You asked earlier that I post the script. Of course, it was constantly changing. Now here's the first script I will now play with:

F13::
ControlSend, , +{F1}, ahk_exe pcsws.exe
return

Best,

Michael
michaeljohara
Posts: 29
Joined: 01 Jan 2019, 12:41

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

03 Jan 2019, 01:37

Ok, this does not work:

F13::
ControlSend, , +{F1}, ahk_exe pcsws.exe
return

I took out one of the commas, but no effect.

Tomorrow I will try the version with ahk_class.
michaeljohara
Posts: 29
Joined: 01 Jan 2019, 12:41

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

03 Jan 2019, 16:19

Scr1pter... The following did not work, with or without commas:

F13::
ControlSend, , +{F1}, ahk_class PCSWS:00400000
return

F13::
ControlSend, , +{F1}, ahk_class PCSWS
return

Moving on to more earlier suggestions.
michaeljohara
Posts: 29
Joined: 01 Jan 2019, 12:41

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

03 Jan 2019, 16:32

Scr1pter... The following did not work, with or without commas:

F13::
ControlSend +{F1}, ahk_pid 8716
return

This is based on the ahk_pid displayed in Window Spy. If that had worked I know it would be necessary to change the pid capture into a run-time variable.

Continuing on ...
User avatar
gwarble
Posts: 524
Joined: 30 Sep 2013, 15:01

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

03 Jan 2019, 19:06

Did you try those sendmodes?

Does this turn your A key into a B key in your emulator?
A::B

I get the feeling the window is getting input in a way ahk doesn't like, like some games do, with DirectInput or RawInput or some other method, that doesn't play nicely with the normal api

Maybe try AHI or WinRing0?
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
michaeljohara
Posts: 29
Joined: 01 Jan 2019, 12:41

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

03 Jan 2019, 22:20

gwarble, Scr1pter ...

Ok, I'm trying to read up on the several suggestions from you guys, and composing and testing scripts.

The below script is my first run:

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
DetectHiddenWindows, On
SetTitleMatchMode, 2
F13::
ControlSend, ahk_parent, +{F1}, ahk_exe pcsws.exe
F14::
ControlSend, ahk_parent, +{F2}, ahk_exe pcsws.exe
F15::
ControlSend, ahk_parent, +{F3}, ahk_exe pcsws.exe
F16::
ControlSend, ahk_parent, +{F4}, ahk_exe pcsws.exe
F17::
ControlSend, ahk_parent, +{F5}, ahk_exe pcsws.exe
F18::
ControlSend, ahk_parent, +{F6}, ahk_exe pcsws.exe
F19::
ControlSend, ahk_parent, +{F7}, ahk_exe pcsws.exe
F20::
ControlSend, ahk_parent, +{F8}, ahk_exe pcsws.exe
F21::
ControlSend, ahk_parent, +{F9}, ahk_exe pcsws.exe
F22::
ControlSend, ahk_parent, +{F10}, ahk_exe pcsws.exe
F23::
ControlSend, ahk_parent, +{F11}, ahk_exe pcsws.exe
F24::
ControlSend, ahk_parent, +{F12}, ahk_exe pcsws.exe
return

NOTE: Only F16 resulted in a reaction. As best as I can tell, pressing F16 caused AHK to send something that forced the keyboard's Shift to ON. And, in the AS/400 OIA / Status window, OS/400 inserted "Shift Key pressed." This message persisted in OIA as I pressed the remaining F17-F24 keys. When I re-tested and skipped over the F16 key, no other key caused a reaction. It appears that AHK did get this keypress through to OS/400.

Also, when focused shifted to the AHK edit window on the desktop, it seemed that the keyboard stayed in Shift ON mode because all the text inside the window kept getting selected (until I again pressed Shift).

It's getting late here in Arizona so I must pause my testing until tomorrow. But meanwhile I would appreciate any feedback. Thanks.

M
michaeljohara
Posts: 29
Joined: 01 Jan 2019, 12:41

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

07 Jan 2019, 00:30

gwarble, Scr1pter ....

I've continued to experiment with ControlSend variations. The below shows some various attempts. In each case F16 changed to the Shift function both inside the emulation window as well as for any other windows on the desktop.

I think I will try to follow the F16 Shift lead to see if any info turns up somewhere.

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
;
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
DetectHiddenWindows, On
SetTitleMatchMode, 2
;
F13::
ControlSend,, +{F1}, ahk_exe pcsws.exe
F14::
ControlSend,, +{F2}, ahk_exe pcsws.exe
F15::
ControlSend,, +{F3}, ahk_exe pcsws.exe
F16::
ControlSend,, +{F4}, ahk_exe pcsws.exe
F17::
ControlSend,, +{F5}, ahk_exe pcsws.exe
F18::
ControlSend,, +{F6}, ahk_exe pcsws.exe
F19::
ControlSend,, +{F7}, ahk_exe pcsws.exe
F20::
ControlSend,, +{F8}, ahk_exe pcsws.exe
F21::
ControlSend,, +{F9}, ahk_exe pcsws.exe
F22::
ControlSend,, +{F10}, ahk_exe pcsws.exe
F23::
ControlSend,, +{F11}, ahk_exe pcsws.exe
F24::
ControlSend,, +{F12}, ahk_exe pcsws.exe
return
;
;F13::
;ControlSend,, +{F1}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F14::
;ControlSend,, +{F2}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F15::
;ControlSend,, +{F3}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F16::
;ControlSend,, +{F4}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F17::
;ControlSend,, +{F5}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F18::
;ControlSend,, +{F6}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F19::
;ControlSend,, +{F7}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F20::
;ControlSend,, +{F8}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F21::
;ControlSend,, +{F9}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F22::
;ControlSend,, +{F10}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F23::
;ControlSend,, +{F11}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F24::
;ControlSend,, +{F12}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;return
;
;F13::
;ControlSend, ahk_parent, +{F1}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F14::
;ControlSend, ahk_parent, +{F2}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F15::
;ControlSend, ahk_parent, +{F3}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F16::
;ControlSend, ahk_parent, +{F4}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F17::
;ControlSend, ahk_parent, +{F5}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F18::
;ControlSend, ahk_parent, +{F6}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F19::
;ControlSend, ahk_parent, +{F7}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F20::
;ControlSend, ahk_parent, +{F8}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F21::
;ControlSend, ahk_parent, +{F9}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F22::
;ControlSend, ahk_parent, +{F10}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F23::
;ControlSend, ahk_parent, +{F11}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;F24::
;ControlSend, ahk_parent, +{F12}, ahk_class PCSWS:Main:00400000 ahk_pid 8204
;return
;
;F13::
;ControlSend, ahk_parent, +{F1}, ahk_exe pcsws.exe
;F14::
;ControlSend, ahk_parent, +{F2}, ahk_exe pcsws.exe
;F15::
;ControlSend, ahk_parent, +{F3}, ahk_exe pcsws.exe
;F16::
;ControlSend, ahk_parent, +{F4}, ahk_exe pcsws.exe
;F17::
;ControlSend, ahk_parent, +{F5}, ahk_exe pcsws.exe
;F18::
;ControlSend, ahk_parent, +{F6}, ahk_exe pcsws.exe
;F19::
;ControlSend, ahk_parent, +{F7}, ahk_exe pcsws.exe
;F20::
;ControlSend, ahk_parent, +{F8}, ahk_exe pcsws.exe
;F21::
;ControlSend, ahk_parent, +{F9}, ahk_exe pcsws.exe
;F22::
;ControlSend, ahk_parent, +{F10}, ahk_exe pcsws.exe
;F23::
;ControlSend, ahk_parent, +{F11}, ahk_exe pcsws.exe
;F24::
;ControlSend, ahk_parent, +{F12}, ahk_exe pcsws.exe
;return
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

07 Jan 2019, 08:47

Hi,

Only the F16 key worked?
Sounds a bit strange.
Your scripts look fine - you did a lot of variations.

Have you also tried to assign the same output to all the keys?
Just let F13 - F24 do all the same and check if it works.

Cheers!
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
michaeljohara
Posts: 29
Joined: 01 Jan 2019, 12:41

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

07 Jan 2019, 12:14

evilC ...
I followed the link and read about AHI. Really hard to wrap my head around what it is doing. Would you summarize for me what it does and how it might help here? Thanks.
michaeljohara
Posts: 29
Joined: 01 Jan 2019, 12:41

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

07 Jan 2019, 12:25

Scr1pter...

Ok, will do. Thanks!

Just to clarify... the only thing F16 is doing is pressing Shift. The emulation window does recognize and confirm Shift has been pressed, but the AS/400 command associated with F16 does not trigger.

I keep thinking there has to be a way to do this. One question that bugs me is:. We know that F13-F24 transmits their own unique scan code sets (i.e., NOT Shift+F4). Seems like there should be some way to trap and act on that.

Also, we never discussed - might the fact that I'm using a Soarer's converter DIN to USB impact any of this?
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

07 Jan 2019, 12:50

Ah, I just read a bit more of the thread, and it seems that you are indeed able to get AHK to recognize an F13 press on your keyboard - I was suggesting AHI because I thought you couldn't, and I know that AHI should be able to.

From reading this bit more, it seems like you are trying to use ControlSend? ControlSend is not 100% guaranteed to work if the app is not the active window when called.

What exactly is this "IBM iSeries Access for 5250 emulation" thing?
If it listens to the real keyboard (eg by using the RawInput API), and performs actions based upon what comes **from that keyboard**, then AHK **will not** be able to fake that, because AHK fakes input coming from windows, not input coming from a device.
ie anything listening to the Model M using RawInput / HID **will not** see input sent using AHK's Send command, but **will** see input sent using AHI's SendKeyEvent command (As long as you send it as Device ID which matches your Model M)
michaeljohara
Posts: 29
Joined: 01 Jan 2019, 12:41

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

07 Jan 2019, 14:11

evilC...

Need to run out for a couple hours, but wanted to make a couple fast observations. When I come home I'll return to look more closely at your thoughts.

First, it's F16 (not F13) that reacts. It does not trigger the corresponding AS/400 command. All it does is press Shift and note that fact in the OS/400 operator information window.

Next, I'm using ControlSend based on gwarble's suggestion. I was having difficulty using Send, and it didn't seem like a bad idea at the time. I used several ahk_ controls to try to target the window.

Last, IBM iSeries Access is an AS/400 terminal emulation program providing 5250 terminal emulation. I don't know if it listens to AHK or the physical keyboard. Throw the Soarer's converter into the mix and you may be raising a very key point. Needs to be explored for sure.

Later

M
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

07 Jan 2019, 14:29

I dunno why ControlSend was recommended. IMHO, The only real use-cases that I see for ControlSend is when trying to send input to a specific application (That's inactive), or interact with a specific control in a window. If you just want to behave as if a key was pressed on the keyboard, just use Send.
In fact, even when I *do* use ControlSend, I typically write it using Send first, to make sure it is all working (Just make sure the app is always active when you Send), *then* switch to ControlSend once I have it all working.

WRT the F16 thing - if sends only work intermittently, then that is usually a sign that the receiving application is watching input via polling, not events, and that the press and release happens between polls (Default behavior with AHK Send is to press and then release instantly). Maybe what is happening is that it just happened to poll between shift being pressed and F4 being pressed.
To test this, make sure you are using regular Send mode (Remove all SendMode commands) and add this line to the start of your script:
SetKeyDelay, 0, 50. This will cause all down events to have a 50ms sleep after them, to give the poll loop a chance to poll.
User avatar
gwarble
Posts: 524
Joined: 30 Sep 2013, 15:01

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

07 Jan 2019, 17:55

For what its worth, i didn't suggest ControlSend, i suggested different SendModes for the Send command, not ControlSend

If you haven't yet, try all the sendmodes with Send, +F1

Did you try the a::b suggestion?

I don't think targeting the window is your problem, its getting that window to "hear" the input you are trying to send it... Try evilC's delay suggestion too
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
michaeljohara
Posts: 29
Joined: 01 Jan 2019, 12:41

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

07 Jan 2019, 19:32

evilC...

Re: "the F16 thing - if sends only work intermittently, then that is usually a sign that the receiving application is watching input via polling, not events, and that the press and release happens between polls (Default behavior with AHK Send is to press and then release instantly). Maybe what is happening is that it just happened to poll between shift being pressed and F4 being pressed. "

Directly pressing Shift + any of the bottom row function keys (F1 thru F12) in fact works to communicate to the emulator to trigger the corresponding AS/400 command associated with F13 (thru F24).

What I've tried to accomplish here is to have directly pressing just one of the actual F13 thru F24 keys (without also pressing Shift) result in transmiting the combined Shift + (F1 thru F12).

The only top row function key that gets any kind of reaction from the emulator window is F16. What happens is the emulator thinks it sees the Shift key was pressed, and adds a message to that effect in the bottom status line of the AS/400 window. This is 100% repeatable. What does NOT seem to be recognized is the the keyboard sent Shift+F4, meaning F16.

I have to go for a while but will return later tonight and keep at it.
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

08 Jan 2019, 06:08

What heppens if you run this script? Does pressing Tab behave exactly as if you physically pressed Shift+F1?

Code: Select all

SetKeyDelay, 0, 50

tab::
   Send +{F1}
   return
Try running the script as admin also.

If it does *not* behave as if you physically pressed Shift+F1, then it doesn't sound like what you want is possible with vanilla AHK
michaeljohara
Posts: 29
Joined: 01 Jan 2019, 12:41

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

08 Jan 2019, 19:46

evilC...

Yes, that worked! It triggered the F13 AS/400 command.

What do you think THAT means?
michaeljohara
Posts: 29
Joined: 01 Jan 2019, 12:41

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

08 Jan 2019, 19:57

Waiting for a reboot because updates were backed up and waiting.

Had to reboot because the TAB key test would not let go, even after deleting & rerunning AHK.
michaeljohara
Posts: 29
Joined: 01 Jan 2019, 12:41

Re: How to assign PF13 thru PF24 as Shift+PF1-12?

08 Jan 2019, 21:21

I simply changed the Tab:: key to F13:: but the emulator/AS/400 had no reaction.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AHK_user and 197 guests