SendKeys.SendWait don't work in Vista

Discussion in 'Windows Vista General Discussion' started by glenn_97124, Jul 18, 2006.

  1. glenn_97124

    glenn_97124 Guest

    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
     
    glenn_97124, Jul 18, 2006
    #1
    1. Advertisements

  2. glenn_97124

    Jimmy Brush Guest

    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/08/macro-scheduler-and-vista/
    http://microsoft.mrmpslc.com/upload...ning/Windows Vista Software Logo Spec 1.0.doc
    http://blogs.msdn.com/shawnfa/archive/2006/04/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/
     
    Jimmy Brush, Jul 18, 2006
    #2
    1. Advertisements

  3. glenn_97124

    glenn_97124 Guest

    Hi JB,

    This is excellent.

    Thanks,
    Glenn
     
    glenn_97124, Jul 19, 2006
    #3
  4. glenn_97124

    Gerhard Guest

    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=ShowTranslations&SearchPhrases=ON&MatchCase=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
     
    Gerhard, Sep 6, 2006
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.