strug
-
Posts
5 -
Joined
-
Last visited
Content Type
Blogs
Gallery
Downloads
Events
Profiles
Forums
Articles
Media Demo
Posts posted by strug
-
-
Here is the link to the one suggesting to ignore/kill the System Events: http://stackoverflow.com/questions/16492839/applescript-on-clicking-menu-bar-item-via-gui-script
-
If I don't ignore and kill that I have to wait ~7 seconds between open the menu bar 2 menu and selecting the submenu. I found somebody having a similar problem and his solution was to kill the "waiting". This works when System Events is already running, but not, when not.
So if I remove the ignoring and kill stuff the workflow works, but have a ~7seconds pause before the submenu is selected.
I tried to combine it:
tell application "System Events" to tell process "Pulse Secure" click menu item "Connect" of menu network of menu item network of menu bar item 1 of menu bar 2 end tell
but so far I couldn't manage it to work:
[ERROR: alfred.workflow.action.applescript] { NSAppleScriptErrorAppName = "System Events"; NSAppleScriptErrorBriefMessage = "Can\U2019t get menu item \"work network\" of menu bar item 1 of menu bar 2 of process \"Pulse Secure\"."; NSAppleScriptErrorMessage = "System Events got an error: Can\U2019t get menu item \"work network\" of menu bar item 1 of menu bar 2 of process \"Pulse Secure\"."; NSAppleScriptErrorNumber = "-1728"; NSAppleScriptErrorRange = "NSRange: {499, 95}"; }
Thanks so far
-
Without ignoring the first menu opens but waits for ~7seconds, after that the submenu is opened and the entry get selected. No matter if System Events was running or not.
To me it seems as if my script requires "System Events" to be running in order to run properly/quick. If it is not running, it will be started (I see that in the Activity Monitor), but my script did not wait for that (because of the ignore;) so that in that case it fails with a timeout/race condition.
Any idea how I can speed up the workflow when removing the ignore?
Thanks a lot!
-
Hi there,
I'm absolutely new to applescript and writing alfred workflows. I want to write a workflow to connect to VPN with "Pulse Secure". Therefore I want to select the menu bar icon and select a connection.
I managed to get it working when "System Events" is already running:
on alfred_script(query) set network to "work network" if query is not "" then set network to query end if ignoring application responses tell application "System Events" to tell process "Pulse Secure" click menu bar item 1 of menu bar 2 end tell end ignoring do shell script "killall System\\ Events" delay 0.2 tell application "System Events" to tell process "Pulse Secure" tell menu bar item 1 of menu bar 2 tell menu item network of menu 1 click tell menu item "Connect" of menu network click end tell end tell end tell end tell end alfred_script
If "System Events" is not running this script fails. I tried a couple of ways to start "System Events" if it's not running, but even with a delay afterwards it fails.
I tried it with
tell application "System Events"
activate
end tell
withlaunch "System Events"delay 2and a couple of other combinations. Unfortunately without success:(
Hopefully you can help me a bit.
Best regards
Need to have "System Events" running before I can access menu bar 2 properly
in Workflow Help & Questions
Posted
mmh, does not work properly either.
I saw that the flux workflow (http://www.packal.org/workflow/flux-control-plus-remote) do s.th. similar, but this workflow doesn't work on my machine either.