Jump to content

GuiB

Member
  • Content Count

    209
  • Joined

  • Last visited

  • Days Won

    12

GuiB last won the day on December 5 2018

GuiB had the most liked content!

3 Followers

About GuiB

  • Rank
    Member

Profile Information

  • Location
    Canada

Recent Profile Visitors

1,533 profile views
  1. From your screenshot it seems to be ok, but if you copy+pasted the string from Alfred to your post above when you say: then we can see there's a space after the "x" at "x -cardhop..." that shouldn't be there... So please try by removing this space if it's there or by copy pasting this: x-cardhop://show?id={uid} I hope this helps!
  2. @luckman212, yes to use the output of the script I would use an Alfred External Trigger that is triggered by the JXA so we can do something from Alfred. So, yes you can write to a file or directly use the argument to the Alfred External Trigger. I've made an example here: https://d.pr/f/2rzrt1 Here is the inside JXA script for those wanting to see directly without downloading: ObjC.import('Foundation') const args = $.NSProcessInfo.processInfo.arguments const argv = [] const argc = args.count for (let i = 0; i < argc; i++) { argv.push(ObjC.unwrap(args.objectAtIndex(i))) } delete args // Use argv[1] and up for the input arguments Progress.description = "Progress indicator; Input Args = " + argv[1] Progress.totalUnitCount = 25; for (var i = 1; i < 26; i++) { Progress.additionalDescription = "Step at: " + i Progress.completedUnitCount = i delay(0.1) } Application('Alfred 3').runTrigger('progress_bar', {inWorkflow: 'gbProgressBarExample', withArgument: "Total Count = " + Progress.totalUnitCount})
  3. @bivalvegruff, the output you wrote means that the preference is not set on you computer, you should see an output that only mention: org.yanex.marta Did you sent the second command as well? ( defaults delete -g NSFileViewer ) This one is meant to be use if you want to revert back to Finder and should then give the output that you have now when writing defaults read -g NSFileViewer . You can try again with the first command only ( defaults write -g NSFileViewer -string org.yanex.marta; ) Here is what I get on my side in the Terminal: $ defaults write -g NSFileViewer -string org.yanex.marta; $ defaults read -g NSFileViewer org.yanex.marta
  4. I also sometimes want to have a way to see some kind of progress (mainly to see if my process as complete), so I used an Automator Process that is called from Alfred so a gear icon appears in the menubar to clearly show that the script is running. However, it stays at 0 and quit when it's done. So, it is a little like what you are after. I thought why not run an AppleScript applet from Alfred and found a way that can also accept an argument to the applet using JXA. For some reasons, the on run argv doesn't work directly to get the input arguments so we need to use the Objective-C bridge. In short, you write a JXA application (applet) using Apple Script Editor that would do the action that you want while updating the progress bar. Move the bundled application into your Alfred Workflow directory and call it (start it) from Alfred using a Bash script like: open ./progress_example.app --args "$1" As for the JXA script, it should look like this (edit to make it do the things that you want...): ObjC.import('Foundation') const args = $.NSProcessInfo.processInfo.arguments const argv = [] const argc = args.count for (let i = 0; i < argc; i++) { argv.push(ObjC.unwrap(args.objectAtIndex(i))) } delete args // Modify what is here after so your applet makes the action that you want // Use argv[1] and up for the input arguments Progress.description = "Progress indicator; Input Args = " + argv[1] Progress.totalUnitCount = 25; for (var i = 1; i < 26; i++) { Progress.additionalDescription = "Step at: " + i Progress.completedUnitCount = i delay(0.1) } Here is an example in a Workflow: https://d.pr/f/rQPVmD So, if you want to see your progress directly in Alfred you can use the rerun feature or if you want to have a popup that shows you the progress while you do something else, then you can try my solution and see if it fit for you. Also, it should also be possible with cocoaDialog or something else, but I didn't have the time to try it at the moment.
  5. @bivalvegruff, did you restart your computer or session? If you write in terminal defaults read -g NSFileViewer you get org.yanex.marta as output? Myself, I'm always opening the files using the Reveal in Finder action (CMD+Enter on a standard search or with the Reveal in Finder file action) and it works great on my side. However, if you open your file using only Enter while doing the file search then it seems that you need to also set another preference to Marta like: defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add '{LSHandlerContentType="public.folder";LSHandlerRoleAll="org.yanex.marta";}' This is all the same as what is explained at the Forklift website, so you can have a look here to have some more info: https://binarynights.com/manual#fileviewer Hope this helps!
  6. Alfred uses the default file browser from your Mac. Finder is the default, but some alternatives (like Path Finder) add a preference to set them as the default file browser (taking the place of Finder). Therefore, to do what you want, it's not really related to Alfred, but to your computer configuration. You can set Marta as the default file browser with the command (inserted into the Terminal): defaults write -g NSFileViewer -string org.yanex.marta; And revert to Finder with this command (if you want to switch back): defaults delete -g NSFileViewer * Note that you would need to restart you computer to make the preference active. Alternatively, if you don't want to change your computer preferences, you can specify an application to open the folder from the Alfred File Actions menu. When you are selecting a folder from Alfred, just press your File Actions key (the one(s) that you've defined in the Alfred preferences) and use "Open With" action and select the Marta application and it should open your folder in Marta.
  7. @Jasondm007 sorry, it seems I skipped your message, but to answer rapidly, yes that's pretty much what you need to do to change the action or application that will be run with the fileAlias. Simply change the line: tell application AppName to ActionToDoOn fileAlias
  8. @michaelwills sorry for the long delay! I got too much work on my side with no free time. Things are starting to settle down Sorry that the nofile.io link is not working anymore. Actually, I had a small update on my side that I needed to push here ;) So here it is: Update Version 1.2.5 What’s new: Cardhop Actions list should be in your own language (I’m getting the localization from the Cardhop application directly, so you should get the same thing as in the application) Some bugs fix Download link: https://d.pr/f/rQTPtu @michaelwills regarding the coffee, actually, I like pretty much all kind of coffee :) I’m not very difficult All the best!
  9. @Jasondm007 Here is the same thing, but using AppleScript. In short, change the last Run Script to an AppleScript one with this script: on trim(theText) return (do shell script "echo \"" & theText & "\" | xargs") end trim on run argv set my text item delimiters to tab set theFileList to text items of (item 1 of argv) repeat with theFile in theFileList set fileAlias to (POSIX file trim(theFile) as alias) tell application "Finder" to move fileAlias to folder (path to downloads folder) end repeat end run Here is a new workflow with this inside in case it is easier to make it work: https://nofile.io/f/qvNgR5gw0pe/-+Example+File+Multi+Selection+Tests.alfredworkflow This one should work and give you something to play around when using AppleScript All the best!
  10. By removing this small part, you made it work as before. Like you said, while doing a real test I saw that the last element in the list of selection wasn't working and found out it was because of problem with whitespaces. So I trimmed the surround spaces with the trimmedPath="$(echo -e "${file}" | tr -d '[:space:]')" line and the trimmedPath variable include the file variable but trimmed. However, now I did more tests and found out there's still a bug with this line and now use an alternative using piping to xargs to do the trimming instead. Now, this seems to work, but again, let me know if you still have a problem! Here is the updated script for the Run Script: # Change IFS to TAB and expand into an array IFS=$'\t' filesListArr=($@) # Loop over the file list array for file in "${filesListArr[@]}" do trimmedPath="$(echo -e "${file}" | xargs)" # Your script to be run mv -i "$trimmedPath" ~/Downloads done Here is your script but updated with this fix: https://nofile.io/f/hjT4JFt6AVw/-+Example+File+Multi+Selection+Tests.alfredworkflow And here is my workflow with this fix: https://nofile.io/f/c8K4KEpkjWa/Example+File+Multi+Selection.alfredworkflow --------- To explain a little more why the other script doesn't work, but worked before on my side. The problem is that I was removing all the space in the file path, while the second one doesn't (it just trim the begining and end of the string; which is what I wanted in the begining, but did it too fast ). I'm used to never insert space on my file name, so that's why it worked before. But, now I tested iton a file that's inside my "Google Drive" and it removed the space inside to output it like "GoogleDrive" and broke it. Now we should be good
  11. Ok, I've tested it with a real action to do on each file. I didn't tested completely before, I just tested by outputing the path string to look at it, but now tested to do a real action on multiple files (copy them to a new file) and saw that the it didn't work on the last file in the list. So a little trimming to remove the whitespace on the file path worked. Therefore, here is an updated version that should work! @Jasondm007 sorry for the little problems with my other versions. I think this one is good now, but let me know if you still have problem! Here is the link to the new workflow: https://nofile.io/f/nTBEXw6Ku3U/File+Multi+Selection+&amp;+OCR_Keywords.alfredworkflow And here the modified script for the Run Script that execute the action # Change IFS to TAB and expand into an array IFS=$'\t' filesListArr=($@) # Loop over the file list array for file in "${filesListArr[@]}" do trimmedPath="$(echo -e "${file}" | tr -d '[:space:]')" # Your script to be run automator -i "$trimmedPath" "/Users/NAME/Library/Services/NAME.workflow" done
  12. @Jasondm007 I just thought this morning that we don't have to create a new string if we combine both of our version... just need to update the array in the AppleScript and set the text item delimter to tab and output the array as a string. So here is my new version set my text item delimiters to tab tell application "Finder" to set theSelection to selection as alias list repeat with i from 1 to count of theSelection set item i of theSelection to POSIX path of item i of theSelection as string end repeat return theSelection as text And an updated Workflow example here: https://nofile.io/f/aqMoJwmGf8O/File+Multi+Selection+&amp;+OCR_Keywords.alfredworkflow
  13. Yes, if you look inside the AppleScript node, I've set it as you did. However, now that you mention that, you're right that the first path uses /Users/ and the other /Macintosh HD/. I tried another way before switching to yours since I didn't test it first and then when I tested your I thought everything was fine. But my other version was to loop over the Finder selection to build a string delimited by TAB. I've tried again my version and with it I get all "/Users/" kind of paths Here is my modified AppleScript code: tell application "Finder" to set theSelection to selection as alias list set theFileList to "" repeat with i from 1 to count of theSelection set theFileList to theFileList & "\t" & POSIX path of item i of theSelection as string end repeat return theFileList And here is the new Workflow if you want to see it: https://nofile.io/f/scHz3m70RpG/File+Multi+Selection+&amp;+OCR_Keywords.alfredworkflow Let me know how it goes!
  14. To simulate a left or right arrow key press you can use the Dispatch Key Combo action inside the Output > Dispatch Key Combo menu. Alternatively, you can use AppleScript, for example: -- To execute a left arrow key press tell application "System Events" to key code 123 -- To execute a right arrow key press tell application "System Events" to key code 124 You can have a look here for some reference on key code: https://eastmanreference.com/complete-list-of-applescript-key-codes
  15. @Jasondm007 I've updated the script for you to work with a multi selection. In short, you were not too far from having it. It's mainly your loop over your file list. I have changed it to: # Change IFS to TAB and expand into an array IFS=$'\t' filesListArr=($@) # Loop over the file list array for file in "${filesListArr[@]}" do # Your script to be run automator -i "$file" "/Users/NAME/Library/Services/NAME.workflow" done Here is the updated workflow: https://nofile.io/f/8ugP4mSgOMu/File+Multi+Selection+&amp;+OCR_Keywords.alfredworkflow Also, I've edited every action to work with a multi selection, so you get an example with a File Action, a Hotkey and a Keyword action
×
×
  • Create New...