politicus Posted August 20, 2014 Posted August 20, 2014 How to add a confirm option to a workflow just like for the System commands (log out, restart, ...) in Features > System ?
deanishe Posted August 21, 2014 Posted August 21, 2014 I think those confirmation dialogs are built in to the respective system functions, not Alfred. If you want to show a dialog, you should look at AppleScript.
rice.shawn Posted August 21, 2014 Posted August 21, 2014 Here you go... look at these to figure it out from here. display dialog "this is the text" display dialog "this is the text" with title "this is a title" display dialog "this is the text" buttons {"cancel", "okay"} display dialog "this is the text" buttons {"cancel", "okay"} default button 2 display dialog "this is the text" with icon Note display dialog "this is the text" with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:SideBarDownloadsFolder.icns" display dialog "this is the text" buttons {"Cancel","Confirm"} default button 2 with title "this is a title" with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:SideBarDownloadsFolder.icns" Bash: osascript -e 'display dialog "this is the text" buttons {"Cancel","Confirm"} default button 2 with title "this is a title" with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:SideBarDownloadsFolder.icns"' Capturing: output = $(osascript -e 'display dialog "this is the text" buttons {"Cancel","Confirm"} default button 2 with title "this is a title" with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:SideBarDownloadsFolder.icns"') answer=${output#button returned:} If you want to use any other language, then you want to run it through the system command anyway. Just make sure you escape everything correctly. Untested for PHP: answer = exec('output = $(osascript -e "display dialog \"this is the text\" buttons {\"Cancel\",\"Confirm\"} default button 2 with title \"this is a title\" with icon file \"System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:SideBarDownloadsFolder.icns\"") && echo ${output#button returned:}');
jdfwarrior Posted August 31, 2014 Posted August 31, 2014 Oh wow ! Thanks you. Another way to do this would be to use External Triggers and a Script Filter. Do whatever you need then use an Output->Run Script, to call an External Trigger. The External Trigger is connected to a Script Filter with 2 options, a Yes and a No, or a Description (with valid=false) and a Yes and No. Then just proceed based on what they select. Personally, I would prefer this over the AppleScript dialogs Florian 1
deanishe Posted September 2, 2014 Posted September 2, 2014 It's a more Alfred-y solution, but it does complicate the workflow logic much more than the AppleScript option. This is one of many complex logic problems that could be solved if Alfred's AppleScript API allowed workflows to call Alfred and receive the output. Currently, Alfred's HTTP-like stateless nature makes doing this kind of thing just with Alfred very complex: it's up to workflow devs to implement their own version of cookies and sessions.
Kaihao Posted April 18, 2019 Posted April 18, 2019 There is an error in bash capturing. It should remove the spaces around the equal sign. output=$(osascript -e 'display dialog "this is the text" buttons {"Cancel","Confirm"} default button 2 with title "this is a title" with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:SideBarDownloadsFolder.icns"') answer=${output#button returned:} or just like this answer=$(osascript -e 'button returned of (display dialog "this is the text" buttons {"Cancel","Confirm"} default button 1 with title "this is a title" with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:AlertStopIcon.icns")')
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now