SendKeys.SendWait don't work in Vista

Posted: 07-18-2006, 10:53 PM
Hi,

I have a beta Vista system and I'm running a program (created in VB.net)
that sends keystroke to an application using
System.Windows.Forms.SendKeys.SendWait. In Vista it throws an exception -
System.Security.SecurityException: Hook cannot be created.

Is there a way to workaround this problem? I'm logged-in as the system
administrator.

Thanks,
Glenn

Reply With Quote

Responses to "SendKeys.SendWait don't work in Vista"

Jimmy Brush
Guest
Posts: n/a
 
Re: SendKeys.SendWait don't work in Vista
Posted: 07-18-2006, 11:20 PM
Hello,

This is related to new security policies in place in Windows Vista. You need
to tell Windows Vista that your application requires access to other
applications' user interface. You can do that by including a manifest with
your application.

Here's a simple one you can test out. Create a file called
APPLICATION.exe.manifest in the same folder where your application resides,
where APPLICATION is the filename of your application.

Inside this file, put:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<asmv3:trustInfo xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:security>
<asmv3:requestedPrivileges>
<asmv3:requestedExecutionLevel
level="asInvoker"
uiAccess="true" />
</asmv3:requestedPrivileges>
</asmv3:security>
</asmv3:trustInfo>
</assembly>

Note that your application will not have access to programs that run
"elevated" (the programs that ask permission to run, such as administrative
tools).

In order to access elevated programs, you will need to change level to
requireAdministrator. This will also cause your program to "ask for
permission" whenever the user starts the program.

For more information, check out these websites:

http://www.mjtnet.com/blog/2006/03/0...ler-and-vista/
http://microsoft.mrmpslc.com/uploade...Spec%201.0.doc
http://blogs.msdn.com/shawnfa/archiv...06/568563.aspx

Also, you may find more helpful responses at the MSDN forum:
http://forums.microsoft.com/MSDN/

- JB

Vista FAQ
http://www.jimmah.com/vista/

Reply With Quote
glenn_97124
Guest
Posts: n/a
 
Re: SendKeys.SendWait don't work in Vista
Posted: 07-19-2006, 07:39 PM
Hi JB,

This is excellent.

Thanks,
Glenn

"Jimmy Brush" wrote:
> Hello,
>
> This is related to new security policies in place in Windows Vista. You need
> to tell Windows Vista that your application requires access to other
> applications' user interface. You can do that by including a manifest with
> your application.
>
> Here's a simple one you can test out. Create a file called
> APPLICATION.exe.manifest in the same folder where your application resides,
> where APPLICATION is the filename of your application.
>
> Inside this file, put:
>
> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
> <asmv3:trustInfo xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
> <asmv3:security>
> <asmv3:requestedPrivileges>
> <asmv3:requestedExecutionLevel
> level="asInvoker"
> uiAccess="true" />
> </asmv3:requestedPrivileges>
> </asmv3:security>
> </asmv3:trustInfo>
> </assembly>
>
> Note that your application will not have access to programs that run
> "elevated" (the programs that ask permission to run, such as administrative
> tools).
>
> In order to access elevated programs, you will need to change level to
> requireAdministrator. This will also cause your program to "ask for
> permission" whenever the user starts the program.
>
> For more information, check out these websites:
>
> http://www.mjtnet.com/blog/2006/03/0...ler-and-vista/
> http://microsoft.mrmpslc.com/uploade...Spec%201.0.doc
> http://blogs.msdn.com/shawnfa/archiv...06/568563.aspx
>
> Also, you may find more helpful responses at the MSDN forum:
> http://forums.microsoft.com/MSDN/
>
> - JB
>
> Vista FAQ
> http://www.jimmah.com/vista/
>
Reply With Quote
Gerhard
Guest
Posts: n/a
 
Re: SendKeys.SendWait don't work in Vista
Posted: 09-06-2006, 09:07 PM
Hello

When I searched this group for “macro and vista”, I found your article. It
is way above my head, but I think it can help me with my problem of macros
that worked in winxp but failed in vista.
Only, I don’t even know how to create the file APPLICATION.exe.manifest.
Windows help says click on file and new, but where my application resides,
there is no file.

Here is my original problem: With RemoteKeys
(http://www.freewarehits.de/RemoteKeys.htm) I created two macros transl and
write:
transl : copies Russian word and proposes English translations
{/BTCH.EXPLICIT}
{/BTCH.REM clear clipboard}
{/CLIP.CLEAR}
{/BTCH.REM highlight Russian word}
{HOLD.SHIFT/CONTROL}{KEY.RIGHT}
{/BTCH.REM copy Russian word}
{HOLD.CONTROL}{KEY.INSERT}
{/BTCH.REM move cursor behind word}
{HOLD.CONTROL}{KEY.RIGHT}
{/BTCH.REM open dictionary}
{/APP.OPEN iexplore,
http://www.multitran.ru/c/m.exe?a=Sh...e=0&ShowLinks= ON&HL=2&L1=1&L2=2}
{/BTCH.REM wait3 sec}
{/BTCH.DELAY 3}
{/BTCH.REM paste Russian word}
{HOLD.SHIFT}{KEY.INSERT}
{/BTCH.REM click search}
{KEY.ENTER}
{/BTCH.REM job done}


write: copies English translation and writes it into Russian text
{/BTCH.EXPLICIT}
{/BTCH.REM clear clipboard}
{/CLIP.CLEAR}
{/BTCH.REM select and highlight by hand English translation}
{/BTCH.REM copy English translation}
{HOLD.CONTROL}{KEY.INSERT}
{/BTCH.REM close dictionary}
{/APP.TOFRONT.Microsoft Internet Explorer}
{HOLD.ALT}{KEY.F4}
{/BTCH.REM switch back to Word}
{/APP.TOFRONT Microsoft Word}
{/APP.ACTIVATION.LAST}
{/BTCH.REM wait 2 sec}
{/BTCH.DELAY 2}
{/BTCH.REM paste translation}
{HOLD.SHIFT}{KEY.INSERT}
{/BTCH.REM job done}
They both worked in WinXP, but fail in vista. So I would like to create the
file
RemoteKeys.exe.manifest
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<asmv3:trustInfo xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:security>
<asmv3:requestedPrivileges>
<asmv3:requestedExecutionLevel
level="asInvoker"
uiAccess="true" />
</asmv3:requestedPrivileges>
</asmv3:security>
</asmv3:trustInfo>
</assembly>
Into Gerhard>Downloads>RemoteKeys, where RemoteKeys.exe is located.
But I don’t know how to create the file.
Thanks in advance, Gerhard


"Jimmy Brush" wrote:
> Hello,
>
> This is related to new security policies in place in Windows Vista. You need
> to tell Windows Vista that your application requires access to other
> applications' user interface. You can do that by including a manifest with
> your application.
>
> Here's a simple one you can test out. Create a file called
> APPLICATION.exe.manifest in the same folder where your application resides,
> where APPLICATION is the filename of your application.
>
> Inside this file, put:
>
> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
> <asmv3:trustInfo xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
> <asmv3:security>
> <asmv3:requestedPrivileges>
> <asmv3:requestedExecutionLevel
> level="asInvoker"
> uiAccess="true" />
> </asmv3:requestedPrivileges>
> </asmv3:security>
> </asmv3:trustInfo>
> </assembly>
>
> Note that your application will not have access to programs that run
> "elevated" (the programs that ask permission to run, such as administrative
> tools).
>
> In order to access elevated programs, you will need to change level to
> requireAdministrator. This will also cause your program to "ask for
> permission" whenever the user starts the program.
>
> For more information, check out these websites:
>
> http://www.mjtnet.com/blog/2006/03/0...ler-and-vista/
> http://microsoft.mrmpslc.com/uploade...Spec%201.0.doc
> http://blogs.msdn.com/shawnfa/archiv...06/568563.aspx
>
> Also, you may find more helpful responses at the MSDN forum:
> http://forums.microsoft.com/MSDN/
>
> - JB
>
> Vista FAQ
> http://www.jimmah.com/vista/
>
Reply With Quote
 
LinkBack Thread Tools Display Modes
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
do xp games work for vista if not how could i make them work? Guest Windows NT/2000/XP 0 05-12-2008 06:26 AM
do xp games work for vista if not how could i make them work? Guest Windows NT/2000/XP 0 05-12-2008 04:17 AM
SendKeys throws "Hook cannot be created" security exception in Vista Beta 2 Dan Dautrich Windows Vista Security 1 03-28-2007 09:47 PM
HP LaserJet 1010 don't work in Vista since Beta2 - Advanced 1384 Printing Support drivers for XP don't work Alexey Windows Vista Printers & Scanners 2 10-19-2006 01:05 AM
SendKeys on Remote Desktop Matthias Windows XP Work Remotely 0 04-05-2005 10:44 AM