IonicWind Software

Creative Basic => General Questions => Topic started by: rossjade on July 06, 2013, 06:06:07 AM

Title: Set the mouse position
Post by: rossjade on July 06, 2013, 06:06:07 AM
Does anyone within the forum know how to set the mouse cursor to a specific position within a window using Creative Basic.

I have tried the following code but this doesn't seem to work.

@MOUSEX =100
@MOUSEY = 100

I would be grateful if anyone within the forum can help with the problem.
Title: Re: Set the mouse position
Post by: Brian on July 06, 2013, 09:05:54 AM
Hi,

You need the SetCursorPos API call. I have just tried it and it works, but how you
get it to be inside your own program window I just don't know

Have a search on the 'net for it

Brian
Title: Re: Set the mouse position
Post by: LarryMc on July 06, 2013, 09:52:53 AM

DECLARE "user32.dll",SetCursorPos(x:INT, y:INT),INT
DECLARE "user32.dll",ClientToScreen(hwnd:INT, lpPoint:POINTAPI),INT
TYPE point
   DEF x:INT
   DEF y:INT
ENDTYPE

def pt:Point
def run:int
def w1:window

window w1,100,100,400,400,@TOOLWINDOW,0,"Position Mouse",mainwin
control w1,"B,Move,10,10,80,30,0,1"
run = 1
waituntil run=0
closewindow w1
end

sub mainwin
select @class
CASE @IDCLOSEWINDOW
run = 0
case @idcontrol
select @controlid
case 1
pt.x=300
pt.y=300
ClientToScreen(w1.hwnd, pt)
SetCursorPos(pt.x,pt.y)
endselect
endselect
return
Title: Re: Set the mouse position
Post by: rossjade on July 07, 2013, 05:05:34 AM
Thanks LarryMc - the Mouse Position code works fine.