Send F7 key to inactive window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fdoped
Posts: 4
Joined: 07 Jan 2018, 09:23

Send F7 key to inactive window

07 Jan 2018, 09:33

Please,

Anyone can help me to how to send a keypress of F7 to another window?

The tittle of the inactive window is " Profitchart Pro".

I know it is a simple code, but I having dificulties to do this with Controlsend.

Thnaks!
User avatar
boiler
Posts: 17041
Joined: 21 Dec 2014, 02:44

Re: Send F7 key to inactive window

07 Jan 2018, 09:50

You may not be doing anything wrong. Some windows/programs just won't react to being sent virtual keys like that. Some won't if they're not the active window. Sometimes it works if you send it to the window itself, sometimes you have to send it to a certain control directly within that window. Sometimes nothing works.

If you want to post your code, we can at least see if everything looks correct from a syntax standpoint.
fdoped
Posts: 4
Joined: 07 Jan 2018, 09:23

Re: Send F7 key to inactive window

07 Jan 2018, 11:51

Thanks for your answer

I am trying the basics as

Code: Select all

ControlSend , , {F7}, Profit
Regards
User avatar
Scr1pter
Posts: 1275
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Send F7 key to inactive window

07 Jan 2018, 12:23

No.

Please do the following:
Compile this script, go to your application and press Ctrl+Shift+Alt+F1 (or change the key combination in the script).
Then you'll have the class name.

Code: Select all

^+!F1::
WinGetClass, class, A
Clipboard = ahk_class %class%
MsgBox, Class of current window is "%class%".
return
After this, go to your script editor (whatever you use), and paste the class name (it is in the clipboard).
Then change your current script to:

Code: Select all

ANYKEY::
ControlSend, ahk_parent, {F7}, ahk_class XYZ
Change ANYKEY to any key, and write the ahk_class (normally you already have it.

If it doesn't work, remove the ahk_parent
So only:

Code: Select all

ANYKEY::
ControlSend, {F7}, ahk_class XYZ
Let us know if it worked.
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
fdoped
Posts: 4
Joined: 07 Jan 2018, 09:23

Re: Send F7 key to inactive window

07 Jan 2018, 14:07

Hi, Scr1pter!

Thanks,but it did not worked.

My code was this:

ControlSend, ahk_parent, {F7}, ahk_class CabinetWClass

I already tried

ControlSend, , {F7}, ahk_class CabinetWClass

I did not put ANYKEY::, because this code must be executed directly without input from any key.


I am a begginer and thanks for your help.

Any addtional suggestion

Regards!
User avatar
boiler
Posts: 17041
Joined: 21 Dec 2014, 02:44

Re: Send F7 key to inactive window

07 Jan 2018, 14:56

If you happen to have more than one window with the class CabinetWClass, it can get sent to the wrong window. Also, changing the WinTitle from Profit to the class of that window does nothing to help make the ControlSend work or be more reliable. As long as the window gets identified, how it's referenced doesn't matter. Using the class alone can be ambiguous and risky.
scriptor2016
Posts: 862
Joined: 21 Dec 2015, 02:34

Re: Send F7 key to inactive window

07 Jan 2018, 17:05

what about this (if it hasn't already been suggested):

Code: Select all

ControlSend, ahk_parent,{F7},Profitchart Pro
User avatar
boiler
Posts: 17041
Joined: 21 Dec 2014, 02:44

Re: Send F7 key to inactive window

07 Jan 2018, 19:08

That's the same as using Profit as the title as long as no other windows start with the word Profit since the default title match mode is to match the start of the title.
User avatar
boiler
Posts: 17041
Joined: 21 Dec 2014, 02:44

Re: Send F7 key to inactive window

07 Jan 2018, 19:11

Scr1pter wrote:

Code: Select all

ANYKEY::
ControlSend, {F7}, ahk_class XYZ
That is missing a comma to skip the Control parameter. Otherwise, the parameters you did include are in the wrong place. EDIT: But I see fdoped realized that and put it in himself.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], haomingchen1998, jdfnnl and 367 guests