Advertisement
anonymous1184

Chrome tabs activation

Aug 28th, 2021 (edited)
603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. F1::runOrActivate("Google Translate", "translate.google.com", "MyFirstName (Person 1)")
  2. F2::runOrActivate("Google Translate", "translate.google.com", "Person 2")
  3.  
  4. runOrActivate(title, url, profile)
  5. {
  6.     path := "4.1.1.1.1.1.1" ; Tab group
  7.     WinGet windows, List, ahk_exe chrome.exe
  8.     loop % windows
  9.     {
  10.         hWnd := WinExist("ahk_id" windows%A_Index%)
  11.         winAcc := Acc_ObjectFromWindow(hWnd, 0)
  12.         winTitle := Acc_Get("Name", 4,, winAcc)
  13.         winProfile := StrSplit(winTitle, " - ").Pop()
  14.         if (winProfile != profile)
  15.             continue
  16.         loop % Acc_Get("ChildCount", path,, winAcc)
  17.         {
  18.             tabTitle := Acc_Get("Name", path "." A_Index,, winAcc)
  19.             if !InStr(tabTitle, title)
  20.                 continue
  21.             WinActivate
  22.             WinWaitActive
  23.             if A_Index <= 8
  24.                 Send % "^" A_Index
  25.             else
  26.             {
  27.                 p := Acc_Get("location", path "." A_Index,, winAcc)
  28.                 RegExMatch(p, "x(\d+) y(\d+)", p)
  29.                 CoordMode Mouse, Window
  30.                 MouseGetPos x, y
  31.                 MouseMove % p1 + 20, % p2 + 10, 0
  32.                 Click
  33.                 MouseMove % x, % y, 0
  34.             }
  35.             return
  36.         }
  37.     }
  38.     Run % "chrome.exe --profile-directory=""" profile """ """ url """"
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement