 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Do you find this group pf wrapper functions for IE Automation Usefull |
| no you suck |
|
8% |
[ 2 ] |
| need better Documentation |
|
29% |
[ 7 ] |
| What is DHTML i dont understand how this helps |
|
8% |
[ 2 ] |
| I use Firefox this is a stupid idea |
|
33% |
[ 8 ] |
| I know DHTML this is a reasonably good AHK adaption |
|
4% |
[ 1 ] |
| This is the best DHTML too in the AHK Forum |
|
16% |
[ 4 ] |
|
| Total Votes : 24 |
|
| Author |
Message |
tank
Joined: 21 Dec 2007 Posts: 1033
|
Posted: Mon Aug 11, 2008 5:22 am Post subject: |
|
|
I am not sure i totally get the question either
but what i think you mean is using within javascript some variable set in ahk
| Code: | js=
(
alert("%ahkvar%");
)
IE7_ExecuteJS(handle, js) | this of course seems self evedent to me but perhaps not to others
| Code: | | IE7_ExecuteJS(handle, "alert("" . ahkvar . "")") | would also work
So back to your example assuming name is an ahk variable
| Code: | IE7_ExecuteJS(myPageHandle, "for (i = 0; x <>'" . name . "'; i++){x=(document.getElementById('Table1').childNodes[1].childNodes[i].innerText); y+=(document.getElementById('Table1').childNodes[1].childNodes[i].childNodes[1].innerText)};", "y")
|
_________________ Read this
Com
Automate IE7 with Tabs |
|
| Back to top |
|
 |
CannedCheese
Joined: 21 May 2008 Posts: 85
|
Posted: Mon Aug 11, 2008 7:25 am Post subject: |
|
|
While it probably should have been obvious, I was thrown by the fact that ahk treats semi-colons wrapped in continuation sections as literal and not as comments. I assumed it would do the same for %'s.
Which is why you can write something like
| Code: |
js=
(
var i = 0; i++;
alert(i)
)
|
I just assumed that it would handle %'s literally was well and wouldn't fill in the variable contents for %name%...
e.g.
| Code: |
COM_Init()
myPageFile := IE7_Get("google")
name := "Joe"
js
(
alert(%name%)
)
IE7_ExecuteJS(myPageFile, js)
|
This should work.
Thanks for the help, guys. |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 1033
|
Posted: Mon Aug 11, 2008 1:12 pm Post subject: |
|
|
no problem ahk has ways of dealing with variables that i just shake my head at it makes no logical sense to have over 15 different conditions by which you use or dont use the modulas % there are arguments that its because chris was going for easy not catering to programmers but i differ it actually makes the language more difficult _________________ Read this
Com
Automate IE7 with Tabs |
|
| Back to top |
|
 |
lnafziger
Joined: 30 Jul 2008 Posts: 7
|
Posted: Wed Aug 13, 2008 6:27 am Post subject: |
|
|
I am trying to use this for the first time, and have a very simple example which I modified from your example. Here is what I am trying:
COM.ahk and IE7Control.ahk are both in the same directory as this script, and IE7Control.ahk includes your functions.
| Code: |
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Include IE7Control.ahk
#Include COM.ahk
COM_Init()
run iexplore.exe https://www.coltinternational.com/ColtAccess/
WinWait,AutoHotkey,,5
sleep,1000
myPageHandle:=IE7_Get("LOGON PAGE")
; MsgBox % myPageHandle
IE7_readyState(myPageHandle) ; waits for onload event of a webpage even if an onload isnt fired
msgbox DEBUG
IE7_Set_DOM(myPageHandle, "txtUser", "aokjets" )
COM_Term()
ExitApp
|
When I run it, I get the following error messages (2) which keep alternating AFTER my DEBUG MsgBox (so it happens during the IE7_Set_DOM)
| Quote: |
---------------------------
GetFuelQuotes.ahk
---------------------------
Function Name: "rdy"
ERROR: The COM Object may not be a valid one!
()
---------------------------
OK
---------------------------
---------------------------
GetFuelQuotes.ahk
---------------------------
Function Name: "execScript"
ERROR: The COM Object may not be a valid one!
()
---------------------------
OK
---------------------------
|
|
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 1033
|
Posted: Wed Aug 13, 2008 2:15 pm Post subject: |
|
|
| Code: | #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Include IE7Control.ahk
#Include COM.ahk
COM_Init()
COM_Error(0) ; turn off error prompts
/*
run iexplore.exe https://www.coltinternational.com/ColtAccess/
WinWait,AutoHotkey,,5
sleep,1000
myPageHandle:=IE7_Get("LOGON PAGE")
i really dont understand what in any of my code made u use winwait with soemthing other than the page title AND a Sleep
*/
IE7_New("https://www.coltinternational.com/ColtAccess/")
myPageHandle:=IE7_Get("LOGON PAGE")
/*
below not needed since its covered in the IE7_New function
IE7_readyState(myPageHandle) ; waits for onload event of a webpage even if an onload isnt fired
msgbox DEBUG
*/
IE7_Set_DOM(myPageHandle, "txtUser", "aokjets" )
COM_Term()
ExitApp |
or using http://www.autohotkey.com/docs/Functions.htm#lib
and cleaning this all up
| Code: | COM_Init()
COM_Error(0)
IE7_New("https://www.coltinternational.com/ColtAccess/")
myPageHandle:=IE7_Get("LOGON PAGE")
IE7_Set_DOM(myPageHandle, "txtUser", "aokjets" )
COM_Term()
ExitApp |
_________________ Read this
Com
Automate IE7 with Tabs |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 1033
|
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 1033
|
Posted: Sun Oct 05, 2008 9:14 pm Post subject: |
|
|
I am making this new function set available which is not stdlib compatable yet if someone has time they should go for it
i recently found a post from paulwarr that is quite old.
I have added his COM_InvokeDeep to this function set but had to alter it so that 64 bit integers inserted into html or element values would not be truncated
as with all of my scripts you must initialize COM first and the latest version of COM is required
you will also notice an updated inject js function
| Code: | IE7_InjectJS(MainWindow_Title, JS_to_Inject, VarNames_to_Return="",CheckState=False)
{
pwb := getwin(MainWindow_Title)
If JS_to_Inject
execScript(pwb,JS_to_Inject)
If VarNames_to_Return {
StringSplit, Vars_, VarNames_to_Return, `,
Loop, %Vars_0%
Ret .= getVar(pwb,Vars_%A_Index%)
StringTrimRight, Ret, Ret, 1
}
IfEqual,CheckState,1
complete(pwb)
COM_Release(pwb), VarSetCapacity(pwb, 0)
Return Ret
}
newGui(top=0,left=0,width=500,hieght=600)
{
If Not DllCall("GetModuleHandle", "str", "atl" . Version)
DllCall("LoadLibrary" , "str", "atl" . Version)
DllCall("atl" . Version . "\AtlAxWinInit")
Gui, +LastFound +Resize
pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(), top, left, width, hieght, "Shell.Explorer"))
gui,show, w%width% h%hieght% ,Gui Browser
Return pwb ? pwb : "Error"
}
newIe()
{
pwb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;uncomment to show
Return pwb ? pwb : "Error"
}
getwin(t)
{
Loop, % COM_Invoke(psw := COM_Invoke(psh := COM_CreateObject("Shell.Application"), "Windows"), "Count")
{
LocationName := COM_Invoke(pwb := COM_Invoke(psw, "Item", A_Index-1), "LocationName")
IfInString,LocationName,%t%
{
COM_Release(psw), VarSetCapacity(psw, 0), COM_Release(psh), VarSetCapacity(psh, 0)
Return pwb
}
COM_Release(pwb), VarSetCapacity(pwb, 0) ;didnt break so release the one we didnt use
}
COM_Release(psw), VarSetCapacity(psw, 0), COM_Release(psh), VarSetCapacity(psh, 0)
Return 0
}
IETabWindow(pwb)
{
psb := COM_QueryService(pwb,IID_IShellBrowser:="{000214E2-0000-0000-C000-000000000046}")
DllCall(NumGet(NumGet(1*psb)+12), "Uint", psb, "UintP", hwndTab)
DllCall(NumGet(NumGet(1*psb)+ 8), "Uint", psb)
Return hwndTab
}
nav(pwb,url) ; returns bool
{
If not pwb is Integer ; test to see if we have a valid interface pointer
ExitApp ; ExitApp if we dont
;~ http://msdn.microsoft.com/en-us/library/aa752133(VS.85).aspx
navTrustedForActiveX = 0x0400
COM_Invoke(pwb, "Navigate", url, 0x0400, "_self")
Return ; return the result(bool) of the complete function
} ; nav function end
complete(pwb) ; returns bool for success or failure
{
If not pwb is Integer ; test to see if we have a valid interface pointer
ExitApp ; ExitApp if we dont
loop 80 ; sets limit if itenerations to 40 seconds 80*500=40000=40 secs
{
If (rdy:=COM_Invoke(pwb,"readyState") = 4)
Return 1 ; return success
Sleep,500 ; sleep half second between cycles
}
Return 0 ; lets face it if it got this far it failed
} ; end complete
getDomObj(pwb,obj)
{
/*********************************************************************
pwb - browser object
obj - object reference optionally a comma delimited list of references a name, id, or index of all value can be used
example of useage
the below will take a browser object and try get an object called username
getDomObj(pwb,"username")
This will cycle thru objects username pass and 3
getDomObj(pwb,"username,pass,3")
*/
col := collection(pwb)
If not col is Integer
{
COM_Release(col), VarSetCapacity(col, 0)
Return 0
}
Loop,Parse,obj,`,
{
If itm := item(col, A_LoopField) ;if this fails there really isnt any need to do below
{
tx := COM_Invoke(itm, T := inpt(itm) ? "value" : "innerHTML")
StringReplace,tx,tx,`,,,,all ; escape all commas in text extracted always
rslt .= tx ","
}
COM_Release(itm), VarSetCapacity(itm, 0) ; release the item reference
}
COM_Release(col), VarSetCapacity(col, 0)
StringTrimRight, rslt, rslt, 1 ;strip trailing coma
Return rslt
}
inpt(i)
{
;~ http://msdn.microsoft.com/en-us/library/ms534657(VS.85).aspx tagname property
typ := COM_Invoke(i, "tagName")
inpt := "BUTTON,INPUT,OPTION,SELECT,TEXTAREA" ; these things all have value attribute and is likely what i need instead of innerHTML
Loop,Parse,inpt,`,
if (typ = A_LoopField ? 1 : "")
Return 1
Return
}
clickDomObj(pwb,obj)
{
/*********************************************************************
pwb - browser object
obj - object reference optionally a comma delimited list of references a name, id, or index of all value can be used
example of useage
the below will take a browser object and try click an object called username
getDomObj(pwb,"username")
This will cycle thru objects username pass and 3
clickDomObj(pwb,"username,pass,3")
*/
col := collection(pwb)
If not col is Integer
{
COM_Release(col), VarSetCapacity(col, 0)
Return 0
}
If itm := item(col, obj) ;if this fails there really isnt any need to do below
{
COM_Invoke(itm, "click")
;~ release and clear out any objects
d=1
COM_Release(itm), VarSetCapacity(itm, 0)
}
COM_Release(col), VarSetCapacity(col, 0)
Return d
}
clickText(pwb,t)
{
/*********************************************************************
pwb - browser object
obj - object reference optionally a comma delimited list of references a name, id, or index of all value can be used
example of useage
the below will take a browser object and try get an link called username
clickText(pwb,"username")
This will cycle thru objects username pass and 3
clickText(pwb,"username,pass,3")
*/
col := collection(pwb, "links")
If not col is Integer
{
COM_Release(col), VarSetCapacity(col, 0)
Return 0
}
lnklen := COM_Invoke(col, "length")
Loop,% lnklen
{
If itm := item(col, A_Index-1) ;if this fails there really isnt any need to do below
{
rslt := COM_Invoke(itm, "innerHTML")
IfInString,rslt,%t%
{
COM_Invoke(itm, "click")
d=1
COM_Release(itm), VarSetCapacity(itm, 0)
Break
}
;~ release and clear out any objects
}
COM_Release(itm), VarSetCapacity(itm, 0)
}
COM_Release(col), VarSetCapacity(col, 0)
Return d
}
clickHref(pwb,t)
{
/*********************************************************************
pwb - browser object
obj - object reference optionally a comma delimited list of references a name, id, or index of all value can be used
example of useage
the below will take a browser object and try get an link called username
clickText(pwb,"username")
This will cycle thru objects username pass and 3
clickText(pwb,"username,pass,3")
*/
col := collection(pwb, "links")
If not col is Integer
{
COM_Release(col), VarSetCapacity(col, 0)
Return 0
}
lnklen := COM_Invoke(col, "length")
Loop,% lnklen
{
If itm := item(col, A_Index-1) ;if this fails there really isnt any need to do below
{
rslt := COM_Invoke(itm, "href")
IfInString,rslt,%t%
{
rslt := COM_Invoke(itm, "click")
;~ release and clear out any objects
COM_Release(itm), VarSetCapacity(itm, 0)
Break
}
}
COM_Release(itm), VarSetCapacity(itm, 0)
}
COM_Release(col), VarSetCapacity(col, 0)
Return 0
}
clickValue(pwb,t)
{
/*********************************************************************
pwb - browser object
t - text to match from visible button
example of useage
the below will take a browser object and try get an object called username
clickValue(pwb,"submit")
*/
col := collection(pwb)
If not col is Integer
{
COM_Release(col), VarSetCapacity(col, 0)
Return 0
}
lnklen := COM_Invoke(col, "length")
Loop,% lnklen
{
If itm := item(col, A_Index-1) ;if this fails there really isnt any need to do below
{
If r:=inpt(itm)
{
rslt := COM_Invoke(itm, "value")
IfInString,rslt,%t%
{
COM_Invoke(itm, "click")
d=1
COM_Release(itm), VarSetCapacity(itm, 0)
break
}
}
}
COM_Release(itm), VarSetCapacity(itm, 0)
}
COM_Release(col), VarSetCapacity(col, 0)
Return d
}
setDomObj(pwb,obj,t)
{
/*********************************************************************
pwb - browser object
obj - object reference optionally a comma delimited list of references a name, id, or index of all value can be used
t - text to replace existing contents with optionally a comma delimited list of references a name, id, or index of all value can be used
example of useage
the below will take a browser object and try get an object called username and set its value or innerHTML to john
setDomObj(pwb,"username","john")
This will cycle thru objects username pass and 3 and set them in that order to john sam and paul
setDomObj(pwb,"username,pass,3","john,sam,paul")
*/
col := collection(pwb)
If not col is Integer
{
COM_Release(col), VarSetCapacity(col, 0)
Return 0
}
StringSplit,tt,t,`,
Loop,Parse,obj,`,
{
If itm := item(col, A_LoopField) ;if this fails there really isnt any need to do below
{
StringReplace,tt%A_Index%,tt%A_Index%,,,`,,all ; unescape all commas in text extracted always
;~ making invoke take integers as Strings ", VT_BSTR:=8"
;~ http://www.autohotkey.com/forum/viewtopic.php?p=221631#221631
COM_Invoke_(itm, v := inpt(itm) ? "Value=" : "innerHTML=", VT_BSTR:=8, tt%A_Index%)
COM_Release(itm), VarSetCapacity(itm, 0)
d=1
Break
}
COM_Release(itm), VarSetCapacity(itm, 0)
}
COM_Release(col), VarSetCapacity(col, 0)
Return d
}
execScript(pwb,js)
{
If not pwb is Integer ; test to see if we have a valid interface pointer
ExitApp ; ExitApp if we dont
If js=
Return "js is null"
IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"
pwin := COM_QueryService(pwb, IID_IHTMLWindow2, IID_IHTMLWindow2)
COM_Invoke(pwin, "execScript", js)
COM_Release(pwin), VarSetCapacity(pwin, 0)
Return
}
getVar(pwb,var)
{
If not pwb is Integer ; test to see if we have a valid interface pointer
ExitApp ; ExitApp if we dont
IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"
pwin := COM_QueryService(pwb, IID_IHTMLWindow2, IID_IHTMLWindow2)
rslt := var ? COM_Invoke(pwin, var) : ""
COM_Release(pwin), VarSetCapacity(pwin, 0)
Return rslt
}
gettext(obj)
{
Return (obj Is Integer ? (inpt(obj) ? COM_Invoke(obj, "value") : COM_Invoke(obj, "innerHTML")) : "Error")
}
settext(obj,t)
{
if obj Is Integer
COM_Invoke_(obj, v := inpt(typ) ? "Value=" : "innerHTML=", VT_BSTR:=8, t)
}
collection(pwb,col="all")
{
pdoc := pdoc(pwb)
If not pdoc is Integer
{
COM_Release(pdoc), VarSetCapacity(pdoc, 0)
Return
}
c := COM_Invoke(pdoc, col)
COM_Release(pdoc), VarSetCapacity(pdoc, 0)
Return c
}
item(col,i)
{
If not col is Integer
{
COM_Release(col), VarSetCapacity(col, 0)
Return
}
c := COM_Invoke(col, "Item", i)
Return c
}
pdoc(pwb)
{
If not pwb is Integer ; test to see if we have a valid interface pointer
Return ; ExitApp if we dont
IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"
pwin := COM_QueryService(pwb, IID_IHTMLWindow2, IID_IHTMLWindow2)
pdoc := COM_Invoke(pwin, "Document")
If not pdoc is Integer
{
COM_Release(pdoc), VarSetCapacity(pdoc, 0), COM_Release(pwin), VarSetCapacity(pwin, 0)
Return
}
COM_Release(pwin), VarSetCapacity(pwin, 0)
Return pdoc
}
striphtml(txt)
{
x = %txt%
Loop Parse, x, <>
If (A_Index & 1)
y = %y%%A_LoopField%
return y
}
escape_text(txt)
{
StringReplace,txt,txt,',\',ALL
StringReplace,txt,txt,"",\"",ALL
;~ StringReplace,txt,txt,`.`.,`.,ALL
StringReplace,txt,txt,`r,%a_space%,ALL
StringReplace,txt,txt,`n,%a_space%,ALL
StringReplace,txt,txt,`n`r,%a_space%,ALL
StringReplace,txt,txt,%a_space%%a_space%,%a_space%,ALL
return txt
}
; Usage:
; res := COM_InvokeDeep(res, dotted-path, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
; Example:
; pBody2 := COM_InvokeDeep(pweb, "document.frames[1].document.body")
; (returns pointer to the body portion of the HTML document located in the second frame on the
; loaded web page, where pweb is a pointer to the parent IID_IHTMLWindow2.
; http://www.autohotkey.com/forum/post-182062.html#182062 and modified to handle 64 bit numbers by me 10/5
COM_InvokeDeep(obj, path, arg1="vT_NoNe", arg2="vT_NoNe", arg3="vT_NoNe", arg4="vT_NoNe", arg5="vT_NoNe", arg6="vT_NoNe", arg7="vT_NoNe", arg8="vT_NoNe")
{
res := obj
COM_AddRef(res) ; compensate for loop's Release()
PathCt := 0
Loop, Parse, Path, .
{
PathCt++
}
Loop, Parse, Path, ., ]
{
prop := A_LoopField
value =
StringGetPos, i, A_LoopField, [
IfEqual, ErrorLevel, 0 ; contains index
{
StringLeft, prop, A_LoopField, %i%
StringMid, value, A_LoopField, % i+2
}
If (value != "") ; contains index or parameter passed to a method, enclosed in "[]"
{
If (prop = "item") or (RegExMatch(value, "^[0-9]+$") = false) ; "item" already specified, or method call
{
If (A_Index < PathCt)
propobj := COM_Invoke(res, prop, value)
Else
propobj := COM_Invoke(res, prop, value, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
COM_Release(res), VarSetCapacity(res, 0)
res := propobj
}
Else
{
propobj := COM_Invoke(res, prop)
If (A_Index < PathCt)
itemobj := COM_Invoke(propobj, "Item", value)
Else
itemobj := COM_Invoke(propobj, "Item", value, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
COM_Release(res), VarSetCapacity(res, 0)
COM_Release(propobj), VarSetCapacity(propobj, 0)
res := itemobj
}
}
Else
{
If (A_Index < PathCt)
propobj := COM_Invoke(res, prop)
Else
{
sParams := 12345678
int:=False
Loop, Parse, sParams
If arg%A_LoopField% is Integer
{
int:=true
Break
}
If int
{
Loop, Parse, sParams
{
If (arg%A_LoopField% == "vT_NoNe")
{
arg%A_LoopField% := ""
VT_BSTR%A_LoopField%:=""
}
Else
VT_BSTR%A_LoopField%:=8
}
propobj := COM_Invoke_(res, prop, VT_BSTR1,arg1,VT_BSTR2,arg2, VT_BSTR3,arg3, VT_BSTR4,arg4, VT_BSTR5,arg5, VT_BSTR6,arg6, VT_BSTR7,arg7, VT_BSTR8,arg8)
}
Else
propobj := COM_Invoke(res, prop, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
}
COM_Release(res), VarSetCapacity(res, 0)
res := propobj
}
if !res ; no sense in continuing - object not found (returns 0 or null)
break
}
Return res
} |
really breife example of use | Code: | COM_Init()
pwb := newGui()
nav(pwb,"http://www.google.com")
complete(pwb)
doc := pdoc(pwb)
q := COM_InvokeDeep(doc, "getElementsByName[q].item[0].value","123456789132456789")
COM_InvokeDeep(doc, "parentwindow.execScript","alert('hi')")
COM_Term()
exitapp | For the most part i tested most of this extensively but im sure i missed something enjoy kids _________________ Read this
Com
Automate IE7 with Tabs |
|
| Back to top |
|
 |
rani
Joined: 18 Mar 2008 Posts: 95
|
Posted: Wed Oct 08, 2008 11:44 am Post subject: IE window object |
|
|
Hi Tank,
I tried the IE components and run JS commands via JS exec.
and it is working prefect.
but this was IE object that I made the instance.
how I can get the IE instance that is running already in a PC ?
how I iterate by on running IE objects,
make some checking,
that 'this' is the IE I need, and the loop can distinguish that this an IE window and not some other window ?
rgrds
ran |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 1033
|
Posted: Wed Oct 08, 2008 11:48 am Post subject: |
|
|
| Code: | | ;~ IE7_Get(title,url="http") gets iwebrowser interface pointer and returns automation dhtml window obj ie parentWindow used itn the below functions |
_________________ Read this
Com
Automate IE7 with Tabs |
|
| Back to top |
|
 |
pantagruel
Joined: 08 Oct 2006 Posts: 91 Location: denmark
|
Posted: Mon Oct 20, 2008 11:25 am Post subject: how to WinActivate a tab |
|
|
| Sean wrote: |
IE7 supports multi-tab windows, but the conventional WebBrowser control is lacking of a function to differentiate one among them, the HWND function in IWebBrowser2 object always returns the window handle of IEFrame, not the new window class TabWindowClass.
Here is a method to obtain the window handle of TabWindowClass from the IWebBrowser2 object pwb (:if applied to IE6 etc, I think it'll just return the window handle of IEFrame).
| Code: | IETabWindow(pwb)
{
psb := COM_QueryService(pwb,IID_IShellBrowser:="{000214E2-0000-0000-C000-000000000046}")
DllCall(NumGet(NumGet(1*psb)+12), "Uint", psb, "UintP", hwndTab)
DllCall(NumGet(NumGet(1*psb)+ 8), "Uint", psb)
Return hwndTab
}
|
|
Ok, so how would one use this to WinActivate or otherwise activate the tab of a browser?
If I use your IETabWindow function and do something like:
| Code: |
IE7_Nav(title,url) {
COM_Init()
Loop, % COM_Invoke(psw := COM_Invoke(psh:=COM_CreateObject("Shell.Application"), "Windows"), "Count")
{
pwb := COM_Invoke(psw, "Item", A_Index-1)
taburl:=COM_Invoke(pwb, "LocationUrl")
SetTitleMatchMode,2
IfInString,taburl,%url%
{
normalhandle := COM_Invoke(pwb, "hWnd")
titlename := COM_Invoke(pwb, "LocationName")
hwnd := IETabWindow(pwb)
hParent := DllCall("GetParent", "Uint",hwnd)
msgbox, %normalhandle%
msgbox, %hParent%
msgBox, %hwnd%
msgBox, %titlename%
WinActivate ahk_id %hwnd%
}
}
COM_Release(psh),COM_Release(psw), COM_Term()
}
IETabWindow(pwb)
{
psb := COM_QueryService(pwb,IID_IShellBrowser:="{000214E2-0000-0000-C000-000000000046}")
DllCall(NumGet(NumGet(1*psb)+12), "Uint", psb, "UintP", hwndTab)
DllCall(NumGet(NumGet(1*psb)+ 8), "Uint", psb)
Return hwndTab
}
IE7_Nav("my title","http://vm-demo:8080/sites/1030/BlankWebPartPage.aspx")
|
If I use hwnd to try to activate the tab I get nothing. If I use normalhandle it activates the toplevel window, if I use titlename it activates the window if it is the activate tab in the window, otherwise nothing happens.
I was thinking what I could do is get the actual IE tab, activate the parent id, then tab between the various tabs in that window and test the active window title - but that still doesn't give me the perfect solution which is activating a tab by that tabs window handle.
Any suggestions?[/code] |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 1033
|
Posted: Mon Oct 20, 2008 1:43 pm Post subject: Re: how to WinActivate a tab |
|
|
| pantagruel wrote: | | Ok, so how would one use this to WinActivate or otherwise activate the tab of a browser? |
in short you wouldnt i know of absolutely no way to single out and activate a tab.
the best you could hope for is to cycle thru the tabs with ctrl+shift+tab
out of curiosity why is it you beleive you need to activate a tab _________________ Read this
Com
Automate IE7 with Tabs |
|
| Back to top |
|
 |
pantagruel
Joined: 08 Oct 2006 Posts: 91 Location: denmark
|
Posted: Mon Oct 20, 2008 1:58 pm Post subject: Reason to activate a tab |
|
|
| The reason is simply that there will be an application running in one particular tab, if it is running there I should activate that tab and run some particular sequence of actions in the open Tab rather than starting a new tab. Basically the same reason for activating a particular browser window in earlier versions of IE. |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 1033
|
Posted: Mon Oct 20, 2008 2:07 pm Post subject: |
|
|
all of my scripts are designed to run while minimized i never activate
so if you had 3 applications open tab 1 and 2 and one on a minimized window the scripts to not need any of them to be active to work _________________ Read this
Com
Automate IE7 with Tabs |
|
| Back to top |
|
 |
pantagruel
Joined: 08 Oct 2006 Posts: 91 Location: denmark
|
Posted: Tue Oct 21, 2008 7:47 am Post subject: |
|
|
| Quote: |
all of my scripts are designed to run while minimized i never activate
so if you had 3 applications open tab 1 and 2 and one on a minimized window the scripts to not need any of them to be active to work |
ok well that makes sense, so what happens is that you do the get an already running tab and inject the JS into it to do some action which is fine, but unfortunately the automation I am trying to do is also requires user interaction at times.
I am looking at this currently as a possible way to get the tab
http://codecentrix.blogspot.com/2007/11/how-to-get-handle-to-current.html although having difficulty translating that nto the COM_Invoke idiom.
[/quote] |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 1033
|
Posted: Tue Oct 21, 2008 11:46 am Post subject: |
|
|
the current tab will affect the windowtitle. in which cace you CAN use winactivate _________________ Read this
Com
Automate IE7 with Tabs |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|