Force mouse click?

Discussion in 'Programming General' started by kharg0, Feb 14, 2008.

Force mouse click?
  1. Unread #1 - Feb 14, 2008 at 10:33 PM
  2. kharg0
    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0

    kharg0 Active Member

    Force mouse click?

    i need a code to force mouse click i have
    DECLARE:
    Code:
     Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
        Private Const MOUSEEVENTF_LEFTDOWN = &H2
        Private Const MOUSEEVENTF_LEFTUP = &H4
    not my code:
    and

    Code:
    Call mouse_event(MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
    now i need to be able to left click and right click

    i have a listbox that displays the button that was pressed in text such as "Left"
    "Right"
    "Middle"

    i need it to read that as click accordingly.
    thx in advance
     
  3. Unread #2 - Feb 16, 2008 at 4:02 PM
  4. skate4lifee
    Joined:
    Jul 22, 2007
    Posts:
    108
    Referrals:
    1
    Sythe Gold:
    0

    skate4lifee Active Member

    Force mouse click?

    that code will only work for the left mouse click hence "mouse event left - up & down."

    i'm not sure what your having trouble with, getting it to click? if this is the case your almost there.

    create a timer and add this the the timer:

    Code:
    mouse_event(mouseeventf_leftdown, 0, 0, 0, 0)
    mouse_event(mouseeventf_leftup, 0, 0, 0, 0)
    then you will obviously need to do something to active it.

    if you want to use a hotkey you can do this...
    on the forms keyup property add something along these lines

    Code:
    if e.keycode = keys.f10 then
    timer1.enabled = true
    or you can use a button and you would obviously say

    Code:
    timer1.enabled = true
    you get the point...i hope.
     
  5. Unread #3 - Feb 16, 2008 at 6:55 PM
  6. kharg0
    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0

    kharg0 Active Member

    Force mouse click?

    ya thats basically what i have its not that my code is wrong its that my code wont work for right clicking
     
  7. Unread #4 - Feb 17, 2008 at 4:39 AM
  8. skate4lifee
    Joined:
    Jul 22, 2007
    Posts:
    108
    Referrals:
    1
    Sythe Gold:
    0

    skate4lifee Active Member

    Force mouse click?

    thats because you haven't told it to right click, your code is doing exactly what you have told it to do.

    for right clicking you would use this code:

    Code:
    Private Const MOUSEEVENTF_RIGHTDOWN = &H8
    Private Const MOUSEEVENTF_RIGHTUP = &H10
    its almost identical to with the left click.

    edit: you also mentioned wanting to be able to use the 'middle' mouse click. its not much different from the other two:

    Code:
    Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
    Private Const MOUSEEVENTF_MIDDLEUP = &H40
     
  9. Unread #5 - Feb 17, 2008 at 11:10 AM
  10. kharg0
    Joined:
    Feb 25, 2007
    Posts:
    131
    Referrals:
    0
    Sythe Gold:
    0

    kharg0 Active Member

    Force mouse click?

    thx skate ur the bomb!
     
< Mouse position rgb color? | [Tutorial] Basic DVD Player for n00blets [/Tutorial] >

Users viewing this thread
1 guest


 
 
Adblock breaks this site