Results 1 to 10 of 10

Thread: mouse tracking

  1. #1

    Thread Starter
    Addicted Member cha0s4u's Avatar
    Join Date
    Apr 2005
    Location
    new Delhi - 1ND1A
    Posts
    209

    Question mouse tracking

    which namespace should i use so that i can track the mouse position on complete window. Not just the screen. If some one has some codes to share it would be of more help.

    What i intend to do is get the application's title on which mouse is released (mouse up) after a in drag drop. So I want to know the application name/title on which the item is being dropped.

    Thanks
    - cha0s4u ENJOI

    Do Remember to RATE a post if it helps u,
    Ratings encrougage those who Know enough,to help others

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Arrow Re: mouse tracking

    You can use a combination of API Calls in order to do it...
    VB Code:
    1. Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As Point) As Integer
    2. Declare Function WindowFromPoint Lib "user32.dll" (ByVal xPoint As Integer,  
    3.       ByVal yPoint As Integer) As Integer
    4. Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" _
    5.      ByVal hwnd As Int32, ByVal lpString As String, ByVal cch As Int32) As Int32
    In your sub...
    VB Code:
    1. Dim rPoint as Point
    2. Dim hWnd as Integer
    3. 'string needs to be assigned a buffer.. not sure the right way but I do this
    4. Dim rString as String = "                                   "
    5.  
    6. 'call this on mouseup
    7. GetCursorPos(RPoint)
    8. hWnd = WindowFromPoint(RPoint.X, RPoint.Y)
    9. 'returns window text
    10. GetWindowText(hWnd, rString, 35)
    11. MsgBox rString

  3. #3

    Thread Starter
    Addicted Member cha0s4u's Avatar
    Join Date
    Apr 2005
    Location
    new Delhi - 1ND1A
    Posts
    209

    Re: mouse tracking

    i have this code, but was having trouble converting it to VB.NET so i asked for the namespace....
    - cha0s4u ENJOI

    Do Remember to RATE a post if it helps u,
    Ratings encrougage those who Know enough,to help others

  4. #4
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: mouse tracking

    Then post the code hard to "guess" the code you're workin with

  5. #5

    Thread Starter
    Addicted Member cha0s4u's Avatar
    Join Date
    Apr 2005
    Location
    new Delhi - 1ND1A
    Posts
    209

    Re: mouse tracking

    dude what i need is just the namespace that contains the class that cna be used to get the mouse properties.

    i dont know the namespace... that is what i asked in my initial question..

    and the code that ur asking me for is quite the same as uses GetCursorPos and WindowFromPoint APIs to track the mouse pos.... its the generic code that we use to track the mouse on screen.

    any ways thanks for ur time and inputs... if u have anything more to share.. im waiting
    - cha0s4u ENJOI

    Do Remember to RATE a post if it helps u,
    Ratings encrougage those who Know enough,to help others

  6. #6
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: mouse tracking

    Is this what you're looking for....
    System.Windows.Forms.Cursor ???
    That can be used to set or get the current mouse cursor position...There isnt any other namespace other than that for mouse movements as far as I know.
    Godwin

    Help someone else with what someone helped you!

  7. #7
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: mouse tracking

    You dont even neet to type the whole thing...
    You can just use cursor.
    And still,an API is a good choice for getting full control of the mouse..To get the API's,use...
    www.pinvoke.net
    Godwin

    Help someone else with what someone helped you!

  8. #8

    Thread Starter
    Addicted Member cha0s4u's Avatar
    Join Date
    Apr 2005
    Location
    new Delhi - 1ND1A
    Posts
    209

    Re: mouse tracking

    thanks i will check in some time... lil busy rt now with some other things...

    thanks for ur inputs.
    - cha0s4u ENJOI

    Do Remember to RATE a post if it helps u,
    Ratings encrougage those who Know enough,to help others

  9. #9
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: mouse tracking

    ummm...
    How did you have the time to say that you are busy if you're sooooooo buzy?
    Last edited by uniquegodwin; Sep 15th, 2005 at 03:44 AM.
    Godwin

    Help someone else with what someone helped you!

  10. #10

    Thread Starter
    Addicted Member cha0s4u's Avatar
    Join Date
    Apr 2005
    Location
    new Delhi - 1ND1A
    Posts
    209

    Re: mouse tracking

    Thanks a lot... it works.. fine. I will try to incorporate this with getting the name of the window under it

    Thanks alot.

    PS: i was busy in another project. .so cudt test it that time.. so thanked u coz i felt that shud work. i dont think u shud mind that :-)
    - cha0s4u ENJOI

    Do Remember to RATE a post if it helps u,
    Ratings encrougage those who Know enough,to help others

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