Help Getting my Script Working

Ask gaming related questions (AHK v1.1 and older)
jasonakademia
Posts: 1
Joined: 05 Oct 2020, 18:35

Help Getting my Script Working

05 Oct 2020, 18:39

I have a script I am using for a titleless game but it only works when the screen is active.
I am trying to get it to work while the screen is inactive, any help would be greatly appreciated.

Code: Select all

capslock::
SetTitleMatchMode, RegEx
loop
{
controlsend,,12345, ^$ ahk_class Chrome_WidgetWin_1,,,, NA
}
User avatar
Ocelot
Posts: 8
Joined: 04 Oct 2020, 16:21

Re: Help Getting my Script Working

05 Oct 2020, 19:45

Have you looked at the documentation? https://www.autohotkey.com/docs/commands/ControlSend.htm

Code: Select all

ControlSend , [Control, Keys, WinTitle, WinText, ExcludeTitle, ExcludeText]

Code: Select all

#Persistent
#NoEnv
#SingleInstance, Force
DetectHiddenWindows, On
SetTitleMatchMode, 2
controlID      := 0

F2::
loop, 1
{
ControlGet, controlID, Hwnd,,Chrome_RenderWidgetHostHWND1, Google Chrome
ControlFocus,,ahk_id %controlID%
ControlSend, Chrome_RenderWidgetHostHWND1, {Ctrl Down}${Ctrl Up}, Google Chrome
}
return

F3::
reload
return
This vaguely works. If doesn't then try {$} with the brackets around it.

You've got 12345 in there as well. Is that what you wanted to send as well as ^$? That'd look like

Code: Select all

ControlSend, Chrome_RenderWidgetHostHWND1, {1}{2}{3}{4}{5}{Ctrl Down}{$}{Ctrl Up}, Google Chrome
Or you can have 6 separate lines for that.

Edit: Now that I think about it. It may actually need to add a {Shift Down} & {Shift Up} as well. Oh well, trial and error.
gregster
Posts: 9111
Joined: 30 Sep 2013, 06:48

Re: Help Getting my Script Working

05 Oct 2020, 21:37

jasonakademia wrote:it only works when the screen is active.
I am trying to get it to work while the screen is inactive
You mean, when the game is (or isn't) the active window? Well, there is no guarantee that a game or application will (fully) cooperate with ControlSend... but you should make sure that the inactive (Chrome) window is at least in the background - and not minimized.


@Ocelot: I think ^$ was meant here as RegEx anchors - and not as a key combination that's meant to be sent. After all, the OP is using SetTitleMatchMode, RegEx.
Edit: Adding ControlFocus is a good idea, but that command uses the control as the first parameter, not the second.

That said, I doubt that RegEx mode will help in this case, if the game has no title anyway, so I would remove SetTitleMatchMode, RegEx and ^$ - although it might not hurt either in this case:

Code: Select all

ControlFocus,, ahk_class Chrome_WidgetWin_1			; worth a try, especially with Chrome browser
ControlSend,, 12345, ahk_class Chrome_WidgetWin_1
And yes, ControlSend has no NA option (in contrast to ControlClick).
If it's necessary to also add the control Chrome_RenderWidgetHostHWND1 (Chrome's control for displaying websites, I suppose) as first parameter for ControlSend and ControlFocus might depend on the specific case. It's worth a try as well. That means, try alternatively

Code: Select all

ControlFocus, Chrome_RenderWidgetHostHWND1, ahk_class Chrome_WidgetWin_1
ControlSend, Chrome_RenderWidgetHostHWND1, 12345, ahk_class Chrome_WidgetWin_1

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 51 guests