AutoHotkey Community

It is currently May 26th, 2012, 6:13 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: February 26th, 2008, 1:00 am 
Offline

Joined: February 19th, 2008, 12:14 am
Posts: 17
Dear all,

I am trying to create a script that should search a password-protected internal terminology database? I managed to create a script that more or less achieves what I was hoping for, but I have a problem now.

Whenever I use the hot key to run the script, it opens a new IE window which is very confusing, because it asks me all the time to enter my user name and password to login to the database. What I want to do is to have one single internet explorer window session and whenever I use the script, it goes to the current IE Window.

Also, it should open just IE, not Firefox even it is the default browser on my machine, because the terminology database website does not work well with Firefox.

Is there a way to get this accomplished?

Thank you in advance for your help which I really need.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 26th, 2008, 4:51 am 
Offline

Joined: February 9th, 2006, 8:36 pm
Posts: 338
it depends on script
maybe you can activate the existing browser window


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2008, 1:13 am 
Offline

Joined: February 19th, 2008, 12:14 am
Posts: 17
wOxxOm wrote:
it depends on script
maybe you can activate the existing browser window


Thanks for your reply.

I want to have my script use the same IE Window for search. How to force such behavior in AHK?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2008, 1:16 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
there is a setting in IE you can turn on called "Reuse windows for launching shortcuts"

Or i am misreading what you want.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2008, 5:38 pm 
Offline

Joined: September 21st, 2006, 10:04 pm
Posts: 32
@ memoday

Your server probably is setting a session-specific cookie for authentication; in Internet Explorer, this means that the *particular instance* of the browser is the only one for which the authentication information is valid. If this is true, then when you start a new tab (in IE7) or a new window (in IE5.x-IE7), a new browser instance is created; since the session cookie is not present in that window, you get prompted for new credentials.

To identify a specific instance of a web browser (either a specific tab or a specific window), your script needs to find the IE session in which the session cookie is running. (Remember that in IE7, this is *not* the same as the larger IE window - rather, it's the tab embedded in the larger IE window.)

The following (untested) snippet makes use both of the COM.ahk standard library, and code from http://www.autohotkey.com/forum/topic24930 initially written by Sean, "wrapped" by Guest:

Code:
COM_CoInitialize()
SetTitleMatchMode, 1
SearchTitleString := "blah"  ; Replace blah (in quotes) with a known substring of
                             ; the window title that shows at the top of the IE
                             ; instance you wish to use.
SearchNavString := "blah"    ; Replace blah (in quotes) with the search URL on
                             ; your server.

pweb := GetWebBrowser(SearchTitleString)  ; Find the applicable IE instance

COM_Invoke(pweb, "Navigate", SearchNavString)  ; Navigate to the search page
Loop   ;  until the search web page is fully loaded
{
   if (COM_Invoke(pweb,  "ReadyState") = 4)
      break
}
COM_Release(pweb)
ExitApp

; Following code from: http://www.autohotkey.com/forum/topic24930
; initially written by Sean, wrapped by Guest
GetWebBrowser(WinTitle)
{
   ControlGet, hIESvr, hWnd, , Internet Explorer_Server1, %WinTitle%
   If Not   hIESvr
   {
      return
   }
   DllCall("SendMessageTimeout", "Uint", hIESvr, "Uint", DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT"), "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 1000, "UintP", lResult)
   DllCall("oleacc\ObjectFromLresult", "Uint", lResult, "Uint", COM_GUID4String(IID_IHTMLDocument2,"{332C4425-26CB-11D0-B483-00C04FD90119}"), "int", 0, "UintP", pdoc)
   IID_IWebBrowserApp := "{0002DF05-0000-0000-C000-000000000046}"
   pweb := COM_QueryService(pdoc,IID_IWebBrowserApp,IID_IWebBrowserApp)
   COM_Release(pdoc)
   Return   pweb
}



HTH


Report this post
Top
 Profile  
Reply with quote  
 Post subject: same issue, no results
PostPosted: March 26th, 2008, 5:26 pm 
@ paulwarr / or whoever could help

I am trying to do the same thing without the search. After login in with my user name and password, i need to be able to create a new window under same session. I am using IE7.

I dled COM.ahk, setworkdir, copy any paste your code, and replaced the "blah" with the window title of the page i want to display. When i run the script, it executes then close. No new window was made and nothing happens. I am new to COM.ahk and i dont really understand the functions and what they do and there are no tutorials on this so its hard for newbies to read.

So, basically, i wanna be able to press F1, open new window of any URL under same cookie session. or IE window session, b/c i have to login with a user name and password, when the new window opens i have to re-enter my username and password everytime. Thanks for you help.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 29th, 2008, 5:10 pm 
Offline

Joined: September 21st, 2006, 10:04 pm
Posts: 32
cursed wrote:
I am trying to do the same thing without the search. After login in with my user name and password, i need to be able to create a new window under same session. I am using IE7....

So, basically, i wanna be able to press F1, open new window of any URL under same cookie session. or IE window session, b/c i have to login with a user name and password, when the new window opens i have to re-enter my username and password everytime.

I don't think that you can do this.

The whole point to having "session cookies" set by a server is to force all subsequent interactions with that session cookie to take place in the same browser "instance". What that means for you is that, attempting to open a new window will start a new instance of your browser - without the session cookie. And since the new window ("browser instance") doesn't have your instance-specific session cookie, the server asks you to authenticate again.

What you'll need to do is to manipulate the first session window (by using the IE_LoadURL command to navigate to another page, for example).
cursed wrote:
I dled COM.ahk, setworkdir, copy any paste your code, and replaced the "blah" with the window title of the page i want to display. When i run the script, it executes then close. No new window was made and nothing happens.

The code that I included was a "snippet" - not meant to be a fully-running example. If the window opened, navigated to the page you desired, and then closed, then the script succeeded - that was all it was written to do. From the above example (and note the inserted comment in red):
Code:
Loop   ;  until the search web page is fully loaded
{
   if (COM_Invoke(pweb,  "ReadyState") = 4)
      break
}
; Your code for manipulating this downloaded page, or navigating to another page, should go here.
COM_Release(pweb)

cursed wrote:
The I am new to COM.ahk and i dont really understand the functions and what they do and there are no tutorials on this so its hard for newbies to read.

Oh, do I share your pain! :shock: The challenges here are many, because you not only have to understand the basics of AHK, but you have to understand at least the basics of how to make use of Microsoft's WebBrowser and Internet Explorer controls. If you want to manipulate the web pages that you're seeing in the control, then you need much more than a basic understanding of the Document Object Model (DOM) and/or Microsoft's mshtml interfaces, connection methods, and element types. So... even trying to write a tutorial that's "easy" enough for newcomers would be very difficult, indeed.

I'm in the middle of a big coding project, which will take me until the end of June. If there's still interest on this subject in July (and if no one else has begun the effort), I'll start to draft a tutorial that collects and exhaustively documents snippets of COM/DOM/mshtml code, oriented specifically to AHK users. But while I will try to make it as understandable as I can, I can make no promises that this tutorial will be "accessible" (readily understandable) by AHK newcomers. Fair enough?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: thank you!
PostPosted: March 31st, 2008, 10:04 pm 
@ paulwarr

Hey man, thank you for your response and for your time. Yeah, even a tutorial which pointed people in the right direction or even explained the "skeleton" of How COM or any other "Expansion" functions worked. Would set people in the right direction, and they can figure stuff out on there own.

Back to the open same session window. I found that it works only when you use ctrl-n, which opens a new browser under same cookie session. Pretty basic, but works. I would actually like to learn, .NET. If you or anyone has a link to a tutorials, that was be greatly appreciated. Thanks, ttyl.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, JSLover, Tipsy3000 and 69 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