Discussion Locked

How can I pass a paramater "Yes" to a sy

0 helpful
13 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How can I pass a paramater "Yes" to a system generated msgbox, so after that user will not be pressing "Yes" key on every time. thanks
Reply me on guru@tough.com

13 replies

by javierrosado

Never have done this myself but I guess you could do it by getting the object reference fo the activecontrol in the screen. The check whether it is a button and whether it has the default property set to true. Maybe this way you could call it click event.

Perhaps another way could be using the sendkeys procedure but I am not quite sure about this one.

by kratka.eric.d

As far as I know, any system message box holds control of the program until manually pressed, so you cannot use send keys or get it's window handle using the same program. It would be theoretically possible to run another program that would deal with the message boxes, but my solution would be to build your own message boxes with a built in timer or a way to make it non-modal.

by amasson

In a vb program, first thing to do is:
- give focus to the application generating the message box. Ex: if your program title bar is "Window's name", do this with:
AppActivate "Window's name".
- after, send the correct keystrokes. For "Yes" (the Yis usualy underlined), you can send the string corresponding to Alt-Y
SendKey "!Y" or something like this (y am not sure of the corresponding char for Alt key, but there is one (like "!").
- This work one time. If you want it to work always, Create a shortcut that start your program instead of the real program. Then your vb program start the desired application with:
Shell "path_name.exe", vbNormal
DoEvents
and then send keystrokes via SendKey...

by mmercer

If I were you I would look to trapping the error generated and inhibiting the production of the system generated msgbox (you can intercept errors at will if you know the errors 'handle') ... I am pressuming that this is a response to a specific error - it would be unwise to just OK all system errors.

Unfortunately I am unsure as to how to do this (except in Oracle), but as I know you can intercept errors (set up an exception/error trap for this this may need to be through the API) it should not be too hard to find in your user documentation.

by hotpro_99

Trap the message. This is done by finding out what causes it, and then writing your own method of dealing with it. Example "divide by zero"
you must work out something like :
{p = ((d-t)/c) * 100}
if c = 0 then p := 0
else
p = ((d-t)/c * 100You syntax will depend on the language you use, therefor I've idn't include most of the syntax. Also find out the handle, and then you can either suppress, or control the error. Windows can be contolled, in a mean way, so just do a bit of research, like reading the "help" in your Development Language. Good Luck

by x-cyber

If you have the MessageBoxs Handle or ClassName and Caption you can Use:

Prnt = FindWindow("ClassName", "Caption")
Chld = FindWindowEx(Prnt,
0, "Button", "Yes")
SendMessage Chld, WM_KEYDOWN, VK_SPACE, 0
SendMessage Chld, WM_KEYUP, VK_SPACE, 0

If you know the Handle then you do not need the first code line, then start with the second line and where says Prnt on the second line put the MessageBoxs Handle

This discussion is closed to new replies.