Open floating window with URL from argument

Hi @Andreas_Hegenberg, are use mini floating windows to open different websites like chatGPT, however I have to configure this floating views with a specific URL. Is there a way for me to configure floating view and pass in the URL via an argument? I will be triggering this via callback URLs from Alfred or elsewhere. An example would help. Thank you

yes, I’ll post an example later!

buzzing for help @Andreas_Hegenberg

The easiest is probably to use the "Load New HTML or URL for Webview Item" action.

You can also easily trigger this from Apple Script from Alfred or similar. For example



tell application "BetterTouchTool"
	trigger_action "{
  BTTPredefinedActionType: 397,
  BTTAdditionalActionData: {
  	BTTMenuActionMenuItemContentHTML: 'https://apple.com', BTTMenuActionMenuName: 'YourMenuName', BTTMenuActionMenuItemName: 'YourWebviewName'}
}"
	
	
end tell

In one of the previous posts, you had mentioned that this is being replaced with Show Floating WebView. Is that accurate, or is it vice versa.

I was mostly hoping if there is a way to do external BTT URL call and pass in a argument. That possible?

I don't think I mentioned this. The "Load New HTML or URL for Webview Item" is very new and won't get replaced by anything.

you can also do that using an URL instead of Apple Script, however for URL's it will always give focus to BTT. In general Apple Script is probably the best solution to trigger things from Alfred.

open "btt://trigger_action/?json={BTTPredefinedActionType: 397,  BTTAdditionalActionData: { BTTMenuActionMenuItemContentHTML: 'https://apple.com', BTTMenuActionMenuName: 'YourMenuName', BTTMenuActionMenuItemName: 'YourWebviewName'}}"

I've been using these to render webpages. This is the correct one right?


I also see :arrow_down: , which i don't know how it's different from the above one I mentioned. Can you clarify?

Yes that's correct!

Yep, that is the action I meant. You can either trigger it directly from BTT like in your second screenshot or dynamically via Apple Script (or e.g. the trigger URL) from an external app. It depends a bit what exactly you are trying to do (there are also various other ways to load dynamic content into a webview - maybe describe exactly what you want to do using a concrete example, then I can think about the best solution)

What I'm trying to do:

right now I have to open floating view every time (for ChatGPT) and then type in the search string. I want to use Alfred to get input search string and open ChatGPT in Floating View with that search string.

Basically I want to populate this URL https://chatgpt.com?q=<INPUT RECEIVED FROM ALFRED> in BTT Floating View.

An example preset would be great (if possible)

PS: BTW, I'm using Toggle Floating View, instead of Load New HTML. Any difference in floating view vs load new html?

how are you currently calling the opening of the webview from alfred? Can you run apple script from alfred or do you need some other way?

I basically want two things:

  1. pressing fn+c opens ChatGPT in floating view
  2. searching for string via alfred opens floating view with that query param in url.

I can run applescript from alfred but then i still need to execute applescript in btt coz of the 1st feature i want.

i guess if you can tell me how to create a container floating view and how it can open any url, which can be passed in via applescript and within btt somehow

So the easist would be to combine the two actions "Toggle Floating Menu Hidden/Shown" and the action "Load New HTML / URL For Web View Menu Item".

Here is an Apple Script that you could call from Alfred:

tell application "BetterTouchTool"
	trigger_action "{
  BTTPredefinedActionType: 388,
  BTTPredefinedActionName: 'Toggle Floating Menu Hidden or Shown',
  BTTAdditionalActionData: {BTTMenuActionMenuID: 'YourMenuName'}
}"
	
	trigger_action "{
  BTTPredefinedActionType: 397,
  BTTPredefinedActionName: 'Load New HTML Or URL For Web View Menu Item',
  BTTAdditionalActionData: {
      BTTMenuActionMenuItemContentHTML : 'https://apple.com', 
      BTTMenuActionMenuName: 'YourMenuName',
      BTTMenuActionMenuItemName: 'YourWebviewName'}
}"
	
	
end tell

You need to replace the "YourMenuName", "YourWebviewName" placeholders and provide the alfred input instead of https://apple.com

Hi @Andreas_Hegenberg,

Following this idea, would it be possible to combine the Floating WebView with the Did URL Open JavaScript to open an URL in different browsers?

For example, right now I'm using the Did URL Open trigger to check if Option key is held, open in a different browser. Would it be possible to, let's say, check if Control is pressed; then open in the Floating WebView? Any ideas on how to orchestrate that?

Thanks.

@Andreas_Hegenberg, do you know if this would be possible?

Thanks in advance.

Hi @Andreas_Hegenberg,

Sorry to bother you. Is it possible to open an URL with the Floating WebView while processing it with the URL Handler trigger?

In general is possible, but most likely not in the way you'd need. Browsers don't allow to intercept the urls they open, thus the "Did Open URL" trigger only works if a URL is opened from a non-browser application.

To do this within a browser, you'd need a browser extension to intercept the links.

Thanks @Andreas_Hegenberg

Yes, of course, I meant for when clicking outside of a browser. That's the way I'm actually using it right now, e.g. to open Calendar invites in Google Meet PWA.

So you say it would be possible to, for example, when "clicking an URL and holding the Option key", make it display a "preview" of the website on a Floating Webview?

Do you have any example JavaScript code I could use in the URL handler of the "Did Open URL" trigger to open a Floating Webview instead of opening in a browser?

Thanks.

Hi @Andreas_Hegenberg,

Would it be possible to open a Floating WebKit View with an URL from the "Did Open URL" handler?