It depends on the details of the dialog box.
Are there currently any other keyboard shortcuts associated with dismissing the dialog box that could be mapped to your desired shortcut?
Is there a control associated with the OK button revealed by the Window Spy tool? If so, you may be able to use ControlClick
. You may also be able to use ControlClick to click on its location, which would have some benefits over the conventional Click approach.
You might be able to interface via browser controls such as COM with Internet Explorer or similar approaches with other browsers.
Is there a specific drawback to using Click that you are looking to avoid?