Kitty Terminal Hotkey Drop-Down/Overlay Hotkey (similar to iTerm2 hotkey window) - macos

TDLR
How to get something similar to the iTerm "dropdown hotkey/overlay" functionality to work with Kitty Terminal (on a Mac)?
I work on a Mac and used iTerm2 for a long time and integrated the "hotkey window" into my workflow. Since I've made the switch to Kitty I have been trying to get the same functionality but couldn't find something that suits my needs.
Caveat/Problems
The one app that has this built-in, that I know of, is also iTerm. There's one big difference with this implementation and the native iTerm implementation.
iTerm is more of a "drop-down", in that it functions as an overlay. The BTT implementation will literally show and hide the application. This means that whenever you are working with multiple desktops, and you trigger this shortcut, BTT will move you to the desktop where the application is.
A similar solution for Lunix is using tdrop. As far as I know there's no equivalent tool for MacOS
I find this quite annoying TBH and would love to know if anyone knows how to do the same thing, but in a "drop-down" or "overlay" fashion
What I've tried
BetterTouchTool (BTT)
This is the way I've set it up using BTT.
AppleScript
This does sort of the same thing, but without the use of BTT.
set appName to "kitty"
tell application "System Events"
if visible of application process appName is true then
set visible of application process appName to false
else
set visible of application process appName to true
end if
end tell

Related

Launch/raise application and cycle through its windows using AppleScript and keyboard shortcut

How can I use AppleScript to create a keyboard shortcut which will:
Launch an application if it's not running.
Bring the application to the foreground if it is running.
Cycle through only the application's windows if I keep pressing the shortcut keys.
For example, when I press Option-Y, it will launch Terminal or bring it to the foreground, and if I keep pressing Option-Y it will cycle through the multiple open Terminal windows if I have more than one open.
I have successfully created an AppleScript using Automator as a service. I have successfully mapped this script to a keyboard shortcut by going to System Preferences, Keyboard, Shortcuts, Services and under General, checking and assigning a keyboard shortcut to the Automator service BringTerminalToTheForeground.
Here is the script to launch the Terminal:
tell application "Terminal"
activate
end tell
I want to do this only with the tools which come with the Mac by default (e.g. AppleScript, Automator). I'm running El Capitan.
Command-"`" will cycle through an application's windows.
tell application "Terminal" -- try other applications. This script might work in other cases. It happens to work with Terminal but I haven't tested it.
activate
set c to count of windows -- we need to know how many windows the application has so we only cycle through all of them once.
tell application "System Events"
repeat c times
keystroke "`" using command down -- this is what cycles through the windows. This doesn't work in every application.
delay 1 -- this is a 1-second delay. Change this to whatever delay you want.
end repeat
end tell
end tell
I have exactly what you are asking for, but I'm using hammerspoon, Karabiner Elements and GokuRakuJoudo (optional but highly recommended).
First you have to create this lua module using Hammerspoon https://github.com/fabiomcosta/keyboard/blob/73b22906b31dfc12cc834c382515e30c4450d0f5/hammerspoon/hyper.lua#L76 then on my karabiner.edn (using Goku) I define a keymapping calling that function using Hammespoon's cli hs.
It's not easy to setup and in fact that's why I'm looking for a new way to achieve the same behavior without this much setup haha.
But it definitely works.

AppleScript to Launch 1Password mini

I use 1Password to store my passwords, and fluid.app to create a few site-specific apps/browsers
While 1Password integrates well with Chrome, Safari and other browsers, it doesn't play nicely with Fluid apps, which is where my troubles lie.
I have therefore created a shortcut (with Keyboard Maestro) to run an applescript to open the mini, when I am in Fluid apps. However, I can't seem to get the applescript to launch the mini. Here are my attempts:
tell application "1Password mini" to launch does nothing, though AppleScriptEditor doesn't report any errors
tell application "1Password mini" to open nothing, though AppleScriptEditor doesn't report any errors
tell application "1Password mini" to activate is pointless, as 1Password mini is already activated
tell application "1Password" to open opens the main 1Password application, not the mini, which is what I need.
Interestingly, when I run (1), (2), and (3), AppleScriptEditor automatically replaces 1Password mini with 2BUA8C4S2C.com.agilebits.onepassword-osx-helper, which doesn't clarify things for me at all.
Does anybody have any clue how this can be solved?
I'm on OSX 10.10.2 (Yosemite), if it matters
I work for AgileBits, the developer of 1Password.
Looks like you found a solution, but here's another option for you:
open location "x-onepassword-helper://search/"
That AppleScript will open 1Password mini ready to search.
And if you're able to get the current website's domain from Fluid, you could even open 1Password Mini with a search term already filled in:
open location "x-onepassword-helper://search/twitter.com"
I hope that helps!
The solution was quite simple, with a little UI scripting:
tell application "System Events" to tell process "1Password mini"
tell menu bar item 1 of menu bar 1 to click
end tell

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.

How to open, close and close the dialogs of another application using cocoa or applescript?

I want to open another separate application, open the projects/documents of that application in a iterative way and then close the application. I also want to close all the modal and non modals dialogs which popped up during the opening of the document. I want to close all the dialogs including the crash dialog in case the application fails/ crashes.
What will be the best way using cocoa or applescript to achieve this and from where i can get more detailed information?
If the app has a scripting interface, of course the best way is to do that.
You generally don't want to iterate in AppleScript, but rather to operate on all of the results of a query.
For example, for almost any application that implements the "standard suite", you can just:
tell app "TextEdit" to close windows
This is much simpler (and faster, and more likely to be implemented correctly in the target app) than:
tell app "TextEdit"
repeat with theWindow in windows
close theWindow
end repeat
end tell
Of course this may pop up save/abandon changes dialogs, and it may skip over or include dialogs and inspectors, and so on, depending on the application's user model.
More importantly, it won't work if the app doesn't support scripting (and the standard suite).
Also, it won't help at all with closing a crash report—that window is owned by CrashReporter, not the original application (which is a good thing, because you can't talk to the original application anymore, now that it's crashed…).
The alternative is the UI Scripting features in System Events. This will only work if assistive access is enabled. It can also be a bit fiddly to figure out which windows are the ones you want to deal with, and which controls are the ones you want.
For example:
tell app "System Events"
click button 1 of windows of application process "TextEdit"
end tell
This works by finding every window (no matter what kind) owned by the TextEdit process, and simulating a click on the first button in that window (the red close button).
If you google "AppleScript UI Scripting" you should find lots of different guides. The first hit I found was http://www.makeuseof.com/tag/applescripts-ui-scripting-mac/ and it looks like a decent place to start.

How to move a window to a certain desktop with AppleScript?

I have an application/window on Desktop 1 (OS X Lion) and I'd like to move it to Desktop 3. Any insights on how to do this? Not as big a deal, but if possible I'd like to ensure there are 3 and only 3 Desktops available.
This answer should offer clues on how to do place applications, specifically...
tell application "System Events"
set x to application bindings of spaces preferences of expose preferences
set x to {|com.apple.textedit|:4} & x -- Have TextEdit appear in space 4
set application bindings of spaces preferences of expose preferences to x
end tell
I would imagine moving a window is not too different.
I realize this question is old, but in case anyone still needs this functionality, I thought I'd share my solution.
Because there aren't any real scripting exposures in Mission Control, you'll need to manipulate the cursor and thus will need access to the Objective-C bridge. This requires using the JXA variant of AppleScript, but still allows things to run natively without any plugins.
If you're still interested I've shared the solution on my GitHub repository, stephan-hates-osascript.
Moving a window works while switching to different desktops with a keyboard shortcut.
With the mouse, click and hold the title bar as if you are moving the window around your desktop, then press ctrl+3. Ctrl+3 has to be mapped to move to desktop 3 in the keyboard shortcuts interface. Ctrl+Right twice also works. Then release the mouse button.

Resources