No internet connection
  1. Home
  2. How to

Go to URL?

By Martin Pavey @Martin_Pavey
    2020-01-08 18:20:04.633Z

    Hi There and Happy New Year!
    I wondered can you go to a URL in SoundFlow.
    I have a macro in KM that opens Safari navigtes to Wetransfer and then logs in for me.
    Is there a way to replicate that in SF
    Thanks

    Solved in post #2, click to view
    • 27 replies

    There are 27 replies. Estimated reading time: 15 minutes

    1. Hi Martin,

      Happy New Year to you too :)
      Hope you got some well deserved time off over the holidays!

      Yes you can go to a URL in SF in several ways.

      Here's one example via macros:
      https://forum.soundflow.org/-1084/go-to-a-website

      Basically that post says you can use the "Open File" action in a macro.
      The "Path" would be the URL (complete with http:// or https:// in the beginning)
      The "Application" would be your choice of app and is optional - that is, if you don't specify an app it will just use the system's default browser choice - for example:

      Reply1 LikeSolution
      1. MMartin Pavey @Martin_Pavey
          2020-01-14 19:37:59.109Z

          Thanks Christian,
          That's really nice and simple, I'll give it a go.
          Cheers
          Martin

          1. In reply tochrscheuer:

            Is there a way to copy the URL of the current web page to the clipboard?

            1. Kitch Membery @Kitch2020-06-23 23:43:29.640Z

              Hi Jonathan!,

              If you are using Safari... Somthing like this should do it;

              //Open Safari's main window
              sf.ui.app('com.apple.Safari').appActivateMainWindow();
              
              //Get the URL from the front most page and store it as a Variable
              var urlValue = sf.ui.app('com.apple.Safari').mainWindow.children.whoseRole.is("AXToolbar").first.groups.allItems[1].children.whoseRole.is("AXSafariAddressAndSearchField").first.textFields.first.value.value;
              
              //Store the URL in the clipboard (ready for pasting later);
              sf.clipboard.setText({text:urlValue});
              
              1. Thanks Kitch....

                I get this error

                24.06.2020 09:42:57.27 [Backend]: Error: Parent's UIElement was null:
                (YT CONVERTER line 5)

                1. Kitch Membery @Kitch2020-06-26 00:10:11.248Z2020-06-26 01:40:21.370Z

                  Try this one @Jonathan_Grossman

                  var app = sf.ui.app('com.apple.Safari');
                  
                  //Get URL
                  var urlValue = sf.ui.app('com.apple.Safari').mainWindow.children.whoseRole.is("AXToolbar").first.groups.allItems[1].textFields.whoseDescription.is('smart search field showing a secure address').first.value.invalidate().value;
                  
                  //Copy url to clipboard
                  sf.clipboard.setText({text:urlValue});
                  
                  log(urlValue);
                  

                  Note: You'll need to have a safari page open with a valid URL for this to work.

                  Also, What is the larger workflow for this as using the OSX clipboard may not be neccisary.

                  Rock on!

                  1. still didn't work.

                    25.06.2020 17:48:33.29 [Backend]: Javascript error with innerexception: System.Exception: Parent's UIElement was null:
                    at SoundFlow.Shortcuts.Ax.AxNodes.AxNode.RequireParentUI() + 0x82
                    at SoundFlow.Shortcuts.Ax.AxNodes.AxStringOrIntProperty.<get_Value>b__6_0() + 0x13
                    at SoundFlow.Shortcuts.Ax.AxNodes.AxNode.GetOrCreateValue[TValue](TValue&, Func`1) + 0x24
                    at sfbackend!+0x14f30af
                    at sfbackend!+0x3349ae
                    Error: Parent's UIElement was null:
                    (YT CONVERTER line 5)

                    I'm using it to grab the URL to then use Softorino's YouTube converter to download the video to my desktop.

                    Here's the script that is working. Clunky, but gets the job done.

                    sf.ui.app('com.apple.Safari').mainWindow.children.whoseRole.is("AXToolbar").first.groups.allItems[3].mouseClickElement({
                    relativePosition: {"x":120,"y":10},
                    });

                    sf.keyboard.press({keys: "cmd+c",});

                    sf.app.launch({
                    path: "/Applications/Softorino YouTube Converter 2.app",
                    });

                    sf.ui.app('com.softorino.syc2').appActivateMainWindow();

                    sf.ui.app('com.softorino.syc2').appWaitForActive();

                    sf.wait({intervalMs: 2000,});

                    sf.ui.app('com.softorino.syc2').mainWindow.buttons.whoseTitle.is('Convert & Transfer To Desktop').first.elementClick();

                    sf.soundflow.runCommand({ commandId: 'user:ck97eizr4001bpr10qticegxn:ckbsbbojc0001jv10ue2n6sjn' });

                    1. Kitch Membery @Kitch2020-06-26 01:07:23.507Z

                      BTW... For easy readability... When entering code into the forum, you can put a line of three back ticks ```` , then on the next line add the code you want to display, follwed by another line of 3 back ticks ``` The "back tick" key is the key below the Escape key on a mac keyboard.

                      Three back ticks on there own line before and after the code translates to this; (Use this for a block of code)

                      //Code between back ticks
                      

                      Here is a screen shot of the above in the forum post editor.

                      If you just want to add a single line of code add one backtick before and after the code translates to this;

                      //Code between back ticks

                      Here is a screen shot of the above in the forum post editor.

                      1. Kitch Membery @Kitch2020-06-26 01:29:08.394Z

                        Are you on OS X Catalina by chance? As I'm seeing the same error as you on my laptop running Catalina. My script is working fine on High Sierra. I'll take a closer look at it later.

                        1. Kitch Membery @Kitch2020-06-26 01:44:43.996Z

                          Jonathan,

                          Can you try just this code;

                          var app = sf.ui.app('com.apple.Safari');
                          
                          //Get URL
                          var urlValue = sf.ui.app('com.apple.Safari').mainWindow.children.whoseRole.is("AXToolbar").first.groups.allItems[1].textFields.whoseDescription.is('smart search field showing a secure address').first.value.invalidate().value;
                          
                          //Copy url to clipboard
                          sf.clipboard.setText({text:urlValue});
                          
                          log(urlValue);
                          

                          And see if that works...

                          1. 25.06.2020 18:49:37.57 [Backend]: Javascript error with innerexception: System.Exception: Parent's UIElement was null:
                            at SoundFlow.Shortcuts.Ax.AxNodes.AxNode.RequireParentUI() + 0x82
                            at SoundFlow.Shortcuts.Ax.AxNodes.AxStringOrIntProperty.<get_Value>b__6_0() + 0x13
                            at SoundFlow.Shortcuts.Ax.AxNodes.AxNode.GetOrCreateValue[TValue](TValue&, Func`1) + 0x24
                            at sfbackend!+0x14f30af
                            at sfbackend!+0x3349ae
                            Error: Parent's UIElement was null:
                            (get url line 4)

                            << Command: get url [user:ck97eizr4001bpr10qticegxn:ckbvk4t0s000ngq10o5u7tn2w]

                            1. Kitch Membery @Kitch2020-06-26 02:55:37.442Z

                              I'm not sure why that's happening,

                              Here is a manual workaround... Let me know if it works.

                              //Switch to Safari
                              sf.ui.app('com.apple.Safari').appActivateMainWindow();
                              
                              //Open URL Field
                              sf.ui.app('com.apple.Safari').menuClick({
                                  menuPath: ["File", "Open Location…"],
                                  targetValue: "Enable",
                              });
                              
                              //Copy URL to clipboard
                              sf.ui.app('com.apple.Safari').menuClick({
                                  menuPath: ["Edit", "Copy"],
                              });
                              

                              This should load your clipboard with the URL, ready for pasting.

                              1. @Jonathan_Grossman I think you replied directly to the email from the forum marked as "don't reply to this email", so your reply never made it here.

                            2. In reply toKitch:
                              MMatt Friedman @Matt_Friedman
                                2024-04-12 01:44:04.332Z

                                Hi Kitch,

                                Sorry to bump an old thread here but I'm seeing an issue, possibly Soundflow or externally related.

                                I'm trying to do something like this, get the browser URL. I'm doing this with all the big browsers, but Firefox is having issues though.

                                I used the SF picker to get the following path for Firefox's URL bar:

                                log(sf.ui.app("org.mozilla.firefox").mainWindow.groups
                                    .whoseTitle.startsWith("Google")
                                    .first.children.whoseRole.is("AXToolbar")
                                    .whoseTitle.is("Navigation")
                                    .first.comboBoxes.whoseValue.startsWith("http")
                                    .first.textFields.whoseDescription.is("Search with Google or enter address")
                                    .first.invalidate().value.value)
                                

                                So after using the SF picker, everything works. But if I relaunch Firefox, and run this again, I get the following errors:

                                Couldn't get item #0 as the array's parent node wasn't found - sf.ui.app('org.mozilla.firefox').<unknown>.groups.whoseTitle.startsWith('Google').first.children.whoseRole.is('AXToolbar').whoseTitle.is('Navigation').first.comboBoxs.whoseValue.startsWith('http').first.textFields (AxElementArrayIndexedItem)
                                

                                It seems like Soundflow can only successfully find Firefox's URL after I've used SF's pick command. Once it's been Picked in the editor, this code works as expected. Otherwise, under all normal usages, it errors instead.

                                Any ideas?

                                1. Kitch Membery @Kitch2024-04-12 02:18:24.494Z

                                  Hi @Matt_Friedman,

                                  The issue you are experiencing does not seem like a SoundFlow bug.

                                  The first group you are referencing is specific to the Google tab that your original URL was on when you picked the UI element.

                                  I've not fully tested... but try changing your code to the following.

                                  const activeTabUrl = sf.ui.app("org.mozilla.firefox").mainWindow.groups
                                      .first.children.whoseRole.is("AXToolbar")
                                      .whoseTitle.is("Navigation")
                                      .first.comboBoxes.whoseValue.startsWith("http")
                                      .first.textFields.whoseDescription.is("Search with Google or enter address")
                                      .first.value.invalidate().value;
                                  
                                  log(activeTabUrl)
                                  

                                  I hope that helps.

                                  1. MMatt Friedman @Matt_Friedman
                                      2024-04-12 03:28:05.937Z

                                      Sadly that still has similar error

                                      Couldn't get item #0 as the array's parent node wasn't found - sf.ui.app('org.mozilla.firefox').<unknown>.groups.first.children.whoseRole.is('AXToolbar').whoseTitle.is('Navigation').first.comboBoxs.whoseValue.startsWith('http').first.textFields (AxElementArrayIndexedItem)
                                      
                                      1. Kitch Membery @Kitch2024-04-12 03:29:57.051Z

                                        Am away from my computer right now but will take a look when I get a moment.

                                        1. In reply toMatt_Friedman:
                                          Kitch Membery @Kitch2024-04-12 03:40:54.376Z

                                          Try this...

                                          const url = sf.system.execAppleScript({
                                              script: `tell application "System Events" to get value of UI element 1 of combo box 1 of toolbar "Navigation" of first group of front window of application process "Firefox"`
                                          }).result;
                                          
                                          log(url)
                                          
                                          1. MMatt Friedman @Matt_Friedman
                                              2024-04-12 03:49:57.843Z

                                              Almost I think? It's returning an empty string at the moment

                                              1. Kitch Membery @Kitch2024-04-12 03:53:49.383Z

                                                This is working for me.

                                                Is the URL field in Firefox empty?

                                                1. In reply toMatt_Friedman:
                                                  Kitch Membery @Kitch2024-04-12 03:56:57.606Z

                                                  You could also give this one a go...

                                                  const activeTabUrl = sf.ui.app("org.mozilla.firefox").mainWindow.groups
                                                      .first.children.whoseRole.is("AXToolbar")
                                                      .whoseTitle.is("Navigation")
                                                      .first.comboBoxes
                                                      .first.textFields
                                                      .first.value.invalidate().value;
                                                  
                                                  log(activeTabUrl)
                                                  
                                                  1. MMatt Friedman @Matt_Friedman
                                                      2024-04-12 04:04:03.155Z

                                                      Hmm Still nothing here. I get either that error with the sf.ui version or nothing from the AppleScript. And the browser is open to an active page.

                                                      1. Kitch Membery @Kitch2024-04-12 04:07:06.120Z

                                                        The screenshot message you are seeing is at the top of the log. Can you scroll to the bottom of the log and try again?

                                                        1. In reply toMatt_Friedman:
                                                          Kitch Membery @Kitch2024-04-12 04:08:11.534Z

                                                          Or press "Control + Shift + C" to clear the log and try again.

                                                          1. MMatt Friedman @Matt_Friedman
                                                              2024-04-12 04:14:43.553Z
                                                              1. Kitch Membery @Kitch2024-04-12 04:21:47.612Z

                                                                Hmm maybe you are on a different version of Firefox.

                                                                Unfortunately I’ll I’m have to pick this up tomorrow.

                                                                Could you start a new thread for this using the sf. version via the red “Need help?” Button and tag me in it.

                                                                If you could also provide the version number of Firefox you are using that would be great.

                                                                It might also be worth trying a restart both SoundFlow and Firefox.

                                                                Thanks in advance.

                                                2. In reply toMatt_Friedman:

                                                  It's generally difficult to construct UI paths correctly for browsers since they're so dynamic. We typically use Javascript execution in Chrome to get the current URL, as this is much more stable. I don't know that we can do the same for Firefox.