Find and Close Incognito Chrome Windows

Hi,

Is there a way to get KM to find and close all incognito chrome windows that are open. I've seen a few macros in the forum that search for windows with specific URLs, but not windows that are incognito irrespective of the URL.

Thanks!

I'm interested in this concept too, and I don't know where to start.

I would also like to minimize them, or windows base on other criteria, not simply close them.

I think I have found the answer with a simple applescript. The "mode" of the window is either "incognito" or "normal" so it is pretty simple:

tell application "Google Chrome"
   close (every window whose mode is "incognito")
end tell

If you want to manipulate them further, and not just close them, you can get the ID and mode of every window with this appliscript:

tell application "Google Chrome"
   set {modelist, idlist} to {mode, id} of every window
end tell

This will give you an array of windows and their modes (normal/incognito) and you can then manipulate the windows as you like using their idlists.

Hey Yevgeny,

Good job on figuring out the AppleScript!  :sunglasses:

In future please use proper code-blocks for AppleScript and any other code.

See this thread for the basics:

Code Block Fencing on the Keyboard Maestro Forum and Paste AppleScript as Markdown Macro

I've adjusted the post above for you already.

--
Best Regards,
Christopher Stone (Keyboard Maestro Moderator)

1 Like