Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2006
    Posts
    2

    Grin On Mouse Move... I don't get it.

    Okay... first time I have a problem I can't solve. I've been trying and trying. I want to make a program where I have this target and I should keep the mouse in the middle even it moves randomly to different directions... a bit like shooting a target or so... my code goes like this...

    * On show *
    -- Set variables
    Power = 1 -- (This ads up by clicking mouse)
    MouseX = 172
    MouseY = 190

    --Start timer
    Page.Timer(200) -- (This speed is just for testing, can be faster)

    * On Timer *
    -- Random direction
    direction = Math.Random(4)
    if direction == 1
    then
    MouseX = MouseX + power
    MouseY = MouseY
    elseif direction == 2
    then
    MouseX = MouseX - power
    MouseY = MouseY
    elseif direction == 3
    then
    MouseX = MouseX
    MouseY = MouseY - power
    elseif direction == 4
    then
    MouseX = MouseX
    MouseY = MouseY + power
    end

    -- Move mouse cursor to new coordinates
    DLL.CallFunction(_SystemFolder .. "\\user32.dll", "SetCursorPos", MouseX..","..MouseY, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);

    So... now my mouse cursor is moving randomly to some direction... and that's it... I can't control it really. Surely it moves to some point if I move my cursor but it goes back to same place, since the code says so... but what I want is that when I move mouse to right it ads MouseX... or down it ads MouseY.... and so on. Is it possible? Or maybe I'm doing it all wrong?

  2. #2
    Join Date
    May 2006
    Posts
    2

    Problem solved

    Never mind. Problem solved... I realised my stupid mistake. I didn't use flat style so I had to make it slightly different and ad some pixels to X and Y coordinates.

    * On Show*
    -- Set variables
    Power = 1 -- (This ads up by clicking mouse)

    -- Start the timer
    Page.StartTimer(50);

    * On Timer *
    -- Get the coordinates
    tMousePos = System.GetMousePosition(true);
    MouseX = tMousePos.X
    MouseY = tMousePos.Y

    -- Random direction
    if direction == 1
    then
    MouseX = MouseX + power
    MouseY = MouseY
    elseif direction == 2
    then
    MouseX = MouseX - power
    MouseY = MouseY
    elseif direction == 3
    then
    MouseX = MouseX
    MouseY = MouseY - power
    elseif direction == 4
    then
    MouseX = MouseX
    MouseY = MouseY + power
    end

    -- Move mouse cursor to new coordinates
    DLL.CallFunction(_SystemFolder .. "\\user32.dll", "SetCursorPos", (MouseX+4)..","..(MouseY+50), DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);


    But if someone has better idea I'm always open for suggestions.

Similar Threads

  1. Move it v.1.0.2
    By sside in forum AutoPlay Media Studio 5.0
    Replies: 2
    Last Post: 04-16-2005, 12:48 PM
  2. Example: Make an Image 'Follow' the Mouse Cursor
    By Desmond in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 05-18-2004, 09:06 AM
  3. 1 AVI file = 1 Video + 2 Audio streams
    By dmla in forum AutoPlay Media Studio 4.0
    Replies: 0
    Last Post: 07-15-2003, 09:41 AM
  4. Replies: 13
    Last Post: 04-18-2003, 08:40 PM
  5. Move the mouse pointer?
    By Lazerpower in forum AutoPlay Media Studio 4.0
    Replies: 2
    Last Post: 04-08-2003, 02:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts