AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

IE and Gui Browser Com Tutorial
Goto page Previous  1, 2, 3, 4, 5  Next
 
This topic is locked: you cannot edit posts or make replies.    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Thu Oct 23, 2008 8:50 pm    Post subject: Reply with quote

@ fongmark Very Happy
As this thread is a tutorial on COM and AHK being used with IE and Gui Browser objects I have the following comments

First of all Bravo !!!! Cool

Please if you can edit your post and include links to the required files. This thread is for Newbs and we want to make it easy to use the script as possible

I see that you did a pretty fair job of commenting code. Surprised Keeping in mind that this is a tutorial it would be very nice if you could break down what your doing before exposing the entire script set for those who might also try to do similar things
For instance Wink where can one learn more about the available functions from LoadCursor Idea
Code:
; Make a copy of the original mouse cursor
      normal_cursor := DllCall( "LoadCursor", "uint", 0, "uint", OCR_NORMAL )


While I would have perfered using COM instead of CoHelper and IEControl this essentially complies with the philosiphy of this thread so i thank you for contributing. I have wondered since the origional posting if any one even bothered

Again if any part of my reply sounds un greatful please excuse. I am glad someone bothered to contribute. and thank you for commenting your code. If you dont object I may post a follow up and replace the IEControl and CoHelper with COM equivilence just for the comparison Very Happy Very Happy Very Happy
_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
DHMH(n-l-i)
Guest





PostPosted: Thu Nov 06, 2008 3:07 pm    Post subject: Reply with quote

Hello fongmark,
can you give me please the GetWebPageContents.ahk ?
It´s important for me, I want to get picture links from a webpage!
Thx in Advance!
Greets,
DHMH
Back to top
DHMH(n-l-i)
Guest





PostPosted: Thu Nov 06, 2008 4:53 pm    Post subject: Reply with quote

I´ve solved the above, but can someone help me!
This topic: http://www.autohotkey.com/forum/topic37489.html
Thx in advance!
Greets,
DHMH
Back to top
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Thu Nov 06, 2008 5:23 pm    Post subject: Reply with quote

http://www.autohotkey.com/forum/viewtopic.php?p=229805#229805
_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
dominique
Guest





PostPosted: Sat Feb 21, 2009 2:15 pm    Post subject: run ie4AHK www.google.com and two related other posts Reply with quote

Hello,
I have one technical question, one conceptual question and one contribution.

1) Tecnical question
I was not success in my attempt to adapt one of several technics published in this topic to make possible the launch of ie4AHK with an url as parameter:
for instance run ie4AHK www.google.com
I know that it's possible but I could n't.
Is someone has a complete code to try ?

2) conceptual question : security
What is the security of the browser?

a: proxy: is the system could bypass the proxy of a company or a school
b: child: is it possible to make definitive the option concerning child protection
c: password, ssl : are there secure? how
d: privacy: is it secure? how.

3) 32 bits --> 64 bits : one argument
I have a "love at first sight" for the job and the quality of this community.
And I imagine to attempt the development of a very very big program automatically generated from the base of our (very big) functional ontology. Then billions of variable (often inactive), threads, methods, subroutine and so on. This remark was only an argue to suggest the availability of a 64 bits kernet for AutoHotkey.

With a sincere admiration for your work,
Back to top
dominique
Guest





PostPosted: Sat Feb 21, 2009 2:15 pm    Post subject: run ie4AHK www.google.com and two related other posts Reply with quote

Hello,
I have one technical question, one conceptual question and one contribution.

1) Tecnical question
I was not success in my attempt to adapt one of several technics published in this topic to make possible the launch of ie4AHK with an url as parameter:
for instance run ie4AHK www.google.com
I know that it's possible but I could n't.
Is someone has a complete code to try ?

2) conceptual question : security
What is the security of the browser?

a: proxy: is the system could bypass the proxy of a company or a school
b: child: is it possible to make definitive the option concerning child protection
c: password, ssl : are there secure? how
d: privacy: is it secure? how.

3) 32 bits --> 64 bits : one argument
I have a "love at first sight" for the job and the quality of this community.
And I imagine to attempt the development of a very very big program automatically generated from the base of our (very big) functional ontology. Then billions of variable (often inactive), threads, methods, subroutine and so on. This remark was only an argue to suggest the availability of a 64 bits kernet for AutoHotkey.

With a sincere admiration for your work,
Back to top
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Sat Feb 21, 2009 4:30 pm    Post subject: Re: run ie4AHK www.google.com and two related other posts Reply with quote

dominique wrote:

1) Tecnical question
I was not success in my attempt to adapt one of several technics published in this topic to make possible the launch of ie4AHK with an url as parameter:
for instance run ie4AHK www.google.com
I know that it's possible but I could n't.
Is someone has a complete code to try ?
this isnt an ie4ahk thread daononlyfreeze uses a dll for the browser. I cannot vouch for its com availability.
but perhaps you might show the code your trying there may be things not approached correctly
Quote:
2) conceptual question : security
What is the security of the browser?

a: proxy: is the system could bypass the proxy of a company or a school
b: child: is it possible to make definitive the option concerning child protection
c: password, ssl : are there secure? how
d: privacy: is it secure? how.

a: I will not aid in answering questions about bypassing security
b:I suppose anything is possible if your wanting to make a filter for browsing while you could make it very functional but as ahk can easily be disabled by the user i recommend a better product just get an off the shelf tool at your local electronics superstore.
Etheir way i do not have the interest or the time to write thousands of lines of code for a product aimed at security that would inevitably be so easily disabled Confused
I will not claim to be an expert on SSl your best bet is to google it. I will say this. No security is un breechable but SSL is a successfull standard because ir requires serious skill to bypass and there for limits targets to multimillion dollar organizations with a known exposed risk.
I recall the answer my college MCSE instructer gave. If you truly dont want the world to know dont connect it to a network. Sorry but security is realative to who is trying to break it and the effective use of the end user of said security products
on number 3 please rephrase to a coherent question i simply dont understand
you ask me to compare 32 bit with 64 bit something i can not guess or read minds. then you go on to tell a story about a dog and a cat living in harmony. Confused Please focus the statment that follows should have specific relavent data that makes your question more concise. I am not sure how billions ov variables is related to 32 bit vs 64 bit

Thanks for the post I am sorry i cant be of more help but lets be clear
I can help you fix specific problems if you post your code and I have access to the site in question.

I will not ever help someone with security questions. they are far to important to be asked and answered anonomously over the internet. Take a class or consult a reputable professional

I am not going to get into discussions over the various technologies that make up networking and network requests. I am neither an expert nor willing to waste yours or any one elses time.

That said i do quite well understand HTML Javascript VBScript XML CSS etc

i know a good deal about how to automate data input and collections from web sites that support the afore mentioned technologies. and i know a bit about web servers and server side programing languages such as sql asp and php but i wont get into QA on the later

So if you have specific code your trying to automate data collected or sent to a web page that uses HTML Javascript VBScript XML CSS feel free to post your code and a link i can get to with the actual content and i will be happy to help Rolling Eyes Very Happy

everything else no Twisted Evil
_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Sat Feb 21, 2009 4:44 pm    Post subject: Reply with quote

Quote:
This remark was only an argue to suggest the availability of a 64 bits kernet for AutoHotkey.
post it on the wish list then why do you think this belongs here
_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
melkis



Joined: 25 Feb 2009
Posts: 2

PostPosted: Wed Feb 25, 2009 3:14 pm    Post subject: Reply with quote

first, THNX for this super tutorial!!!
2nd...I need help with this...im using the same code you posted, i edited the code a little bit... and i dont know why but i cant use the tab keystroke and i only want to select any name of a list like 1/2 Prince on the top list of the page automatically

Code:
#include COM.AHK

COM_AtlAxWinInit()
Gui, +LastFound +Resize
;pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),top,left,width,height, "Shell.Explorer") )  ;left these here just for reference of the parameters
pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),0,0,510,600, "Shell.Explorer") )
;http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.ole.interop.ioleinplaceactiveobject(VS.80).aspx
IOleInPlaceActiveObject_Interface:="{00000117-0000-0000-C000-000000000046}"
pipa := COM_QueryInterface(pwb, "IOleInPlaceActiveObject_Interface")
OnMessage(WM_KEYDOWN:=0x0100, "WM_KEYDOWN")
OnMessage(WM_KEYUP:=0x0101, "WM_KEYDOWN")
gui,show, w510 h600 ,Gui Browser
;take from the IE example
url:="http://www.onemanga.com/"
COM_Invoke(pwb, "Navigate", url)
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         break

sleep 1000
ControlSend, , {tab}, Gui Browser
sleep 1000
ControlSend, , 1/2 prince, Gui Browser
sleep 1000
ControlSend, , Enter, Gui Browser

msgbox, ok

GuiClose:
Gui, Destroy
COM_CoUninitialize()
COM_AtlAxWinTerm()
ExitApp

GuiSize:
WinMove, % "ahk_id " . COM_AtlAxGetContainer(pwb), , 0,0, A_GuiWidth, A_GuiHeight
return
WM_KEYDOWN(wParam, lParam, nMsg, hWnd)
{
;  Critical 20
;tooltip % wparam
  If  (wParam = 0x09 || wParam = 0x0D || wParam = 0x2E || wParam = 0x26 || wParam = 0x28) ; tab enter delete up down
  ;If  (wParam = 9 || wParam = 13 || wParam = 46 || wParam = 38 || wParam = 40) ; tab enter delete up down
  {
      WinGetClass, Class, ahk_id %hWnd%
      ;tooltip % class
      If  (Class = "Internet Explorer_Server")
          {
            Global pipa
             VarSetCapacity(Msg, 28)
             NumPut(hWnd,Msg), NumPut(nMsg,Msg,4), NumPut(wParam,Msg,8), NumPut(lParam,Msg,12)
             NumPut(A_EventInfo,Msg,16), NumPut(A_GuiX,Msg,20), NumPut(A_GuiY,Msg,24)
             DllCall(NumGet(NumGet(1*pipa)+20), "Uint", pipa, "Uint", &Msg)
             Return 0
          }
  }
}



the html of the page looks like this

Code:
 <select onchange="javascript:if (this.value){window.location='/'+this.value+'/';}">
       <option value="">Select Manga Series...</option>
 
       <option value="random-manga">Can't decide? Click here for a random manga</option>
       
 
       <option value="Anima">+Anima</option>
 
       <option value="07_Ghost">07 Ghost</option>
 
       <option value="090_-_Eko_to_Issho">090 - Eko to Issho</option>
 
       <option value="12_Prince">1/2 Prince</option>
 
       <option value="13_no_Kareshi">1/3 no Kareshi</option>
 
       <option value="13">13</option>
 
       <option value="20th_Century_Boys">20th Century Boys</option>
 
       <option value="21st_Century_Boys">21st Century Boys</option>
 
       <option value="3x3_Eyes">3x3 Eyes</option>
       .
       .
       .
       .
      </select>
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Thu Feb 26, 2009 1:40 am    Post subject: Reply with quote

first of all this site itself pisses me off

second why after reading the tutprial are you sending key strokes

third your keystrokes dont work in IE either what made you think they would work in the browser object

I am tempted to let your lack of effort cause you pain but folks once helped me in my ignorance too
Code:
COM_Invoke(pwb,"document.all.tags[select].item[0].selectedIndex",5) ; 6 th item in the list 5 selects the 6th item in a 0 based index
;dont use the below
;~ sleep 1000
;~ ControlSend, , {tab}, Gui Browser
;~ sleep 1000
;~ ControlSend, , 1/2 prince, Gui Browser
;~ sleep 1000
;~ ControlSend, , Enter, Gui Browser

_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
melkis



Joined: 25 Feb 2009
Posts: 2

PostPosted: Thu Feb 26, 2009 2:04 pm    Post subject: Reply with quote

tank wrote:
first of all this site itself pisses me off


don't you like Manga? Crying or Very sad

tank wrote:

second why after reading the tutprial are you sending key strokes

i tried to let you know what i want in the stupiest way...

tank wrote:

third your keystrokes dont work in IE either what made you think they would work in the browser object

really?.... it kinda worked on another code i tried....like 2 minutes ago Smile

tank wrote:

I am tempted to let your lack of effort cause you pain but folks once helped me in my ignorance too
Code:
COM_Invoke(pwb,"document.all.tags[select].item[0].selectedIndex",5) ; 6 th item in the list 5 selects the 6th item in a 0 based index
;dont use the below
;~ sleep 1000
;~ ControlSend, , {tab}, Gui Browser
;~ sleep 1000
;~ ControlSend, , 1/2 prince, Gui Browser
;~ sleep 1000
;~ ControlSend, , Enter, Gui Browser


Yesterday was my first time using COM(you can guest what about knowing this page),im new on ahk and kinda lazy, btw i tried to use another way, i tested it once and didnt work so ill try to check it later... of course ill not write anything else because you helped me Shocked ...


Code:
#include COM.AHK
#include ws4ahk.ahk

WS_Initialize("JScript")
COM_AtlAxWinInit()
Gui, +LastFound +Resize
;pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),top,left,width,height, "Shell.Explorer") )  ;left these here just for reference of the parameters
pwb := COM_AtlAxGetControl(COM_AtlAxCreateContainer(WinExist(),0,0,510,600, "Shell.Explorer") )
;http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.ole.interop.ioleinplaceactiveobject(VS.80).aspx
IOleInPlaceActiveObject_Interface:="{00000117-0000-0000-C000-000000000046}"
pipa := COM_QueryInterface(pwb, "IOleInPlaceActiveObject_Interface")
OnMessage(WM_KEYDOWN:=0x0100, "WM_KEYDOWN")
OnMessage(WM_KEYUP:=0x0101, "WM_KEYDOWN")
gui,show, w510 h600 ,Gui Browser
;take from the IE example
url:="http://www.mininova.org/"
COM_Invoke(pwb, "Navigate", url)
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         break


item:=COM_Invoke(all:=COM_Invoke(doc:=COM_Invoke(pwb,"Document"), "All") ,"Item","cat")

   
Code =
    (
        for (i=0 i==item.length i++)
   {
      if (item.options[i].text=="Books")
         {
             item.selectedIndex=i
         }
   }
    )
   
WS_Exec(Code)

msgbox, ok

GuiClose:
Gui, Destroy
COM_CoUninitialize()
COM_AtlAxWinTerm()
ExitApp

GuiSize:
WinMove, % "ahk_id " . COM_AtlAxGetContainer(pwb), , 0,0, A_GuiWidth, A_GuiHeight
return
WM_KEYDOWN(wParam, lParam, nMsg, hWnd)
{
;  Critical 20
;tooltip % wparam
  If  (wParam = 0x09 || wParam = 0x0D || wParam = 0x2E || wParam = 0x26 || wParam = 0x28) ; tab enter delete up down
  ;If  (wParam = 9 || wParam = 13 || wParam = 46 || wParam = 38 || wParam = 40) ; tab enter delete up down
  {
      WinGetClass, Class, ahk_id %hWnd%
      ;tooltip % class
      If  (Class = "Internet Explorer_Server")
          {
            Global pipa
             VarSetCapacity(Msg, 28)
             NumPut(hWnd,Msg), NumPut(nMsg,Msg,4), NumPut(wParam,Msg,8), NumPut(lParam,Msg,12)
             NumPut(A_EventInfo,Msg,16), NumPut(A_GuiX,Msg,20), NumPut(A_GuiY,Msg,24)
             DllCall(NumGet(NumGet(1*pipa)+20), "Uint", pipa, "Uint", &Msg)
             Return 0
          }
  }
}


it worked using your code now i need something to go to the page of the selected item lol...
Back to top
View user's profile Send private message
Guest






PostPosted: Mon Apr 06, 2009 2:19 pm    Post subject: Reply with quote

Code:

loop
  If (rdy:=COM_Invoke(pwb,"readyState") = 4)
     break


When the page is updating itself via AJAX, then the above is not enough. For example the page has a subform and a button, that adds items to a grid.

I modified the loop as follows and it seems to work. Any suggestions are welcome!

Code:

Loop
{
  rdy := COM_Invoke(pwb,"readyState")
  text:= COM_Invoke(pwb,"StatusText")
  if ((rdy = 4) and ( text = "Done" ))
  {
    Break
  } else    
  {
    Sleep 100
  }
}

Back to top
tank



Joined: 21 Dec 2007
Posts: 3700
Location: Louisville KY USA

PostPosted: Mon Apr 06, 2009 10:05 pm    Post subject: Reply with quote

Anonymous wrote:
Code:

loop
  If (rdy:=COM_Invoke(pwb,"readyState") = 4)
     break


When the page is updating itself via AJAX, then the above is not enough. For example the page has a subform and a button, that adds items to a grid.

I modified the loop as follows and it seems to work. Any suggestions are welcome!

Code:

Loop
{
  rdy := COM_Invoke(pwb,"readyState")
  text:= COM_Invoke(pwb,"StatusText")
  if ((rdy = 4) and ( text = "Done" ))
  {
    Break
  } else    
  {
    Sleep 100
  }
}

Thanks but done may or may not be the resulting text and it may or may not work
Since this is the exception not the rule we should be aware that the idea is to look for something unique to the page loading such as specific elements or legnth property of the all collection when readystate isnt enuff
_________________

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Back to top
View user's profile Send private message
Guestisism
Guest





PostPosted: Sun Apr 26, 2009 9:12 am    Post subject: Reply with quote

I need a hand with this whole thing. I understand alot, but I don't understand even more.

I am currently written a script that does multiple things. One of the things is playing a java based, multiplayer, online game.

I had it running fine. You could alt-tab and come back to the game later and it would work. However, since I got it to work I began to code other areas of the script.

All of the new things added had nothing to do with the embeded IE. Was a few animated buttons using SKAN's examples in Tips N Tricks that would do things like hide the taskbar, etc.

Now, I can load a web page through the GUI no problem. I can alt-tab, switch windows and come back to the GUI later with no problems. However, if I switch to another window when the GUI has any form of java on it, AHK no longer responds. I can not for the life of me figure this out. I can't even activate a window owned by the same AHK process!

I was able to do it before (Change windows even if the embed IE window had java on it)... Now for some reason it won't. Any ideas?
Back to top
Guestisism
Guest





PostPosted: Sun Apr 26, 2009 9:27 am    Post subject: Reply with quote

Sorry for the double post, but even when I use a few other scripts I've found here on the forums, you can switch windows fine unless it's got Java on the embedded IE.

For the curious, it's RuneScape.

Try it yourself. Go to RuneScape.Com (In your embedded IEs), click either of the "Click here to play". Let it load completely. Switch to another window, then switch back to the GUI with RuneScape in it. It won't respond.

Even if you click "Log In". If you let that Java applet load, switch windows, it becomes unresponsive. Or is it just my computer for some reason?

Odd how it worked fine then stopped. Even stranger how it won't work in the other scripts on the forums either. :S.
Back to top
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies.    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5  Next
Page 2 of 5

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group