AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with using COM

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Erittaf



Joined: 02 Nov 2007
Posts: 182

PostPosted: Wed Feb 20, 2008 8:00 pm    Post subject: Help with using COM Reply with quote

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 Smile
Back to top
View user's profile Send private message Send e-mail
Jero3n



Joined: 19 Jan 2007
Posts: 151

PostPosted: Wed Feb 20, 2008 8:32 pm    Post subject: Reply with quote

Isn't it just WinExist() without parameters?
I'm not sure..
_________________

Watch my css video!
Back to top
View user's profile Send private message
Erittaf



Joined: 02 Nov 2007
Posts: 182

PostPosted: Wed Feb 20, 2008 8:41 pm    Post subject: Reply with quote

fron the manual:
Wink
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 Very Happy
Back to top
View user's profile Send private message Send e-mail
ahklerner



Joined: 26 Jun 2006
Posts: 1249
Location: USA

PostPosted: Wed Feb 20, 2008 8:58 pm    Post subject: Reply with quote

look at the ie_injectjs script.
_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
tonne



Joined: 06 Jun 2006
Posts: 1259
Location: Denmark

PostPosted: Wed Feb 20, 2008 9:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
Erittaf



Joined: 02 Nov 2007
Posts: 182

PostPosted: Wed Feb 20, 2008 9:35 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
tonne



Joined: 06 Jun 2006
Posts: 1259
Location: Denmark

PostPosted: Wed Feb 20, 2008 9:46 pm    Post subject: Reply with quote

; 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
View user's profile Send private message
Erittaf



Joined: 02 Nov 2007
Posts: 182

PostPosted: Wed Feb 20, 2008 10:07 pm    Post subject: Reply with quote

cool!!! know where i can find a COM for dummies book?
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group