Results 1 to 3 of 3

Thread: Rodent problems

  1. #1

    Thread Starter
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    I have to create a program that moves the mouse cursor around the screen and stops when the user touches the mouse.

    I know that it can be created in VB, I have a program which does it and it was created with VB, I just really need the code.

    Help?

  2. #2
    Junior Member
    Join Date
    May 2000
    Posts
    24
    Well, I am guessing you use some type of iteration loop with the setcursorpos API to perform the mouse movement (I don't know of any other way). Immediately after the setcursorpos, store the x and y values using getcursorpos. Now, right before the setcursorpos, compare the current x and y values with the stored ones.

    Code:
    Dim p as Point
    Dim p2 as Point
    
    Call GetCursorPos(p)
    
    Do
      Call GetCursorPos(p2)
      If p.x <> p2.x Then Exit Sub
      If p.y <> p2.y Then Exit Sub
      SetCursorPos(whatever coordinates)
      Call GetCursorPos(p)
      Call TimeOut(0.02)
    Loop (Until Other Condition?)
    I hope this helps.

    [Edited by CreepingDeath on 06-05-2000 at 08:27 AM]

  3. #3

    Thread Starter
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Red face DOH!!! Why didn't I think of that? Thanks a lot!

    Thanks!!!

    Here I am, trying to figure out the horrible use of WM_MOUSEMOVE with journal hooks which would fire themselves for no reason because the mouse cursor changed. And then you come along and give me the simplest and most logical answer.

    I feel like kicking myself and banging my head against the wall.
    Code:
    Call Kick(Me)
    Ouch = Bang(Me.Head, Room.Wall)
    Call Think(Straight, FromNowOn)
    There, I did it.

    I'll still have to use the journal hook and a little subclass for all the other mouse messages (I need to take care of the buttons and the wheel button), but that's no problem. So thanks again!

Posting Permissions

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



Click Here to Expand Forum to Full Width