How to access item dragged onto menu?

I can't figure out how to retrieve an item dragged onto my floating menu. I spent a few hours on this before it occurred to me - maybe this isn't possible?

I'd like to drag a URL (while in the browser) onto the floating menu, in order to trigger an action that is supposed to pass the URL to a shell script. Except I am stuck on accessing the value of the URL. I tried everything I could come up with. Any help is appreciated.

You should drag it onto a menu item, then you can use get_menu_item_value.

However this contains the full dragging pasteboard contents which would need to be parsed. For example with apple script a simple dragged url would look like this with all the meta info:

Formatted this would be

{
   "com.apple.pasteboard.promised-file-content-type":[
      {
         "uti":"com.apple.pasteboard.promised-file-content-type",
         "value":"com.apple.web-internet-location",
         "timestamp":"2025-09-10T09:27:30Z",
         "type":"text"
      }
   ],
   "com.apple.pasteboard.NSFilePromiseID":[
      {
         "type":"base64",
         "value":"wKvisAsAAAA=",
         "uti":"com.apple.pasteboard.NSFilePromiseID",
         "timestamp":"2025-09-10T09:27:30Z"
      }
   ],
   "com.apple.pasteboard.promised-file-url":[
      {
         "value":"",
         "type":"base64",
         "uti":"com.apple.pasteboard.promised-file-url",
         "timestamp":"2025-09-10T09:27:30Z"
      }
   ],
   "public.utf8-plain-text":[
      {
         "timestamp":"2025-09-10T09:27:30Z",
         "uti":"public.utf8-plain-text",
         "value":"https:\/\/community.folivora.ai\/t\/how-to-access-item-dragged-onto-menu\/45060",
         "type":"text"
      }
   ],
   "dyn.ah62d4rv4gu8y6y4usm1044pxqzb085xyqz1hk64uqm10c6xenv61a3k":[
      {
         "value":"YnBsaXN0MDCgCAAAAAAAAAEBAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAJ",
         "timestamp":"2025-09-10T09:27:30Z",
         "type":"base64",
         "uti":"dyn.ah62d4rv4gu8y6y4usm1044pxqzb085xyqz1hk64uqm10c6xenv61a3k"
      }
   ],
   "public.url-name":[
      {
         "uti":"public.url-name",
         "timestamp":"2025-09-10T09:27:30Z",
         "type":"text",
         "value":"How to access item dragged onto menu? - Floating Menus \/ Widgets - BetterTouchTool Community"
      }
   ],
   "com.apple.NSFilePromiseItemMetaData":[
      {
         "timestamp":"2025-09-10T09:27:30Z",
         "uti":"com.apple.NSFilePromiseItemMetaData",
         "value":"YnBsaXN0MDDRAQJfEC9jb20uYXBwbGUucGFzdGVib2FyZC5wcm9taXNlZC1maWxlLWNvbnRlbnQtdHlwZV8QH2NvbS5hcHBsZS53ZWItaW50ZXJuZXQtbG9jYXRpb24ICz0AAAAAAAABAQAAAAAAAAADAAAAAAAAAAAAAAAAAAAAXw==",
         "type":"base64"
      }
   ],
   "dyn.ah62d4rv4gu8zs3pcnzme2641rf4guzdmsv0gn64uqm10c6xenv61a3k":[
      {
         "timestamp":"2025-09-10T09:27:30Z",
         "value":"YnBsaXN0MDCiAQOhAl8QSmh0dHBzOi8vY29tbXVuaXR5LmZvbGl2b3JhLmFpL3QvaG93LXRvLWFjY2Vzcy1pdGVtLWRyYWdnZWQtb250by1tZW51LzQ1MDYwoQRfEFxIb3cgdG8gYWNjZXNzIGl0ZW0gZHJhZ2dlZCBvbnRvIG1lbnU\/IC0gRmxvYXRpbmcgTWVudXMgLyBXaWRnZXRzIC0gQmV0dGVyVG91Y2hUb29sIENvbW11bml0eQgLDVpcAAAAAAAAAQEAAAAAAAAABQAAAAAAAAAAAAAAAAAAALs=",
         "type":"base64",
         "uti":"dyn.ah62d4rv4gu8zs3pcnzme2641rf4guzdmsv0gn64uqm10c6xenv61a3k"
      }
   ],
   "com.apple.Safari.bookmarkDictionaryList":[
      {
         "uti":"com.apple.Safari.bookmarkDictionaryList",
         "value":"YnBsaXN0MDChAdQCAwQFBgcICV8QD1dlYkJvb2ttYXJrVVVJRFlVUkxTdHJpbmdfEA9XZWJCb29rbWFya1R5cGVdVVJJRGljdGlvbmFyeV8QJDUxMUZDQkU1LTZFNDEtNDE4OC1CQUJFLUMxMjZGRjAxOEM1OF8QSmh0dHBzOi8vY29tbXVuaXR5LmZvbGl2b3JhLmFpL3QvaG93LXRvLWFjY2Vzcy1pdGVtLWRyYWdnZWQtb250by1tZW51LzQ1MDYwXxATV2ViQm9va21hcmtUeXBlTGVhZtEKC1V0aXRsZV8QXEhvdyB0byBhY2Nlc3MgaXRlbSBkcmFnZ2VkIG9udG8gbWVudT8gLSBGbG9hdGluZyBNZW51cyAvIFdpZGdldHMgLSBCZXR0ZXJUb3VjaFRvb2wgQ29tbXVuaXR5AAgACgATACUALwBBAE8AdgDDANkA3ADiAAAAAAAAAgEAAAAAAAAADAAAAAAAAAAAAAAAAAAAAUE=",
         "type":"base64",
         "timestamp":"2025-09-10T09:27:30Z"
      }
   ],
   "com.apple.Safari.bookmarkStatistics":[
      {
         "timestamp":"2025-09-10T09:27:30Z",
         "value":"YnBsaXN0MDDSAQIDBFtGb2xkZXJDb3VudFpUb3RhbENvdW50EAAQAQgNGSQmAAAAAAAAAQEAAAAAAAAABQAAAAAAAAAAAAAAAAAAACg=",
         "type":"base64",
         "uti":"com.apple.Safari.bookmarkStatistics"
      }
   ],
   "com.apple.pasteboard.promised-file-name":[
      {
         "value":"",
         "type":"base64",
         "timestamp":"2025-09-10T09:27:30Z",
         "uti":"com.apple.pasteboard.promised-file-name"
      }
   ],
   "dyn.ah62d4rv4gu8yc6durvwwa3xmrvw1gkdusm1044pxqyuha2pxsvw0e55bsmwca7d3sbwu":[
      {
         "type":"base64",
         "uti":"dyn.ah62d4rv4gu8yc6durvwwa3xmrvw1gkdusm1044pxqyuha2pxsvw0e55bsmwca7d3sbwu",
         "timestamp":"2025-09-10T09:27:30Z",
         "value":"YnBsaXN0MDChAV8QH2NvbS5hcHBsZS53ZWItaW50ZXJuZXQtbG9jYXRpb24ICgAAAAAAAAEBAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAs"
      }
   ],
   "com.apple.pasteboard.promised-suggested-file-name":[
      {
         "timestamp":"2025-09-10T09:27:30Z",
         "type":"text",
         "value":"How to access item dragged onto menu? - Floating Menus - Widgets - BetterTouchTool Community.webloc",
         "uti":"com.apple.pasteboard.promised-suggested-file-name"
      }
   ],
   "public.url":[
      {
         "uti":"public.url",
         "value":"https:\/\/community.folivora.ai\/t\/how-to-access-item-dragged-onto-menu\/45060",
         "type":"text",
         "timestamp":"2025-09-10T09:27:30Z"
      }
   ]
}

I would recommend to use a little Java Script for this. This should work for most standard url formats.

async function getItemValue() {
   let itemVal = await get_menu_item_value({'item_uuid': '238947BA-766A-49CA-AED0-323B893A10CE'});
   
   let parsed = JSON.parse(itemVal);
   let url = parsed["public.url"]?.[0]?.value;
   return url;
}

Afterwards it depends what you want to do with the url, you could directly run the shell script from the JS as well:

async function getItemValue() {
   let itemVal = await get_menu_item_value({'item_uuid': '238947BA-766A-49CA-AED0-323B893A10CE'});
   
   let parsed = JSON.parse(itemVal);
   let url = parsed["public.url"]?.[0]?.value;
   
    let shellScript = `open "${url}"`;

    let shellScriptWrapper = {
        script: shellScript
    };

    let result = await runShellScript(shellScriptWrapper);
    return result;
}
1 Like

Thanks @Andreas_Hegenberg, I really appreciate your help.

I wasn't able to get it working even though everything looked correct, but I now have a bigger problem - I managed to brick the config when I added another menu item, it inadvertently crashed the app. It's now crashing as soon as it opens. Going to try downgrading from alpha to the latest stable to see if it helps.

Could you post the crash log? (you can access it in the macOS console app's crash report section)

You can enable safe mode for BTT via this terminal command:

defaults write com.hegenberg.BetterTouchTool BTTSafeModeEnabled YES

Here is a example floating menu that speaks out any dropped url via the say terminal command:

drop-to-speak.bttpreset (16.3 KB)

btt-crashlog.txt (50.2 KB)

Log attached. Thanks for that terminal command :melting_face:

Ah unfortunately that is a very generic crashlog. If you can open BTT in safe mode, can you try to copy & paste or export the broken menu ? (or go to Help => Export Diagnostic Debug Information and send the result to andreas@folivora.ai)

Emailed you the logs. I was able to undo the cause of the app crashing thanks to your safemode command. The issue arose when I added the Folder View widget. Soon as I removed it I was able to run the app normally again.

Much appreciated. This is incredibly helpful. I didn't want to test on a shell invocation so I was calling set_clipboard_content. My mistake was in not realizing that call writes to BTT's own clipboard.
Thank you again for your time and support. I bought a license 15 years ago and it was easily the best money I ever spent on software.

Actually it should write to the system clipboard! If it doesn't work, maybe post the code then I can try here

I'll check whether I can reproduce the folder widget issue