Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTA VBScript SendKeys

Status
Not open for further replies.

ddaon

Programmer
Jul 27, 2012
1
US
I know that with Windows Vista and Windows 7 the SendKeys was seriously nerfed, and that it is highly recommended NOT to use SendKeys in the first place. Don't care.

I've been tasked with modifying a program created by a previous employee (it is property of the company, not the employee) to make it compatible with Win7. Well, for the most part it's been an easy task, edit a single line to update where the data is stored (My Documents -> Documents). So far, all the functions work (copying to clipboard, opening IE and going to the provided address, etc.), but the original program used SendKeys to bypass copying to the clipboard and sent the content straight to the last window open. For the sake of sanity, I need to produce the same results as everyone that uses the program has been using it this way for years. The problem, is I can't find a solution to fix, or bypass, SendKeys that doesn't screw up the rest of the program.

Code:
Dim WSH
set WSH = CreateObject("WScript.Shell")

Dim sendStr
case "SEND"
set sendStr = arrKeys(2,intKeyNum)
WSH.SendKeys "%({TAB})" & Replace(sendStr,vbCrLf,"~")

For the sake of sanity, and the fact that I can't legally provide the full code, I provided most that applies to the actual function. Suffice to say that I've tested everything upto, and including, the setting on sendStr by adding in a copy to clipboard for the string and then manually pasting, leaving the problem to be in the SendKeys line, that anyone with a little VBScript and Win7 experience would already know it has a tendency to toggle the Num lock instead of actually working.

Basically, what I need is a modification to the SendKeys line that will still take the sendStr and paste it into the accessed document, just as if you copied it from one window, hit the Alt-Tab once, and then pasted.

For the record, these identical lines allow the program to work in WinXP, so I know that as they are they work, just not in Win7.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top