Script detection of the open window

Post your working scripts, libraries and tools
Yversam
Posts: 3
Joined: 04 Jan 2019, 08:17

Script detection of the open window

04 Jan 2019, 08:26

Hi,
Here I start with the software and I don't know which functions to use to create my script.

I will briefly explain the principle to you.
There is Chrome and Mozilla running on the same PC.
I would like to detect when Mozilla is used, so in the main window, with X (10 minutes for example) inactivity time on Mozilla, we automatically return to Chrome.
I hope I was understandable?

If you can help me
Thank you!

Clem
User avatar
TheDewd
Posts: 1384
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Script detection of the open window

04 Jan 2019, 08:49

Do you want to change the system default web browser based on inactivity, or just which browser window is active?

For example, if you use Chrome as your default browser, but you occasionally use Firefox for a specific task, and while Firefox is open you want any clicked hyperlinks to open in Mozilla instead of Chrome for a period of time?

Hope that makes sense...
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
Yversam
Posts: 3
Joined: 04 Jan 2019, 08:17

Re: Script detection of the open window

04 Jan 2019, 09:34

Oh no, but I understood your idea.
In fact on Chrome there is an animation that scrolls, but when the person wants to use the internet they go to Mozilla.
So I would like, when the person no longer uses Mozilla and after a period of inactivity, to put the Chrome window back where there is animation
I think my idea is clearer?
Yversam
Posts: 3
Joined: 04 Jan 2019, 08:17

Re: Script detection of the open window

04 Jan 2019, 09:38

The problem I currently have is that I haven't found for window detection, so even when it's in Chrome my script runs while I wish it didn't work when it's in Chrome
User avatar
aeiklmr
Posts: 11
Joined: 09 Dec 2018, 22:28
Location: Hungary
Contact:

Re: Script detection of the open window

04 Jan 2019, 10:55

Hi,

Use 'Window Spy' to detect windows.

You'll need to use the If WinActive("ahk_class Chrome_WidgetWin_1") command (I don't have Mozilla on my desk). And also the If WinExist command.

If WinActive("ahk_class Chrome_WidgetWi ... Active.htm

winactive.PNG
winactive.PNG (26.92 KiB) Viewed 786 times
#Persistent so the script will run all the time

And the Settimer command.

https://autohotkey.com/docs/commands/SetTimer.htm

I got high fever but it should look something like this:

If both windows exist and chrome not active for 10 mins then activate Mozilla.

The examples on the SetTimer page helps a lot!

Hope I could help a bit. Enjoy scripting!
I like to think extroverts have attention dependency disorder.
User avatar
TheDewd
Posts: 1384
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Script detection of the open window

04 Jan 2019, 11:01

aeiklmr wrote:I don't have Mozilla on my desk
ahk_class MozillaWindowClass

Here's a screenshot from my computer:
Firefox.png
Firefox.png (28.74 KiB) Viewed 783 times
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: radi0n and 41 guests