keep focus/working on the current window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Barney15
Posts: 168
Joined: 12 Jan 2020, 14:18

keep focus/working on the current window

10 Oct 2020, 06:56

a simple load coords and click script,

it's reads my emails and click on the links.

the issue is, after opening my email, some clicks open new tabs/windows/pop ups

Q : how can i make the script keep the focus/work on the targeted window and ignores others.

Code: Select all

;#Warn
#NoEnv
#Persistent
; #WinActivateForce
#MaxThreadsPerHotkey 4
#SingleInstance, force
SetBatchLines -1
settitlematchmode 2
CoordMode, Pixel, Window
Coordmode, Mouse, Window
CoordMode, ToolTip, Screen
SetWorkingDir %A_ScriptDir%
F2::Reload
F1::

; WinSet, AlwaysOnTop, On, A
TxtFile_5       :=  A_ScriptDir "\0.cvc"
Loop, Read, % TxtFile_5
{
    _Click_ := A_Index
    Loop, Parse, A_LoopReadLine, % A_Tab
    {
        Arr_Coord   :=  StrSplit(A_LoopReadLine, "`, ")

        _Pos_ := % "x" . Arr_Coord[1] . A_Space . "y" . Arr_Coord[2]

        MouseMove, Arr_Coord[1], Arr_Coord[2]

        ToolTip, % "Loop : " . _Click_ . "`nClick " . _Pos_

        ControlClick, % _Pos_, A,, Left, 1, NA
    }
    Sleep, 1500
}
; WinSet, AlwaysOnTop, Off, A
MsgBox, Done
ToolTip
return
User avatar
mikeyww
Posts: 27121
Joined: 09 Sep 2014, 18:38

Re: keep focus/working on the current window

10 Oct 2020, 07:24

Since you are opening new windows with each loop iteration, you might need to WinActivate the original window at the start of each iteration. It depends on where the newly opened windows are being positioned. If new windows cover your original window, then you might be clicking on things unintentionally. Another approach, worth a try, is changing "A" to the window title of your original window. "A" is going to send to whichever window happens to be active at the time the command is executed.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: haomingchen1998, ntepa, sofista, Tvlao and 133 guests