How to move a window to a certain desktop with AppleScript? - 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.

Related

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

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

Applescript - Opening apps on different Desktops "Spaces"

I am very new to applescript, but was wondering if it is possible to open applications to different desktops "spaces" using applescript. I have found how to launch applications, but don't know how to assign them to different desktops. Basically I am looking to open;
Outlook - Desktop 1
Skype - Desktop 1
Safari - Desktop 2
Onenote - Desktop 3
Thanks for any help, I really appreciate it.
Last system versions do not include any scripting of spaces. the only thing you can now do is to assign, in system preferences, shortcut keys to switch to a space, and once done, launch applications you want to.
To simulate action keys in Applescript, use system event "keystroke" instruction.
Easy: start these applications, one by one, in your "chosen" space, click on and hold Dock's icon, move cursor to "Options" (below), select this one (of three) options:
– Current desktop (or: this desktop, or similar)
… which from now on will always open THIS application in THIS space.
There is no programmatic way in AppleScript to instruct your Mac to switch spaces/workspaces or even to return the identity (number) of the current desktop.
Switching may happen, though, if the relevant option in System Preferences, Mission Control, is set.
(Indirectly, comparing a desktop "picture" to a user-defined list empowers a script to get its "number".)

Tabbing between Xcode project windows?

Basically I am supposed to press Command + the [`~] button that is above the Tab.
This question has been answered twice here:
Tabbing between Xcode projects?
and
Navigate Between Projects in XCode 4.0
But it just wont work for me, has anything changed in the xcode versions? or the way the mac behaves?
When I press this combination all I hear is the "invalid" sound.
I am using the newest Mac OS mountain lion.
Sorry if this belong to the super user stack overflow I just figured more Xcode users would be found here.
I can do the swipe on the mouse pad to bring the screen where I see all the active windows for the current application... but this is much slower than just tabbing between the 2 projects I'm usually working with.
Thanks
Do I infer from your comment about using the three finger swipe (for Mission Control) that the second window is not on the same desktop as the other windows? The command+` sequence only jumps between windows on the same desktop, not between different desktops (which is not to be confused with two physical monitors, which you can jump between, if you have multiple monitors hooked up to your computer).
The inability of command+` to not jump between desktops is a little curious, because command+tab, which jumps between apps, does go across desktops. If you want to jump between desktops, you can press control+1 or control+2 to jump to desktop 1 or 2, respectively. It should be noted, though, that while that might be a good alternative when trying to jump between your two desktops, though it admittedly selects the last active window in that other desktop, not necessarily a window from your current app in that other desktop. Also control+left and control+right let you jump between desktops, too.
This is a Mac OS "feature", not an Xcode issue, I believe. The command+` ability to jump between windows (but not windows across Mission Control desktops) is the same behavior across the Mac OS.
Update:
If this keyboard shortcut is not working at all, in any app, even within a single Mission Control desktop, then you don't need to worry about Xcode settings, but rather focus your attention on the keyboard settings:
You might want to look at your "Move focus to the next window" keyboard shortcut. There have been reported problems of people with international keyboards not getting this to work properly, but by clicking on (and thereby selecting) the command+` graphic, you can try using different keyboard shortcut, and see if that does it for you.
I have mountain lion as far as i know.
How about this?
control + down
You'll get the current application windows.
Below them there should be a horizontal list of recent projects for Xcode (both opened and closed). With arrows left or right choose the project (it should be highlighted with blue) and press enter.

Mac OS X / Open terminal with specified windows *on specified desktops*

The accepted answer to this question explains how to create a "window group" in Terminal.app so that you can open a set of windows with predefined tabs executing predefined commands in predefined positions.
That's great, but it doesn't appear to play nice with Mission Control. I save my window group with the windows spread out across different desktops in Mission Control, but when I restore the window group they all pile up on top of each other in the desktop I'm currently using!
How can I get a Window Group to restore the windows to the desktops from which I saved them?
Thanks!
Doesn't look like separating application windows by desktop is an option anymore; not according to this MacForums thread.
There's an app called TotalSpaces that claims to restore pre-Mission Control window grouping, but it's a paid app so I haven't tried it.
You might be better off asking this question on AskDifferent or SuperUser...

Mac OS X vs. Windows mouse wheel scrolling

Mac OS X determines what area to scroll by the mouse position. Windows does this by what application is active.
So I thought anyway. If Notepad++ is the active application in Windows, I can scroll underlying applications by placing the mouse pointer on them. But this seems like the only application with this behaviour. Windows Explorer (Win7) doesn't even allow scrolling in the side pane if the pane is not active.
My question is, can this be controlled by developers, and why is Windows behaving like this? I am not about to make a Windows application, but as a developer this makes me curious (and annoyed).
There are a number of applications that do the focus-window-under-mouse, but I like Alt-Drag: http://code.google.com/p/altdrag/
Since the code is Open Source, you may find something reusable there.

Resources