blackzeal

Untitled

Aug 28th, 2021
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. Hey, I finally got to modify your script and can now give feedback. Firstly, here's the new code:
  2.  
  3. F6::runOrActivate("Messenger", "https://www.messenger.com/", "Profile 2")
  4. F7::runOrActivate("Messenger", "https://www.messenger.com/", "Profile 4")
  5.  
  6. runOrActivate(title, url, profile) { path := "4.1.1.1.1.1.1" ; Tab group
  7. SetTitleMatchMode 2
  8. WinGet windows, List, - Google Chrome
  9. loop % windows
  10. {
  11. hWnd := WinExist("ahk_id" windows%A_Index%)
  12. winAcc := Acc_ObjectFromWindow(hWnd, 0)
  13. winTitle := Acc_Get("Name", 4,, winAcc)
  14. winProfile := StrSplit(winTitle, " - ").Pop()
  15. if (winProfile != profile)
  16. continue
  17. loop % Acc_Get("ChildCount", path,, winAcc)
  18. {
  19. if A_Index > 9
  20. continue
  21. tabTitle := Acc_Get("Name", path "." A_Index,, winAcc)
  22. if InStr(tabTitle, title)
  23. {
  24. WinActivate
  25. WinWaitActive
  26. Send % "^" A_Index
  27. return
  28. }
  29. }
  30. }
  31. Run % "chrome.exe --profile-directory=""" profile """ " url
  32. }
  33. I got Acc.ahk properly integrated to my system and my installation of AHK so it ran successfully, but not as expected. It still opens new tabs of the same websites that I added at the top of this code block, in the arguments given to runOrActivate(). The window title of the website's window I'm trying to target here is Messenger - Google Chrome which I got with this method:
  34.  
  35. ^q::
  36. WinGetTitle, title, A MsgBox, %title% return
  37. Thus, it doesn't really function differently from my original code. (This one.)
  38.  
  39. !Numpad1::
  40. Run, chrome.exe --profile-directory="Profile 2" https://www.messenger.com return
  41.  
  42.  
  43. P.S.: I just made two new posts in r/AskProgramming and in this subreddit about this but with a new inquiry about Visual Basic. I'll mention you there too if you don't mind.
  44.  
  45.  
Advertisement
Add Comment
Please, Sign In to add comment