AfloatX icon indicating copy to clipboard operation
AfloatX copied to clipboard

FeatureRequest: Shortcuts

Open zqso opened this issue 4 years ago • 8 comments

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

zqso avatar Jan 20 '20 10:01 zqso

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!

jslegendre avatar Jan 24 '20 21:01 jslegendre

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!

DrBones avatar Feb 19 '20 21:02 DrBones

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

zqso avatar Feb 20 '20 15:02 zqso

And/or expose some kind of CLI options?

TryTryAgain avatar Sep 23 '20 00:09 TryTryAgain

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

zqso avatar Dec 16 '20 05:12 zqso

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.

kevinjohncutler avatar Dec 17 '20 07:12 kevinjohncutler

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.

zqso avatar Dec 17 '20 08:12 zqso

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!

cocoaaa avatar Mar 25 '22 19:03 cocoaaa