Jump to content

Pete31

Member
  • Posts

    17
  • Joined

  • Last visited

Pete31's Achievements

Helping Hand

Helping Hand (3/5)

0

Reputation

  1. First off you didn't tell me anything new about AppleScript, I'm well aware. It's not meant disrespectful, however as a new (active) forum member I'm quite surprised how massive people here are trying to force something upon me which I repeatedly said I neither need nor plan to do in the near future. I'm regular on several forums and never experienced something like this. How clear do I have to say: I love AppleScript. I write almost every day. I don't want to learn any other language at this point, except AppleScriptObjC. Gentlemen that's really not how new members should be treated. If I were to start to script and didn't know anything about it then it might be ok, however I'm quite experienced in AppleScript and told you so. There's no reason for me to start a new language as AppleScript won't die, believe me.
  2. I'm aware. I totally understand what you're telling me, however keep in mind that I'm writing my first workflow that does more than opening a URL in a new Safari window or initiating a DEVONthink search. Doesn't make sense to immediately start to learn another language just because I want one more "advanced" workflow (speaking as a bloody beginner). I can see how you and others repeatedly speak against AppleScript and it's definitely right to warn beginners so they don't get on the wrong track when they mainly want to write Alfred workflows. However I'm writing AppleScript for some years now, there's seldom a day where I don't write for me or someone on a forum. Starting another language at this point would simply be insane, especially as I already started with AppleScriptObjC. The time for another language will come and then I'll choose one that works well with Alfred but first I'll get familiar with AppleScriptObjC as that's what makes sense to me. There's not only Alfred.
  3. Well, if almost all you want to do is scripting apps then AppleScript is the way to go. Of course there's JavaScript but it happened that it's AppleScript for me and there simply wasn't a need for any other language. I also don't want to miss UI scripting when there's no other way. AppleScript does things you can't do with any other language (maybe JavaScript is capable of UI scripting too, don't know).
  4. Thank you very much for looking into this deanishe! No idea why I didn't try to do it in AppleScriptObjC. However I've found an even better way, no idea why I didn't think of this before, though. It's actually possible to use any string we want as a key in an AppleScript record, we just have to use pipes 🙂 set newRecord to {title:theQuery, arg:theQuery, variables:{scope:"", modifyScope:"false", modifyQueryWith:""} ¬ , mods:¬ {ctrl:{arg:theQuery, subtitle:"scope:", variables:{scope:"", modifyScope:"true", modifyQueryWith:""}} ¬ , alt:{arg:theQuery, subtitle:"Anführungszeichen", variables:{scope:"", modifyScope:"false", modifyQueryWith:"quotes"}} ¬ , cmd:{arg:theQuery, subtitle:"scope:selection", variables:{scope:"selection", modifyScope:"true", modifyQueryWith:""}} ¬ , shift:{arg:theQuery, subtitle:"Asterisks", variables:{scope:"", modifyScope:"false", modifyQueryWith:"asterisks"}} ¬ , |ctrl+shift|:{arg:theQuery, subtitle:"CTRL + SHIFT", variables:{scope:"", modifyScope:"false", modifyQueryWith:"asterisks"}} ¬ , |alt+shift|:{arg:theQuery, subtitle:"ALT + SHIFT", variables:{scope:"", modifyScope:"false", modifyQueryWith:"asterisks"}} ¬ , |cmd+shift|:{arg:theQuery, subtitle:"CMD + SHIFT", variables:{scope:"", modifyScope:"false", modifyQueryWith:"asterisks"}} ¬ } ¬ } as record
  5. Yeah I noticed that. It seems to be really hard to learn AppleScript if you already know any other language. I'm lucky as I started with AppleScript (and love it), now learning AppleScriptObjC and if I can't do something with it that I desperately want to do in Alfred then maybe I'll look into Python. However I don't think I'll do things I can't solve with AppleScript(ObjC).
  6. That sounds very good! One thing I especially like about AppleScriptObjC is that everything is crystal clear when you read code, it's self-explanatory (once you've found what's needed …)
  7. No library involved, just AppleScriptObjC. -- Read & Write Write JSON in AppleScriptObjC use AppleScript version "2.7" use scripting additions use framework "Foundation" property maxResults : 500 property theJSONPath : "/Users/USER/Desktop/demo.json" property theIconPath : "/Applications/DEVONthink 3.app/Contents/Resources/DEVONthink 3.icns/" property NSJSONWritingPrettyPrinted : a reference to 1 on run (argv) try set theQuery to (item 1 of argv) set newRecord to {title:theQuery, arg:theQuery, variables:{scope:"", modifyScope:"false", modifyQueryWith:""} ¬ , mods:¬ {ctrl:{arg:theQuery, subtitle:"scope:", variables:{scope:"", modifyScope:"true", modifyQueryWith:""}} ¬ , alt:{arg:theQuery, subtitle:"Anführungszeichen", variables:{scope:"", modifyScope:"false", modifyQueryWith:"quotes"}} ¬ , cmd:{arg:theQuery, subtitle:"scope:selection", variables:{scope:"selection", modifyScope:"true", modifyQueryWith:""}} ¬ , shift:{arg:theQuery, subtitle:"Asterisks", variables:{scope:"", modifyScope:"false", modifyQueryWith:"asterisks"}} ¬ } ¬ } as record set theJSONFile to POSIX file theJSONPath if (get eof theJSONFile) ≠ 0 then -- Read JSON set oldJSON_data to current application's NSData's dataWithContentsOfFile:(theJSONPath) set {oldJSON, theError} to current application's NSJSONSerialization's JSONObjectWithData:oldJSON_data options:0 |error|:(reference) if oldJSON = missing value then error (theError's localizedDescription()) as text if oldJSON's isKindOfClass:(current application's NSDictionary) then set oldJSON_AS to {oldJSON as record} else set oldJSON_AS to oldJSON as list end if set newJSON_AS to {newRecord} & oldJSON_AS else set newJSON_AS to {newRecord} end if -- Write JSON set theJSONData to current application's NSJSONSerialization's dataWithJSONObject:newJSON_AS options:NSJSONWritingPrettyPrinted |error|:(missing value) theJSONData's writeToFile:(theJSONPath's POSIX path) atomically:false set JSONStr to (current application's NSString's alloc()'s initWithData:theJSONData encoding:(current application's NSUTF8StringEncoding)) as text -- testing on error error_message number error_number if the error_number is not -128 then display alert "Error" message error_message as warning return end try end run
  8. Hi, it's not possible to set e.g. this mod ctrl+cmd as name in an AppleScript record. Would be awesome if Alfred could accept also e.g. ctrl_cmd.
  9. I'm learning AppleScriptObjC as it's the right language for what I'm doing outside of Alfred. Also started to collect info for other languages. I've read that AppleScript is not what people use for their workflows and found a post where you said PERL is also not used much. What would be the recommended language for someone who knows nothing except AppleScript?
  10. Hi, I create JSON from an AppleScript record via AppleScriptObjC. Names of single "mods" are no problem (e.g. "ctrl" ), but it's not possible to set "ctrl+cmd" as name in an AppleScript record. Tried "ctrlcmd" and "ctrl_cmd" but that's not what Alfred needs. Are there other ways to define ctrl+cmd that Alfred understands? Here's the record: set theQuery to "hello world" set newRecord to {title:theQuery, arg:theQuery ¬ , mods:¬ {ctrl:{arg:theQuery, subtitle:"scope:selection", variables:{cleanQuery:"false", modifyQueryWith:"scope:selection"}} ¬ , alt:{arg:theQuery, subtitle:"Anführungszeichen", variables:{cleanQuery:"true", modifyQueryWith:"quotes"}} ¬ , cmd:{arg:theQuery, subtitle:"Entferne scope:", variables:{cleanQuery:"false", modifyQueryWith:"remove scope"}} ¬ , shift:{arg:theQuery, subtitle:"Asterisks", variables:{cleanQuery:"true", modifyQueryWith:"asterisks"}} ¬ , ctrl_cmd:{arg:theQuery, subtitle:"THIS DOESN'T WORK IN ALFRED", variables:{cleanQuery:"false", modifyQueryWith:"do something"}} ¬ } ¬ } as record Here's the JSON (I'm adding Alfred's "{"items" : " in the Script Filter, that's not the problem) : [ { "title" : "hello world", "arg" : "hello world", "mods" : { "ctrl_cmd" : { "arg" : "hello world", "subtitle" : "THIS DOESN'T WORK IN ALFRED", "variables" : { "cleanQuery" : "false", "modifyQueryWith" : "do something" } }, "alt" : { "arg" : "hello world", "subtitle" : "Anführungszeichen", "variables" : { "cleanQuery" : "true", "modifyQueryWith" : "quotes" } }, "ctrl" : { "arg" : "hello world", "subtitle" : "scope:selection", "variables" : { "cleanQuery" : "false", "modifyQueryWith" : "scope:selection" } }, "cmd" : { "arg" : "hello world", "subtitle" : "Entferne scope:", "variables" : { "cleanQuery" : "false", "modifyQueryWith" : "remove scope" } }, "shift" : { "arg" : "hello world", "subtitle" : "Asterisks", "variables" : { "cleanQuery" : "true", "modifyQueryWith" : "asterisks" } } } } ] Edit: How can I use inline code in this forum? Backticks didn't work.
  11. Never would have found this, thanks! However Alfred's history only remembers the last 20 queries globally, not for each workflow. That doesn't help much I'm afraid. Any pointers which action (List or Script Filter) to use? I probably could create JSON via AppleScriptObjC however I hope there's an easier way.
  12. Thanks. Should have added that I invoke the workflow via hotkey. Alfred's history doesn't remember these, or am I missing something?
  13. Hi, first off I'm a complete workflow newbie. I'm using a workflow to initiate a search in a new DEVONthink window. Quite often I want to redo a search after some time but DEVONthink's "recent searches" dropdown doesn't list searches that were initiated via AppleScript (and even if they were included I'd still want to use Alfred). What's the easiest way to save workflow queries to later get back to them when using the workflow with a modifier? I know I can use the "Append To File" action or write the query into a file via AppleScript, but I've no idea what format I should write (a newline separated file? CSV? JSON?) because I've no idea what action to use to access the file. Already thought of simply using AppleScript's "choose from list" but finally want to learn how to write an Alfred workflow.
  14. There's a way to search workflows from a Time Machine Backup by name. It might seem like a lot of work but it's done in minutes. tl;dr: Replace the "plist" extension in a copied version of the "Alfred.alfredpreferences" Backup with "txt". Then search for whatever you recall from your lost workflows name. 1. Open your Time Machine Volume in Finder 2. Go to the desired Backup date 3. Go to file "Alfred.alfredpreferences" 4. Right click the file, then select "Show package contents" 5. Copy folder "workflows" 6. Paste the copied folder to your prefered destination (e.g. "/Users/USER/Desktop/") 7. Open the copied folder 8. Hit CMD + F to start a search 9. Click the Plus sign 10. Select "Dateisuffix" from the first drop down menue (guess it's something like "Filesuffix" in english) 11. Hit CMD + A to select all results 12. Right click the file, then select "X Objekte umbenennen" (should be something like "Rename X objects") 13. Select "Text auswählen" (should be "Replace text") 14. Type "plist" in the next field 15. Type "txt" in the next field 16. Go to the folder you've pasted in step 6.) 17. Hit CMD + F to start a search 18. Click the Plus sign 19. Select "Inhalt" from the first drop down menue (guess it's "Content" in english) 20. Type whatever you recall from your lost workflows name. By the way, deanishe, I've recently found your Fuzzy search workflow and it totally changed my use of DEVONthink databases. Thanks a lot!
×
×
  • Create New...