Link to home
Start Free TrialLog in
Avatar of E=mc2
E=mc2Flag for Canada

asked on

Using AutoHotKey script to open internal website using IE and then entering login details

I would like to use an AutoHotKey script so that when you double click on it, it will open a browser using either Internet Explorer and then once the internal website is open to automatically enter the username and password.
It will be used internally only.
Is this possible?

@JoeWinograd perhaps you have much experience with this?
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

> open a browser using either Internet Explorer

either IE or...what?

> Is this possible?

Probably.

> @JoeWinograd perhaps you have much experience with this?

I have a lot of experience with AutoHotkey, but only a modest amount in this particular area. There are two approaches for IE...either sending keystrokes or using the IE Component Object Model (COM) interface. I generally much prefer COM (for Office apps, too, as you can see at this EE post), since sending keystrokes tends to be error prone, although since it is an internal site, this (simpler) approach may work fine. My EE AutoHotkey - Getting Started article discusses COM and here's an EE article with an example of the sending-keystrokes method:
How to copy the short link of an ID at Experts Exchange to the clipboard with a single keystroke

It could be as simple as this (sending-keystrokes) script, depending, of course, on the internal website:

#Warn,UseUnsetLocal ; warning on uninitialized variables
#NoEnv ; avoid checking empty variables to see if they are environment variables
#SingleInstance Force ; replace old instance immediately
SetBatchLines,-1 ; run at maximum speed
SendMode,Input ; faster and more reliable

; *** begin variables to change ***
; there are three possibilities for SetTitleMatchMode - pick the one you need
; SetTitleMatchMode,1 ; starts with
; SetTitleMatchMode,2 ; contains
SetTitleMatchMode,3 ; matches exactly
WebsiteTitle:="Helping IT Professionals Succeed at Work | Experts Exchange - Internet Explorer" ; Important - CASE SENSITIVE!
IEexe:="C:\Program Files (x86)\Internet Explorer\iexplore.exe" ; this is usually the 32-bit location
;IEexe:="C:\Program Files\Internet Explorer\iexplore.exe"  ; this is usually the 64-bit location
URL:="www.experts-exchange.com"
LoadWaitTime:=1000 ; number of milliseconds to wait after the page is active to make sure that the username field is there
PasswordWaitTime:=100 ; number of milliseconds to wait after entering Username (before entering Password)
Username:="Emc2"
Password:="AlbertEinstein"
; *** end variables to change ***

Run,%IEexe% %URL%
WinWaitActive,%WebsiteTitle%
Sleep,%LoadWaitTime%
Send %Username% ; presumes that the username field comes up first at the page and has focus
Sleep,%PasswordWaitTime%
Send {Tab} ; presumes that the tab key works to get from the username field to the password field
Sleep,%PasswordWaitTime% ; probably not needed, but just in case
Send %Password%
Sleep,%PasswordWaitTime% ; probably not needed, but just in case
Send {Enter} ; presumes that the Enter key works to submit the username and password
ExitApp

Open in new window

> when you double click on it

Btw, instead of having to double-click on the script, you can define a hotkey for it. To do that, you would need two changes to the script above:

(1) Put your hotkey definition before the Run,%IEexe% %URL% command, such as:

!^F12:: ; Alt+Ctrl+F12

Open in new window

See this EE article for an explanation of hotkeys:
How to move all windows on one monitor to another monitor with a single keystroke

(2) Change the ExitApp command to the Return command.

Regards, Joe
Somewhat off-topic but .......
I can give an absolute 100% cast-iron guarantee that TYPEITIN
can be easily programmed to do exactly what you want with ONE CLICK!
(You can easily assign a keyboard combination instead of having to click).

When you create a new button, you can write the script yourself, or ...
you can go into record mode and typeitin will create the script for you
as you perform the desired keyboard & mouse actions.
Press Stop to end the recording.

You can then edit the automatically created script if needed.
ASKER CERTIFIED SOLUTION
Avatar of E=mc2
E=mc2
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, that's exactly what I meant when I said this in my first post:
or using the IE Component Object Model (COM) interface. I generally much prefer COM (for Office apps, too, as you can see at this EE post), since sending keystrokes tends to be error prone
To give credit where credit is due, I presume you found that script here:
https://www.autohotkey.com/boards/viewtopic.php?t=15061

Regards, Joe