WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: siocnarf on January 22, 2020, 10:37:08 AM

Title: cwndbywndspec variable
Post by: siocnarf on January 22, 2020, 10:37:08 AM
Hi,

I have this script. I start Internet explorer then running that script.


;RoboScripter
; Made with
;   RoboScripter ver: 45
;   CtlMgr ver: 44040
AddExtender("wwctl44i.dll")
;AddExtender("wwctl64i.dll")


;IgnoreInput(@true)
BoxOpen ("Activation de Alternatiff, un instant SVP","Le clavier et la souris sont désactivés. %@crlf%  Ne pas éteindre l'ordinateur! Cela nécessite quelques instants.")
IntControl(54,"",1,0,0)

timedelay(10)

; Default cWndByWndSpec seems OK here
;window1=cWndByWndSpec("IEFrame","iexplore",7,0,0,0,0,0,0,0)
; window1=cWndByWndSpecName("AlternaTIFF ActiveX control installation - Internet Explorer","iexplore",7,0,0,0,0,0,0,0)
window1=DllHwnd('AlternaTIFF ActiveX control installation - Internet Explorer')
;ControlHandle=cWndByClass(window1,`Client Caption`)
ControlHandle=cWndBySeq(window1,3)
ret=WinWaitExist('AlternaTIFF ActiveX control installation - Internet Explorer', 15 )  ;Wait for window to exist ;TODO Check title and timeout value
if ret== @false

IgnoreInput(@OFF)
BoxShut()
   exit

End if

;Title: <untitled>
;ID: 0
;Class: Client Caption
;Level: 2

; Default cWndByWndSpec seems OK here
window1=cWndByWndSpec("IEFrame","iexplore",7,0,0,0,0,0,0,0)
ControlHandle=cWndByClass(window1,`Client Caption`)
cSetFocus(ControlHandle)  ; Activates Window


;Title: <untitled>
;ID: 0
;Class: Client Caption
;Level: 2

; Default cWndByWndSpec seems OK here
window1=cWndByWndSpec("IEFrame","iexplore",7,0,0,0,0,0,0,0)
ControlHandle=cWndByClass(window1,`Client Caption`)
cSetFocus(ControlHandle)  ; Activates Window
TimeDelay(1)
SendKey(`{TAB}{TAB}{ENTER}`)     ;Sends Keystrokes

My problem is cWndByWndSpec("IEFrame","iexplore",7,0,0,0,0,0,0,0) is not returning the same value all the time. Sometimes it is 7 and sometimes it is 6,

How may I handle that situation?

Thanks,


Title: Re: cwndbywndspec variable
Post by: td on January 22, 2020, 02:00:49 PM
Obviously, you have a varying number of child windows associated with your IE main window when you open and close tabs so cWndByWndSpec is not very useful.  Your Roboscripter generated script has a DllHwnd example that can be used assuming you know at least part of IE's window name.  Otherwise, you can use something like WinItemNameId or WinItemize to get a list of open Windows and perhaps deduce the correct WinID but that would be dicey. 
Title: Re: cwndbywndspec variable
Post by: theladycroft on January 31, 2020, 07:33:49 AM
Sorry for bumping. I cannot find necessary thread. Should I make new one or it's possible ask here?