March 28, 2024, 11:33:23 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Set the mouse position

Started by rossjade, July 06, 2013, 06:06:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

rossjade

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.

Brian

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

LarryMc


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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

rossjade

Thanks LarryMc - the Mouse Position code works fine.