Jump to content

Switching App Without Losing Keyboard/Mouse Focus


GeekA
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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:

 

#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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...