Jump to content
Macro Express Forums

Getting current URL


Recommended Posts

Hello everyone!

 

I've been racking my brains and am all Googled out trying to find what should be very simple. How do you get the full current URL from the address bar and store it as a string variable? I know you can do an <ALT>+<D> followed by COPY but I don't want to navigate away from my current position in the page.

 

I assume this can be done using HTML / VB Script / JScript (I don't have Autoit installed)?

 

I've found some code examples on the net, but don't know how to impliment these into MEP. I have tried using Extenal Script, but so far it keeps coming up with syntax errors or hangs the macro.

 

Does anyone have a simple way of doing this and if so, how do I interface it with the External Script command?

 

Thanks in advance!

Edited by amonaghan
Link to comment
Share on other sites

Perhaps simplest would be to do this:

// Save position of mouse
Variable Set Integer %X%: Set to the Mouse X Coordinate
Variable Set Integer %Y%: Set to the Mouse Y Coordinate

Text Type (Simulate Keystrokes): <ALTD>d<ALTU>
Delay: 0.1 seconds
Text Type (Simulate Keystrokes): <CTRLD>c<CTRLU>
Delay: 0.1 seconds
Variable Set String %URL% from the clipboard contents

// Restore position of mouse
Mouse Move: %X%, %Y% Relative to Screen
Delay: %Delay% seconds
Mouse Left Click

This moves the mouse but moves it back.

Link to comment
Share on other sites

Perhaps simplest would be to do this:

// Save position of mouse
Variable Set Integer %X%: Set to the Mouse X Coordinate
Variable Set Integer %Y%: Set to the Mouse Y Coordinate

Text Type (Simulate Keystrokes): <ALTD>d<ALTU>
Delay: 0.1 seconds
Text Type (Simulate Keystrokes): <CTRLD>c<CTRLU>
Delay: 0.1 seconds
Variable Set String %URL% from the clipboard contents

// Restore position of mouse
Mouse Move: %X%, %Y% Relative to Screen
Delay: %Delay% seconds
Mouse Left Click

This moves the mouse but moves it back.

 

Thanks for the suggestion. I knew that method, but was hoping there was a neater way of doing it.

Link to comment
Share on other sites

A quick test of the following looked promising:

 

1. View Source to open a new window. (In Firefox I do that with Right click > View Page Source; in IE I think it's from the menu: View > Source.)

2. In that, search for a line beginning <meta name="identifier-url" content="

3. To its right is the required URL, e.g. http://pgmacros.invisionzone.com/index.php?showtopic=4966" />

4. Remove the unwanted end tag.

5. Do whatever you want with the URL.

5. Activate your original page, which should be as you left it.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

A quick test of the following looked promising:

 

1. View Source to open a new window. (In Firefox I do that with Right click > View Page Source; in IE I think it's from the menu: View > Source.)

2. In that, search for a line beginning

/>

4. Remove the unwanted end tag.

5. Do whatever you want with the URL.

5. Activate your original page, which should be as you left it.

 

--

Terry, East Grinstead, UK

This looks like another possibility Terry. The problem is it is the login page to my personal banking, so capturing the URL and trying to download the HTML using Cory's method (VBScript) doesn't work. This is when issuing the URL the page returned is different from the original page (security reasons I'm sure).

 

This used to be easy in earlier versions of IE by using Search for text then a TAB would take you to where you wanted to be on that page. Then you could select text from that point on the page. Later versions don't seem to allow this sadly. So now I have to capture the whole source code and drill it down or do a CTRL+C of the page then drill that down. Oh well, I'm getting there.

Edited by amonaghan
Link to comment
Share on other sites

This used to be easy in earlier versions of IE by using Search for text then a TAB would take you to where you wanted to be on that page. Then you could select text from that point on the page. Later versions don't seam to allow this sadly.

 

I still use this technique occasionally, and I can usually get it to work. Usually the script looks something like this:

 

[ESC][ESC] // Cancel menu if accidentally open

{CONTROL}f // Find...

<word to find>

{Enter} // Initiate search

[ESC] // Cancel search

Delay 200 ms // Wait for window to regain focus after search bar loses focus

{Tab}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...