AutoHotkey Community

It is currently May 27th, 2012, 6:58 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: COM Click Issue
PostPosted: February 10th, 2012, 4:14 pm 
Offline

Joined: May 18th, 2010, 5:13 pm
Posts: 101
Hey guys,

I created a hot key to automatically check in for southwest. It used to work fine. but now when i tried to run today. i get the following error. The error comes up after the script is able to send the confirmation number and first and last name to the form and the error happens when it tries to click on the submit button. It used to work before, what could have changed?:

Function Name: "click"
ERROR: The COM Object may not be a valid Dispatch Object!
First ensure that COM library has been initialized through COM_Init().
()

Will Continue?

Here's my code:
Code:
#include C:\Program Files\AutoHotkey\Lib\COM.AHK
COM_Release( pwb ) ; Always release COM objects
COM_Term()
COM_Init() ; Initialize COM
pwb := COM_CreateObject( "InternetExplorer.Application" ) ; Create an IE object
COM_Invoke( pwb, "Visible", True ) ; Make the IE object visible
COM_Invoke( pwb, "Navigate", "http://www.southwest.com/flight/retrieveCheckinDoc.html" ) ; Navigate to a webpage
Sleep, 2000
While, COM_Invoke( pwb, "ReadyState" ) <> 4
; While, COM_Invoke( pwb, "Busy" )
   Continue
WinMaximize, A
COM_Invoke(pwb, "document.all.confirmationNumber.value", CONFIRM)
COM_Invoke(pwb, "document.all.firstName.value", FNAME)
COM_Invoke(pwb, "document.all.lastName.value", LNAME)

While, COM_Invoke( pwb, "ReadyState" ) <> 4
 ;While, COM_Invoke( pwb, "Busy" )
   Continue
COM_Invoke(pwb, "document.all[submitButton].click")
Sleep, 2000
While, COM_Invoke( pwb, "ReadyState" ) <> 4
 ;While, COM_Invoke( pwb, "Busy" )
   Continue
COM_Invoke(pwb, "document.all[printDocuments].click")
COM_Release( pwb ) ; Always release COM objects
COM_Term() ; Always Uninitialize COM


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 4:51 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
They could've simply changed something on the web page, have you double-checked to make sure that's still the valid name/id of the Submit button?

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 4:55 pm 
Offline

Joined: May 18th, 2010, 5:13 pm
Posts: 101
it looks the same to me.

<input tabindex="4"
class="submitButton swa_buttons_submitButton"
id="submitButton"
name="submitButton"
type="submit"
title="Check In"
value="Check In"/>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 6:17 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
When you choose to continue on the error message does it work for the other click without error?

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2012, 10:24 pm 
Offline

Joined: May 18th, 2010, 5:13 pm
Posts: 101
I ran this script on a different PC which is running IE8 and it ran fine without issues. I have recently updated to IE9 and it is erroring for me. Anyone know what needs to be updated going from IE8 to IE9 or what needs to be changed so it runs on both?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: COM Click Issue
PostPosted: February 10th, 2012, 11:03 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
That problem sounds vaguely familiar, humor me and run this modified code for me:


Code:
#include C:\Program Files\AutoHotkey\Lib\COM.AHK
IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ; IHTMLWindow2
COM_Init() ; Initialize COM
pdsp := COM_CreateObject( "InternetExplorer.Application" ) ; Create an IE object
COM_Invoke( pdsp, "Visible", True ) ; Make the IE object visible
COM_Invoke( pdsp, "Navigate", "http://www.southwest.com/flight/retrieveCheckinDoc.html" ) ; Navigate to a webpage
pwb := COM_QueryService(pdsp, IID, IID)
Sleep, 2000
While, COM_Invoke( pwb, "ReadyState" ) <> 4
; While, COM_Invoke( pwb, "Busy" )
   Continue
WinMaximize, A
COM_Invoke(pwb, "document.all.confirmationNumber.value", CONFIRM)
COM_Invoke(pwb, "document.all.firstName.value", FNAME)
COM_Invoke(pwb, "document.all.lastName.value", LNAME)

While, COM_Invoke( pwb, "ReadyState" ) <> 4
 ;While, COM_Invoke( pwb, "Busy" )
   Continue
COM_Invoke(pwb, "document.all[submitButton].click")
Sleep, 2000
While, COM_Invoke( pwb, "ReadyState" ) <> 4
 ;While, COM_Invoke( pwb, "Busy" )
   Continue
COM_Invoke(pwb, "document.all[printDocuments].click")
COM_Release( pwb ), COM_Release( pdsp ) ; Always release COM objects
COM_Term() ; Always Uninitialize COM

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2012, 11:53 am 
Offline

Joined: May 18th, 2010, 5:13 pm
Posts: 101
The script didnt make it to the click portion.

The new error states:
Funcation Name: "ReadyState"
Error: The COM object may not be a valid Dispatch Object!
First ensure that COM library has been initialized through COM_INIT().
()
Continue?

:(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2012, 11:55 am 
Offline

Joined: July 10th, 2008, 8:49 am
Posts: 1865
Location: Brussels, Belgium
My eyes are bleeding !!! :P

You should thing about "rewriting" yoru script with AHK_L (get rid of COM).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2012, 1:18 pm 
Unrelated: Quick question when using .click or .value which thing should I use. the "id" or the "name" and what if the id for two different things are the same?

id="submitButton"
name="submitButton"

Thanks :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2012, 3:14 pm 
Offline

Joined: May 18th, 2010, 5:13 pm
Posts: 101
CodeKiller wrote:
My eyes are bleeding !!! :P

You should thing about "rewriting" yoru script with AHK_L (get rid of COM).


lol i'll look into that. i need to read up on that...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2012, 4:25 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
Let's try this a different way then...

Code:
#include C:\Program Files\AutoHotkey\Lib\COM.AHK
IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ; IHTMLWindow2
COM_Init() ; Initialize COM
pdsp := COM_CreateObject( "InternetExplorer.Application" ) ; Create an IE object
COM_Invoke( pdsp, "Visible", True ) ; Make the IE object visible
COM_Invoke( pdsp, "Navigate", "http://www.southwest.com/flight/retrieveCheckinDoc.html" ) ; Navigate to a webpage
Sleep, 2000
While, COM_Invoke( pdsp, "ReadyState" ) <> 4
; While, COM_Invoke( pdsp, "Busy" )
   Continue
pwb := COM_QueryService(pdsp, IID, IID)
WinMaximize, A
COM_Invoke(pwb, "document.all.confirmationNumber.value", CONFIRM)
COM_Invoke(pwb, "document.all.firstName.value", FNAME)
COM_Invoke(pwb, "document.all.lastName.value", LNAME)

While, COM_Invoke( pdsp, "ReadyState" ) <> 4
 ;While, COM_Invoke( pdsp, "Busy" )
   Continue
COM_Invoke(pwb, "document.all[submitButton].click")
Sleep, 2000
While, COM_Invoke( pdsp, "ReadyState" ) <> 4
 ;While, COM_Invoke( pdsp, "Busy" )
   Continue
COM_Invoke(pwb, "document.all[printDocuments].click")
COM_Release( pwb ), COM_Release( pdsp ) ; Always release COM objects
COM_Term() ; Always Uninitialize COM

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2012, 10:09 pm 
Offline

Joined: May 18th, 2010, 5:13 pm
Posts: 101
sinkfaze wrote:
Let's try this a different way then...

Code:
#include C:\Program Files\AutoHotkey\Lib\COM.AHK
IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ; IHTMLWindow2
COM_Init() ; Initialize COM
pdsp := COM_CreateObject( "InternetExplorer.Application" ) ; Create an IE object
COM_Invoke( pdsp, "Visible", True ) ; Make the IE object visible
COM_Invoke( pdsp, "Navigate", "http://www.southwest.com/flight/retrieveCheckinDoc.html" ) ; Navigate to a webpage
Sleep, 2000
While, COM_Invoke( pdsp, "ReadyState" ) <> 4
; While, COM_Invoke( pdsp, "Busy" )
   Continue
pwb := COM_QueryService(pdsp, IID, IID)
WinMaximize, A
COM_Invoke(pwb, "document.all.confirmationNumber.value", CONFIRM)
COM_Invoke(pwb, "document.all.firstName.value", FNAME)
COM_Invoke(pwb, "document.all.lastName.value", LNAME)

While, COM_Invoke( pdsp, "ReadyState" ) <> 4
 ;While, COM_Invoke( pdsp, "Busy" )
   Continue
COM_Invoke(pwb, "document.all[submitButton].click")
Sleep, 2000
While, COM_Invoke( pdsp, "ReadyState" ) <> 4
 ;While, COM_Invoke( pdsp, "Busy" )
   Continue
COM_Invoke(pwb, "document.all[printDocuments].click")
COM_Release( pwb ), COM_Release( pdsp ) ; Always release COM objects
COM_Term() ; Always Uninitialize COM


Same error! :(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2012, 11:59 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
@sinkfaze - querying for the ihtmlwindow returns a window object, not a webbrowser object.

What are the results of:
Code:
MsgBox %    "document: " COM_Invoke(pwb, "document")
      .     "all:   " COM_Invoke(pwb, "document.all")
      .     "button:    " COM_Invoke(pwb, "document.all[submitButton]")
      .     "length:    " COM_Invoke(pwb, "document.all[submitButton].length") ; length may cause a com error

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2012, 3:19 am 
Offline

Joined: May 18th, 2010, 5:13 pm
Posts: 101
jethrow wrote:
@sinkfaze - querying for the ihtmlwindow returns a window object, not a webbrowser object.

What are the results of:
Code:
MsgBox %    "document: " COM_Invoke(pwb, "document")
      .     "all:   " COM_Invoke(pwb, "document.all")
      .     "button:    " COM_Invoke(pwb, "document.all[submitButton]")
      .     "length:    " COM_Invoke(pwb, "document.all[submitButton].length") ; length may cause a com error


I added that after this line:
COM_Invoke( pwb, "Navigate", "http://www.southwest.com/flight/retrieveCheckinDoc.html" ) ; Navigate to a webpage

And i got this error:
Function Name: "document"
Error: Unspecified Error
(0x80004005)

Prog:
Desc:
Help: ,0

Will continue?


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

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
wait for the page to load

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: migz99, sjc1000 and 75 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