Keepass is an excellent program. The only restriction I don't like is that you have open a program/webpage first, and then use the global hotkey or CTRL-V. IMHO it is better, just to doubleclick on an Keepass entry and everything else happens automatically. I also had problems with web pages that don't activate the focus for the "username" field (e.g. citibank)
I have solved those issues with autoit.
Please let me know, in case you find any bugs or need help.
Dave
Hopefully the mini-solution is not overkill, which it would be if Keepass could do all this (may be I didn't read the manual well enough...) But in this case it was still fun to learn autoit :-)
(By the way, it would be great if Keepass would use autoit instead of the current SendKeys engine)
Fortunately it is possible to use "cmd://" in the URL field, which allows to run any command with parameters.
When I doubleclick on the url in Keepass, then the script KeePrg logs me into yahoo automatically and safely (no matter how long it takes to load yahoo messenger)
Here is an example how to login to Yahoo mail (no matter how long it takes to load the page)
Please note the values 2 and 0 are web site specific information (so it doesn't work for other web pages). In order to make it work for other sites, you would have to figure out the form and username field indices, by running a cool javascript (see below)
Instructions how to create the two Scripts KeeUrl and KeePrg.
First install autoit v3 beta (very stable, very small, freeware/opensource)
It accepts 3 parameters now. The third is optional and specifies the title of the window.
Example:
cmd://KeeUrl "http://hotmail.com" "{USERNAME}{TAB}{PASSWORD}" "Sign In"
or
cmd://KeeUrl "http://hotmail.com" "{USERNAME}{TAB}{PASSWORD}" "{TITLE}"
Create a the file KeeUrl.au3 with the following content
Opt("WinTitleMatchMode", 2)
$UrlVar = $CmdLine[1]
$AutotypeVar = $CmdLine[2]
If $CmdLine[0] = 3 Then
$WinTitle = $CmdLine[3]
Else
$WinTitle = ""
EndIf
$oIE=ObjCreate("InternetExplorer.Application")
With $oIE
.Visible = True
.Navigate($UrlVar)
If $WinTitle = "" Then $WinTitle = $oIE.name
If WinWaitActive ($WinTitle, "", 60) = 0 Then Exit
Do
Sleep(100)
Until .ReadyState = 4
EndWith
If WinActivate ($WinTitle) = 0 Then Exit
Sleep(100)
Send ($AutotypeVar)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am intrigued with the potential for AutoIt and I have downloaded and installed version 3 and version 3 beta but I don't understand how to get to the option "toggle to beta."
Thanks in advance for your help and thanks for introducing me to AutoIt.
Hello Tee, "Toggle AU3 betaA" is a menu item in the start menu (shortcut to "C:\Program Files\AutoIt3\beta\AutoIt3.exe" "C:\Program Files\AutoIt3\beta\Extras\Toggle AU3 Beta.au3").
You have to click it once, to make sure that the beta version is used (the beta version is stable).
You need the beta version, because at the moment only the beta version supports Internet Explorer automation (COM/OLE ...)
By the way, I have to thank KeePass. Because of the "auto-type" feature I learnt about autoit (and autohotkey).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Last update, here is an improved and final version of KeeUrl.au3:
Opt("WinTitleMatchMode", 2)
$UrlVar = $CmdLine[1]
$AutotypeVar = $CmdLine[2]
If $CmdLine[0] = 3 Then
$WinTitle = $CmdLine[3]
Else
$WinTitle = ""
EndIf
$oIE=ObjCreate("InternetExplorer.Application")
With $oIE
.Visible = True
.Navigate($UrlVar)
If $WinTitle = "" Then $WinTitle = $oIE.name
Do
Sleep(100)
Until (.ReadyState = 4) and (.document.readystate = "complete")
EndWith
If WinActivate ($WinTitle) = 0 Then Exit
Sleep(100)
Send ($AutotypeVar)
-----------
Here are some examples:
Please note {USERNAME} and {PASSWORD} are KeePass commands will be subsituted. {ENTER} {TAB} +{TAB} (=shift TAB) etc are autoit commands. Luckily they have the same syntax :-)
KeePrg needs exactly 3 arguments. The second one is the title of the window/popup, that KeeUrl has to wait for, before auto-typing.
Hope this helps. Let me know, if you find any web pages or programs, where it doesn't work. I have never tested it on slow connections. Does anybody use AOL and could test it?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, It looks like that all my examples have a semicolon";" included. No idea why. Please ignore that ; I copied and pasted the examples without semicolon .,,,
It must have been inserted by the "forum software" (a bug?). Strange ...
Dave
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I actually use it via Remote Desktop, and it works. But you need to install the two scripts on the host machine as well. Then it should work for you as well.
I never heard of .htaccess before. Do you have a couple of example web sites? Then I could try to figure out a way in the script to deal with them.
The main problem with automating web pages is basically to determine when a web page is finished loading. Because only when a page is finished loading, you can be sure that all form fields are visible (otherwise your password might be entered in the wrong field).
Internet explorer has very nice automation support. You can basically check some simple flags with one line of code (see my script).
Mozilla does not support this (as far as I know) currently.
For Mozilla an alternative would be to always wait like 5 or 10 or x seconds before executing the autotype sequence (in fact I posted a script that does this for Mozilla using autohotkey; search for it in the other forum. But when I discovered that autoit supports Internet Explorer automation I switched to autoit.)
If you know how to automate Mozilla via APIs, then let me know ...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have access to multiple fast hosts from 1and1.com from a promotion that they had 2 years ago, which I basically use to host files on - if you send them to me I can host them and provide you with a link (not a very pretty one, as the URLs are something along the lines of [http://s########.onlinehome.us] - and I also am running my own FTP server courtesy of Gentoo Linux on my laptop - with a 1 Mbps connection, so it is not too terribly slow - and this is hosting files for the Jackass! Gentoo project, so it is rather reliable *and* is accessible by a simple dynamic domain name.
Let me know if you are interested - I am logged in so you should be able to email me for details.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem here is, that the logon within RDP is actually a picture, and not a control/window/popup, that a script could wait for (complicated to detect pixels of the login box on the screen :-)
The "work around" would be to wait "manually" for it, e.g. to use a popup with a timeout (that waits until it disappears after 5 seconds or ok is clicked).
Dave
So here is my work around. Let me know, whether it works for you (please note, strings like "remote desktop connection" might be OS/language dependent. Just look at the titles of your windows to get the right strings)
Example
cmd://KeeRdp {USERNAME} {PASSWORD} 193.165.2.5
create a File KeeRdp.au3 with the following content:
Opt("WinTitleMatchMode", 2)
If $CmdLine[0] <> 3 Then
MsgBox (0, "Error", "Correct syntax is: KeyPrg Program Title Autotype")
exit
EndIf
Keepass is an excellent program. The only restriction I don't like is that you have open a program/webpage first, and then use the global hotkey or CTRL-V. IMHO it is better, just to doubleclick on an Keepass entry and everything else happens automatically. I also had problems with web pages that don't activate the focus for the "username" field (e.g. citibank)
I have solved those issues with autoit.
Please let me know, in case you find any bugs or need help.
Dave
Hopefully the mini-solution is not overkill, which it would be if Keepass could do all this (may be I didn't read the manual well enough...) But in this case it was still fun to learn autoit :-)
(By the way, it would be great if Keepass would use autoit instead of the current SendKeys engine)
Fortunately it is possible to use "cmd://" in the URL field, which allows to run any command with parameters.
In the URL field I put for example
cmd://KeePrg "C:\Program Files\Yahoo!\Messenger\YPager.exe" "Sign In" {USERNAME}{TAB}{PASSWORD}{ENTER}
(how to get KeeUrl or KeePrg see below)
When I doubleclick on the url in Keepass, then the script KeePrg logs me into yahoo automatically and safely (no matter how long it takes to load yahoo messenger)
Here is an example how to login to Yahoo mail (no matter how long it takes to load the page)
cmd://KeeUrl "http://mail.yahoo.com" {USERNAME}{TAB}{PASSWORD}{ENTER}
For webpages that don't set the focus in the first field, I'll use the following (advanced feature).
cmd://KeeUrl "https://web.da-us.citibank.com/cgi-bin/citifi/scripts/home/visitor_homepage.jsp" "^ojavascript:document.forms[2].elements[0].focus(){ENTER}{TAB}+{TAB}{USERNAME}{TAB}{PASSWORD}"
The javascript part activates the focus.
^o is equal CTRL-O in internet explorer
Please note the values 2 and 0 are web site specific information (so it doesn't work for other web pages). In order to make it work for other sites, you would have to figure out the form and username field indices, by running a cool javascript (see below)
Instructions how to create the two Scripts KeeUrl and KeePrg.
First install autoit v3 beta (very stable, very small, freeware/opensource)
download and install autoit v3 first
http://www.autoitscript.com/autoit3/downloads.php
then install the beta
http://www.autoitscript.com/autoit3/files/beta/autoit/
after installation, go to the autoit v3 beta menu and click "toggle to beta"
Installation is finished now.
Now create two files KeeUrl.au3 and KeePrg.au3
And please them into the KeePass directory
File KeyUrl.au3:
Opt("WinTitleMatchMode", 2)
If $CmdLine[0] <> 2 Then
exit
EndIf
$UrlVar = $CmdLine[1]
$AutotypeVar = $CmdLine[2]
$oIE=ObjCreate("InternetExplorer.Application")
With $oIE
.Visible = True
.Navigate($UrlVar)
Do
Sleep(100)
Until .ReadyState = 4
EndWith
;MsgBox (0, "test ", $oIE.name)
WinActivate ($oIE.name)
Send ($AutotypeVar)
File KeePrg.au3:
$Prog = $CmdLine[1]
$Title = $CmdLine[2]
$Autotype = $CmdLine[3]
Run ($Prog)
WinWaitActive ($Title)
Send ($Autotype)
Now compile the script (right click on each au3 file and select "compile script"). The result should be KeePrg.au3 and KeyUrl.au3
That's it. For me the time savings are enormous :-)
Appendix A:
In case you want to know the syntax for the autotype key sequence.
http://www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm
Appendix B:
Javascript to scan form fields. Run by pasting into the address field of your internet explorer and press enter
javascript:function ROIoiW(){var i=0,j,A='anonymous',D,E,F=document.forms;while(i<F.length){E=F[i].elements;for(j=0;j<E.length;j++){D=E[j];alert(i+'/'+j+'/'+D.type+'-'+E.name+'-'+D.name+'-'+D.value)}i++}}ROIoiW();void(null)
Hello,
the auto-type replacement works great. Thanks! Very convenient!
For KeePrg you can specify three options
KeePrg Program Windowtitle Autotypestring
For KeeUrl you can only speciffy two options
KeeUrl URL Autotypestring.
Please also add an option Windowtitle.
Thanks in advance!
OK, here is the new KeeUrl.au3 file
It accepts 3 parameters now. The third is optional and specifies the title of the window.
Example:
cmd://KeeUrl "http://hotmail.com" "{USERNAME}{TAB}{PASSWORD}" "Sign In"
or
cmd://KeeUrl "http://hotmail.com" "{USERNAME}{TAB}{PASSWORD}" "{TITLE}"
Create a the file KeeUrl.au3 with the following content
Opt("WinTitleMatchMode", 2)
$UrlVar = $CmdLine[1]
$AutotypeVar = $CmdLine[2]
If $CmdLine[0] = 3 Then
$WinTitle = $CmdLine[3]
Else
$WinTitle = ""
EndIf
$oIE=ObjCreate("InternetExplorer.Application")
With $oIE
.Visible = True
.Navigate($UrlVar)
If $WinTitle = "" Then $WinTitle = $oIE.name
If WinWaitActive ($WinTitle, "", 60) = 0 Then Exit
Do
Sleep(100)
Until .ReadyState = 4
EndWith
If WinActivate ($WinTitle) = 0 Then Exit
Sleep(100)
Send ($AutotypeVar)
I am intrigued with the potential for AutoIt and I have downloaded and installed version 3 and version 3 beta but I don't understand how to get to the option "toggle to beta."
Thanks in advance for your help and thanks for introducing me to AutoIt.
Tee
download and install autoit v3 first
http://www.autoitscript.com/autoit3/downloads.php />then install the beta
http://www.autoitscript.com/autoit3/files/beta/autoit/ />
after installation, go to the autoit v3 beta menu and click "toggle to beta"
Hello Tee, "Toggle AU3 betaA" is a menu item in the start menu (shortcut to "C:\Program Files\AutoIt3\beta\AutoIt3.exe" "C:\Program Files\AutoIt3\beta\Extras\Toggle AU3 Beta.au3").
You have to click it once, to make sure that the beta version is used (the beta version is stable).
You need the beta version, because at the moment only the beta version supports Internet Explorer automation (COM/OLE ...)
By the way, I have to thank KeePass. Because of the "auto-type" feature I learnt about autoit (and autohotkey).
Last update, here is an improved and final version of KeeUrl.au3:
Opt("WinTitleMatchMode", 2)
$UrlVar = $CmdLine[1]
$AutotypeVar = $CmdLine[2]
If $CmdLine[0] = 3 Then
$WinTitle = $CmdLine[3]
Else
$WinTitle = ""
EndIf
$oIE=ObjCreate("InternetExplorer.Application")
With $oIE
.Visible = True
.Navigate($UrlVar)
If $WinTitle = "" Then $WinTitle = $oIE.name
Do
Sleep(100)
Until (.ReadyState = 4) and (.document.readystate = "complete")
EndWith
If WinActivate ($WinTitle) = 0 Then Exit
Sleep(100)
Send ($AutotypeVar)
-----------
Here are some examples:
Please note {USERNAME} and {PASSWORD} are KeePass commands will be subsituted. {ENTER} {TAB} +{TAB} (=shift TAB) etc are autoit commands. Luckily they have the same syntax :-)
KeePrg needs exactly 3 arguments. The second one is the title of the window/popup, that KeeUrl has to wait for, before auto-typing.
cmd://KeePrg "C:\Program Files\Yahoo!\Messenger\YPager.exe" "Sign In" {USERNAME}{TAB}{PASSWORD}{ENTER}
KeeUrl usually needs only 2 arguments:
cmd://KeeUrl "http://brokerage.comdirect.de" "{USERNAME}{TAB}{PASSWORD}"
cmd://KeeUrl "web.da-us.citibank.com" "^ojavascript:document.forms[2].elements[0].focus(){ENTER}{TAB}+{TAB}{USERNAME}{TAB}{PASSWORD}{ENTER}"
cmd://KeeUrl "https://www.paypal.com" "{USERNAME}{TAB}{PASSWORD}{ENTER}"
cmd://KeeUrl "http://hotmail.com" "{USERNAME}{TAB}{PASSWORD}{ENTER}"
cmd://KeeUrl "http://mail.yahoo.com" {USERNAME}{TAB}{PASSWORD}{ENTER}
But you could also specify a third argument. The title of the Window (probably not needed at all).
cmd://KeeUrl "http://hotmail.com" "{USERNAME}{TAB}{PASSWORD}{ENTER}" "{TITLE}"
or
cmd://KeeUrl "http://hotmail.com" "{USERNAME}{TAB}{PASSWORD}{ENTER}" "Sign In"
Hope this helps. Let me know, if you find any web pages or programs, where it doesn't work. I have never tested it on slow connections. Does anybody use AOL and could test it?
Hello all, just to clarify.
The installation of autoit is only needed to compile the two scripts. Once you have generated the two .exe files, you could uninstall autoit.
I could also post those two executables, but I don't have a provider/space to host them.
Dave
Sorry, It looks like that all my examples have a semicolon";" included. No idea why. Please ignore that ; I copied and pasted the examples without semicolon .,,,
It must have been inserted by the "forum software" (a bug?). Strange ...
Dave
Thanks a lot. Great stuff. Very easy installation.
I hope this feature would be integrated into KeePass though.
This is very useful! Thank you.
Hi, cool script! ;)
but how can i get it to work with .htaccess popups?
and how can in use Mozilla Firefox instead of InternetExplorer?
and how can i get it to work with MSTSC (RemoteDesktop from WinXP)
I actually use it via Remote Desktop, and it works. But you need to install the two scripts on the host machine as well. Then it should work for you as well.
I never heard of .htaccess before. Do you have a couple of example web sites? Then I could try to figure out a way in the script to deal with them.
The main problem with automating web pages is basically to determine when a web page is finished loading. Because only when a page is finished loading, you can be sure that all form fields are visible (otherwise your password might be entered in the wrong field).
Internet explorer has very nice automation support. You can basically check some simple flags with one line of code (see my script).
Mozilla does not support this (as far as I know) currently.
For Mozilla an alternative would be to always wait like 5 or 10 or x seconds before executing the autotype sequence (in fact I posted a script that does this for Mozilla using autohotkey; search for it in the other forum. But when I discovered that autoit supports Internet Explorer automation I switched to autoit.)
If you know how to automate Mozilla via APIs, then let me know ...
can you give a real-life example for rdp?
you don't know .htaccess? try this one: http://dcp17.c.artfiles.de
but i can't give you a password ;)
I enable remote desktop connection on my XP pro machine. And then run mstsc.exe from a different machine to connect to it. My scripts work fine.
I see, now I know what you mean by .htaccess :-)
This is acutally even easier, because you don't have to wait for the web page to finish loading.
In fact you use the existing script KeePrg for this purpose (see above).
Solution in your case:
cmd://KeePrg "C:\Program Files\Internet Explorer\IEXPLORE.EXE http://dcp17.c.artfiles.de" "Connect to" {USERNAME}{TAB}{PASSWORD}{ENTER}
Of course couldn't test it on your, because I don't have the password, but it should work.
I think e.g. ewallet is not able to handle htaccess, because htaccess can not be automated via com, right?
Again ... No idea why the semicolon got added.
I copied and pasted the link without semicolon.
Please remove the semicolon in the above example
Dave
Dave,
I have access to multiple fast hosts from 1and1.com from a promotion that they had 2 years ago, which I basically use to host files on - if you send them to me I can host them and provide you with a link (not a very pretty one, as the URLs are something along the lines of [http://s########.onlinehome.us] - and I also am running my own FTP server courtesy of Gentoo Linux on my laptop - with a 1 Mbps connection, so it is not too terribly slow - and this is hosting files for the Jackass! Gentoo project, so it is rather reliable *and* is accessible by a simple dynamic domain name.
Let me know if you are interested - I am logged in so you should be able to email me for details.
Dave, this is very useful. Thanks.
but with rdp to win-servers, you get a second dialog for authentication....
.htaccess solution is not working for me.... script is pausing and nothing is written in dialog
Hi regarding,
RDP, ok I understand. You actually want to automate to login via RDP. Hmm, tried it and does not work. If I figure how to, i post it here ...
.htaccess
You have to check the title of the pop-up window. Might be different for different browser or languages.
On my machine with IE 6.0 the title starts with "Connect to". May be it is different on your machine or browser?
The problem here is, that the logon within RDP is actually a picture, and not a control/window/popup, that a script could wait for (complicated to detect pixels of the login box on the screen :-)
The "work around" would be to wait "manually" for it, e.g. to use a popup with a timeout (that waits until it disappears after 5 seconds or ok is clicked).
Dave
So here is my work around. Let me know, whether it works for you (please note, strings like "remote desktop connection" might be OS/language dependent. Just look at the titles of your windows to get the right strings)
Example
cmd://KeeRdp {USERNAME} {PASSWORD} 193.165.2.5
create a File KeeRdp.au3 with the following content:
Opt("WinTitleMatchMode", 2)
If $CmdLine[0] <> 3 Then
MsgBox (0, "Error", "Correct syntax is: KeyPrg Program Title Autotype")
exit
EndIf
$Username = $CmdLine[1]
$Password = $CmdLine[2]
$ipaddress = $CmdLine[3]
Run("C:\WINDOWS\system32\mstsc.exe")
WinWaitActive("Remote Desktop Connection")
Send($ipaddress)
Send("{ENTER}")
WinWaitActive("- Remote Desktop")
;Sleep(5000)
MsgBox (0, "Message", "Wait until login appears", "5")
Send("!u")
Send($Username)
Send("!p")
Send($Password)
Send("{ENTER}")
hi,
i've slightly modified KeeRdp...
Opt("WinTitleMatchMode", 2)
If $CmdLine[0] <> 3 Then
MsgBox (0, "Error", "Correct syntax is: KeyPrg Program Title Autotype")
exit
EndIf
$Username = $CmdLine[1]
$Password = $CmdLine[2]
$ipadress = $CmdLine[3]
Run("C:\WINDOWS\system32\mstsc.exe")
WinWaitActive("Remotedesktopverbindung")
Send($ipadress)
Send("{ENTER}")
;WinWaitActive("- Remote Desktop")
;Sleep(5000)
MsgBox (0, "Message", "Wait until login appears", "30")
Send($Password)
Send("+{TAB}")
Send($Username)
Send("{ENTER}")
But i think either KeeRdp (AutoIt) or KeePass has a Problem with my password... i use special chars in it like ! and , and . and -
is there any way to solve that?
for .htaccess:
I took my Dialog Caption but it still won't work :(
Cheers
Guido
You could try Send($Password,1), Send($Username,1) and so on.
Regarding .htaccess. It works for me, can you provide more details?
Hi,
could you follow there?
http://keepass.datensysteme-lenk.de/viewtopic.php?p=105#105