Jump to content

WinMenuSelectItem() Difficulties


Recommended Posts

I am trying to automatically sign onto AIM, and set an away. I've accomplished this using mouse clicks, but occasionally someone will IM me right away, or the something else causes it to go wrong. So I tried using WinMenuSelectItem(). The problem is that it will not work with menus within the main menu.

I tried it again in a different scenario; creating a new folder.

WinMenuSelectItem("bin", "", "&File", "Ne&w", "&Folder")

Menu:

Posted Image

Help? :D

Edited by darknuke
Link to comment
Share on other sites

WinMenuSelectItem() only works on real menu's. Explorer doesn't use real menu's, it uses other controls masquerading as real menu's. In the real world, very few applications actually do use a real menu.

Link to comment
Share on other sites

Why not use a ControlSend? I use this method to open menus and select items in it all the time, including to minimized or hidden windows. You might also be interested in checking out my ControlSendPlus funtion, which properly uses the shift, control, and alt keystrokes. The standard ControlSend function won't always work, and there's nothing that we can do to change that. (For more information on this issue, see the NOTE 1 in my readme included with my function.)

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

If it works with the first level, are you positive that you are using the correct name on the second level? Make sure you use & for the accelerator, even if it isn't always visible, it still might be there.

Link to comment
Share on other sites

I'm positive, I was pressing Alt + Letter to figure which it is because the underscores aren't below the letters.

WinMenuSelectItem("dkennedy15's Buddy List Window", "", "&My AIM", "&Away Message", "&New Message...")

Posted Image

The underscore under N isn't shown in the image, and I even removed the & from &New to see if that was the problem, but to no avail.

Edited by darknuke
Link to comment
Share on other sites

I assume youi checked the help file it's usually, well helpful

Rick

and by 'helpful' we mean "it will tell you exactly how to do this"

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

and by 'helpful' we mean "it will tell you exactly how to do this"

Took 30 seconds for look this up hope it helps

ControlSend

--------------------------------------------------------------------------------

Sends a string of characters to a control.

ControlSend ( "title", "text", "classnameNN", "string" [, flag] )

Parameters

title The title of the window to access.

text The text of the window to access.

classnameNN The classname and instance of the required control or the exact title/text of the control with any underlined character denoted with a preceding &.

string String of characters to send to the control.

flag [optional] Changes how "keys" is processed:

flag = 0 (default), Text contains special characters like + to indicate SHIFT and {LEFT} to indicate left arrow.

flag = 1, keys are sent raw.

Return Value

Success: Returns 1.

Failure: Returns 0 if window/control is not found.

Remarks

ControlSend can be quite useful to send capital letters without messing up the state of "Shift."

When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

Note, this function cannot send all the characters that the usual Send function can (notably ALT keys) but it can send most of them--even to non-active or hidden windows!

Related

ControlCommand, Send

Example

ControlSend("Untitled", "", "Edit1", "This is a line of text in the notepad window")

Link to comment
Share on other sites

Yes, I've been scouring through the help file and particularly the CommandSend() & WinMenuSelectItem() topics. (That topic is actually open at the time I'm posting this :D) I meant I didn't know how to use CommandSend() on menus, as the example in the help file is just the text box in notepad. I did try using CommandSend() with no success.

@Emmanuel

It's one line of code, I'm not asking you guys to write me a whole script.

Posted Image

Edited by darknuke
Link to comment
Share on other sites

Yes, I've been scouring through the help file and particularly the CommandSend() & WinMenuSelectItem() topics. (That topic is actually open at the time I'm posting this :huh2:) I meant I didn't know how to use CommandSend() on menus, as the example in the help file is just the text box in notepad. :D

It's the same thing as a Send... the string does the exact same thing, but only sends it to a control. So:

Send("!fwf")

becomes:

ControlSend($title , "", $control, "!fwf")

Please note that since it is only sending to a control, some applications will not work with this method because they will ignore the local control shift, alt, and/or control keystrokes. To do that, use my UDF.

Typo corrected

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

I can't even find the control name for the menu. The control name I found earlier must have been below the menu.

Use it instead. As long as the keystroke is sent to a control that's in the main window (and not a text control itself) it should open the menu. Have a look at the following example:

Opt("WinTitleMatchMode", 4)
Run("explorer.exe")
$exists = WinWaitActive("classname=ExploreWClass", "", 10)
If NOT $exists Then
  MsgBox(0, "Error", "Explorer window not becomming active")
  Exit
EndIf
$title = "classname=ExploreWClass"
$control = "ToolbarWindow323"
ControlSend($title , "", $control, "!fwf", 0)

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

For some reason it doesn't work correctly unless the window with the control on it is in focus. :D

ControlSend("dkennedys15's Buddy List Window", "", "_Oscar_Tree1", "!a{DOWN}{ENTER}")
Edited by darknuke
Link to comment
Share on other sites

As I did mention in some above post, sometimes Controls won't accept the local alt, control, or shift keystrokes. Did you try my UDF? With flag 2 or 4 it might work, since those two modes use the global alt keystroke.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

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