PDA

View Full Version : SendKeys to WinUAE


Jim
15 December 2004, 04:03
IT'S OK - I DON'T THINK I NEED HELP NOW! THANKS :D

Does anyone know how to do this?

The standard Windoze API stuff (SendKeys) doesn't work, as I imagine WinUAE is somehow taking control of the keyboard input before this stage.

Basically I want to write a PC host program to send some keys to WinUAE - possible? how? Normally I do this sort of stuff (with other applications) writing some simple code in VB and using the SendKeys routines.

I don't fancy modding WinUAE/recompiling as last time I tried this I download 101 different things and wasted an evening getting nowhere.

Thanks in advance

Jim
15 December 2004, 04:33
Maybe now this can be moved to Coders Heaven, or indeed Off-Topic

I forgot the magic word "Google" and found that the SendKeys method I've been using all my life in VB/VBA is basically pants.

I should be using SendInput API instead.

I'm just playing around now with some mouse moving/clicking code, and have yet to think of a use of it in WinUAE - surely there must be some game that could now be cheated on or some fun to be had?

Anyway, here's the code to move the mouse to Windoze screen co-ordinates 50,150 and click the button (wow!):


Declare Function SendInput Lib "user32" (ByVal nCommands As Long, _
iCommand As Any, ByVal cSize As Long) As Long

Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long

Type MOUSECOMMAND ' INPUT structure
iType As Long ' 0 for mouse
iDx As Long ' rel movt in pixels (unless ABSOLUTE)
iDy As Long
iWheelData As Long ' we don't use this
iFlags As Long ' we use this (see MOUSEEVENT flags below)
iTime As Long ' don't use this
iXtra As Long ' or this
End Type

Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Const MOUSEEVENTF_LEFTUP = &H4 ' left button up

Sub MoveAndClick(ByVal X As Long, ByVal Y As Long)

Dim mCOMMAND As MOUSECOMMAND
'
' Move
SetCursorPos X, Y
'
' Click
'
mCOMMAND.iFlags = MOUSEEVENTF_LEFTDOWN
SendInput 1&, mCOMMAND, Len(mCOMMAND)
mCOMMAND.iFlags = MOUSEEVENTF_LEFTUP
SendInput 1&, mCOMMAND, Len(mCOMMAND)
End Sub

Sub jimtest()
MoveAndClick 50, 150
End Sub

Paul
15 December 2004, 11:37
Moved to Coders Heaven