Hi Yvan Koenig,
I finally got the properties of ui elements and see what you’re saying with the role property. Now I remember looking at the dictionary for System Events as I did just now.
Thanks,
kel
Hi Yvan Koenig,
I finally got the properties of ui elements and see what you’re saying with the role property. Now I remember looking at the dictionary for System Events as I did just now.
Thanks,
kel
Hello.
Here is a quick demo of what I want to do.
In order to try this, you’ll need to have an open window in Preview, then cover it with Safari or something, then run the script below from Apple Script Editor or whatever.
tell application "System Events"
tell process "Preview"
tell (first UI element whose role is "AxWindow") to perform action "AXRaise"
end tell
end tell
Edit
I just threw away my test pdf! No problem.
Hi McUsr,
I got:
action “AXRaise” of window “hello (1 page)” of application process “Preview” of application “System Events”
What Happened? I saw something happen. Maybe the window flashed or something.
Edited: I think the script editor was blocking things.
Hello kel.
I’m sorry about your Test.pdf. I was assuming that if the Preview window wasn’t visible, then it would have been brought to the foreground.
Try to make the script editor window as small as possible. Put the preview window to the right, and then make a Safari window cover it, and then try.
Hopefully the Preview window should then be brought to front. I can’t test with Preview, as I have hacked it to be scriptable. (Only possible on Snow Leopard and earlier.)
Hi McUsr,
Your script didn’t make the window rise above AppleScript Editor.
gl,
kel
No, it won’t do that, as Apple Script editor becomes active again when the script has finished executing. But it will raise over any other window, when executed from the Script Menu for instance. And best of all: I don’t think it drags other windows of the same app with it up to the front, which caters for much more tranquil screens when performing the operation.
Hi McUsr,
It worked! The Prview window moved in front of the Stickies windows. Why isn’t it going above the AppleScript Editor window?
Edited: that’s ok, I reread your post. Wow, that’s interesting. How can you use that?!
I just thought of something. Maybe you can use that to order your windows somehow.
It is like things happening behind the scene.
Hello.
I’ll have to experiment, with what is possible, and what is not. And this was just a demo, we’ll have to test if the action AXRaise is there and so on, (And if the window has a name or not. I haven’t figured it all out, because this approach, assumes no scriptability of any apps, in order to be general.
But I think that in the end, I might end up with a very pleasant script for bringing any window of any app to the front, or tab for that matter.
At least that is what I hope.
Well have a good Friday, I’m logging out.
I just thought of a big thing that might happen. If the user quits an app while, then the list will not update itself. I might have a solution to this.
Wow this system is amazing. I had almost all the apps in the dock running and the script still ran ok. Almost thirty apps were running!
Hello.
It is still a great idea to have two monitors, so that you can run flash on lower resolution. Maybe you don’t hear fans when you run Flash player, but I do, no matter how few apps I have open, but running the flash player on my second screen with lower resolution, helps a whole lot!
Hello.
Totally off topic, its summer fun! I call it kaleidoscope
( I think you’ll have to have Quartz Composer installed among the Developer tools for it to work.)
do shell script "(test -f /System/Library/Compositions/Kaleidescope.qtz && qlmanage -p /System/Library/Compositions/Kaleidescope.qtz ) &> /dev/null &"
Edit
Bored . I call this one “The Usual Suspects”.
on run
set supspects to every paragraph of "ASCII Art.qtz
BlackAndWhite.qtz
Blue Print.qtz
Blur.qtz
Bulge.qtz
City Lights.qtz
Clouds.qtz
Color Controls.qtz
Color Dots.qtz
Color Invert.qtz
ColorPencil.qtz
ComicBook.qtz
Compound Eye.qtz
Concert.qtz
Copy Machine.qtz
Crystallize.qtz
Cube.qtz
Dent.qtz
Dissolve.qtz
Dot Screen.qtz
Earthrise.qtz
Exposure Adjust.qtz
False Color.qtz
Film Stock.qtz
Fish.qtz
FishEye.qtz
Flip-Flop.qtz
Gamma Adjust.qtz
Glow.qtz
Image Resizer.qtz
LightTunnel.qtz
Line Overlay.qtz
Line Screen.qtz
Mask.qtz
Mirror.qtz
Mod.qtz
Monochrome.qtz
Motion Blur.qtz
Neon.qtz
Pinch.qtz
Pixellate.qtz
Pointillize.qtz
PopArt.qtz
Posterize.qtz
Push.qtz
Sepia.qtz
Sharpen.qtz
Squeeze.qtz
Stretch.qtz
Sunset.qtz
Swing.qtz
ThermalCamera.qtz
Twirl.qtz
XRay.qtz
Zoom Blur.qtz
Zoom Dissolve.qtz"
set a to alias POSIX file "/System/Library/Compositions"
gander(supspects)
end run
on gander(_files)
try
repeat with _file in _files
do shell script "{ sleep 2.3 ; killall qlmanage ; } & qlmanage -p " & quoted form of ("/System/Library/Compositions/" & _file)
end repeat
on error e number n
if n ≠-128 then display dialog e & " : " & n
end try
end gander
Here is a different approach to switching windows to the last active window in the last active app. This is something I need often. and the Cycle-through windows key doesn’t work in all programs, so this is a better approach to have something to work in all cases.
Maybe the delay is not needed, but I have put it in, to just be “human” to the keyboard, I put it back in after having managed to somehow kill the keyboard, while playing with this script. Seems to work fine now.
tell application id "com.apple.systemevents"
keystroke tab using command down
delay 0.05
keystroke 1
delay 0.05
key code 124
delay 0.05
keystroke return
end tell
Come to think about it, not every window may show up in the windows menu, Spotlight windows in finder for instance doesn’t show up. I guess that is because the window doesn’t have a path, or some other reason. (It isn’t strictly a finder window after all.)
I guess those cases are so few, that they can be handled individually.
Hi McUsr,
AXRaise solved everything. It now handles dialog windows or could detect dialog windows with SubRole. It solved the toggling of iTunes window when doing it from the menu. It solved HexEdit locking up things because of its Open window (dialog). Still working on this script, but it was easy to change to AXRaise.
-- SEChooseProcessWindow
set my_name to name of me
tell application "System Events"
-- show hidden processes
set visible of every process to true
-- get list of processes
set process_list to name of every process whose visible is true and name is not my_name
end tell
-- create list of processes and their windows
set user_list to {}
set i to 0
repeat with this_process in process_list
set i to i + 1
set end of user_list to ((i as string) & tab & (contents of this_process))
tell application "System Events"
set window_list to name of every window of process this_process
end tell
repeat with this_window in window_list
set end of user_list to ((i as string) & tab & tab & (contents of this_window))
end repeat
end repeat
-- user chooses a process or window
activate
set user_choice to (choose from list user_list) as string
if user_choice is "false" then error number -128 -- user canceled
set process_index to word 1 of user_choice -- string
set user_process to item process_index of process_list
-- bring to front
tell application "System Events"
tell process user_process
set frontmost to true
if user_choice contains (tab & tab) then
set user_window to (text ((count process_index) + 3) thru -1 of user_choice)
tell window user_window
perform action "AXRaise"
end tell
end if
end tell
end tell
return
-- Notes:
-- Some processes may not have the same name as the application.
I still have to try the things you posted.
Edited: added some comments to the above script. Think I have to bring the script dialog to front if run from Script Menu.
Edited: added activate to the script dialog I think.
Edited: also, a biggie that AXRaise solved was the international name of the Window menu!
Thanks for the tips,
kel
I wonder if AXRaise can bring an LSBackgroundOnly app’s dialog, to the front. I don’t like to use the LSBackgroundOnly though.
Hello.
I see some managed to have fun. I have been busy all day, summer guests, that are in for the long haul.
It is very late here, (12 hours diff), and I have just glanced at your script, I will try it tomorrow, I see that you set “frontmost” I don’t believe that is necessary (without having tried it!). Because the beauty, with AXRaise, is that it moves the window to front, without making any other window of the app follow it. That may not be how you want it though.
And I haven’t tried this, but I think there should be some role to check for, or modality or something when it comes to dialog windows.
A script that looked for hidden dialogs, had been nice now and then. I just hate it when I have to hide everything to find that dialog!
There is only one way to find out if you can raise a dialog in an app with LSBackground only set, but I think it will. I don’t use LSBackgroundOnly I use LSUIElement, because it has never occured to me, but LSUIElement apps are allowed to show dialogs, and at the same time, they don’t disturb the Dock, which I think is a plus.
I like to keep every thing as calm and undisturbed as possible.