Use Control Send on Chrome without Activating it Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
theholyscripture
Posts: 62
Joined: 26 Apr 2019, 17:11

Use Control Send on Chrome without Activating it

Post by theholyscripture » 22 Feb 2020, 16:47

Hi all, I'm trying to send the down arrow key to Chrome using RAlt with ControlSend in order to scroll down.

My problem is that it isn't working for me without first activating chrome, which defeats the purpose of ControlSend. Any help would be appreciated!

My code:

Code: Select all

#NoEnv  
#SingleInstance, Force
;#Persistent
SetTitleMatchMode, RegEx

RAlt::
WinActivate, Google Chrome ;<<<Without this line, Option 1 or 2 will not send anything to Chrome
;ControlSend, Chrome_RenderWidgetHostHWND1,{Down},Google Chrome  ;<< OPTION 1
ControlSend,,{Down},Google Chrome  ;<<< OPTION 2
Return

theholyscripture
Posts: 62
Joined: 26 Apr 2019, 17:11

Re: Use Control Send on Chrome without Activating it  Topic is solved

Post by theholyscripture » 22 Feb 2020, 16:57

I figured it out, just use ControlFocus.

Code: Select all

#NoEnv  
#SingleInstance, Force
;#Persistent
SetTitleMatchMode, RegEx

#IfWinExist, Google Chrome
RAlt::
ControlFocus, Chrome_RenderWidgetHostHWND1
ControlSend,,{Down}, Google Chrome
return

User avatar
boiler
Posts: 16771
Joined: 21 Dec 2014, 02:44

Re: Use Control Send on Chrome without Activating it

Post by boiler » 22 Feb 2020, 17:18

Thanks for pointing this out. I haven't seen this before, and it seemed like Chrome (and other windows) just didn't respond to ControlSend when not active. Using ControlFocus on them when they're not active may work for many more windows than Chrome. A nice addition to the toolbox. :thumbup:

theholyscripture
Posts: 62
Joined: 26 Apr 2019, 17:11

Re: Use Control Send on Chrome without Activating it

Post by theholyscripture » 22 Feb 2020, 17:42

boiler wrote:
22 Feb 2020, 17:18
Thanks for pointing this out. I haven't seen this before, and it seemed like Chrome (and other windows) just didn't respond to ControlSend when not active. Using ControlFocus on them when they're not active may work for many more windows than Chrome. A nice addition to the toolbox. :thumbup:
No problem at all, I discovered it looking through similar posts trying to use ControlSend on Chrome!

AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Use Control Send on Chrome without Activating it

Post by AHKStudent » 19 Mar 2020, 20:05

anyway to do this while chrome is minimized?

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

Re: Use Control Send on Chrome without Activating it

Post by gregster » 19 Mar 2020, 20:16

anyway to do this while chrome is minimized?
Well, certainly with things like Chrome.ahk, Selenium or Acc.ahk - but this will get much a little bit more complex.

albertocv
Posts: 1
Joined: 03 Mar 2021, 05:41

Re: Use Control Send on Chrome without Activating it

Post by albertocv » 08 Mar 2021, 05:24

Thanks. It seems what I need but I can't make it work.
I have two Chrome windows open. One of them is a Google Slides presentation. I want to advance the slides without showing the window.

I adapted the script this way:

Code: Select all

#NoEnv  
#SingleInstance, Force
;#Persistent
SetTitleMatchMode, RegEx

#n::
if WinExist("Presentazioni Google")
	ControlFocus,,"Presentazioni Google"
	ControlSend,,{Down},"Presentazioni Google"
return
Winexist sees the window. But then nothing happens. Even if the window has focus.

What am I missing?

steelweaver
Posts: 2
Joined: 03 Mar 2021, 14:43

Re: Use Control Send on Chrome without Activating it

Post by steelweaver » 02 Feb 2023, 13:43

I found this on reddit it it worked well for me:
https://www.reddit.com/r/AutoHotkey/comments/4lr9n0/chrome_unresponsive_to_controlsend/

Code: Select all

	; Gets the control ID of google chrome
	ControlGet, controlID, Hwnd,,Chrome_RenderWidgetHostHWND1, Google Chrome

	; Focuses on chrome without breaking focus on what you're doing
	ControlFocus,,ahk_id %controlID%
	
	ControlSend, Chrome_RenderWidgetHostHWND1, ^r, Google Chrome

Post Reply

Return to “Ask for Help (v1)”