AutoHotkey Community

It is currently May 27th, 2012, 11:32 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: March 10th, 2010, 4:08 am 
Offline

Joined: February 26th, 2009, 8:45 pm
Posts: 29
Oh, yes i`m sorry. Now , i tried with AHKL and COM_L and the script works but only once. If I go back and hit Search again, the msgbox doesnt pop. I`m searching the code to fix this. Any help?

Thanks again!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2010, 8:13 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
First off, this is only an example of concepts really. I'm not an expert when it comes to the ConnectObject function. Currently the script disconnects the objects each time a button is clicked ( you could leave it connected, but you'd want to disconnect it sometime - I think ) and then reconnects when the webpage exists again. My guess is that you might be clicking the button before it has a chance to reconnect. If you provide an example of what this could be productively used for, I might help some more. Otherwise, I'd say look at how the code currently works and modify it for your purposes. :D

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 8:16 pm 
Offline

Joined: February 26th, 2009, 8:45 pm
Posts: 29
OK. I think i have something. Here it is

Code:
#Persistent
COM_CoInitialize()
OnExit,Close
SetTimer, ConnectWindow, 100

ConnectWindow:
pwb:=iWeb_getwin("Google - Windows Internet Explorer")
If pwb{
   ;iWeb_complete(pwb)
   If feel_lucky:=COM_Invoke(pwb,"document.all[btnI]."){
      psink:=COM_ConnectObject(feel_lucky,"buttons_")
     ;msgbox Connected
   }
}
return

buttons_onClick(){
   SetTimer,ExecuteScript,-10
}

ExecuteScript:
   msgbox Script
return   
   
Close:
COM_Release(pwb)
COM_CoUninitialize()
ExitApp


But I eventually get the "No interface event exists" msgbox. Why is that?

Thanks!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 2:14 am 
Offline

Joined: February 26th, 2009, 8:45 pm
Posts: 29
Any guess? :?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 2:25 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
I reckon that there are multiple btnIs. Then the return object will be the collection object of btnIs, and a collection object usually has no event interface. You have to connect to an individual btnI object each.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 7:31 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Sean, please correct me if I'm wrong, but the script seems to keep connecting - and reconnecting - to the element as long as there's a web browser with the main Google page loaded ( this doesn't seem good as you would only want to connect once per webpage load, right? ) Then, I believe the "No interface event exists" error is occurring because the webpage is changing while the object is being connected. I'm getting this error if I either click the button ( which navigates to a new page ), or if I simply navigate to another webpage.

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 10:37 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Oh, sorry, I spotted only COM_ConnectObject part, I didn't notice/expect that he used SetTimer. It may still work, however, highly discouraged as it creates/connects multiple event sinks. There was no way to prevent this with COM.ahk, but now with AutoHotkey_COM attempting multiple connections will be (silently) failed.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 18th, 2010, 7:56 pm 
Offline

Joined: February 26th, 2009, 8:45 pm
Posts: 29
Ok, i think almos have it
Code:
#Persistent
COM_CoInitialize()
OnExit,Close
SetTimer, ConnectWindow, 100

ConnectWindow:

pwb:=iWeb_getwin("Google - Windows Internet Explorer")
If pwb{
   iWeb_complete(pwb)
   If cmd_agregar:=COM_Invoke(pwb,"document.all[btnI]."){
      psink:=COM_ConnectObject(cmd_agregar,"buttons_")
     ;msgbox Connected
   }
}


IfWinNotExist Google - Windows Internet Explorer
{
   msgbox close
   WinWait Google - Windows Internet Explorer
   msgbox abrir
}

return

buttons_onClick(){
   SetTimer,ExecuteScript,-10
}

ExecuteScript:
   
   msgbox Script
   
return   


Close:
COM_Release(pwb)
COM_CoUninitialize()
ExitApp


Now i get a "readyState" error msgbox and a "Will continue?" question, when I close the window. I guess is it from the iWebcomplete function.

Also to connect the object, the webpage has to finish loading. Is it possible to connect the object before the webpage finish loading. So if the user clicks the button before the page loaded, the code still run?

Thanks again


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 3:27 pm 
Offline

Joined: February 26th, 2009, 8:45 pm
Posts: 29
May be setting the warnings off?


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher, Yahoo [Bot] and 19 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