WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: siocnarf on May 22, 2020, 08:39:45 AM

Title: Focus in an Internet explorer Windows
Post by: siocnarf on May 22, 2020, 08:39:45 AM
HI,

I have in Internet explorer a window asking to activate an activex (see attachment). I would like geting focus on the button.
;RoboScripter
; Made with
;   RoboScripter ver: 45
;   CtlMgr ver: 44040
AddExtender("wwctl44i.dll")

;Title: <untitled>
;ID: 0
;Class: DirectUIHWND
;Level: 3

; Default cWndByWndSpec seems OK here
;window1=cWndByWndSpec("IEFrame","iexplore",8,0,0,0,0,0,0,0,0)
; window1=cWndByWndSpecName("AlternaTIFF ActiveX control installation - Internet Explorer","iexplore",8,0,0,0,0,0,0,0,0)
window1=DllHwnd('AlternaTIFF ActiveX control installation - Internet Explorer')
window2=cWndByClass(window1,`Frame Notification Bar`)
;window2=cWndBySeq(window1,1)
ControlHandle=cWndByID(window2,0)
;ControlHandle=cWndByClass(window2,`DirectUIHWND`)
;ControlHandle=cWndBySeq(window2,1)
cSetFocus(ControlHandle)  ; Activates Window




But I cannot get the focus on that window.

Any  help would be appreciate.
Title: Re: Focus in an Internet explorer Windows
Post by: td on May 22, 2020, 09:43:15 AM
Surprised anyone is still using the UI version of Internet Explorer.  Just guessing but the button you are attempting to set the focus too is likely not a window (in the Windows sense.)  It is likely an HTML button input type and the frame window displaying it is likely an IE popup window.  If you can gain access to the popup window you might be able to use the DOM focus event to place the focus on the button.

A click example can be found here:
https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/OLE~with~MSIE+IE9~Click~or~Focus~Methods~Fail.txt

Of course the trick is to get an object handle to the COM Automation object representing the IE popup window; assuming that is what the window with a button is.  You might be able to use the "Shell.Application" object to get the popup window's object or there may be a way to access the popup window's object using DOM methods of the tab window.  Not sure which would work.

Perhaps someone else on the forum can offer you a better solution.