AutoHotkey Community

It is currently May 26th, 2012, 5:48 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Help with using COM
PostPosted: February 20th, 2008, 9:00 pm 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
I have found the COM function that I need to retrieve a url from IE here:
http://www.autohotkey.com/forum/viewtop ... ocationurl

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 :-)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2008, 9:32 pm 
Offline

Joined: January 19th, 2007, 9:09 pm
Posts: 147
Isn't it just WinExist() without parameters?
I'm not sure..

_________________
Image
Watch my css video!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2008, 9:41 pm 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
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 :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2008, 9:58 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
look at the ie_injectjs script.

_________________
Image
ʞɔпɟ əɥʇ ʇɐɥʍ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2008, 10:00 pm 
Offline

Joined: June 6th, 2006, 3:19 pm
Posts: 1654
Location: Denmark
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.

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2008, 10:35 pm 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
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]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2008, 10:46 pm 
Offline

Joined: June 6th, 2006, 3:19 pm
Posts: 1654
Location: Denmark
; 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)

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2008, 11:07 pm 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
cool!!! know where i can find a COM for dummies book?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: bobbysoon, Google Feedfetcher, JSLover, patgenn123, tank and 61 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group