Activate open chrome window with profile X - applescript

I wonder if there is any possibility to iterate over all open Chrome windows and check against the profile (name).
If the window has a specific name, then activate it.
I know that you can check against the URL, but I'm interested in the profile.
Thanks,
If it is possible by zsh or any other ways, that could also be interested.

Related

Force Firefox to open new tab and not new window

My application sometimes opens URLs in a browser. I do this with Process.Start("http://www.example.com").
My default browser is Firefox. I notice that if the above code runs when no Firefox window is active, each URL (I open several URLs in one go) is opened in its own window.
However, if a Firefox window is already open, the URLs all get opened as new tabs.
How can I make it always open as tabs? Always as windows? Open a single new window and make everything a tab in that?
Because command-line arguments differ between browsers, to do this successfully you would need to launch Firefox explicitly and pass in the appropriate parameters. You would have to create a similar solution for each additional browser you wanted to drive.
If this is something you're doing just for yourself or in an environment where you have some control over what's installed on user machines, then it may be solvable. But if it's a general purpose program meant to work on any Windows PC, then it probably isn't practical.
For firefox, the command line arguments are:
-new-tab URL
Opens URL in a new tab.
-new-window URL
Opens URL in a new window.

How to minimize MOG using applescript

I am working on an AppleScript to toggle between minimize and maximize of specific windows. I have it working pretty well. But I am running into a specific issue with one application the MOG app for Mac does not seem to have a variable for miniaturize, collapse, or minimize.
I know that I could use click to toggle the window, but I would prefer a solution that works with the API.
Here is the applescript just for MOG:
tell application "MOG"
set (miniaturized of windows whose miniaturizable is true) to true
end tell
I would really appreciate it if someone could point me in the right direction.
Not every application is going to allow something like miniaturization of windows via AppleScript, even when the application is scriptable. One way to find out the properties of an application's window:
tell application "MOG"
get properties of window 1
end tell
You can also open the MOG dictionary and find out what you're able to script. Pressing cmd-shift-o will open a window listing all applications' scripting dictionaries.

Observe any Window if it Moved on OSX

I want to observe any window on OSX if it is moved. I don't own the windows so i can't get to it directly so I think I have to use the Accessibility APIs. I found a solution for the current active Application here: How can my app detect a change to another app's window? but I can't figure out how I have to modify this that it works for any window which is open. I hope anybody could give me a hint in which direction I have to look.
As I mentioned in the comments, people usually only want to detect window-move events on focused windows. (As unfocused windows seldom move.) If you want to detect application switches, you can poke into this sample project by Apple that shows how to update iChat status with the frontmost application’s name. And as you said, there’s already a solution for an active window.

How to close or minimize browser windows with Selenium RC?

Every time I launch a Firefox instance via Selenium RC I get 3 windows that I don't need appearing:
the add-ons windows notifying me that
"3 new add-ons have been installed"
(since I'm using a custom profile for
Selenium to which it evidently adds
the DocumentReadyState, KillFF, and
Selenium RC Runner add-ons)
the http://localhost:4444/selenium-server/core/Blank.html?start=true window
the dual window with two tabs starting with chrome://src/content/RemoteRunner.html?sessionId=... each
I don't need any of these to be visible, and each time I have to manually close the add-ons window, to minimize the two other windows, and to maximize the main browser windows which Selenium controls. After going through this too many times, I got annoyed enough to seek a solution:
Is there any way to automate closing the add-ons window and minimizing the two other windows?
By the way, I'm on OS X so I'd also appreciate some alternative solution which automates this via the OS instead of directly using Selenium.
There's a few preferences you can change in your custom profile to prevent the addons window and the additional tab on startup:
Set the extensions.lastAppVersion preference to the version of Firefox that you have installed.
Set the extensions.newAddons preference to false.
Set the extensions.update.notifyUser preference to false.
There might be some more, perhaps others can provide their suggestions in comments or their own answers.
As long as Selenium is running in multi window mode (the default mode) you'll get two browser windows. You could either maximize the main window using the following command:
selenium.windowMaximize();
Or use the multiWindow command line parameter to disable the use of multuple windows and just use a single window - note that this causes issues on some websites, especially if they attempt to break out of frames.

Open a URL in Firefox in current tab/window from a Windows application?

I have a Windows application that works with Firefox. If Firefox is already open, I'd like to have it open a given URL in the current tab+window as is currently showing. Our application tends to open a lot of URLs and reusing the same browser window makes the most sense. I already have a COM application that works with Internet Explorer, but haven't been able to find something similar for an external application to work with Firefox.
The only way I know of to do this in Firefox is to set the browser.link.open_newwindow preference to 1. Unfortunately this also stops all in-page links from opening a new tab or window.
If you use SeaMonkey as your default browser then you can use the Preferences window under Tabbed Browsing or Link Behaviour to make links from external applications open in the current tab.

Resources