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".)
Related
I'm using the XFCE4 desktop environment under Ubuntu 20.0.4.
I have several virtual desktops set up, each of which containing one or more applications which are running.
Is there any way I can run an X-Windows-based command from one desktop and have it manipulate a window in a different desktop, without switching desktops?
For example, suppose I have an xterm shell window running in virtual desktop 0, and that I currently am focused in virtual desktop 0.
And suppose I have a text editor window open in virtual desktop 1.
Is there any way for me to remain focused in desktop 0 and to run a command within the xterm shell window which will send text to the text editor window in desktop 1?
I don't want to see desktops shifting back and forth between desktop 0 and desktop 1 while this text is being sent to the text editor. I want to remain focused in desktop 0 for the entire duration of the running of this command.
I know I can use xdotool to send text to another X window, but xdotool only seems to function when the destination window is in the same virtual desktop which currently has the focus. For example, I can do the following with xdotool, but it won't work unless the destination window (referred to by $windowid in the following example) is in my currently viewed virtual desktop:
xdotool type --window $windowid Sample text
What I want is to send text and mouse clicks to windows in desktops that differ from the desktop that I'm currently viewing, and have the windows in those other desktops receive and respond to the text and mouse clicks without any switch to the other desktops taking place.
If necessary, I'm willing to write a program in C, C++, or pretty much any other language in order to implement this functionality.
But I'm wondering: is what I'm trying to do even possible in an X Windows environment?
Thank you very much in advance for any thoughts and suggestions.
Virtual Desktops:
Most X servers have only a single screen. The window manager may virtualize this resource and offer multiple so-called 'virtual desktops', of which only one can be shown on the screen at a time. There is some variation among the features of virtual desktop implementations. There may be a fixed number of desktops, or new ones may be created dynamically. The size of the desktops may be fixed or variable.
Implementation note
There are at least two options for implementing virtual desktops. The first is to use multiple virtual roots and change the current desktop by manipulating the stacking order of the virtual roots.
The second option is to keep all managed windows as children of the root window and unmap the frames of those which are not on the current desktop.
In any case, you should study the Extended Window Manager Hints.
These properties might be of interest to you:
Root Window Properties:
_NET_SUPPORTED - set by the Window Manager to indicate which hints it supports
_NET_CLIENT_LIST - all X Windows managed by the Window Manager
_NET_NUMBER_OF_DESKTOPS - indicate the number of virtual desktops
_NET_CURRENT_DESKTOP - the index of the current desktop
_NET_DESKTOP_NAMES - the names of all virtual desktops
_NET_VIRTUAL_ROOTS - a list of IDs for windows that are acting as virtual root windows
Application Window Properties:
_NET_WM_DESKTOP - determine the desktop the window is in (or wants to be)
_NET_WM_STATE - list of hints describing the window state
_NET_WM_ALLOWED_ACTIONS - list of atoms indicating user operations that the Window Manager supports for this window
Xlib:
Sending Events to Other Applications (XSendEvent)
Obtaining Window Properties (XGetWindowProperty)
Properties and Atoms (XInternAtom)
Obtaining Window Information (XQueryTree)
For those who remember (or still use) Windows XP, you might remember that you could launch the start bar with your Windows key on your keyboard and then hit the letter of the program/folder/file you wanted and as long as there wasn't another program/folder/file on the start bar starting with the same letter, it'd launch right away.
e.g. If you wanted to open excel, you'd hit the windows key and press the letter "e" and excel would launch.
So, for those who do remember that feature, I'm wondering, is there any way to get that functionality back in Windows 8.1? Right now, what happens is that when you hit the windows key, Metro pops up (which is fine) but if you type "e", for example, windows will automatically start searching instead of just launching Excel (or whatever letter you've typed).
I'd rather keep the interface as it is and, if possible, prefer not to install any 3rd party software (unless there's no other go). My preference is to be able to utilize the OS to get that option (if available), even if that includes going through regedit.
Just a note, I am already aware that 8.1 and XP are completely different architectures and I also realize that automatic searching does have its benefits but I prefer that specific XP functionality so it'd be great if I could get it back in 8.1.
Thanks in advance for your help.
This isn't the exact thing that I'm looking for but I've found somewhat of a workaround. You can create global keyboard shortcuts and thereby circumvent the metro/start screen altogether.
To do so, create a shortcut of the program/folder/file you want to easily access (the shortcut can be placed anywhere). Then, go to the properties of the shortcut and go to the shortcut tab where you can enter a global shortcut key (about half way down the box).
Of course, there are limitations to this because there are only a few keys (key combinations) free that you can use globally whereas with the XP method I was looking for, you could essentially have up to 36 different items you can access with just two keystrokes (26 letters, 10 numbers - not sure if other characters worked).
If anyone has figured out the XP method, though, that would be great.
my system is Win7 Ultimate 32bit, and my taskbar buttons group poliy is "Always combine, hide laybels".
There is one program that have some shortcuts, when I open that program by clicking different shortcuts, I found that the icons didn't combine as the policy says.
All these shortcuts are targeted to the same position.
Can anyone tell me why this happen and how to combine all these icons?
Thanks
PS:The system says that I am a new user and have no right to post images....
Applications do have some control over their taskbar appearance but the shortcut used to start them also matters. If one shortcut specifies a App Model Id and a different shortcut does not (One you created perhaps?) then Windows might decide that these are two different apps (Or the same app with separate "modes")
If the application does not call SetCurrentProcessExplicitAppUserModelID then the auto generated Id might also not match if you run 32 and 64 bit versions of the same app...
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...
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.