Results 1 to 14 of 14

Thread: [Resolved][VB6] 'Hidden Mouse'

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    4

    Resolved [Resolved][VB6] 'Hidden Mouse'

    I was wondering if there is a way to simulate mouse movement/clicking in a VB6 application without having it in focus. Like my title says a hidden mouse. Perhaps i have a window completely over my VB app, the mouse can't click the application if there is something over it. I know there are ways to control the mouse/cursor, and i know how to do this. If anyone could lead me in the right direction that would be great.
    Last edited by letram; Jul 26th, 2007 at 01:41 AM.

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: [VB6] 'Hidden Mouse'

    To move the mouse cursor you would use the SetCursorPos() API function. Real easy to use:
    http://allapi.mentalis.org/apilist/SetCursorPos.shtml

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    4

    Re: [VB6] 'Hidden Mouse'

    I'm sorry that you mis-understood. Or perhaps I can't explain my self right. I was wondering if there is a way to click something on a VB6 application without using the mouse. Literally 'simulate'. This may sound kind of dumb, but i am wondering. But thank you for the quick reply.

  4. #4
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: [VB6] 'Hidden Mouse'

    I think what you want to do is use a sub in a command button click or the like. Say you had the code:

    Code:
    Private Sub Command1_Click()
    Print "Hello,World!"
    End Sub
    and wanted to make the mouse click that in a timer event. All you would do is use this code in the timer:

    Code:
    Private Sub Timer1_Timer()
    Call Command1_Click
    End Sub

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: [VB6] 'Hidden Mouse'

    The thing you're "simulating" by - if you can find a way - "clicking the mouse" (in software) is firing the Click event of the control (or form) the mouse cursor is on. So just run the code in the event - either by calling the Click event (sub), which is a bad practice, or by putting that code into another sub and calling it from your "I want to click the mouse here now) code and from the actual Click event.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  6. #6
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: [VB6] 'Hidden Mouse'

    if you are wanting to click the button on a program you didn't write yourself, you will need to use the sendmessage or postmessage api to send the button a virtual enter or space.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  7. #7
    Addicted Member Jazz00006's Avatar
    Join Date
    Feb 2006
    Posts
    185

    Re: [VB6] 'Hidden Mouse'

    I think I can see where this is going....

    This one, while not what you want, can simulate mouse movement http://cruels.net/index.php?showtopic=4895

    and this one can click anywhere on a specified window, providing you have its window handle (hWnd as it's commonly called)
    http://cruels.net/index.php?showtopic=4406 (Or see attachment for direct download)
    Attached Files Attached Files

  8. #8

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    4

    Re: [VB6] 'Hidden Mouse'

    Thank you very much Jazz that is what i needed. Also thank you to the others who tried to help.

    EDIT: another question, i want to click a shockwave flash component. How would i get the handle of it?
    Last edited by letram; Jul 26th, 2007 at 01:52 AM.

  9. #9
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: [Resolved][VB6] 'Hidden Mouse'

    That is nearly impossible. It is actually not too hard if you leave the window open but i don't recommend you even ask this question in this forum because some people might take it that you are wanting to make a program to cheat on flash games. This is against forum rules.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  10. #10
    Addicted Member Jazz00006's Avatar
    Join Date
    Feb 2006
    Posts
    185

    Re: [Resolved][VB6] 'Hidden Mouse'

    Quote Originally Posted by Lord Orwell
    That is nearly impossible.
    I beg to differ there my lord ^_^

    On a command button or pictures MouseUp Sub, call GetWindow

    It saves the window handle in selwnd

    Paste this into a module
    Code:
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    Public Type POINTAPI
            x As Long
            y As Long
    End Type
    public selwnd as long
    Sub GetWindow()
        Dim mousexy As POINTAPI
        GetCursorPos mousexy
        selwnd = WindowFromPoint(mousexy.x, mousexy.y)
    End Sub

    and if you do not want to do that, you may want to look at : http://cruels.net/index.php?showtopic=3266


    I have no idea what you plan on using this for, I am just supplying code, but be careful from now on.

  11. #11
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: [Resolved][VB6] 'Hidden Mouse'

    he said flash animation which means it's in a web browser. The hard part of this is getting the handle to the flash animation. It is possible to get the handle to the browser window, but even this is not exactly easy.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  12. #12

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    4

    Re: [Resolved][VB6] 'Hidden Mouse'

    Quote Originally Posted by Lord Orwell
    he said flash animation which means it's in a web browser. The hard part of this is getting the handle to the flash animation. It is possible to get the handle to the browser window, but even this is not exactly easy.
    I said exactly what i meant, the shockwave flash component. It loads the .swf directly. And thank you jazz.
    Last edited by letram; Jul 27th, 2007 at 01:13 AM.

  13. #13
    Addicted Member Jazz00006's Avatar
    Join Date
    Feb 2006
    Posts
    185

    Re: [Resolved][VB6] 'Hidden Mouse'

    don't forget to rate the people who helped
    and no problem

  14. #14
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: [Resolved][VB6] 'Hidden Mouse'

    ok then sorry. It is a form control then? I have never tried putting a shockwave form on a control but i can see how that would be very useful. All the demo disks from pc world run that way.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

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