Reputation: 23
I Have an ole object browser where there is a popup message box to the website I open, I want to programmatically trigger the enterkey to automatically close the message box.
Upvotes: 1
Views: 1549
Reputation: 2397
If it is a messagebox you might try Send(32770, 16, 0, 0) with '16' being the decimal value for WM_CLOSE and '32770' being the handle for a Messagebox.
Upvotes: 2
Reputation: 4174
Since it's functionality in an OLE I think you either need control that dialog via the OLE API and if that doesn't have the tooling you need- the only other way is go "around" the OLE directly to Windows.
So the answer would likely be the same for most Windows programming languages- in case you don't get big enough audience being tied to the PowerBuilder tag alone. Big question is do you know title of that dialog?
The idea isn't much different than clicking a button on any web based dialog window which opens up a can of "right or wrong dilemma" and sure you're doing it for the right reasons.
The PB specific parts would be define External Function something like:
PUBLIC FUNCTION unsignedlong FindWindow (long &
classname, string windowname) LIBRARY "user32.dll" &
ALIAS FOR FindWindowW
Then add code to use it:
unsignedlong hwnd
hwnd = FindWindow( 0, "Window Title if known if not hahaha" )
if hwnd = 0 then
// fml^2 ("fml squared" originated here now- shared conscious test #1 )
else
// Yes! Now we have the Windows API, or Post, Send might work fine.
// Send(hwnd, 273, 0, Handle(cb_OK)) or similar
end if
Upvotes: 2