The idea is to capture the mouse via Win32 API so I can utilize all mouse buttons without Sketchup interfering (it's for a mini first person shooter in SketchyPhysics).
Now I got it to work half way but I don't know how to read the buttons, and I know alot of you guys are more knowledgeable then me so I would appreciate the help.
The working code I got sofar:
-
window handle
getForegroundWindow = Win32API.new('user32', 'GetForegroundWindow', [], 'L') window_handle = getForegroundWindow.Call()
-
capture mouse input
setCapture = Win32API.new('user32', 'SetCapture', 'L', 'L') setCapture.call(window_handle)
-
release mouse (EDIT: fixed the input parameters)
releaseCapture = Win32API.new('user32', 'ReleaseCapture', 'V', 'L') releaseCapture.call()
So those are the parts that work, you can try it in the Ruby console directly, until releaseCapture is called SU wont get any mouse input.
Now I a script that reads the mouse input/clicks while the mouse is captured.
I have found a Ruby example for reading window input messages but I'm not sure how it is suppose to work, if it's the right way to do it at all.
` getmessage = Win32API.new('user32', 'GetMessage', ['p', 'l', 'i', 'i'], 'l')
dispatchmessage = Win32API.new('user32', 'DispatchMessage', 'p', 'l')
translatemessage = Win32API.new('user32', 'TranslateMessage', 'p', 'l')
while getmessage.call(msg, 0, 0,0)
dispatchmessage.call(msg)
translatemessage.call(msg)
end`