0

I have my browsers opened in this configuration on my desktop:

display diagram

Is there a way to press red buttons simultaneously?

I found similar question: Can I mirror / duplicate mouse events on both halves of my screen?

But provided script is too complex for me to modify, if there is a way to simply offset my click coordinates from initial click to get desirable result?

2

There are probably more elegant ways to do this, but here's a semi-manual way you could use.

First, get your windows in position.

Once they are in position and ready to use, figure out what the offsets will be for sending secondary clicks to them.

Here is a code snippet that will calculate position offsets by moving your mouse to the locations you want to "measure" and pressing F1 and F2.

#Persistent
#SingleInstance, Force
#NoEnv

F1::
    CoordMode, Mouse, Screen
    MouseGetPos, firstX, firstY
    Gosub ShowTooltip
Return

F2::
    CoordMode, Mouse, Screen
    MouseGetPos, secondX, secondY
    Gosub ShowTooltip
Return 

F3::ToolTip     ; Clear setup tooltip

ShowToolTip:
    ToolTip % msg:="1stX, 1stY `t= " firstX ", " firstY "`t`t (set with F1, where you will click in operation)`n" 
    . "2ndX, 2ndY `t= " secondX ", " secondY "`t`t (set with F2, where you want it mirrored to)`n"
    . "offsetN[X, Y] `t= [" secondX-firstX ", " secondY-firstY "] `t`t hard code this once windows are in position"
Return

In your case with 5 extra windows, go to the position you want to sync on the first window and hit F1, then move the mouse to the position on the second window and hit F2. The tooltip will tell you the difference between the two as an [X, Y] offset. Write it down then go to the next window and hit F2 again. If you accidently clear or change F1 (firstX/firstY), make sure and always set F1 on the window where the original click will occur. Just set it once, then calculate secondary points for each window using F2 until you have all offsets written down.

(Alternate ways to do this would be to detect the windows, move them into location, resize them, etc. This is just the dumb/easy way as far as coding is concerned, at the cost of a little setup work each time you want to use it.)

After you have the window offsets, use a second bit of code (maybe in a second script, but doesn't have to be), in order to detect mouse clicks and mirror those clicks to each window you have defined.

After writing down your offsets to each of the secondary windows, update them in the hard-coded offset list definition section of [X, Y] offsets. If you have more or less than 5 extra windows, reduce or add offset pairs using similar notation with the offset pair number immediately following the word offset, i.e., offset13:=[X,Y], and also update the maxDup count accordingly, i.e., maxDup:=13

#Persistent
#SingleInstance, Force
#NoEnv

~LButton::      ; tilde allows the LButton click to pass through and not get blocked
    CoordMode, Mouse, Screen
    MouseGetPos, mouseX, mouseY
    dupClicks(mouseX, mouseY)        ; duplicate clicks using mouse position as input
Return

dupClicks(mouseX, mouseY) {

    ; hard-code offsets to the windows you want to click
    ; there are other ways of detecting windows and clicking
    ; at a relative offset within each window (regardless of where it is at),
    ; but the original post doesn't have enough information to show something
    ; fancy like that

    Offset1:=[300, 0]
    Offset2:=[500, 0]
    Offset3:=[100, 200]
    Offset4:=[300, 200]
    Offset5:=[500, 200]

    maxDup := 5          ; set to number of extra windows defined above to be clicked

    Loop, % maxDup {
        x:=mouseX+offset%A_Index%[1]    ; get first value of OffsetN, i.e., xOffset
        y:=mouseY+offset%A_Index%[2]    ; get second value of OffsetN, i.e., yOffset
        Click, %x%, %y%
    }
}

After the offsets are set, run the script to test it out. If you want to test fewer offsets out, comment additional offset lines out and change maxDup to match.

Something else you may want to do for easier testing might also be to make the LButton:: hotkey conditional, i.e., use #IfWinActive ahk_exe chrome.exe or similar (based on your browser) and put that as the line immediately preceding the LButton:: hotkey definition line. That would keep the duplicate mouse clicking from going crazy on other programs besides your browser, as long as the non-browser window was active before you clicked on it.

1

With AutoHotkey, the following script will click the red areas of your screen one after another when Win+F11 is pressed:

#F11::
;Clicks the X, Y pixel with a 10 ms delay between each click
Click 427, 289
Click 1049, 289
Click 1675, 289
Click 427, 805
Click 1049, 805
Click 1675, 805
Return

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.