Results 1 to 4 of 4

Thread: [RESOLVED] Get mouse position for compare

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2006
    Location
    Sweden
    Posts
    173

    Resolved [RESOLVED] Get mouse position for compare

    Hi,

    I'm using the mouse_event API to move the mouse.
    If we say that the mouse first is at one point and this point is stored into a variable.
    After that, I'll move the mouse a bit to the right.
    Then the mouse_event code moves the mouse 100 to the right.
    Now, I want to get the mouse position again and then be able to get a number of how much I've moved the mouse.

    I know you can use the MouseMove code event to get the position of the mouse. My problem is that 100 in the mouse_event doesn't seem to be 100 in MouseMove.

    So, does anyone know how to do this?
    Please Help Us To Save Ana

    You never fail before you stop trying!
    ______________________________
    If I manage to say something good...please reputate
    ______________________________
    ________

    Links:
    Intellithing
    Digitala.nu
    Norrköpings Goklubb
    WoW Trade Center

  2. #2

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2006
    Location
    Sweden
    Posts
    173

    Re: Get mouse position for compare

    okay, but do the GetCursorPos use the same measurement? Is 100 the same distance in mouse_event as in GetCursorPos?
    Please Help Us To Save Ana

    You never fail before you stop trying!
    ______________________________
    If I manage to say something good...please reputate
    ______________________________
    ________

    Links:
    Intellithing
    Digitala.nu
    Norrköpings Goklubb
    WoW Trade Center

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Get mouse position for compare

    It's always beneficial to try it yourself rather than continuously asking.
    To see the difference run this quick sample:
    Code:
    Option Explicit
    
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    
    Private Sub Form_Load()
        Timer1.Interval = 100
        Timer1.Enabled = True
    End Sub
    
    Private Sub Timer1_Timer()
    Dim pt As POINTAPI
    
        GetCursorPos pt
        
        Label1.Caption = "VB6 default: " & pt.X * Screen.TwipsPerPixelX
        Label2.Caption = "API Default: " & pt.X
    
    End Sub
    But to answer your question directly - VB's default scalemode is set to Twips and APIs return Pixels so you need to convert unless you set ScaleMode to Pixels as well.

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