AutoHotkey Community

It is currently May 27th, 2012, 9:22 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 56 posts ]  Go to page Previous  1, 2, 3, 4

Did this guide help you?
Ya! COM ftw rawr!
No. I am now dumber for having read this...
You may select 1 option

View results
Author Message
 Post subject:
PostPosted: December 27th, 2011, 9:39 pm 
Offline

Joined: February 29th, 2008, 12:11 pm
Posts: 943
sinkfaze wrote:
For DOM (or HTML or DHTML or what have you), how objects work isn't quite as broad as how they work in Excel, but the same principles generally apply. For instance, if you wanted to access a cell in a table, you wouldn't expect to go through the links object to do it. That's why you only access cells through a rows collection, which is accessed through a table object. It's a matter of sorting and limiting how things are accessed.

And just to re-emphasize, Microsoft's HTML and DHTML Reference is an excellent resource to keep around for your own learning

- 1) When you are talking here about objects in HTML here what programming language do you mean? I looked up the references you gave me and it seems that javascript is the language being considered there.

2) When you talk about objects here, is it somehow different from Object-oriented programming or you are still taking about the same thing? I am still at the very beginning of learning OOP in AHK_L;

3) You mentioned HTML here. Actually, I am quite familiar with HTML, but I had no idea that HTML would be somehow related to objects. I thought objects are altogether an attribute of programming in some OOP language, but I have never considered HTML to be a programming language;

4) Thank you for all these references.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 27th, 2011, 9:57 pm 
Offline

Joined: July 6th, 2011, 5:37 pm
Posts: 214
Location: Looking over my domain
I think the key concept your missing here Benny is that it doesnt matter about the language the objects are the same
the only difference would be syntax accross languages to create an object. in the case of ahk_L vs javascript very little at all will change once you have created the base object.
if in javascript you would go
Code:
var somevar = document.getElementsByID("someid").innerText;
then in ahk it would be
Code:
somevar := IE.document.getElementsByID("someid").innerText
the current window is assumed from javascript within the page so it isnt created explicitely like you would have to do with ahk
Code:
 ControlGet,cHwnd, Hwnd,, Internet Explorer_Server1, ahk_class IEFrame
IE  := IE_GetBrowser(cHwnd)

IE_GetBrowser(hWnd)
   {
   static IID_IHTMLWindow2   := "{332C4427-26CB-11D0-B483-00C04FD90119}", IID_IWebBrowserApp := "{0002DF05-0000-0000-C000-000000000046}" 
   return, ComObj(9,ComObjQuery(ComObj(9,ComObjQuery(Acc_ObjectFromWindow(hwnd),IID_IHTMLWindow2,IID_IHTMLWindow2),1),IID_IWebBrowserApp,IID_IWebBrowserApp),1)
   }
is one way to get the topmost browser

_________________
Image Stolen from SKAN


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2011, 6:49 am 
Offline

Joined: February 29th, 2008, 12:11 pm
Posts: 943
Zod wrote:
I think the key concept your missing here Benny is that it doesn't matter about the language the objects are the same
the only difference would be syntax across languages to create an object. in the case of ahk_L vs javascript very little at all will change once you have created the base object

- Thank you very much, Zod, for these explanations and for the diagram above. The last piece of code has a lot of mysterious points to me. I think I will firstly try fathoming the matter of objects and object-programming in this thread as I started that one specially for that purpose (I was given a lot of good examples that I haven't fully researched yet. As far as I understand, objects is one of the key new features that make AHK_L different from AHK.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 19th, 2012, 3:46 am 
Please help me guys. I'd like to use the InternetExplorer.Application object to download the whole HTML into a variable. But how?

Pwb := ComObjCreate("InternetExplorer.Application")
Pwb.Visible := True
Pwb.Navigate("http://www.google.com")

ok, this works so far. How can I have the whole page HTML in a string variable. I expected...

HTML := Pwb.document.all

will work, but it doensn't, cuz it is an object not a text. And I can not use innertext or innerhtml like this...

HTML := Pwb.document.all.innerhtml

this is simply not working. So, how? Clould you please help?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2012, 6:23 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Code:
Pwb.document.documentElement.outerHTML

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2012, 8:09 am 
jethrow wrote:
Code:
Pwb.document.documentElement.outerHTML


Thank You!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 21st, 2012, 11:04 pm 
Offline
User avatar

Joined: February 28th, 2012, 11:13 pm
Posts: 59
Location: Denmark
Mickers wrote:
Now that weve proven that we can locate a post based on the name and author let's try to navigate to that post. I haven't had any luck using the Click() method to follow the hyperlink so instead were going to use a work around:

Code:
URL := IE.LocationURL ; grab the current url
Rows := IE.Document.All.Tags("table")[4].Rows ; table 4 holds all the post information

Loop % Rows.Length
   If InStr(Rows[A_Index].InnerText, "What's on your mind?") and InStr(Rows[A_Index].InnerText, "tomoe_uehara") { ; if post title and author match
      HTML := Rows[A_Index].Cells[1].InnerHTML ; pull the html off the page
      Needle := "viewtopic.php?t=" ; string to search for
      StringGetPos, Pos, HTML, %Needle% ; get starting position of search string
      Pos += 17 ; search 17 characters to the right
      StringMid, Post, HTML, Pos, 5 ; pull the unique post number out of the html
      StringTrimRight, URL, URL, 13 ; cut off forum.php?f=
      URL .= "topic.php?t=" . Post ; set to topic + unique post number
      IE.Navigate(URL) ; navigate to the post
      break
   }

I spent several hours trying to get the Click() method to work for this example but sometimes it's just easier to stick with what you know.


Hey all im a little new to .ahk and programing but im trying to learn all that i can and I've done some trial and error to see if i could get this Click() to work and i found a way and thought i'ed share it here for anyone who'd like to know... :D

Code:
Loop % Rows.Length
   If InStr(Rows[A_Index-1].InnerText, "What's on your mind?") and InStr(Rows[A_Index-1].InnerText, "tomoe_uehara") { ; if post title and author match
      Rows[A_Index-1].GetElementsByTagName("A")[0].Click()
   }


The "GetElementsByTagName("A")[0]"'s InnerText is "« What's on your mind? »" you can also use [1] because its the link for page 1 but thats only for multipage threads so no need for that :lol:


At least it works for me :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Need help
PostPosted: March 30th, 2012, 2:40 am 
Offline

Joined: February 21st, 2012, 5:51 pm
Posts: 7
Hi Mickers and all others who can help,

Thanks for the great tutorial - now I understand a bit more how the IEGet() function is working and how it could be used. I tried a little bit with this function and was able to "manipulate" some DOM-Objects on Webpages. Now the problem:

I taken an open webpage, set the WB and use the wb.navigate to get to another page. But I have 15 open Tabs in IE and use only 1 to navigate. If the one wich I "manipulate" is not the active one then all happens in background - It is still working fine but I need to search through the 15 Tabs to find the one wich was navigated. Is there any way to set the IE-Tab wich is used for the WB to the active one ( WinActivate only activates when the used Tab is currently the active Tab in this IE Window - but doesn't work if the Tab is "inactive")

Sounds complicated - I know - just as a sample:
I have 3 Tabs (Bing, Google, Autohotkey.com)
Bing is currently the activ Tab
I set the WB to Google and let it Navigate to Ebay
Now the 3 Tabs are Bing, Ebay, Autohotkey.com but as active Tab in Front still Bing is shown but I want to see the Ebay automaticly in front.

I allready mixed up different AHK commands & Javascript like window.focus a.s.o. but it was all ignored by my system... :(

Thanks for answering


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 25th, 2012, 6:00 pm 
Offline

Joined: November 18th, 2010, 7:26 pm
Posts: 124
Is there a way to force the IE pointer to create a new IE window, rather than dealing with the IE settings default of open in current tab/new tab/new window?

Something like this line, but just forcing your own new window preference rather than using the IE defaults:
Code:
Pwb := ComObjCreate("InternetExplorer.Application")


I do see that you can use a run switch like this, but then there is no pointer associated with it:
Code:
run iexplore.exe -new google.com


Any ideas? Or should I be looking at creating the window with run and then using a function to look for the particular IE window and attach the pointer to it after the fact?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 25th, 2012, 7:14 pm 
Offline

Joined: October 11th, 2010, 6:15 pm
Posts: 1211
Location: Right behind you
I'm not sure what you mean by "forcing your own new window preference"s. Can you elaborate?
Code:
; misaiahh@gmail.com

; create new window
run iexplore.exe -new google.com
Sleep, 5000

; grab new window
pwb := false
for window in ComObjCreate("Shell.Application").Windows
{
   if (window.LocationName == "Google")
   {
      pwb := window
      break
   }
}

; check if window was found
if (!pwb)
{
   MsgBox, Window not found.
   ExitApp
}

; test
pwb.Navigate("autohotkey.com")
Pause
An issues with this script is it will pull the first window named "google" it finds. If you already have an open google window it will connect with that.

_________________
COM Tutorial for Webpages
COM Tutorial for Excel


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 25th, 2012, 7:29 pm 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
You can use IEGet() by jethrow... I found a copy of it here: viewtopic.php?t=72471

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 56 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC [ DST ]


Who is online

Users browsing this forum: Ragnar and 12 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