Giter Site home page Giter Site logo

alfredswitchwindows's Introduction

Swift Windows Switcher

Catalina Users

Make sure that Alfred is added to "Security & Privacy -> Screen Recording". The context on why that is needed is here.

* * *

My little "weekend" project. Alfred workflow to switch between open windows in the system and Safari tabs.

Features

  • Switch between the open windows using Alfred
  • Switch between the Safari tabs using Alfred
  • Very quick comparing to the alternative implementations because of the native search implementation.

Releases

You can download the ready-to-use .workflow files from the releases page.

Source code

You can start exploring the source code at main.swift

ScriptingBridge in Swift

It turns out, that ScriptingBridge implementation is not fully compatible with Swift.

(Classes like SafariApplication are not imported, so we can't use them).

One of the possible solutions to this issue is demonstrated in BrowserApplication.swift (used for both Safari and Chrome automation)

UPD: There is a better solution using optional protocol methods:

@objc fileprivate enum PlayerState: NSInteger {
    case stopped = 0x6b505353
    case playing = 0x6b505350
    case paused = 0x6b505370
    case fastForwarding = 0x6b505346
    case rewinding = 0x6b505352
};

@objc fileprivate protocol iTunesBridge {
    @objc optional var isRunning: Bool { get }
    @objc optional var playerState: PlayerState { get }
    @objc optional func pause() -> Void
}

extension SBApplication: iTunesBridge{}

guard let app = SBApplication(bundleIdentifier: "com.apple.iTunes") as? iTunesBridge else {
   return
}

let isPlaying = app.playerState == .playing

NSLog("isPlaying: \(isPlaying)")

License

Copyright 2017 © Igor Mandrigin

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

alfredswitchwindows's People

Contributors

cdzombak avatar fow5040 avatar m1kep avatar mandrigin avatar yqrashawn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alfredswitchwindows's Issues

Thanks!

This has helped my workflow greatly 😄

Can't switch to a Safari tab

macOS 10.12.4
Can see all tabs, can switch to window, but failed to change the active tab

Starting debug for 'Swift Window Switcher'

[2017-03-28 08:08:55][ERROR: action.applescript] {
    NSAppleScriptErrorAppName = Safari;
    NSAppleScriptErrorBriefMessage = "Can\U2019t get tab 1079 of window 1. Invalid index.";
    NSAppleScriptErrorMessage = "Safari got an error: Can\U2019t get tab 1079 of window 1. Invalid index.";
    NSAppleScriptErrorNumber = "-1719";
    NSAppleScriptErrorRange = "NSRange: {420, 11}";
}

Issues with multiple Brave Browser windows

Thanks for the great workflow!
I recently found that it doesn't work with multiple Brave Browser windows - only able to switch in the window with active/foremost tab open.

doesn't work on catalina

After I upgraded the OS to catalina, it doesn't work.

It says

“EnumWindows” can’t be opened because Apple cannot check it for malicious software.

Any help would be appreciated

Can you use this yet?

And if so, how do you actually get the .workflow file to import?

Thank you for any help.

Dock displayed in the results

The dock is displayed in the search results, but it's not something you would normally switch to imo 🤔 Do you reckon is worth to exclude it from the search scope?

screen shot 2017-11-03 at 12 10 46

Nice workflow, I'm a big fun of it 👍

Chrome: only the foremost window works

For Chrome, the workflow only takes you to tabs on the foremost (last active) window and doesn't work on windows behind that one. However, it will show tabs from all windows in the search results.

Chrome: 72.0
Alfred: 3.8
macOS: 10.14.3

This is an utterly fantastic idea for a workflow and I can't wait to see where it goes.

Listing windows and tabs on launch

Hello, thank you very much for this Alfred Workflow. I was search for replacing Contexts and I found this which could be a good solution. A few questions I have, whenever you have a moment.

I was using it a bit and I think it would be more useful to get the windows and tabs listed as soon as the hotkey is pressed instead of having to start typing. Sometimes you want to change to a tab or window but don't remember the name and need to visually see something. This would allow to cut off some waiting time too as you don't have that "Searching...." moment when you start typing.

What do you think? Thanks again!

applescript error

Every time I run I get an error like this:

[2017-03-05 14:56:16][ERROR: action.applescript] {
NSAppleScriptErrorBriefMessage = "Can\U2019t set backup of {""} to some object.";
NSAppleScriptErrorMessage = "Can\U2019t set backup of {""} to some object.";
NSAppleScriptErrorNumber = "-10006";
NSAppleScriptErrorRange = "NSRange: {532, 48}";
}

Adding url to enumWindows output

Long time and happy user of this workflow - thank you for making it.

Would it be possible to add url output to enumWindows?

Would be really useful for adapting the workflow to be able to paste markdown links from selected window

Safari tabs on different spaces are not available

We can only switch to the safari tabs that are on the current space (even though we display all of them).

We should either:

  • filter-out safari tabs from the other spaces
  • give the ability to switch to the other spaces

Can it support searching by application name?

For applications where the title doesn't contain the application name - e.g. chrome only contains the active tab title and not searchable by typing "chrome".

Thanks, great workflow!

EXC_BAD_INSTRUCTION on SwiftUI Project

Hi, Many thanks for your ongoing support.

I called search(query:, onlyTabs:) function on the SwiftUI Mac project. But when this function is called, the app is crashed with EXC_BAD_INSTRUCTION error.

image

image

image

It seems that there is a duplicated release of the same instance in the function BrowserEntity.performSelectorByName.

Would you help me to fix this issue?

EnumWindows can't be opened

Hi - I'm wondering why I'm getting this error and if there's something I may need to enable manually. Also, is the source code for EnumWindow in this repo as well?

'w' doesn't work anymore in Catalina MacOS 10.15

It seems that on Catalina the alfred command 'w' doesn't allow to switch to windows of any other programme than Safari, i.e. calling 'w' only shows Safari windows but no other window.

This is one of my most used workflows and it would really be fantastic if this could be solved on Catalina.

firefox...

Hey, cool workflow!

How can I add firefox support?

VS-code support

Hi, I find it is nice that it supports iTerm tabs. I'm wondering if it is also possible to support the tabs in vscode? Thank you!

Vivaldi

Any plans to support Vivaldi tabs in the future?

Is it possible raise single window to the front?

Sometimes there are several windows for one application, now it will bring every window to the front in a big stack, it would be better to be able to bring the single selected window.

Thanks for the awesome workflow!

Windows for different spaces are not available

Thank you very much for this great plugin!

For me it would be even more useful if it included windows not only from the current spaces, but also from spaces that are currently hidden.

If such a window is chosen, it should switch to the space it's on and bring it to the front.

Give more context on screen recording

Hi! Thanks for the project.

Could you please give more context on why screen recording is necessary or when it is used?

I'd love to give this workflow a try but, given that I deal with some sensitive data at work, enabling this permission is a red-flag for me at the moment.

Tab not switching on Chrome

I downloaded the latest version, and tried to switch to a chrome (full-screened) window's tab. But it only bring me to the chrome window. It is essentially not switching the tab.

And another thing I found is that it works on Safari (with or without the window being minimized), it will be great to maximize window if it is hidden/minimized after switching tab.

Great work 👍

List windows from all Spaces

Is it possible to list windows from all Spaces? The way it currently works seems to be to list only windows from the current space.

Safari 15 TabGroups

EnumWindows will only enumerate the currently selected tab group from Safari 15. It would be nice to be able to enumerate all of the tabs.

Maybe it can't be done? (It doesn't appear possible to enumerate the tabs not in the current tab group via the Shortcuts / Script Editor APIs so I'll file an Apple feedback about that.)

I'll update this issue if I learn anything useful.

Support fuzzy match?

Some windows might be hot spots, so fuzzy match will be helpful to save some typing time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.