Page 1 of 1

The right click on the windows in the background works but not the left

Posted: 08 Jun 2023, 03:02
by Lulumi
Hello guys,
I don't understand why the left click does not work while the right does.
Maybe i'm wrong with this code...i try to keep the focus on a window game and execute the same action on others behind without change window.

Code: Select all

#SingleInstance Force
#Persistent
#NoEnv
SetBatchLines -1
DetectHiddenWindows, On

CoordMode, mouse, relative

WinGet, gamename, List, ahk_exe namegame.exe

#IfWinActive ahk_exe namegame.exe

!a::
MouseGetPos xpos, ypos

loop, %namegame%

{

Id := namegame%A_Index%

ControlClick, x%xpos% y%ypos%, ahk_id %Id%, , Left, 1



}

return
Thanks a lot for your help ! :)

[Mod edit: Wrong subforum: Moved topic to AHK v1 help, since this is not v2 related.]

Re: The right click on the windows in the background works but not the left

Posted: 08 Jun 2023, 05:34
by mikeyww
Welcome to this AutoHotkey forum!

As far as I know, you cannot directly control whether the window becomes activated following the click, but you could try other coordinates or controls, or try making your primary window an on-top window (set to always on top).

Re: The right click on the windows in the background works but not the left

Posted: 08 Jun 2023, 06:28
by Lulumi
Thank you for your first answer, what I want to do is stay on my main window and when I click on a place X, all my background windows also do it in the same place

Re: The right click on the windows in the background works but not the left

Posted: 08 Jun 2023, 07:09
by Lulumi
@mikeyww
Thanks, I would simply like, while remaining on my main window, to do the same left click in the same place on the windows in the background without changing my main window

Re: The right click on the windows in the background works but not the left

Posted: 08 Jun 2023, 07:51
by mikeyww
Your script provides an example of how the selection of variable names may be conducive to coding errors (bugs). I would have a look at whether your pseudoarray is called gamename or namegame.

Re: The right click on the windows in the background works but not the left

Posted: 08 Jun 2023, 08:36
by Lulumi
Gamename it's an exemple, but yes Gamename for all, i change with the name of my game

Re: The right click on the windows in the background works but not the left

Posted: 08 Jun 2023, 08:41
by mikeyww
OK. I was merely pointing out the bug in your script, as you used the wrong name in your loop.

Re: The right click on the windows in the background works but not the left

Posted: 08 Jun 2023, 11:59
by Lulumi
So, any help? :P

Re: The right click on the windows in the background works but not the left

Posted: 08 Jun 2023, 14:11
by mikeyww
I would start with a bug fix, as you'll want the WinGet output variable to match your loop variable.