Windows 7 (& Vista?) UAC bug
I have several Access databases that use the Sendkeys statement in VBA. Sendkeys worked fine in XP and in Windows 7 it still works but it also toggles Numlock consistently and sometimes Caps Lock and Insert mode (that's disconcerting!) as well. Check out
http://www.eggheadcafe.com/software/aspnet/35456235/vb6-and-windows-scripting-host-sendkeys-in-vista-and-windows-7.aspx. Turning off UAC ("Never notify") takes care of it, but that's a security issue and definitely not a good solution. Sendkeys may
not be elegant coding, but it's quick and it works when you have old (read "legacy") or workstation apps that don't support Automation.
December 7th, 2010 12:51am
IweyOL,
It is possible that the intergty level of the application where send your keys to is higher then your Access app.
And this could result in the problem that you have.
Can you check with sysinternals process explorer what the integrity levels are of the both applications?
Didier Stevens has an excelent article that explains, what integrity levels are and how you can view and change them.
Take a look here
http://blog.didierstevens.com/2010/09/07/integrity-levels-and-dll-injection/
Kind Regards
DFT
IM me - TWiTTer: @DFTER
Free Windows Admin Tool Kit Click here and download it now
December 7th, 2010 4:46am
It does it even when I send it to a form within the same database.
December 7th, 2010 12:39pm
IweyOL,
It seems that since Windows Vista the sendkeys function doesn't work anymore. Normaly you recive an runtime error 70 "Access Denied".
Try this workarround to fix problem
http://www.jack-frost.co.uk/vb6_sendkeys_vista.html
Kind Regards
DFTIM me - TWiTTer: @DFTER
Free Windows Admin Tool Kit Click here and download it now
December 8th, 2010 5:08am
Maybe they tried to fix it (the UAC) in Windows 7 so that Sendkeys would work and didn't entirely succeed? It's still a valid statement in VBA in MS Office Pro 2010 and it does work. It just always toggles Numlock as well.
Thanks for posting the workaround - I'll have a look at it.
("You have to believe in free will, you have no choice." I.B. Singer ; - )
December 8th, 2010 11:30am
I finally took time to look at
http://www.jack-frost.co.uk/vb6_sendkeys_vista.html and it's not a drop-in fix in VBA, so it's not really an answer. As above, Sendkeys is still a valid statement in Office 2010, and it does work - with the proviso, of course - and without security warnings.
Microsoft should address the Windows 7 issue and fix the bug.("You have to believe in free will, you have no choice." I.B. Singer ; - )
Free Windows Admin Tool Kit Click here and download it now
December 15th, 2010 11:26pm
What is a drop-in fix can be found here: http://orlando.mvps.org/SendKeysMore.asp. It's a little stand-alone utility app., SendKeys.exe. It has a few more arguments then the VBA Sendkeys statement, but it's a clean substitute in the code. I've been using
it for several weeks or a month now and have had no trouble with NumLock, CapsLock or Insert modes. Ideally, this shouldn't be marked as the "Answer": Microsoft should fix their problem. But in the real world...
("You have to believe in free will, you have no choice." I.B. Singer ; - )
February 21st, 2011 10:58am