I've so far made some simple scripts to ease my usual working routine, but I am currently stuck on this one.
So, I am trying to make a script that runs whenever a specific tab inside Chrome is opened, thus it should run in the background and only activate when that tab is opened (it opens through a specific button press from another program.) I've tried to look into loops together with wintitle with the getter method, but without any success so far. Another thing to mention is that it should preferably run only once each time the window is opened.
Is this possible?
Appreciate all the help I can get.
How to wait for specific tab to be opened before performing action
How to wait for specific tab to be opened before performing action
Last edited by aimbot on 23 Sep 2019, 14:30, edited 1 time in total.
Re: How to wait for specific tab to be opened before performing action
Whenever a specific window is opened?
Or whenever a specific tab is opened?
The difference is important.
What if the window/tab is not focused? Does your script work on unfocused windows or inactive tabs?
It really depends on what you want to do with that window/tab/webpage.
Some operations will work if the window/tab is focused and other won't.
TL;DR: More details needed.
Or whenever a specific tab is opened?
The difference is important.
What if the window/tab is not focused? Does your script work on unfocused windows or inactive tabs?
It really depends on what you want to do with that window/tab/webpage.
Some operations will work if the window/tab is focused and other won't.
TL;DR: More details needed.
Re: How to wait for specific tab to be opened before performing action
Sorry for the confusion.Getfree wrote: Whenever a specific window is opened?
Or whenever a specific tab is opened?
The difference is important.
What if the window/tab is not focused? Does your script work on unfocused windows or inactive tabs?
It really depends on what you want to do with that window/tab/webpage.
Some operations will work if the window/tab is focused and other won't.
TL;DR: More details needed.
It is whenever a specific tab is opened, often in an already existing window of chrome. I am quite sure it's NOT focused, unless it's done so automatically, I'll check tomorrow.
And I don't intend to do anything in the tab/window really. The script is supposed to do something in another program (where the button that opens the tab is placed), more specifically write a specific message in that program if the specific tab is opened.
- flyingDman
- Posts: 2817
- Joined: 29 Sep 2013, 19:01
Re: How to wait for specific tab to be opened before performing action
Have you tried WinWaitActive ?
14.3 & 1.3.7
Re: How to wait for specific tab to be opened before performing action
Have looked at it, but how can I specify a specific tab window, I don't know what to type in the winTitle. Might be obvious, but I don't get it when it is one tab inside chrome.flyingDman wrote:Have you tried WinWaitActive ?
And also, if I find a solution, do you have any thoughts on how to make it rerun automatically when a new tab of the same page is opened again?
- flyingDman
- Posts: 2817
- Joined: 29 Sep 2013, 19:01
Re: How to wait for specific tab to be opened before performing action
Use something like this. This works because the title of the browser is that of the current tab.
If you change tabs and revert to the previous tab, the part of the script between the winwait commands is executed again. If you want to executed that code only once per Chrome session, you can do something like this:
Now it will wait for Chrome to close before the script is "reloaded".
Code: Select all
Loop
{
WinWaitActive, Quick Reference | AutoHotkey ;<< online AHK help file as example
msgbox Bingo!!
WinWaitNotActive, Quick Reference | AutoHotkey
}
Code: Select all
Loop
{
WinWaitActive, Quick Reference | AutoHotkey
msgbox Bingo!!
winwaitclose, Google Chrome
}
14.3 & 1.3.7
Re: How to wait for specific tab to be opened before performing action
Thank you very much, was not aware this could be solved so easily, I'll try it tomorrow.flyingDman wrote: Use something like this. This works because the title of the browser is that of the current tab.If you change tabs and revert to the previous tab, the part of the script between the winwait commands is executed again. If you want to executed that code only once per Chrome session, you can do something like this:Code: Select all
Loop { WinWaitActive, Quick Reference | AutoHotkey ;<< online AHK help file as example msgbox Bingo!! WinWaitNotActive, Quick Reference | AutoHotkey }
Now it will wait for Chrome to close before the script is "reloaded".Code: Select all
Loop { WinWaitActive, Quick Reference | AutoHotkey msgbox Bingo!! winwaitclose, Google Chrome }