WinAutomation - windows automation software with macro recorder

      How To - Shorten URL With Hotkey

      One of the tasks that almost everyone repeats daily is the URL shortening. Whenever we want to post a link in our twitter/facebook status, we usually follow the steps below:

      1) Select and copy the really long URL to the clipboard (Ctrl+C),
      2) Paste it in a shortening service's form,
      3) Hit the submit button,
      4) Wait for the service to return the short URL,
      5) Copy the short URL,
      6) Paste the short URL into our social networking site.

      The job that I will create today, will remove steps 2, 3, 4 and 5 from the equation. All you will have to do in order to paste a short URL instead of a long one, is:

      1) Select and copy the really long URL to the clipboard (Ctrl+C),
      2) Hit a specific HotKey (i.e Ctrl+Shift+V) and the short URL will be pasted instead of the long one.

      So, let's get started. The URL shortening service that I will use is http://is.gd. It does not only provide the shorter URLs out there, but it also has a very simple submission form for the purpose of this tutorial.

      The first thing that we need to do, is visit the service's webpage:

      IsGd Initial Page

      Now, we need to examine its source code so that we can understand how the form works. To do that, we just right click anywhere in the page and select "View Source" in Internet Explorer or "View Page Source" in Mozilla Firefox (alternatively in Firefox you can just hit the Ctrl+U keystroke combination). The part of the web page source that we are interested in is shown in the screenshot below:

      IsGd Source Code

      The path that is mentioned in the form's action property is the URL that we will fill in the "Download from Web" action.
      The method will be selected by the action's drop down menu.
      In this specific case, the form has only one input, so the only POST parameter that needs to be declared is the URL parameter. In the URL parameter we will pass the "long URL" and the site will generate a short URL for us.

      Before we start creating our job, we need to define the exact steps of our process. Since the URL will already be in the clipboard:
      1) We need to retrieve the URL from the clipboard and save it to a variable,
      2) Submit the "long URL" to the shortening service,
      3) Parse the text that the webpage returns to isolate the short URL
      4) Store the short URL to the clipboard
      5) Send a Ctrl+V keystroke combination to paste the short URL that is saved on the clipboard

      All of the steps above are pretty straightforward and can be implemented by a single action. The corresponding actions are shown below:

      1) "Get Clipboard Text" (under "Clipboard" category)
      2) "Download from Web" (under "Web" category)
      3) "Parse Text" (under "Text Actions" category)
      4) "Set Clipboard Text" (under "Clipboard" category)
      5) "Send Keys" (under "Mouse and Keyboard" category)

      Since the "Download from Web" action is analyzed above, the only tricky part now is to isolate the short URL in the result page:

      IsGd Result Page

      And if we look at the source code:

      IsGd Shortened URL Source Code

       we can easily understand how the regular expression should look like. Since it is out of the scope of the specific article to explain how to build the regular expression, I will just give a screenshot of Expresso, the application that I'm using to build my regular expressions:

      Expresso Regular Expression Testing

      Our job should look like this now:

      Final Job Screenshot
       
      The final thing that we need to do, is create a trigger that will fire the job. After the job is saved, right click on it in the console window and select "Edit Triggers".

      Edit Triggers
      Then, follow the steps that are shown in the screenshots below:

      Add New Trigger
      Add Keyboard Monitor Trigger
      Keyboard Monitor Trigger Properties
      Hit OK and we are done!

      In order to test your newly created job now, select a very long URL, hit Ctrl+C to copy it to the clipboard, place your cursor in your twitter/facebook status and press Ctrl+Shift+V. After a couple of seconds the short URL will be pasted instead of the original long one.

      Your rating: None Average: 5 (4 votes)

      Comments:

      Post new comment

      The content of this field is kept private and will not be shown publicly.
      • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
      • Lines and paragraphs break automatically.
      • Web page addresses and e-mail addresses turn into links automatically.
      • You may quote other posts using [quote] tags.

      CAPTCHA
      This question is for testing whether you are a human visitor and to prevent automated spam submissions.
      Image CAPTCHA
      Enter the characters shown in the image.



      Featured Clients