3/17/2010

Sendkeys method

When I set up an additional Domino server, I felt annoyed with typing server id password to console every time I launched domino server. Not to mention, you just need to reset server id password from administrator client to avoid this but I previously wrote following VBScript.
(This file needs to be located on Domino program directory)



StartServer.vbs
Dim WshShell
set WshShell = CreateObject("WScript.Shell")
WshShell.Run("nserver.exe")
WScript.Sleep(100)
WshShell.AppActivate("Lotus Domino Server")
WshShell.SendKeys("password")
WshShell.SendKeys("{Enter}")

See following page for the details about SendKeys method


Yes, you should not do this. This is VERY dangerous - Password information is directly written on plain text file. However, this is interesting...

I imagined that the VBS like following works like client automation testings tools!
See the following VBS code. This script is open notes client and open mail database, quit notes.


StartNotes.vbs
# Edit blue variable to fit your environment.
Dim WshShell
set WshShell = CreateObject("WScript.Shell")
WshShell.Run("notes.exe")
WScript.Sleep(8000)
WshShell.AppActivate("Lotus Notes")
WshShell.SendKeys("password")
WshShell.SendKeys("{Enter}")
WScript.Sleep(4000)
WshShell.SendKeys("^o")
WshShell.SendKeys("%i")
WshShell.SendKeys("mailserver")
WshShell.SendKeys("{Enter}")
WshShell.SendKeys("%f")
WshShell.SendKeys("mail/xxxx.nsf")
WshShell.SendKeys("%o")
WScript.Sleep(10000)
WshShell.SendKeys("%(fx)")


I tried this script, but I saw that this cannot be run for a long time. you know, This kind of script is very timing-dependent.

Anyway, it might be useless sample code, I just thought it was interesting.

No comments:

Post a Comment