0

I have the below code which finds a window and presses an 'OK' button in it.

I want to run this using standalone VBScript. Can this be done?

While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE
    DoEvents
    If ie.Busy Then
        DoEvents
        hWND = FindWindow(vbNullString, "Message from webpage")
        If hWND <> 0 Then childHWND = FindWindowEx(hWND, ByVal 0&, "Button", "OK")
        If childHWND <> 0 Then SendMessage childHWND, BM_CLICK, 0, 0
    End If
Wend
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Suman Kumar
  • 63
  • 1
  • 12
  • 2
    VBScript does not support calling the Windows API. Your only option is to write a COM DLL that can be instantiated using `CreateObject()`. – user692942 Feb 18 '20 at 07:41
  • Thank you fo the response, I was little bit aware of this but I have found the link where they have run it from vbs...I didnt get it completely, may be you can explain it. https://social.msdn.microsoft.com/Forums/en-US/48f022dd-f62d-437e-be0e-b502c8f4cd94/accessing-win32-api-in-vb-scriptvbs-files?forum=isvvba – Suman Kumar Feb 18 '20 at 07:59
  • This is asking the wrong question. The question you should be asking is: How do I automate a UI? The answer to that question is: Use UI Automation. UI Automation is exposed as a COM interface. – IInspectable Feb 18 '20 at 08:40
  • @IInspectable - 100% agree on the principle, but unfortunately AFAIK UI Automation doesn't support COM automation so you can't use it from VBScript, which is a pity. It should. Maybe someone has written a wrapper? Not aware of any – Simon Mourier Feb 18 '20 at 08:47

0 Answers0