Results 1 to 6 of 6

Thread: Popup menu question

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Location
    NJ
    Posts
    3

    Popup menu question

    I have a program that clicks on a button (in another program), once the button is clicked on a popup menu comes up. I want to click ont he second item on the popup menu (there are only two). How do I do it?

    Window Class Name: "#32768"
    Window Text: ""
    - Peter

  2. #2
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    I'm assuming you're clicking the first button using API... Just find the handle of the first button, then use FindWindowEx with that handle as its first argument, and voila, you get the next control fitting that class.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Location
    NJ
    Posts
    3
    I think I need to be a little clearer. I have my program click on a button. After it clicks on this button a popup menu comes up. There are to selection you can make on the menu. I want to click the second one. How can this be done?
    - Peter

  4. #4
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    Once your program has clicked on the main form, have it do a DoEvents in a loop until FindWindowEx turns up the dialog box where you want to click the second button. Then find the first button of whatever class the button is, then the second button. Here's some pseudo-code:

    Find handle of target app
    Find handle of first button (via its class), then use FindWindowEx until we have the desired button
    Send a click message to the button using SendMessage
    Wait until the dialog box pops up
    Find the handle of the first button
    Find the handle of the second button and send it a click message

    Does this make sense? Hopefully the pseudo-code I wrote will help you narrow down what you need to figure out how to do.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Location
    NJ
    Posts
    3
    Umm what pops up after the button is clicked is a menu. It's a popup menu, it is a menu like when you right click on your desktop, a menu comes up. When I click on this button a menu comes up like that but it only has two options and I wanna know how to click the second one...
    - Peter

  6. #6
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    The only way I could figure out how to do that is use SendKeys, which I know is bad. For some reason, sending WM_Keydown with wparam of vbKeyDown did not work...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width