jslegendre / AfloatX

An alternative to Afloat that lives in the dock icon menu
348 stars 12 forks source link

FeatureRequest: Shortcuts #5

Open zqso opened 4 years ago

zqso commented 4 years ago

Hi jslegendre, Got any plan to embed some shortcuts in this bundle? Thanks, Walter

jslegendre commented 4 years ago

I have thought of this but haven’t figured out a way to have the AX shortcuts not interfere with shortcuts of host apps. If you know a way, I’m open!

DrBones commented 4 years ago

Hi,

I would love shortcuts as well! Maybe not a solution but would a scriptable interface (like AppleScript, or python, or similar) be feasible in any way? That way one could use tools like BetterTouchTool or Keyboard Maestro, etc to either set up the hotkey in each app individually or simply be cool with it clobbering a default hotkey.

Awesome tool by the way, thank you so much!

zqso commented 4 years ago

I have thought of this but haven’t figured out a way to have the AX shortcuts not interfere with shortcuts of host apps. If you know a way, I’m open!

or can it be compiled like the original Afloat, with a menubar UI, where shortcuts are changeable in the System Preferences - Keyboard - Shortcuts

TryTryAgain commented 3 years ago

And/or expose some kind of CLI options?

zqso commented 3 years ago

Recently the good old "Afloat" acts weirdly in MacForge in Big Sur, so I have to give up on it and eventually switch to "AfloatX".

Still, there are no shortcut or CLI options to make it easy to use for those whose Dock is always hidden.

So I use Applescript to get it done,

Example: Invert Colors of the front app:

on run
    -- get active application
    tell application "System Events" to set activeApp to name of first application process whose frontmost is true

    -- right click that application in the dock
    tell application "System Events" to tell UI element activeApp of list 1 of process "Dock"
        perform action "AXShowMenu"
        click menu item "AfloatX" of menu 1
        click menu item "Invert Colors" of menu 1 of menu item "AfloatX" of menu 1
    end tell
end run

Replace the "Invert Colors" with whatever function you want.

References: How can I assign an application to all desktops using the keyboard? - Ask Different - https://apple.stackexchange.com/questions/200757/how-can-i-assign-an-application-to-all-desktops-using-the-keyboard

kevinjohncutler commented 3 years ago

Recently the good old "Afloat" acts weirdly in MacForge in Big Sur, so I have to give up on it and eventually switch to "AfloatX".

Still, there are no shortcut or CLI options to make it easy to use for those whose Dock is always hidden.

So I use Applescript to get it done,

Example: Invert Colors of the front app:

on run
  -- get active application
  tell application "System Events" to set activeApp to name of first application process whose frontmost is true

  -- right click that application in the dock
  tell application "System Events" to tell UI element activeApp of list 1 of process "Dock"
      perform action "AXShowMenu"
      click menu item "AfloatX" of menu 1
      click menu item "Invert Colors" of menu 1 of menu item "AfloatX" of menu 1
  end tell
end run

Replace the "Invert Colors" with whatever function you want.

References: How can I assign an application to all desktops using the keyboard? - Ask Different - https://apple.stackexchange.com/questions/200757/how-can-i-assign-an-application-to-all-desktops-using-the-keyboard

Can this be adapted to run when a specific app is launched? I've never worked with applescript before.

zqso commented 3 years ago

Recently the good old "Afloat" acts weirdly in MacForge in Big Sur, so I have to give up on it and eventually switch to "AfloatX". Still, there are no shortcut or CLI options to make it easy to use for those whose Dock is always hidden. So I use Applescript to get it done, Example: Invert Colors of the front app:

on run
    -- get active application
    tell application "System Events" to set activeApp to name of first application process whose frontmost is true

    -- right click that application in the dock
    tell application "System Events" to tell UI element activeApp of list 1 of process "Dock"
        perform action "AXShowMenu"
        click menu item "AfloatX" of menu 1
        click menu item "Invert Colors" of menu 1 of menu item "AfloatX" of menu 1
    end tell
end run

Replace the "Invert Colors" with whatever function you want. References: How can I assign an application to all desktops using the keyboard? - Ask Different - https://apple.stackexchange.com/questions/200757/how-can-i-assign-an-application-to-all-desktops-using-the-keyboard

Can this be adapted to run when a specific app is launched? I've never worked with applescript before.

You can use application trigger in Keyboard Maestro to run them when application is launched. Applescript adjustments are needed.

cocoaaa commented 2 years ago

Recently the good old "Afloat" acts weirdly in MacForge in Big Sur, so I have to give up on it and eventually switch to "AfloatX".

Still, there are no shortcut or CLI options to make it easy to use for those whose Dock is always hidden.

So I use Applescript to get it done,

Example: Invert Colors of the front app:

on run
  -- get active application
  tell application "System Events" to set activeApp to name of first application process whose frontmost is true

  -- right click that application in the dock
  tell application "System Events" to tell UI element activeApp of list 1 of process "Dock"
      perform action "AXShowMenu"
      click menu item "AfloatX" of menu 1
      click menu item "Invert Colors" of menu 1 of menu item "AfloatX" of menu 1
  end tell
end run

Replace the "Invert Colors" with whatever function you want.

References: How can I assign an application to all desktops using the keyboard? - Ask Different - https://apple.stackexchange.com/questions/200757/how-can-i-assign-an-application-to-all-desktops-using-the-keyboard

Thank you so much for this. It works like a charm with Alfred: I set a hotkey trigger (e.g. cmd+shift+F) that is linked to the apple script, and now can toggle the "Float Window" options so easily. Much appreciated!