small medium large xlarge

05 Feb 2012, 04:38
Dat Nguyen (25 posts)

require ‘win32/api’ include Win32

def getCursorPos =begin BOOL WINAPI GetCursorPos( __out LPPOINT lpPoint ); =end ‘GetCursorPos’, ‘?’, ‘?’, ‘user32’ end

How do I define the getCursorPos function? How do I prepare the parameter to call it? How do I extract the (x, y) values from the call?

Thanks, Dat

05 Feb 2012, 06:03
Ian Dees (207 posts)

Hello, Dat.

@GetCursorPos@ takes a pointer to a @POINT@ structure, and returns a @BOOL@. So the declaration is similar to the @GetWindowRect@ example on page 20, something like this:

get_cursor_pos = 'GetCursorPos', 'P', 'I', 'user32'

To pass in a @POINT@ struct, you can pack the integers into a string:

point = [0, 0].pack 'L*' point
x, y = point.unpack 'L*'


05 Feb 2012, 07:11
Dat Nguyen (25 posts)

Ian: Bunch of Thanks! -Dat

  You must be logged in to comment