Jump to content
Macro Express Forums

Load Web Address


Recommended Posts

The short answer, Bob, is "Yes." The slightly longer answer is "Yes, there is."

 

I'm betting you're looking for a bit more than that. So here it goes: Since you want the macro to open a website if that site isn't already opened, you know already that you're going to need an If/Then style sequence. So you need to establish what the address is going to be, or what the window title will be for that If to check.

 

Since it sounds like you'll be running the macro multiple times over the course of a day, week, or longer, you'll most likely want to establish the window title in a way that the macro will be able to check to see if that window is running, regardless of the last time you checked.

 

A simple macro will be something along the lines of:

 

Variable Set String %Web Title% to "Test Web Site Title Bar - Internet Explorer"
If Not Window "%Web Title%" is running
 Web Site, "http://www.TestWebSiteTitleBar.com", using Internet Explorer
End If

Of course this will require you to know what the title bar is when you write the macro. Another option, as long as you know the web-address, which I'm presuming you do, would be to build a slightly more complex macro that you can write using nothing more than the URL:

Read Registry Value "HKEY_CURRENT_USER\MEProVariables\Test\Amerifax\web title" into %Web Title%
If Not Window "%Web Title%" is running
 Web Site, "http://www.macros.com", using Internet Explorer
 Wait for Web Page: http://www.macros.com
 Variable Set String %Web Title% to topmost window title
 Write Registry Value "%Web Title%" into HKEY_CURRENT_USER\MEProVariables\Test\Amerifax\web title
End If

The very first time you run this macro, if you already have the window open, it will open a second instance. After that, however, it will never open the web-site again if it is already running. Also, you will probably want to change the path inside the HKCU. I have a specific path for Testing, and if you're planning on using a permanent path, you might want to direct it elsewhere, but it's completely up to you.

 

You could also save it along a path within your primary drive (e.g. C:// ) and save it as a .txt or .ini, but again, it is all up to you.

 

Here's the macro as I built it, if you want to download it and test it out for your own purposes:

 

Launch_or_Check_If_Open.mex

 

One more thing: This will only work in IE. If you use a different browser, you'll need to tweak it for that browser. That means changing from IE - in the Web Site command - to "Default Browser", and changing the "Wait for Web Page" command to a Delay or Wait for Time to Elapse command.

 

I tested it in Google Chrome with a 2 second delay, but for purposes of distribution I switched to IE. I can't test it in IE on my machine because IE 8 crashes on my PC almost every time I launch it. And I can't seem to get rid of it... <sigh> but that's a story for another post on a different forum. Anyway, as long as your IE works, this macro should work fine.

Link to comment
Share on other sites

Good ideas but I can see a hole in your logic Steve…………………………….

The problem is that a web browser title is not indicative of the web address. I could have multiple browser windows open and they could all have the title “Home Page” and each have different URLs. So even if you cached them you could have problems.

 

I was thinking I would do a Repeat With Windows and check the address bar for each instance of IE using a control but again we have the annoying problem that MEP can not distinguish between two of the same title. Oddly ISS allowed us to enumerate the handles which are distinct but I don’t see any way to use them to solve this persistent problem. So I don’t think there is a way to do it if there’s a chance of identical window titles.

 

Now if in this particular instance the window title he’s looking for is unique to this one site and it’s not important if there are duplicates then I would do one of the two.

  1. Predetermine the window title at the time of writing and us the If Window Exists.
  2. Set a control for the address bar of an Internet Explorer window. Repeat With Windows and each time modify the window title of the control, read the control text and test. This would be completely invisible to the user and instantaneous. Caveat would be to be careful never to launch web sites in tabs as I have no idea how one would check them.

Link to comment
Share on other sites

Holes in my logic? The devil you say!!!...................

Good ideas but I can see a hole in your logic Steve

I never said it was a perfect solution. It's a pretty good one, though, if you consider the potential for a website whose title bar may change from time to time, or varies based on content (such as various Wikipedia pages). Or something. It's late, and my brain isn't firing 100% right now.

 

Honestly, as far as dealing with multiple web pages that may have the same title bar, you'd really have to figure out additional logic to verify pages. I agree completely with that, and hadn't considered that when I hacked out that macro.

 

What would be really cool is an If website option.

Link to comment
Share on other sites

Please clarify...................................................................

I'm hoping to have three sites open on the same Window.
Do you mean in tabs? If so I can't imagine how you could make this work without getting ugly.

 

Personally I turn off tabbed browsing. I just don't see the point of adding another mouse click to every switch. And with Vista Aero it's better to have them all on the taskbar anyway. Although i do hang my taskbar on the side with no autohide so I can actually have 30 things open and be able to read them all:)

Link to comment
Share on other sites

So far I have got to this point.

 

Mouse Move: 1644, 1189 Relative to Screen

Delay: 3 seconds

Get Mouse Position into (%N[1]%, %N[2]%) Relative to Screen

Mouse Left Click

Text Type (Simulate Keystrokes): <DELETE>

Delay: 1 seconds

Text Type (Simulate Keystrokes): nf

Delay: 1 seconds

Text Type (Simulate Keystrokes): <ENTER>

Delay: 3 seconds

Mouse Move: %N[1]%, %N[2]% Relative to Screen

Mouse Left Click

Text Type (Simulate Keystrokes): <DELETE>

Delay: 1 seconds

Text Type (Simulate Keystrokes): de

Delay: 1 seconds

Text Type (Simulate Keystrokes): <ENTER>

Delay: 3 seconds

Mouse Move: %N[1]%, %N[2]% Relative to Screen

Mouse Left Click

Text Type (Simulate Keystrokes): <DELETE>

Delay: 1 seconds

Text Type (Simulate Keystrokes): im

Delay: 1 seconds

Text Type (Simulate Keystrokes): <ENTER>

Delay: 3 seconds

 

Note: Next 4 lines are unrelated to the macro. It's just the way I create shortcuts.

The use of nf - de - im is a short cut I create in Reg

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\nf.exe

nf.exe is http://dvdempire.com

I use many short cuts this way.

 

The only thing I have left to do is do some knid of check to make sure the sites are not already in Internet Explore. Some kind of an "IF" statement. I could use help on the "IF"

 

Bob

Link to comment
Share on other sites

By using the Macro I posted in the message above I was able to load 3 websites into one Window, each on their own tab.

 

I had also written the following Macro to Load the same 3 websites. The macro below checks to see if the Website is already open and if not loads it (in it's own window).

 

 

Variable Set String %Web Title 1% to "Netflix - "

If Not Window "%Web Title 1%" is running

Web Site, "http://www.netflix.com", using Internet Explorer

End If

Variable Set String %Web Title 2% to "DVD Empire"

If Not Window "%Web Title 2%" is running

Web Site, "http://www.dvdempire.com/", using Internet Explorer

End If

Variable Set String %Web Title 3% to "IMDb Pro"

If Not Window "%Web Title 3%" is running

Web Site, "http://pro.imdb.com/", using Internet Explorer

End If

 

I tried to piece the two Macros together but it isn't working. I want to use the Macro from the Post above because it loads all 3 sites into one IE window on seperate tabs. But I want the functionality of the 2nd macro to check if the Website is already open and if not then continue on. This is the way I pieced them together:

 

Mouse Move: 1644, 1189 Relative to Screen

Delay: 3 seconds

Get Mouse Position into (%N[1]%, %N[2]%) Relative to Screen

Variable Set String %Web Title 1% to "Netflix - "

If Not Window "%Web Title 1%" is running

Mouse Move: %N[1]%, %N[2]% Relative to Screen

Mouse Left Click

Text Type (Simulate Keystrokes): <DELETE>

Delay: 1 seconds

Text Type (Simulate Keystrokes): nf

Delay: 1 seconds

Text Type (Simulate Keystrokes): <ENTER>

Delay: 3 seconds

End If

 

It seemed logical to me but I am getting a sytax error at line six.

 

Sorry for such a long post but I was really hoping that someone could shed some light on this or guide me in the right direction. I basically want to use the Macro from the post above, but have the functionality of the Macro included with this message.

 

Any help will be greatly appreciated!

 

Bob

Link to comment
Share on other sites

Please read my posts.......................................................

Do you mean in tabs? If so I can't imagine how you could make this work without getting ugly.

Like I told you I do not think you can use window titles if using tabs. You may have 3 windows open but only one of them can appear at a time to affect the window title of the browser. Another reason I think tabbed browsing is less efficient.

 

I did notice you said that you get a syntax error on line 6. Line 6 has nothing to do with the conditions as it’s a mouse move. IE there must be something wrong with your mouse move command.

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...