AutoHotkey Community

It is currently May 26th, 2012, 6:33 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 309 posts ]  Go to page Previous  1 ... 16, 17, 18, 19, 20, 21  Next
Author Message
 Post subject:
PostPosted: June 1st, 2009, 6:19 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Anxious_Patient wrote:
As my first post indicated I am using an existing Internet Explorer web page.
Where? Notice the name CreateObject, it always tries to create a new instance whenever possible than to get an already running instance.

There is a way to get a running instance posted here:
http://www.autohotkey.com/forum/topic19256.html


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 1st, 2009, 7:41 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
what sort of debachery is this
you post the most intense misuse and misunderstanding of my old and posted to be discontinued functions in Seans thread of a no longer supported library. you have obviously no understanding whatsoever what your attempting to do or the slightest ability to learn from dozens of examples


there is nothing productive about your code at all

Code:
COM_CoInitialize()
OnExit,COM_CoUninitialize
pwb:=iWeb_getwin("google")
;~ get the text from the page
pagetext:=COM_Invoke(pwb,"document.body.innertext")
IfInString,pagetext,keword
{
;~    do something that would include navigating
   
}


;~ you can only goback if there is history in the current browser
COM_Invoke(pwb, "GoBack")




COM_CoUninitialize:
COM_CoUninitialize()
ExitApp

;~ get an already running instance of IE
iWeb_getwin(t)
{
   psw   :=   COM_Invoke(psh   :=   COM_CreateObject("Shell.Application"),   "Windows"),COM_Release(psh)
   Loop, %   COM_Invoke(psw,   "Count")
   {
      LocationName   :=   COM_Invoke(psw,"Item[" A_Index-1 "].LocationName")
      IfInString,LocationName,%t%
      {
         pwb         :=   COM_Invoke(psw,"Item" ,A_Index-1)
         COM_Release(psw)
         Return   pwb   
      }
   }
   COM_Release(psw)   
   Return   0
}
Now i want to be clear here dont play with fire. you dont have yet working code nor is this working code yet because you have a condition and a step that cant work without other things happening first

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2009, 8:38 pm 
Offline

Joined: May 31st, 2009, 10:50 pm
Posts: 6
tank wrote:
what sort of debachery is this
you post the most intense misuse and misunderstanding of my old and posted to be discontinued functions in Seans thread of a no longer supported library. you have obviously no understanding whatsoever what your attempting to do or the slightest ability to learn from dozens of examples


there is nothing productive about your code at all

Now i want to be clear here dont play with fire. you dont have yet working code nor is this working code yet because you have a condition and a step that cant work without other things happening first


I would like to makes 4 points about your reply. I realize this is long but after your reply I think you should read it completely. thanks for your time.

1.
tank wrote:
there is nothing productive about your code at all

My code was a DEMONSTRATION code, just as I said here
Anxious_Patient wrote:
I added more code to demostrate what I am trying to do.

It was not meant to be productive. It was meant to demostrate what I wanted to do.

2.
tank wrote:
you post the most intense misuse and misunderstanding of my old and posted to be discontinued functions in Seans thread of a no longer supported library

Please notice what I said
Anxious_Patient wrote:
I am using Tanks IE7 functions for everything else and it is working great. I see Tank has updated his IE7 to iWeb. I plan on leaving my script using IE7 because it is working so well.

Notice, I said my script was working so well using your IE7 Functions, I just needed to learn how to GoBack a page. I came across Seans GOBACK function and wanted to know how to either use it or use an update version of it. As you can see, I know that Sean does not use IE.ahk anymore and your IE7 functions are discontinued. But my script works so I see no need to change it now.
Notice what I said, I do have a working script
Anxious_Patient wrote:
My script is able to navigate an IE webpage even with the webpage minimized. I just need this one last thing fixed.

3.
tank wrote:
you post the most intense misuse and misunderstanding of my old and posted to be discontinued functions in Seans thread

Also, notice on my first post to Sean that I did not have any of your IE7 functions in it. I only added more code to my post to show Sean I had a webpage that I could GOBACK to.

4.
tank wrote:
you have obviously no understanding whatsoever what your attempting to do or the slightest ability to learn from dozens of examples
Actually I do have some idea. I have automated a webpage using your IE7 function examples that can run 24 hours a day without any errors. How could I do that if I had no ability to learn from dozens of examples.

As you noticed I do not know COM nor do I need to know COM to use your IE7 functions.

I just needed to know how to GOBACK a page hence my original post.


I am posting another DEMONSTRATION code using your iWeb functions. Your suggestion on how to use Seans GOBACK works perfectly.

I thank you for that.

Simply
Code:
pwb:=iWeb_getwin("google")
COM_Invoke(pwb, "GoBack")

would have been enough to send me in the right direction.

You completely misunderstood my entire situation.

Here is my WORKING DEMONSTRATION . I put some notes for you at the bottom.
Code:
iWeb_Init()
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance,force
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
#Include COM.ahk
OnExit,Term
SetTitleMatchMode,2
MsgBox -----------------This is only a DEMONSTRATION-----------------`n`nIt is not designed to do anything PRODUCTIVE.`n`nIt will DEMONSTRATE to me that the code is working as planned.`n`n1. Code will click on Google news.`n2. Get the html source code`n3. Parse the code for keywords.`n4. Do something based on the keywords it finds`n5. Then GOBACK a page to DEMONSTRATE that it can GOBACK a page.`n`nOnce I see that it works I will apply it to my CONFIDENTIAL script.`n`nPlease open www.google.com, then click Ok

IfWinNotExist,Google
 MsgBox A Google window could not be found.`n`nOpen www.google.com, then click OK

pwb:=iWeb_getwin("google")
iWeb_clickDomObj(pwb,17)
sleep 1000
iWeb_complete(pwb)
sleep 1000
Gosub GetHtmlSourceCode
sleep 1000
IfInString,HtmlCode,Obama
 MsgBox Obama keyword is in the source code`n`nClick okay and see if it goes back a page
Else
 MsgBox Obama keyword was not found in the source code`n`nClick okay and see if it goes back a page

COM_Invoke(pwb, "GoBack")
iWeb_complete(pwb)


MsgBox The DEMONSTRATION code is now complete.`n`nDid it GOBACK a page?`n`nScript will now exit
term:
iWeb_Term()
exitapp

GetHtmlSourceCode:
ControlGet, hIESvr, Hwnd,, Internet Explorer_Server1,Google
WinGetClass, class, ahk_id %hIESvr%
if (!hIESvr or class != "Internet Explorer_Server")
 return
COM_Error(0)
WM_HTML_GETOBJECT := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
SendMessage, WM_HTML_GETOBJECT,,,, ahk_id %hIESvr%
lResult := ErrorLevel
DllCall("oleacc\ObjectFromLresult", "uint", lResult, "uint", COM_GUID4String(IID_IHTMLDocument2,"{332C4425-26CB-11D0-B483-00C04FD90119}"), "int", 0, "uint*", pDoc)
DocEle:=COM_Invoke(pDoc, "documentElement")
htmlcode:=COM_Invoke(DocEle,"innerHTML")
COM_Release(DocEle)
COM_Release(pDoc)
return

/*
Tank - Please Note: the iWeb_complete(pwb) posted on the first page of your thread... http://www.autohotkey.com/forum/topic30599.html did not work for me, using Vista and IE8

I found your alternate method which works very well posted here and listed below...http://www.autohotkey.com/forum/topic30599-120.html

iWeb_complete(pwb)                  ;   returns bool for success or failure
{   
   If  !pwb      ;   test to see if we have a valid interface pointer
      sleep, 5000                  ;   ExitApp if we dont
else {
   loop 10                     ;   sets limit if itenerations to 40 seconds 80*500=40000=40 secs
   {   
      If not (rdy:=COM_Invoke(pwb,"readyState") = 4)
         Break            ;   return success
      Sleep,100               ;   sleep .1 second between cycles
   }
   loop 80                     ;   sets limit if itenerations to 40 seconds 80*500=40000=40 secs
   {   
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         Return    1            ;   return success
      Sleep,500               ;   sleep half second between cycles
   }
}
   Return 0                  ;   lets face it if it got this far it failed
}                            ;   end complete

*/





take care
Anxious_Patient


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 4th, 2009, 5:23 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
much better
Yes i will be the first to admit i desparately need to update my own thread especially the iweb functions


One thing to note
you must be aware that goback can only work if there are previous pages in the current browsers history

I am a little unsure why you insist on the subroutine for the page source when it is sufficient to use
Code:
HtmlCode:=COM_Invoke(pwb,"document.documentelement.outerHTML")
but i spose it works so whatever i wont give you greif over it
outerHTML should be used for full source not innerhtml
I am certain i have copied and pasted innerhtml many times myself but i feel it essential to steer you the right direction

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 4th, 2009, 7:50 pm 
Offline

Joined: May 31st, 2009, 10:50 pm
Posts: 6
tank wrote:
I am a little unsure why you insist on the subroutine for the page source when it is sufficient to use
Code:
HtmlCode:=COM_Invoke(pwb,"document.documentelement.outerHTML")
I needed a way to get the page source, I searched the forum and that subroutine is what I found.

I like your way much better.

thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2009, 11:00 am 
Offline

Joined: July 17th, 2008, 9:46 am
Posts: 225
Hi Sean,
i've got a question...
Is it possible to go to a specific position in the ie control...
i.e.:
I've got a string containing <img src="C:/test.png"></img> and an IE Control which is displaying the picture....
Now i've got some pages text above the picture, for example 3 pages...
Can i automatically determine the position of <img> and then scroll to it ?
I thought it might be possible with IE_Find()...
please help me

Thank you!
Greets,
DHMH


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2009, 1:54 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
DHMH wrote:
Can i automatically determine the position of <img> and then scroll to it ?
Why don't you read the documentation and figure it out yourself? HTML and DHTML Reference
Anyway, what you really want to do seems: scrollIntoView


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2009, 2:11 pm 
Offline

Joined: July 17th, 2008, 9:46 am
Posts: 225
Hey, that's great! Thank you!
But can you give me an example how i could use it ?
thx!
Greets,
DHMH


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2009, 2:52 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
you asked me about anchors not scrolling to an image i would have used the same suggestion Sean gave for that as for how think about it if you have the document object in any other language according to the msdn how would you then get to use the scrollIntoView method? think about it the answer is definately there.
At any rate it seems anchors do not function in the embeded browser

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2009, 2:57 pm 
Offline

Joined: July 17th, 2008, 9:46 am
Posts: 225
That was an example.
But thanks, i will see if i can find i solution!
thx!
Greets,
DHMH


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2009, 4:01 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
Code:
com_invoke(pwb,"document.all.item[someid].scrollintoview",1)
example

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2009, 4:13 pm 
Offline

Joined: July 17th, 2008, 9:46 am
Posts: 225
Code:
Com_Init()
COM_AtlAxWinInit()
COM_Error(1)
Gui, +LastFound +Resize
pwb := COM_AtlAxGetControl(hAx:=COM_AtlAxCreateContainer(WinExist(), 0, 30, 700, 550, "Shell.Explorer"))
Gui, Show, x0 w700 h600
loop 50
    lb.=".<br />"

IE_LoadHTML(pwb,lb "<img src='http://www.google.de/intl/de_de/images/logo.gif'>")
;MsgBox   %  url:=COM_Invoke(pwb,"locationURL")
;  COM_Invoke(pwb,"navigate",url "#anchor")
;MsgBox   % COM_Invoke(pwb,"locationURL")
settimer,go,6000
Return

go:
settimer,go,off
1 := "<img>"
com_invoke(pwb,"document.all.item['1'].scrollintoview",1)
Return

GuiClose:
COM_CoUninitialize()
ExitApp

#include, Resources\IE.ahk
#include, Resources\COM.ahk

Thank you, but it doesn't work :(
MfG,
DHMH


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2009, 4:23 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
OK, I think it can be a good example to use DocumentComplete event recently utilized.

Code:
Gui, +Resize +LastFound
Gui, Show, w1024 h768 Center, WebBrowser

COM_AtlAxWinInit()
pweb :=   COM_AtlAxCreateControl(WinExist(), "Shell.Explorer")
sink :=   COM_ConnectObject(pweb, "Web_")
bComplete := False
COM_Invoke(pweb, "Navigate2", "http://www.autohotkey.com/docs/Functions.htm")
While   !bComplete
   Sleep, 100
COM_Invoke(pweb, "document.anchors[BuiltIn].scrollIntoView")
Return

GuiClose:
Gui, Destroy
COM_DisconnectObject(sink)
COM_Release(pweb)
COM_AtlAxWinTerm()
ExitApp

OnComplete:
bComplete := True
Return

Web_DocumentComplete(prms, sink)
{
   If   NumGet(NumGet(prms+0)+24) = NumGet(sink+12)
      SetTimer, OnComplete, -10
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2009, 4:49 pm 
Offline

Joined: July 17th, 2008, 9:46 am
Posts: 225
Thank you!
Greets,
DHMH


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 13th, 2009, 6:42 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
ha ha the msdn deceaves me into thinking that it took a bool :wink:

_________________
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  [ 309 posts ]  Go to page Previous  1 ... 16, 17, 18, 19, 20, 21  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Google Feedfetcher, Jaaaaaaaaay and 7 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