Sign in to follow this  
Followers 0
alexmidre

ClickMouseButton (SendInput)

4 posts in this topic

SendInput code (API) It doesn't work

-Func ClickUpMouseButton()
    Local Const $INPUT_MOUSE = 0
        Local Const $MOUSEEVENTF_LEFTDOWN = 0x0002
        Local Const $MOUSEEVENTF_LEFTUP = 0x0004

        
    Local Const $tagINPUT_mouse = "DWORD type;long dx;long dy;long mouseData;DWORD dwFlags;DWORD time;ULONG_PTR dwExtraInfo;dword;ULONG_PTR;"
    $NOTIFY = DllStructCreate($tagINPUT_mouse)
    _ZeroMemory($NOTIFY)
    DllStructSetData($NOTIFY, "type", $INPUT_MOUSE)
    DllStructSetData($NOTIFY, "dwFlags", $MOUSEEVENTF_LEFTDOWN)
    SendInput($NOTIFY)
    _ZeroMemory($NOTIFY)
    DllStructSetData($NOTIFY, "type", $INPUT_MOUSE)
    DllStructSetData($NOTIFY, "dwFlags", $MOUSEEVENTF_LEFTUP)
    SendInput($NOTIFY)

EndFunc
        
Func SendInput($NOTIFY)
    Local $sendDLL = DllOpen("user32.dll")
    $ret = DllCall($sendDLL, "uint", "SendInput", "uint", 2, "ptr", DllStructGetPtr($NOTIFY), "int", DllStructGetSize($NOTIFY)/2)
    DllClose($sendDLL)
    return $ret
EndFunc

Func _ZeroMemory(ByRef $struct)
    Local $temp = DllStructCreate("byte[" & DllStructGetSize($struct) & "]", DllStructGetPtr($struct))
    For $i = 1 To DllStructGetSize($temp)
        DllStructSetData($temp, 1, 0, $i)
    Next
EndFunc

 

Share this post


Link to post
Share on other sites



Make a small runable reproducer script which have the issue.

1 person likes this

Share this post


Link to post
Share on other sites

I think that in the _ZeroMemory function you are setting the parts of the "$temp" struct, but the function is ByRef'ing the "$struct" struct.  Those are never seen outside the Function.

That's just a shot in the dark. Like AutoBert said, we really need more to work with.

Why not just use MouseClick() or MouseDown() & MouseUp()?

1 person likes this

Share this post


Link to post
Share on other sites
1 hour ago, MagnumXL said:

I think that in the _ZeroMemory function you are setting the parts of the "$temp" struct, but the function is ByRef'ing the "$struct" struct.  Those are never seen outside the Function.

That's just a shot in the dark. Like AutoBert said, we really need more to work with.

Why not just use MouseClick() or MouseDown() & MouseUp()?

I do not want to call MouseClick, MouseDown, MouseUp (API -> mouse_event)

Thanks you for helping :) 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0