| View previous topic :: View next topic |
| Author |
Message |
Erittaf
Joined: 02 Nov 2007 Posts: 182
|
Posted: Wed Feb 20, 2008 8:00 pm Post subject: Help with using COM |
|
|
I have found the COM function that I need to retrieve a url from IE here:
http://www.autohotkey.com/forum/viewtopic.php?t=19255&highlight=locationurl
I can't figure out how to just get the URL of the currently active IE window.
Something like this: (does not work)
| Code: |
COM_Init()
pwb := WinExist ("A") ;<---- pretty sure this is wrong
CurrentURL := COM_Invoke(pwb, "LocationURL")
Msgbox, %CurrentUrl%
return
|
I've looked around for a definition of "pwb" but couldn't find one. a search with COM in it turns up a LOT of results (mostly scripts using yahoo.com or google.com for examples)
I have the list of COM functions, just need to know what to pass to them to get them to work  |
|
| Back to top |
|
 |
Jero3n
Joined: 19 Jan 2007 Posts: 151
|
Posted: Wed Feb 20, 2008 8:32 pm Post subject: |
|
|
Isn't it just WinExist() without parameters?
I'm not sure.. _________________
Watch my css video! |
|
| Back to top |
|
 |
Erittaf
Joined: 02 Nov 2007 Posts: 182
|
Posted: Wed Feb 20, 2008 8:41 pm Post subject: |
|
|
fron the manual:
| Quote: | | The function WinExist() returns the Unique ID (HWND) of the first matching window (0 if none). Since all non-zero numbers are seen as "true", the statement if WinExist("WinTitle") is true whenever WinTitle exists. | WinExist("A") will retrieve the HWND of the active window.
My problem is COM_Invoke wants something other than a HWND in the pwb variable, I don't know what it does want though. thanks for the effort though  |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1249 Location: USA
|
Posted: Wed Feb 20, 2008 8:58 pm Post subject: |
|
|
look at the ie_injectjs script. _________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1259 Location: Denmark
|
Posted: Wed Feb 20, 2008 9:00 pm Post subject: |
|
|
I rewrote sean's example:
| Code: | COM_Init()
psh := COM_CreateObject("Shell.Application")
psw := COM_Invoke(psh, "Windows")
Loop, % COM_Invoke(psw, "Count")
{
pwb := COM_Invoke(psw, "Item", A_Index-1)
; note here the wnd of Item[A_Index-1] is found
wnd := COM_Invoke(pwb, "hWnd")
sInfo .= COM_Invoke(pwb, "hWnd") . " : """ . COM_Invoke(pwb, "LocationURL") . """,""" . COM_Invoke(pwb, "LocationName") . """,""" . COM_Invoke(pwb, "StatusText") . """,""" . COM_Invoke(pwb, "Name") . """,""" . COM_Invoke(pwb, "FullName") . """`n"
COM_Release(pwb)
}
COM_Release(psw)
COM_Release(psh)
COM_Term()
MsgBox, % sInfo
Return |
I don't know which window id but my point is that pwb is returned from the iteration on windows in shell.application and that you dont invoke "locationurl" with a window id. _________________ there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face
- Kashmir |
|
| Back to top |
|
 |
Erittaf
Joined: 02 Nov 2007 Posts: 182
|
Posted: Wed Feb 20, 2008 9:35 pm Post subject: |
|
|
hrm... all this i know. can anyone tell me what to hand it, or walk me through understanding what all this garbledee goop means? I know it works but I want to know why and how!! | Code: | psh := COM_CreateObject("Shell.Application")
psw := COM_Invoke(psh, "Windows")
Loop, % COM_Invoke(psw, "Count")
{
pwb := COM_Invoke(psw, "Item", A_Index-1)
| [/code] |
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1259 Location: Denmark
|
Posted: Wed Feb 20, 2008 9:46 pm Post subject: |
|
|
; ask the OS COM to create a named object Shell.Application
psh := COM_CreateObject("Shell.Application")
; call the function named Windows on the created object
; presumable this returns another new created object
psw := COM_Invoke(psh, "Windows")
; loop for all windows (get the count by calling the count function on the windows object
Loop, % COM_Invoke(psw, "Count")
{
; create an object representing the a_index-1'th item by calling the function Item with an index on the windows object
pwb := COM_Invoke(psw, "Item", A_Index-1) _________________ there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face
- Kashmir |
|
| Back to top |
|
 |
Erittaf
Joined: 02 Nov 2007 Posts: 182
|
Posted: Wed Feb 20, 2008 10:07 pm Post subject: |
|
|
| cool!!! know where i can find a COM for dummies book? |
|
| Back to top |
|
 |
|