GeekA Posted October 7, 2019 Posted October 7, 2019 Hi, I can switch between Chrome windows, however, when the switch happens and if I am typing in an application, for example, notepad, the focus goes to the Chrome tab. Here is my script: #include <Constants.au3> AutoItSetOption("WinTitleMatchMode", $OPT_MATCHANY) ;2 While 1 WinActivate("[TITLE: ChromeTitle1;CLASS:Chrome_WidgetWin_1]") Sleep(3000) WinActivate("[TITLE: ChromeTitle2;CLASS:Chrome_WidgetWin_1]") Sleep(3000) WinActivate("[TITLE: ChromeTitle3;CLASS:Chrome_WidgetWin_1]") Sleep(3000) WinActivate("[TITLE: ChromeTitle4;CLASS:Chrome_WidgetWin_1]") Sleep(3000) WEnd Is there a way to switch the windows w/o losing the keyboard/mouse focus? genius257 1
david1337 Posted October 7, 2019 Posted October 7, 2019 Hi GeekA, WinActivate will always take the focus. How about using WinSetState -> Minimize/Maximize like this, to cycle through your Chrome windows without taking focus: expandcollapse popup#include <Constants.au3> AutoItSetOption("WinTitleMatchMode", $OPT_MATCHANY) ;2 $Title1 = "[TITLE: ChromeTitle1;CLASS:Chrome_WidgetWin_1]" $Title2 = "[TITLE: ChromeTitle2;CLASS:Chrome_WidgetWin_1]" $Title3 = "[TITLE: ChromeTitle3;CLASS:Chrome_WidgetWin_1]" $Title4 = "[TITLE: ChromeTitle4;CLASS:Chrome_WidgetWin_1]" WinSetState($Title1,"", @SW_MINIMIZE) WinSetState($Title2,"", @SW_MINIMIZE) WinSetState($Title3,"", @SW_MINIMIZE) WinSetState($Title4,"", @SW_MINIMIZE) While 1 WinSetState($Title1,"", @SW_RESTORE) WinSetState($Title2,"", @SW_MINIMIZE) WinSetState($Title3,"", @SW_MINIMIZE) WinSetState($Title4,"", @SW_MINIMIZE) Sleep(3000) WinSetState($Title2,"", @SW_RESTORE) WinSetState($Title1,"", @SW_MINIMIZE) WinSetState($Title3,"", @SW_MINIMIZE) WinSetState($Title4,"", @SW_MINIMIZE) Sleep(3000) WinSetState($Title3,"", @SW_RESTORE) WinSetState($Title1,"", @SW_MINIMIZE) WinSetState($Title2,"", @SW_MINIMIZE) WinSetState($Title4,"", @SW_MINIMIZE) Sleep(3000) WinSetState($Title4,"", @SW_RESTORE) WinSetState($Title1,"", @SW_MINIMIZE) WinSetState($Title2,"", @SW_MINIMIZE) WinSetState($Title3,"", @SW_MINIMIZE) Sleep(3000) WEnd - David
GeekA Posted October 8, 2019 Author Posted October 8, 2019 Hi David, Thank you for the suggestion, since I have two monitors and would to keep the screen on other screens, I modified the code a bit: While 1 WinSetState($Title1,"", @SW_RESTORE) WinSetState($Title3,"", @SW_MINIMIZE) Sleep(30000) WinSetState($Title2,"", @SW_RESTORE) WinSetState($Title4,"", @SW_MINIMIZE) Sleep(30000) WinSetState($Title3,"", @SW_RESTORE) WinSetState($Title1,"", @SW_MINIMIZE) Sleep(30000) WinSetState($Title4,"", @SW_RESTORE) WinSetState($Title2,"", @SW_MINIMIZE) Sleep(30000) WEnd This is working fine, however, I still lose the keyboard focus when the screen minimizes/maximizes.
david1337 Posted October 8, 2019 Posted October 8, 2019 Hi GeekA, That is weird - when I have this script running, and have notepad opened, I don't lose focus in Notepad. I can type inside the notepad window, and there is no interruption? 😏
GeekA Posted October 8, 2019 Author Posted October 8, 2019 (edited) I have Chrome running in full-screen (F11) mode for the above-mentioned titles, can you please test with a full-screen mode? Thanks! Edited October 8, 2019 by GeekA
david1337 Posted October 8, 2019 Posted October 8, 2019 I just tested with the Chrome windows running in full-screen. Still working!
GeekA Posted October 8, 2019 Author Posted October 8, 2019 You are correct, I tested with notepad, and it is working fine. I noticed that if I am on the same domain as the domains used for the switch, I lose the focus.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now