AutoHotkey Community

It is currently May 27th, 2012, 2:13 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 271 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 19  Next

Do you think this tutorial is beneficial to the AHK Community?
Yeah, I think this tutorial is a great value-add to the Community.
Nope - I think this tutorial is a waste of web space.
I think this tutorial would be better if it incorporated AHK_L & COM_L.
You may select 1 option

View results
Author Message
 Post subject:
PostPosted: February 3rd, 2010, 6:32 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Have you navigated to the page yet?

Code:
url:="http://www.thatwebsiteyourlywant2get2.com"
COM_Init()
pwb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
COM_Invoke(pwb, "Navigate",url)
Loop
  if (COM_Invoke(pwb,"readyState") = 4) ; wait for page to load
    break

text := COM_Invoke(pwb, "document.documentElement.outerHTML") ; should be correct to get the source
msgbox %text%

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 6:37 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
sinkfaze wrote:
Have you navigated to the page yet?

Code:
url:="http://www.thatwebsiteyourlywant2get2.com"
COM_Init()
pwb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pwb , "Visible=", "True") ;"False" ;"True" ;
COM_Invoke(pwb, "Navigate",url)
Loop
  if (COM_Invoke(pwb,"readyState") = 4) ; wait for page to load
    break

text := COM_Invoke(pwb, "document.documentElement.outerHTML") ; should be correct to get the source
msgbox %text%


This is awesome, and exactly the example I'm looking for (thank you!) but I still receive an error.

I am using AHK_L and the COM (not _L) standard library at the moment. I'm thinking this might be the problem.

Do I have to use the latest official AHK with this?
Can I use AHK_L and the COM_L library?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 7:42 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
randallf wrote:
I am using AHK_L and the COM (not _L) standard library at the moment.
Don't do that :(

randallf wrote:
Can I use AHK_L and the COM_L library?
Try this:
Code:
url:="http://www.thatwebsiteyourlywant2get2.com"
pwb := COM_CreateObject("InternetExplorer.Application")
pwb.Visible := True
pwb.Navigate(url)
Loop
  if (pwb.readyState = 4) ; wait for page to load
    break
text := pwb.document.documentElement.outerHTML ; should be correct to get the source
msgbox %text%

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 4th, 2010, 4:43 pm 
Offline

Joined: January 26th, 2010, 6:16 pm
Posts: 5
[*]Dropdown Box Selection - selectedIndex
Quote:
<SELECT class=post name=sort_by><OPTION selected value=0>Post Time</OPTION><OPTION value=1>Post Subject</OPTION><OPTION value=2>Topic Title</OPTION><OPTION value=3>Author</OPTION><OPTION value=4>Forum</OPTION></SELECT>
This is the HTML for the Sort By Dropdown. The following will set the Dropdown to Author:
Code:
javascript: document.all.sort_by.selectedIndex = 3; void 0   ; Note - you could use value = 3
COM_Invoke(pwb, "document.all.sort_by.selectedIndex", 3)


I'm having troube getting the example to work with a drop down.
When I use IE HTML Element SPY I get a code of:
<SELECT style="WIDTH: 100px" id=selectedStatus onchange=javascript:changeMailingStatus(this.value,20); name=test> <OPTION selected value=0>Select Status</OPTION> <OPTION value=5>Archive</OPTION></SELECT>

There are multiple drop dows on the page. The next one would be:
<SELECT style="WIDTH: 100px" id=selectedStatus onchange=javascript:changeMailingStatus(this.value,21); name=test> <OPTION selected value=0>Select Status</OPTION> <OPTION value=5>Archive</OPTION></SELECT>

Any insight on how I would get AHK to make the appropriate selection to 5>Archive?

Thank You for the support.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2010, 5:48 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
It should just be:
Code:
javascript: document.all.selectedStatus.selectedIndex = 5; void 0   ; Note - you could use value = 5
COM_Invoke(pwb, "document.all.selectedStatus.selectedIndex", 5)


Now, this drop down also has an "onchange" event
Quote:
:<SELECT style="WIDTH: 100px" id=selectedStatus onchange=javascript:changeMailingStatus(this.value,20); name=test> <OPTION selected value=0>Select Status</OPTION> <OPTION value=5>Archive</OPTION></SELECT>
You should be able to invoke this using the fireEvent method:
Code:
javascript: document.all.selectedStatus.selectedIndex.fireEvent('onchange')
COM_Invoke(pwb, "document.all.selectedStatus.selectedIndex.fireEvent", "onchange")
NOTE - untested

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2010, 11:09 pm 
Offline

Joined: January 26th, 2010, 6:16 pm
Posts: 5
jethrow wrote:
It should just be:
Code:
javascript: document.all.selectedStatus.selectedIndex = 5; void 0   ; Note - you could use value = 5
COM_Invoke(pwb, "document.all.selectedStatus.selectedIndex", 5)


Now, this drop down also has an "onchange" event
Quote:
:<SELECT style="WIDTH: 100px" id=selectedStatus onchange=javascript:changeMailingStatus(this.value,20); name=test> <OPTION selected value=0>Select Status</OPTION> <OPTION value=5>Archive</OPTION></SELECT>
You should be able to invoke this using the fireEvent method:
Code:
javascript: document.all.selectedStatus.selectedIndex.fireEvent('onchange')
COM_Invoke(pwb, "document.all.selectedStatus.selectedIndex.fireEvent", "onchange")
NOTE - untested


How do I diferentiate bewteen the different dropdowns?
There are multiple per page, the only thing I can see that could possably be an identifier is "(this.value,20)" which inciments +1 for the next dropdown available.
I assume I somehow need to include that into the scripting?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 5th, 2010, 12:33 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Gundeck wrote:
How do I diferentiate bewteen the different dropdowns?
By "dropdowns", I'm assuming you mean different dropdown boxes, and not the different options in the dropdown. Each dropdown should have a unique id
Quote:
<SELECT style="WIDTH: 100px" id=selectedStatus onchange=javascript:changeMailingStatus(this.value,20); name=test> <OPTION selected value=0>Select Status</OPTION> <OPTION value=5>Archive</OPTION></SELECT>

You're examples don't seem to follow this, which I haven't seen before. You could also get a collection of all the SELECT (dropdown) elements on the page:
Code:
javascript: select=document.all.tags('SELECT'); alert('There are ' + select.length + ' dropdowns on the page.')
select := COM_Invoke(pwb, "document.all.tags", "SELECT")
MsgBox, % "There are " COM_Invoke(select, "length") " dropdowns on the page."
*Remember, the variable "select" will now be an object, and needs to be released

You could now access the dropdown by which item it is in the collection (collection starts at 0):
Code:
select[0]
COM_Invoke(select, "item", 0)

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 5:06 pm 
jethrow wrote:
randallf wrote:
I am using AHK_L and the COM (not _L) standard library at the moment.
Don't do that :(

randallf wrote:
Can I use AHK_L and the COM_L library?
Try this:
Code:
url:="http://www.thatwebsiteyourlywant2get2.com"
pwb := COM_CreateObject("InternetExplorer.Application")
pwb.Visible := True
pwb.Navigate(url)
Loop
  if (pwb.readyState = 4) ; wait for page to load
    break
text := pwb.document.documentElement.outerHTML ; should be correct to get the source
msgbox %text%


This is really cool, I finally got it working - I think I had the wrong version of COM_L, I guess 2 versions come in the one zip??? - anyway, this works really great but is there a way to make it do it in the background, without opening a window?

Thanks again!!! :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 5:14 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
Quote:

This is really cool, I finally got it working - I think I had the wrong version of COM_L, I guess 2 versions come in the one zip??? - anyway, this works really great but is there a way to make it do it in the background, without opening a window?

Thanks again!!! :)


I hardly deserve to call myself a programmer,

Code:
pwb.Visible := False


when I miss stuff like this all the time.

:D TY!!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 5:17 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Code:
url:="http://www.thatwebsiteyourlywant2get2.com"
pwb := COM_CreateObject("InternetExplorer.Application")
pwb.Visible := True ; <--- leave this line out & the window will be Invisible ;)
pwb.Navigate(url)
Loop
  if (pwb.readyState = 4)
    break
text := pwb.document.documentElement.outerHTML
msgbox %text%
pwb.Quit() ; <--- this will close the Invisible IE window

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Why does this not work
PostPosted: February 9th, 2010, 11:11 pm 
Offline

Joined: January 26th, 2010, 6:16 pm
Posts: 5
javascript: document.getElementsByTagName('input')[11].click()
COM_Invoke(pwb, "javascript: document.getElementsByTagName[input].item[11].click")

This is from the Tut.
What I'm trying to do is just a simple login into Facebook.
I got it entering in the User and Password using

COM_Invoke(userName:=COM_Invoke(all:=COM_Invoke(doc:=COM_Invoke(pwb,"Document"),"All"),"Item","Email"),"value",gUser)

COM_Invoke(password:=COM_Invoke(all,"Item","pass_placeholder"),"value",gPass)

from the COM tut, but I could not get this to work:
COM_Invoke(submit:=COM_Invoke(all,"Item","submit"),"click").
Mostly because the button does not have a name field os the other had. When I use various spy apps it comes up with:
,input value="Login" type="submit" class="UIButton_Text.

I can use:
javascript: document.getElementsByTagName('input')[6].click()
to fire it off, but it COM equivelent:
COM_Invoke(pwb, "javascript: document.getElementsByTagName[input].item[11].click")

Pops up errors.

I'm pretty nub in this whole thing, I have been following posts and have review almost every topic that involves "Facebook". I really don't want to send click or {TAB} {ENTER} to fire this button off. Am I missing something obvious?

Thanks all.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 9th, 2010, 11:23 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Gundeck wrote:
Am I missing something obvious?


Not entirely. Even though the input button does not have a name or ID, your information does show that it has a value:

Code:
input value="Login" type="submit" class="UIButton_Text.


So what you need to do is look through input element collection, find the one with a value "Login" and click it:

Code:
COM_Invoke(pwb,"document.all.item[email].value",gUser)
COM_Invoke(pwb,"document.all.item[pass_placeholder].value",gPass)
Loop % COM_Invoke(pwb,"document.all.tags[input].length") { ; loop runs equal to the number of input elements on the page
  if (COM_Invoke(pwb,"document.all.tags[input].item[" A_Index-1 "].value") = "Login") { ; if current input element has value of 'Login'
    COM_Invoke(pwb,"document.all.tags[input].item[" A_Index-1 "].click") ; click it
    break ; break the loop
  } ; else the loop continues
}

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 11:25 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Quote:
COM_Invoke(pwb, "javascript: document.getElementsByTagName[input].item[11].click")

Thanks for pointing this out. Remove the red. I have updated the tutorial.

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject: CSS !important
PostPosted: February 23rd, 2010, 5:17 am 
Offline

Joined: April 23rd, 2009, 6:05 pm
Posts: 34
Is there a way to add !important to the following code?
Code:
COM_Invoke(pwb, "document.getElementById[box].style.display", "none")

I have tried adding " !important" after none, but that doesn't work. Doing so results in the following:

COM Error Notification
Function Name: "display"
ERROR: Not Implemented
(0x80004001)
ERROR2: The parameter is incorrect
(0x80070057)

I do not receive an error like this when adding !important to a margin style, so I am guessing that it may not be possible on the display style. If anyone can help I would appreciate it. Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2010, 5:32 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
what on earth makes you think you should

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 271 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 19  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSN [Bot], notsoobvious and 6 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