Q: Automaticly click ok when a message dialog appears.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Arvidsson, Visual Systems AB

    Q: Automaticly click ok when a message dialog appears.

    Hi!

    I am constructing a program that will massverify some reports.

    How ever there is a message dialog comming up saying that the report is up
    to date or needs change.

    Is there a way to detect when this dialog appears and send a key stroke or
    send a message to the button on the dialog?

    I know the title of the message dialog.

    Regards
    Martin


  • Andrew Faust

    #2
    Re: Q: Automaticly click ok when a message dialog appears.

    I assume the message boxes are being generated by a separate app that you
    have no ability to modify?

    You can do this using the Windows API. You can iterate through all the
    windows with EnumWindows and EnumChildWindow s and get the window text with
    GetWindowText. Or you can search for the window directly with FindWindow and
    FindWindowEx.

    Once you have the handle to the window you can send a message to it via
    SendMessage. If it's a standard dialog box, you can probably just send it
    WM_KEYDOWN with a parameter of VK_ENTER.

    You can find documentation on these APIs in C# on Pinvoke.net. You can also
    google the functions I mentioned to find code samples.

    As for getting a notification of a new message box, you could probably
    create a windows event hook to do it. You can Google windows hooks to find
    out more. That's probably overkill, though. I'd probably just use a timer to
    have my app check for a new dialog box every 10 seconds or so.

    Andrew Faust

    "Martin Arvidsson, Visual Systems AB" <martin.arvidss on@vsab.netwrot e in
    message news:uRMLU9y4IH A.3796@TK2MSFTN GP03.phx.gbl...
    Hi!
    >
    I am constructing a program that will massverify some reports.
    >
    How ever there is a message dialog comming up saying that the report is up
    to date or needs change.
    >
    Is there a way to detect when this dialog appears and send a key stroke or
    send a message to the button on the dialog?
    >
    I know the title of the message dialog.
    >
    Regards
    Martin
    >

    Comment

    • Martin Arvidsson, Visual Systems AB

      #3
      Re: Q: Automaticly click ok when a message dialog appears.

      Thank you!

      That realy solved my problem.

      Regards
      Martin

      "Andrew Faust" <andrew@andrewf aust.comskrev i meddelandet
      news:67335D87-51AB-4D4F-A59C-75DBE0DE852F@mi crosoft.com...
      >I assume the message boxes are being generated by a separate app that you
      >have no ability to modify?
      >
      You can do this using the Windows API. You can iterate through all the
      windows with EnumWindows and EnumChildWindow s and get the window text with
      GetWindowText. Or you can search for the window directly with FindWindow
      and FindWindowEx.
      >
      Once you have the handle to the window you can send a message to it via
      SendMessage. If it's a standard dialog box, you can probably just send it
      WM_KEYDOWN with a parameter of VK_ENTER.
      >
      You can find documentation on these APIs in C# on Pinvoke.net. You can
      also google the functions I mentioned to find code samples.
      >
      As for getting a notification of a new message box, you could probably
      create a windows event hook to do it. You can Google windows hooks to find
      out more. That's probably overkill, though. I'd probably just use a timer
      to have my app check for a new dialog box every 10 seconds or so.
      >
      Andrew Faust
      >
      "Martin Arvidsson, Visual Systems AB" <martin.arvidss on@vsab.netwrot e in
      message news:uRMLU9y4IH A.3796@TK2MSFTN GP03.phx.gbl...
      >Hi!
      >>
      >I am constructing a program that will massverify some reports.
      >>
      >How ever there is a message dialog comming up saying that the report is
      >up to date or needs change.
      >>
      >Is there a way to detect when this dialog appears and send a key stroke
      >or send a message to the button on the dialog?
      >>
      >I know the title of the message dialog.
      >>
      >Regards
      >Martin
      >>

      Comment

      Working...