Jump to content

[Workflow Helpers] AppleScript solution


Recommended Posts

Hey all Alfred lovers out there,

 

After David Ferguson created the PHP Workflows class to help PHP gurus create complex workflows with ease, I decided to create an equivalent solution for AppleScript gurus, because let's face it: you can't really do with PHP (or other languages) what you can do with AppleScript in terms of controlling your Mac system and its apps.

 

This library provides an object-oriented library of functions for working with plist settings files, reading and writing data to files, generating Alfred feedback results, requesting remote data, and more. But before you begin working with it, please make sure you read the documentation first as it contains vital information on how to use it, as well as help & examples (there's even an example AlfredWorkflow file that uses this library to show you how you can use it for your own workflows).

 

P.S. at the moment the library lacks JSON support since AppleScript doesn't know anything about it, so until I develop a JSON parser for AppleScript you can either use David's PHP class or improvise on my work :)and keep an eye on the github repository because I will probably add more AlfredWorkflows, and hopefully I'll manage to make a proper JSON parser in the meantime.

Edited by ursanrazvan
Link to comment

This is awesome for AppleScripter like me! Very useful HELPER! Thanks!

 

 
Very powerful helper! I've tried it carefully and learned a lot.  :D 
 
It's time to update all my workflow!
Edited by iKam
Link to comment

This is awesome for AppleScripter like me! Very useful HELPER! Thanks woofy!

 

You're very welcome :) And keep an eye on the github repository because I will publish updates with bug fixes and improvements from time to time ;)

Link to comment

SAWEET!! Will surely come in handy. Might just have to refactor my workflows that rely on AppleScript to use this helper ;)

 

Cheers!

 

Hehe, thanks, I appreciate your joy :D Please keep in mind that it has support for everything (OOP, default settings plist and working with files and plists, argument passing as seen in the example workflow on github, remote requests, etc), but it still lacks JSON support - however, I'm on this matter and I hope I'll manage to create a parser for JSON that will allow AppleScript programmers to use dot notation "users[2].user_name" :D

Edited by ursanrazvan
Link to comment

Hehe, thanks, I appreciate your joy :D Please keep in mind that it has support for everything (OOP, default settings plist and working with files and plists, argument passing as seen in the example workflow on github, remote requests, etc), but it still lacks JSON support - however, I'm on this matter and I hope I'll manage to create a parser for JSON that will allow AppleScript programmers to use dot notation "users[2].user_name" :D

Awesome. I'm no AppleScript programmer (heck I no programmer, just a newbie hacker :) )so this will come in handy for those workflows that I have to use AppleScript for.

Edited by Pedro Lobo
Link to comment
  • 1 year later...

Hi there!

 

qWorkflow looks like what I was looking for since long, thank you for this! Based on your iTunes Ratings workflow, I'm trying to have Alfred show a list of my calendars, as in the Calendar app.

tell application "Calendar"
	set calendarsList to name of calendars
end tell

Typing a few letters, I would like Alfred to display the matching calendar names, so as to perform some magical calculations with the one of my choice at next step, using AppleScript again.

I assumed the Script Filter should be something like this:

# get the workflow's source folder
set workflowFolder to do shell script "pwd"

# load the Workflow library
set wlib to load script POSIX file (workflowFolder & "/q_workflow.scpt")

# create a new Workflow Class
set wf to wlib's new_workflow()

try
	tell application "Calendar"
		set calendarList to name of calendars
	end tell
	repeat with i from 1 to (count of calendarList)
		add_result of wf with isValid given theUid:"", theArg:i, theTitle:(item i of calendarList), theAutocomplete:"", theSubtitle:(item i of calendarList)
	end repeat
	
	# show all the results in Alfred
	wf's to_xml("")
on error
	# if an error, it's probably because there's no
	# song currently playing in iTunes, so show
	# the appropriate feedback error result
	add_result of wf without isValid given theUid:"", theArg:missing value, theTitle:"There is no song playing :(", theAutocomplete:"", theSubtitle:"Couldn't get the currently playing song", theIcon:"icon.png", theType:""
	wf's to_xml("")
end try

I kept the same error message from the iTunes Ratings workflow, at least it confirms me that it's not working :D  I guess I simply don't understand how qWorkflow works  :wacko: So, I'm sorry for this very low level question, but... How could I generate such a feedback in Alfred?

 

Thank you very much in advance for your help!

Link to comment

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...