23. juli 2006 - 23:49Der er
7 kommentarer og 1 løsning
Program til at trykke på taster
Er der nogle som kan lave et lille .exe program til mig. Det eneste programmet skal gøre er, at når man eksekvere det, så trykker programmet på tasterne CTRL + F1 etc.
øh.. hvad skal det dog bruges til.. tror ikke du får noget ud af at sende CTRL + F1 ud i den blå luft.. taster skal sendes til et program fx.. et active program..
Det burde virke.. Men ellers har jeg fundet en anden måde:
Const KEYEVENTF_KEYUP = &H2 Const INPUT_MOUSE = 0 Const INPUT_KEYBOARD = 1 Const INPUT_HARDWARE = 2 Private Type MOUSEINPUT dx As Long dy As Long mouseData As Long dwFlags As Long time As Long dwExtraInfo As Long End Type Private Type KEYBDINPUT wVk As Integer wScan As Integer dwFlags As Long time As Long dwExtraInfo As Long End Type Private Type HARDWAREINPUT uMsg As Long wParamL As Integer wParamH As Integer End Type Private Type GENERALINPUT dwType As Long xi(0 To 23) As Byte End Type 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)
Public Sub SendKeyCtrlF1() Dim GInput(0 To 1) As GENERALINPUT Dim KInput As KEYBDINPUT 'Ctrl KInput.wVk = 162 'the key we're going to press KInput.dwFlags = 0 'press the key 'copy the structure into the input array's buffer. GInput(0).dwType = INPUT_KEYBOARD ' keyboard input CopyMemory GInput(0).xi(0), KInput, Len(KInput)
'F1 KInput.wVk = 112 'the key we're going to press KInput.dwFlags = 0 'press the key 'copy the structure into the input array's buffer. GInput(0).dwType = INPUT_KEYBOARD ' keyboard input CopyMemory GInput(0).xi(0), KInput, Len(KInput)
'do the same as above, but for releasing the key KInput.wVk = 112 ' the key we're going to realease KInput.dwFlags = KEYEVENTF_KEYUP ' release the key GInput(1).dwType = INPUT_KEYBOARD ' keyboard input CopyMemory GInput(1).xi(0), KInput, Len(KInput) 'send the input now Call SendInput(2, GInput(0), Len(GInput(0)))
'do the same as above, but for releasing the key KInput.wVk = 162 ' the key we're going to realease KInput.dwFlags = KEYEVENTF_KEYUP ' release the key GInput(1).dwType = INPUT_KEYBOARD ' keyboard input CopyMemory GInput(1).xi(0), KInput, Len(KInput) 'send the input now Call SendInput(2, GInput(0), Len(GInput(0))) End Sub
Beklager, men jeg kunne ikke bruge det, så jeg har fået en ven til at lave et program til mig i C. Ellers tak for hjælpen.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.