Jump to content

Running AppleScript with Alfred to unminimize windows is slow


mbigras

Recommended Posts

Hello,

 

Thanks for such an awesome program. Please see the attached video for a detailed description and the below scripts. Thanks for your help! 

 

video description

 

applescript in editor:

try
tell application "System Events" to tell process "Dock"
click (UI elements of list 1 where role description is "minimized window dock item")
end tell
end try

applescript in alfred:

on alfred_script(q)
  try
tell application "System Events" to tell process "Dock"
click (UI elements of list 1 where role description is "minimized window dock item")
end tell
end try
end alfred_script

 

Edited by mbigras
Link to comment
Share on other sites

 

Hello,

 

Thanks for such an awesome program. Please see the attached video for a detailed description and the below scripts. Thanks for your help! 

 

video description

 

applescript in editor:

try
tell application "System Events" to tell process "Dock"
click (UI elements of list 1 where role description is "minimized window dock item")
end tell
end try

applescript in alfred:

on alfred_script(q)
  try
tell application "System Events" to tell process "Dock"
click (UI elements of list 1 where role description is "minimized window dock item")
end tell
end try
end alfred_script

 

 

The Reason why, the windows unminimize so slow in the first case is, that you can "slowmow" minimize windows 

in OS X by pressing the shift key(Source: here). Changing the hotkey would fix this problem but it would still be a bit slower than usual.

To get it as quick as when you click, don't use "Run NSApplescript" use "Run Script" instead.

Deanishe pointed the differences out in this post:

 

 

 

Generally, it's a better idea to ignore the Run NSAppleScript Action and use the normal Run Script Action with language = /usr/bin/osascript (AS) instead.

 

The reason is that Alfred blocks while a Run NSAppleScript is running, so you can't use Alfred, but a Run Script is always run in the background.

 
In addition the hotkey doesn't matter then either :)
 
Hope that helps :)
Edited by FroZen_X
Link to comment
Share on other sites

Hey FroZen_X,

 

Thanks so much! That helped me a lot! I changed the hot key to ctrl + cmd + m and the windows are coming up much faster  :)

 

It is definitely still noticeably slower though coming up then going down so I did some more experimenting with your second comment about changing from Run NSAppleScript to Run Script; however it didn't seem to make a difference in speed, also when I tried switching the hotkey back to shift + cmd + m it went back to going slow so it seems like the hot key does matter even if it's a different script, am I missing something here? Like to I need to write a script in a different language for the windows to come up more snappily and to be able to use shift in the hotkey? Anyways, thanks so much for your help so far  :)

Link to comment
Share on other sites

Hey FroZen_X,

 

Thanks so much! That helped me a lot! I changed the hot key to ctrl + cmd + m and the windows are coming up much faster  :)

 

It is definitely still noticeably slower though coming up then going down so I did some more experimenting with your second comment about changing from Run NSAppleScript to Run Script; however it didn't seem to make a difference in speed, also when I tried switching the hotkey back to shift + cmd + m it went back to going slow so it seems like the hot key does matter even if it's a different script, am I missing something here? Like to I need to write a script in a different language for the windows to come up more snappily and to be able to use shift in the hotkey? Anyways, thanks so much for your help so far  :)

 

My mistake sorry :/, was a little late yesterday. I checked again and the hotkey still matters there. What you can do tho is, set a delay at the start, as of a delay 

for the time till you release the hotkey. I was pressing the hotkey fairly quick and didn't notice ^^

So here is an example of what you could do if you wanna keep "Shift" and Applescript:

delay 0.2
try
tell application "System Events" to tell process "Dock"
click (UI elements of list 1 where role description is "minimized window dock item")
end tell
end try

That's the quickest and easiest i can come up with atm :)

Hope that helps, else gotta check for yeah another language or another trick ^^

Edited by FroZen_X
Link to comment
Share on other sites

I'm silly....way way way better solution....forget about the delay or anything else....

Go to your workflow->doubly click on your hotkey to open the hotkey settings(can also right click->configure)->Right click in the hotkey field and change

the trigger behaviour to "Wait until modifier keys are released" :)

That will do it!

 

Always learn something new ^^

Link to comment
Share on other sites

Yeah, the slow minimise/maximise is a "feature" of OS X. It happens when you SHIFT-click on a minimised application.

 

This is a general problem with Hotkeys: if you've still got your fingers on modifier keys when an AppleScript that simulates clicks/keypresses runs, you also get the modifiers you've got your fat fingers on.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...