There are probably still some glitches here, when an app isnāt scriptable and so on, but this is as good as it gets from my side, to pick a window among those you have in the current space, or select from all spaces if you have no more than one window. If you have none, then you command - tab to the app. The script is in post #7 together with a skeleton for an app, so you can use it from various places.
Invisible windows, that should have stayed invisible started to turn up as a result of former fixes. It is updated in post #7.
Now it moves you into the space where a window resides, if the window you chose didnāt reside in the current space, (if you had just one window in this space, youāll get the opportunity to select windows from other spaces, if the app has any). It is all in post #7.
Factored out a subroutine, and tested it thoroughly, with document based and non documentbased apps. It should work as intended for applications that are scriptable.
One last bug is fixed. The problem was not getting the window to front, when the window is residing in another space.
I had to differentiate between cases where there were just one window in another space, and more than one.
Perfect, as far as it goes.
Apart from when there were multiple windows in the current space. That is fixed now.
It is totally finished. I really need that script object, thatās why I have bothered all of this, if you wonder.
So the finished thing resides in post # 7.
It is a script called Pike, that lets you pick a window from any app that is active in current space, if there is just one window active in current space, then you are allowed to select windows in other spaces.
The idea is that if you want something ānewā, from an app that isnāt there then youāll switch or fire up that app, and arrange things as you want.
Fixed one bug relating to activating a window in another space, when there is just one window. There are still problems when there are several windows in another space, and you want to get a window that is not the front in that space (index = 1 ), I canāt bypass bringing all of the windows of that app in the front of the other windows in that space then. Maybe Iāll fix this one day, but I fear it will be a rather slow solution in AppleScript.
One thing I have forgotten to mention is that the whole thing relies on auto-swooshing of windows, that is, when you select a window in another space, that space is activated/you are taken to that space (pick your view).
You activate auot-swooshing by entering this from the command line:
.
The whole setup also works best with apps, that arenāt dedicated to any space, nor all spaces.
And the right version is posted in post #7 above.
Wait so can I use this along with the script that you helped me edit that uses UIElements to connect to bluetooth devices so that it would seem like I had not even opened up system preferences to connect to the bluetooth device?
I am sorry for this whole thread, but it works as should at my place.
With auto-swoosh enabled and all. It is practical, but its not comfortable, and perfect in any sense I realize that now.
Hi McUsr,
That is a puzzle. How do you make just one window of an app frontmost? does it work? Iāll read it later. Interesting.
Hello.
There are certain situations where that wonāt work, and that is, when there are more than one window in another space, from that app which window you want to bring to the foreground, as it is I have no way of bringing just that window forward.( if it is followed immediately by an window of the same app, in the z-order (front to back ordering of the windows).
I hope you try it, and find it useful.
I am still working on it, to make it more friendly, as even I are at a loss at times.
Later today, Iāll post a new version, this version will gather all windows, from the app that are active in the current space, regardless, if it has only one window open there, or not. Iāll also use āStoneās ticksā on the windows that are from the current space, to differentiate between ānativeā and āforeignā windows.
OK.
Even more bugfixes, when a user escapes out of a choose from list, and leaves the screen in a more tranquil state, with regards to windows visible, and frontmost, before and after a cancel.
All windows for an app will be visible in the window list dialog, if it has any, but this behaviour can be changed by a property.
There is no way to just activate a window from an app in another space, and bring that to front, without bringing the windows of that app in your current space to front. So the price for jumping to a window in another space, is that you rearrange the window layout in your current space. The second caveat is that all windows of the same app will be brought to front, once activated, because I have to activate the app, to make the jump to the window.
This could have been fixed by ui scripting the window menu, and jump from there, right now I am fed up with itā¦
Hello.
It still disrupts your screen a whole lot less, when you have many windows open in an app, compared to the usual way of getting a window: activating an app, and then looking for the window.
And, my test shows that it disrupt the screens less than command tab (choose app ) 1.
So. In my eyes, it is an improvement, although small. (Not worth it.)
(You really need to have auto-swoosh enabled to see any benefits by this script, this is described in post #7 where you also find the script.
Hello.
I had to implement a time out for cases where the app you want to get a window list from is busy, and then bail out with a dialog about the situation.
This doesnāt happen often but say if you left an app in a modal dialog, then it may.
Hi McUsr,
I downloaded the Pike script from post #7. Chose Smile and had open a new untitled script window and the worksheet. When I choose the worksheet from the dialog, the untitled window comes up. When I choose the untitled window the worksheet becomes frontmost. Iāll try to look through the script to see what is happening.
Nice idea though. I always want to bring some window from some app frontmost. I always used to bring the app to the front first, then try to click on the right window.
Later,
kel
Thank you very much kel! One - nil to Hawaii!
It was nice of you to tell me. It appears that since Smile, operates with several kinds of windows, both AppleScript Terminals, Dialogs and AppleScripts, that may āTrickā to bring a window frontmost doesnāt work. I have implemented a work-around for Smile, so that the correct window gets to be activated.
I have tested the script alot, and that is the first time just that has happened.
Please tell me, if you find other flaws.
In the passing. I wrote the script for some of the same reasons, most of my apps arenāt assigned to any space, so that they get started in the space that I am in. Those apps where I have a window open that covers all contexts, (my working contexts) are set to show up in every space.
If I did this with the apps, that I may use in a separate space on a project, then I would have all its windows cluttering up everything. So this program enables me to jump into a space, and have that window I want active when I get there. Then it is easy to jump back with the window.
Pike diversifies your options with regards to window configuration of your spaces. That was what I was trying to say. Or. Pike gives you an option in between of everything and nothing. But it is intended to be used with auto-swoosh, as described together with the script in post #7.
Enjoy your evening!
Foggy morning here.
Hello.
I have changed login name, and canāt access the script in post #2 Elevate: So Iāll post the update here, which arenāt much more than embedding the script into a script object, and then running it, because that speeds things up.
This little script is very practical, when you are having many windows open in the same space, because it lifts forward, the current window of an app, but lets the rest be untouched.
I have placed this in an AppleScript action in an Automator service like this:
End I have gone into the keyboard preferences pane, and assigned it to cmd-F3.
(My keyboard is configured so that I have to press the āfnā button in order to adjust the volume by F11/f12).
Together with the ācycle through windows buttonsā (shift-cntrl-F4 and cntrl-4) this gives me an easy window-activation from the keyboard.
Here is the updated script:
-- Elevate http://macscripter.net/viewtopic.php?pid=154619#p154619
-- Ā© McUsr and put into public domain (Parts stolen from MacOSXAutomation.com )
-- http://macosxautomation.com/mavericks/notifications/01A.html
-- revised to use current application instead of system ui server
property parent : AppleScript
on run
try
script o
property a : missing value
property b : missing value
end script
local a, b, c, d, i
set e to (path to frontmost application as text)
tell application id "com.apple.systemevents"
set {o's a, o's b} to {bundle identifier, name} of (every process whose visible is true)
set pcount to count o's b
repeat with i from 1 to pcount
if (count every window of (application process (item i of o's b))) = 0 then
set {item i of o's a, item i of o's b} to {missing value, missing value}
else if (frontmost of (application process (item i of o's b))) = true then
set ebid to item i of o's a
set {item i of o's a, item i of o's b} to {missing value, missing value}
end if
end repeat
end tell
set {o's a, o's b} to {o's a's text, o's b's text}
set pcount to count o's b
set deli to "." & space & space
repeat with i from 1 to pcount
set item i of o's b to character id (i + 96) & deli & item i of o's b
end repeat
tell application id "com.apple.systemuiserver"
activate
try
with timeout of 30 seconds
set c to (choose from list o's b default items item 1 of o's b with title "Elevate a window")
end timeout
on error thisErr number thisNr
if thisNr = -1712 then
tell application id "com.apple.systemevents"
tell process "SystemUIServer"
tell button 2 of its window 1 to click
end tell
end tell
set c to false
end if
end try
end tell
if c = false then
do shell script "/usr/bin/open -b " & ebid & " &>/dev/null &"
error number -128
else
do shell script "/usr/bin/open -b " & item ((id of character 1 of (item 1 of c)) - 96) of o's a & " &>/dev/null &"
end if
on error errorMessage number theErrNo
if theErrNo is -25211 then
my addAppletToAccessibilityList()
else if theErrNo âⰠ-128 then
tell application (path to frontmost application as text)
display dialog "Elevate got an Error: " & errorMessage & " : " & theErrNo
end tell
end if
end try
end run
-- stolen from MacOSXAutomation.com
on addAppletToAccessibilityList()
set thisApplication to (path to frontmost application)
tell application "Finder" to reveal thisApplication
tell application "System Preferences"
launch
reveal anchor "Privacy_Assistive" of pane id "com.apple.preference.security"
activate
display alert "ADD APPLICATION TO ACCESSIBILTY" message "In order to let this application control the computer by running Elevate, it must must be added to the list of applications approved to use the accessibility controls of the OS." & return & return & "To add this Application to the Accessibility list:" & return & return & "1) Click the lock icon (if it is locked) at the bottom left of the System Prefences window, and enter your adminstrative password in the forthcoming dialog." & return & return & "2) If the Application is already in the list, select the checkbox next to its name. Otherwise, drag the icon of the applet (now revealed in the Finder) into the list area displayed on the right side of the System Preference window." & return & return & "3) Click the lock icon to re-lock the preference pane."
end tell
end addAppletToAccessibilityList
I have a snippet like this in my script folder, so I can run it from the scripts menu as well.
property parent : AppleScript
set hfsScriptName to "Macintosh HD:Users:you:path to:Elevate.scpt"
run script (hfsScriptName as alias)