Jump to content

WinMenuSelectItem and Browsers


lgodfrey
 Share

Recommended Posts

Hi Gurus!

I want to make my scripts more robust by avoiding the "send" method as much as possible, from within Excel VBA. The problem that I find with send is that the mouse usually needs to be over the window in question, even though it has been selected without an error code. Move the mouse and you are out of luck.

I have tried using WinMenuSelection to automate some simple browser actions, eg to copy a site whose window name starts with "title" use

sSuccess=oAIX.WinMenuSelection ( "Title","","Edit", "Select All")

sSuccess=oAIX.WinMenuSelection ( "Title","","Edit", "Copyl")

(FireFox version has some & in the text, oAIX is my AutoItX3 object name,)

but I get window not found error return. (sSuccess=0)

I know the help files warn that a lot of window menus are just made to look like menus, and will not work a lot of times, but "surely" Ineternet Explorer should work!

Has anyone had success usning menu selction methods with IE or FireFox?

ANy hints on what to look at?

Thanks as always

Larry

:ph34r:

I'm, Lovin' IT, X

Link to comment
Share on other sites

sSuccess=oAIX.WinMenuSelection ( "Title","","Edit", "Select All")

sSuccess=oAIX.WinMenuSelection ( "Title","","Edit", "Copyl")

:ph34r:

<{POST_SNAPBACK}>

From the help file on WinMenuSelection

You should note that underlined menu items actually contain a & character to indicate the underlining. Thus, the menu item File would actually require the text "&File", and Convert would require "Con&vert" You can access menu items up to six levels deep; and the window can be inactive, minimized, and/or even hidden.

Should be:

sSuccess=oAIX.WinMenuSelection ( "Title","","&Edit", "Select &All")

sSuccess=oAIX.WinMenuSelection ( "Title","","&Edit", "&Copy")

Edited by bshoenhair
Link to comment
Share on other sites

All of IE menus are standard except for Favorites. The Favorites menu is the same kind of control as the Start Menu on 2000/XP (The expanded windows, not necessarily the first window that pops up when you press Start)

Firefox, on the other hand, may or may not respond, it uses custom controls.

Edit: Re-wrote for better clarity

Edited by Valik
Link to comment
Share on other sites

Should be:

sSuccess=oAIX.WinMenuSelection ( "Title","","&Edit", "Select &All")

sSuccess=oAIX.WinMenuSelection ( "Title","","&Edit", "&Copy")

<{POST_SNAPBACK}>

Dear guru, I think you are showing the need for the & for Excel select and copy menu items. but IEexporer has no underlines shown. One would think there should be an underline for the E in Edit menu item since it can be accessed by "alt E" keystrokes in the window, but it doesn't display any underlines. I've got WXP, SP2 installed.

I previously tried what I think are all variatiions of with and without &, using the Excel & locations as a guide as what to try. Just to be sure, I tried your version again, with no luck.

Maybe I should ask some specific questions:

1. MS IE appears to be acting like it is non-standard windows menu, even though one would expect MS to get this one right. Does any one know definitively if IE is stanard menus and can use WinMenuSelection?

2. Does anyone have example of WinMenuSelection for the simple task of select all and copy to clipboard for IE using AutoITX3?

Best Regards

Larry

I'm, Lovin' IT, X

Link to comment
Share on other sites

Ahhh, what we have here is two different things... Yes, I can assure you that the menus are a standard menu... however, the menu-bar (File, Edit, View, et cetera) may not be, which is probably the source of the trouble here. You have to go through the menubar to get to the menu's. This is where its non-standard because the menubar is really just a toolbar.

Link to comment
Share on other sites

You would think this should be easy...copy from a browser and paste into a spreadsheet.

Monsieurs Valik and bshoenhair gave me the insights to get things to work. FYI I am running Excel VBA code that uses AutoITX3.

1) treat the IE menu bar like a control, not a menu Use controlsend, once with "ea" and then with "ec".

2) The excel VBA clipboard retrieval cannot handle HTML coded source. Also, the Excel menubar pastspecial menu pops up a non-standard window if the clipboard contains HTML code, so do not go this route with controlsend. INstead, Use an executable autoit scriipt to strip out non-standard characters from the clipboard entry and repaste it. Then use the "getclipboard" function inside VBA, and you are off and running.

Yuck, two days wasted. but it feels good when you stop :ph34r:

Thanks

Larry

ps, here is my strip script. For my purposes it has to be fast, any thoughts on how to make it faster?

Dim $BOOKCLIP = "", $I = 0, $L = 0, $A = 0

$BOOKCLIP = ClipGet()           ;Get HTML source from clipboard

$L = StringLen($BOOKCLIP)
For $I = 1 To $L   
   $A = Asc(StringMid($BOOKCLIP, $I, 1))
   If $A < 32 Or $A > 122 Then ;strip out all but numbers, letters, comma, period, apostraphe, colon
      $BOOKCLIP = StringLeft($BOOKCLIP, $I - 1) & " " & StringRight($BOOKCLIP, $L - $I - 1)  'replace unwanted character with blank
      ContinueLoop
   EndIf
   If $A > 96 And $A < 123 Then ContinueLoop
   If $A > 64 And $A < 91 Then ContinueLoop 
   If $A > 47 And $A < 59 Then ContinueLoop
   If $A = 32 Or $A = 39 Or $A = 44 Or $A = 46 Then ContinueLoop  
   $BOOKCLIP = StringLeft($BOOKCLIP, $I - 1) & " " & StringRight($BOOKCLIP, $L - $I - 1)
Next
$BOOKCLIP = StringStripWS($BOOKCLIP, 4) ;strip out double blanks etc.
ClipPut($BOOKCLIP) ;paste it back to the clipboard for Excel to use
Exit

I thought of trying to keep track of how long the new string is but thought this would be slower than just replacing characters I do not want with a blank.

I need to strip out as many characters as possible to make sure Excel can handle the length of the final answer, that's why the final stringstripws function. Would it be better to try to do this in the loop, remembering the last character and deleting the current one if it is a duplicate?

I'm, Lovin' IT, X

Link to comment
Share on other sites

but  IEexporer has no underlines shown.    One would think there should be an underline for the E in  Edit menu item  since it can be accessed by "alt E" keystrokes in the window, but it doesn't display any underlines.  I've got WXP, SP2 installed.

<{POST_SNAPBACK}>

Just so you know:

When you say IEexporer you mean IEXPLORE.EXE then yes the underlines are there but you have them set not to show. If you hold down the alt key the underlines will appear.

Link to comment
Share on other sites

Just so you know:

When you say IEexporer you mean IEXPLORE.EXE then yes the underlines are there but you have them set not to show. If you hold down the alt key the underlines will appear.

<{POST_SNAPBACK}>

Thanks for this tidbit, Jon. I can see it work. However, the menubar doesn't seem to act like a menu, so I needed to use controlsend, and it works fine without the & for underline.

I do not remember purposely setting the underlines not to show in IE, and I've looked around in options and TweakUI to find this setting...to no avail. Do you know where the setting is?

Best regards

Larry

I'm, Lovin' IT, X

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...