SendKeys not working on Windows 10

Page 3 of 3 FirstFirst 123

  1. Posts : 579
    Windows 10
    Thread Starter
       #21

    Antoops said:
    I am also having similar issue with my program which was working windows 7 and not in windows 10. My requirement is to keep my machine not to get screen locked, so i am keep on sending NUMLOCK on every 5 seconds to keep it alive. So with this requirement, how can i replace sendkeys to something else? Please point if you see any solutions
    SendKeys are locked in Win 10 and 8.1 by the UAC.
    If you need to use Sendkeys you may want to try Disabling it in the Registry :
    HKLM>Software>Microsoft>Windows>CurrentVersion>Policies>System>EnableLUA=0.
      My Computer


  2. Posts : 1
    Windows 10
       #22

    SendKeys does not work, but it appears the API function SendInput does.

    If you're in VB6, copy/paste this code into a module:

    Private Type KEYBDINPUT
    wVk As Integer
    wScan As Integer
    dwFlags As Long
    Time As Long
    dwExtraInfo As Long
    End Type
    Private Type GENERALINPUT
    dwType As Long
    xi(0 To 23) As Byte
    End Type
    Private Const INPUT_KEYBOARD = 1
    Private Declare Function SendInput Lib "user32.dll" (ByVal nInputs As Long, pInputs As GENERALINPUT, ByVal cbSize As Long) As Long
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal BYTELEN As Long)

    ' Overrides VBA.SendKeys, which throws Permission Denied error in Windows 10
    Public Function SendKeys(ByVal Text As String)
    Dim n As Long
    For n = 1 To Len(Text)
    SendKeysA Asc(Mid(Text, n, 1))
    Next
    End Function

    ' Send keycode
    Public Function SendKeysA(ByVal vKey As Integer)
    Dim GInput(0) As GENERALINPUT
    Dim KInput As KEYBDINPUT

    KInput.wVk = vKey
    GInput(0).dwType = INPUT_KEYBOARD
    CopyMemory GInput(0).xi(0), KInput, Len(KInput)
    Call SendInput(1, GInput(0), Len(GInput(0)))
    End Function
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 15:55.
Find Us




Windows 10 Forums