Hook's Alfred workflow on Alfred's workflows forum

Earlier we shared an Alfred Workflows for Hook. That workflow is now listed on the Alfred App Community Forum’s Share your Workflows list. (Not actually uploaded there since they seem to have a 131kb limit.)

Our Alfred workflow has moved from /help2/… to /help/automation/alfred-workflows/. We’ll migrate the rest of the “help2” content into the main help section (/help) as part of the reorganization of Hook’s documentation, replacing the /help2/… pages with links and or redirects.

1 Like

The hm .pdf doesn’t seem to work. hm works fine, but the pdf one doesn’t show up

Hi,

The ‘hm pdf’ doesn’t not work.

The argument can’t be longer than one character

Alfred does some filtering on the first character. E.g. ‘hm p’ will change the list, but as soon as a second letter ( hm pd) is punched Alfred will switch to google search.

As fare as I can see in the version 1 of the workflow applescript doesn’t support filtering on the argv

Hook version 1.8
macos 10.15.6
Alfred. 4.1.1
Workflow. Version 1

Very best regards

Jens

Welcome to the Hook Productivity Forum @yashodhankhare and @jkjelsbak. Thanks for letting us know. And Sorry about that. I forgot to upload the latest version (1.1) of the Alfred workflow from one of our Alfred using devs here (I, myself, use LaunchBar). The new one (1.1) is now linked from our Alfred Workflows for Hook page.

3 Likes

Hi LucB,

Thanks for your attention. As fare as I can see the version1.1 zip container have version 1 of the workflow.

Very best regards

Jens Kjelsbak

Thanks Luc, I’ll check and revert

If I type hm and wait for a second or I type a word, the it shows relevant hooked articles. But hm pdf doesn’t do work. What am I doing wrong?

Rats and regrets. I hate it when that happens. (My Finder downloads had multiple copies.) Re-uploaded so the link from Alfred Workflows for Hook – Hook, a page which has not changed, points to to the new version at the same URL. (I don’t share the specific download URL here so that people can pick up the workflow file from this link for versions > 1.1 of the workflow too.

Thanks, this me gets the job done

2 Likes

EDIT: :joy: Of course I decide to try Hook on the day that v2.0 comes out. I’ll leave this post for now, but mods feel free to remove it since it looks like you’re in the process of updating everything.

I’m not sure if I’m running into an error because I’m on Big Sur, or v2.0 of Hook, but this Alfred workflow is not working for me. I made some changes and managed to get it working. Not sure if I broke anything unintentional in the process, but here’s the changes if anyone else is running into issues.

What did I change?

  1. Removed all in set _allBookmarks to all bookmarks
  2. Renamed the title reference of the Hook item to name instead of title in the if argv conditional and set _bookmark line.
use framework "Foundation"

on run argv
	
    -- For troubleshooting in Script Editor
    -- set argv to {}
	
	tell application "Hook"
		set _allBookmarks to bookmarks
		set _listOfUrls to {}
		set re1 to a reference to _listOfUrls
		set re2 to a reference to _allBookmarks
				
		repeat with i from 1 to (count re2)
			set _theItem to item i of re2
			
			if argv is equal to {} or name of _theItem contains argv or address of _theItem contains argv then
				set _bookmark to {title:name of _theItem, subtitle:address of _theItem, arg:address of _theItem, icon:"com.cogsciapps.hook"}
				copy _bookmark to end of re1
			end if
		end repeat

		if _listOfUrls is not {} then
			set {_jsonData, _jsonError} to current application's NSJSONSerialization's dataWithJSONObject:_listOfUrls options:0 |error|:(specifier)
			if _jsonData is missing value then error (_jsonError's localizedDescription() as text) number -10000
			set res to current application's NSString's alloc()'s initWithData:_jsonData encoding:(current application's NSUTF8StringEncoding)
			return ("{\"items\":" & res as text) & "}"
		end if
		
		return "{\"items\":[]}"
	end tell
end run

This fixed mine. Thanks!

Edit: I uploaded an updated version (1.2 with above script and the v2 logo) here

1 Like

Thanks for reporting and fixing this. we will have a look asap.

1 Like

Where/how do I edit this script as @kennonb suggested above?

  1. Invoke Alfred
  2. Press CMD+COMMA (,)
  3. Go to Workflows
  4. Search for “Hook”
  5. Double-click “hm Script Filter” in the right-side pane
  6. Copy & paste the above script into the editor window, replacing what is currently in there.
2 Likes

Thanks! When I double click on the “hm Script Filter” box, I only see a few lines of code:

#open a hook bookmark
on run argv
open location item 1 of argv
end run

I was under the impression from your previous post that there should be more code in there? I just want to be sure I’m replacing the correct code.

I suppose this workflow needs a little update after the rebranding of Hook to Hookmark? The script in the trigger still refers to Hook.

1 Like

Simple fix here - Browse Hook Bookmarks - Share your Workflows - Alfred App Community Forum

1 Like

Does anyone know if its possible to invoke a new hookmark from within Alfred? I quite often find myself searching for something in Alfred which I then need to add a hook to, but the only way to do it right now is to open or browse to the file and hook from there. It would be great if I could skip the middle step and simply add a Hookmark right from Alfred.

1 Like

You can implement this with the help of Hook CLI and Alfred Workflow, theoretically. @bishblaize

2 Likes

Huh, that was easy, thanks for the tip.

Installed the CLI, made a new workflow. Linked a Universal Action Trigger to a script Action. It only took one line (hook cp {query}) and it worked.

Might see else I can get it to do.

3 Likes