Jump to content
Sign in to follow this  
jackyyll

Silent mouse clicking

Recommended Posts

Can someone please help me with this? I really need silent clicking would improve my both 100%. The one thats on the forums just doesnt work..

Share this post


Link to post
Share on other sites

Can someone please help me with this? I really need silent clicking would improve my both 100%. The one thats on the forums just doesnt work..

sorry... not sure what you mean by silent? Does ControlClick() work?

Share this post


Link to post
Share on other sites

Larry made a UDF for something like this a while back using actual coords:

Opt("WinTitleMatchMode",4)
ClickInControl("left","Program Manager","","SysListView321",30,10)

Func ClickInControl( $szLR, $szTitle, $szText, $szControl, $nX, $nY )
  If $szLR <> "left" And $szLR <> "right" Then Return 0
  $hWnd = ControlGetHandle( $szTitle, $szText, $szControl )
  If @error Then Return 0
  $hWndDad = WinGetHandle( $szTitle, $szText )
  If @error Then Return 0
  $me = DLLCall( "kernel32.dll", "long", "GetCurrentThreadId" )
  $you = DLLCall( "user32.dll", "long", "GetWindowThreadProcessId", "hwnd", $hWndDad, "long_ptr", 0)
  $coord = _MakeLong( $nX, $nY )
  If $szLR = "left" Then
     $msg1 = 0x0201;WM_LBUTTONDOWN
     $msg2 = 0x0202;WM_LBUTTONUP
     $i = 0x0001;MK_LBUTTON
  Else
     $msg1 = 0x0204;WM_RBUTTONDOWN
     $msg2 = 0x0205;WM_RBUTTONUP
     $i = 0x0002;MK_RBUTTON
  EndIf
  $ret = DLLCall("user32.dll","int","AttachThreadInput","long",$me[0],"long",$you[0],"int",1)
  If $ret[0] = 0 Then Return 0
  $ret = DLLCall("user32.dll","long","PostMessage","hwnd",$hWnd,"int",$msg1,"int",$i,"int",$coord)
  If $ret[0] = 0 Then Return 0
  Sleep(100)
  $ret = DLLCall("user32.dll","long","PostMessage","hwnd",$hWnd,"int",$msg2,"int",0,"int",$coord)
  If $ret[0] = 0 Then Return 0
  DLLCall("user32.dll","int","AttachThreadInput","long",$me[0],"long",$you[0],"int",0)
  If $ret[0] = 0 Then Return 0
  Return 1
EndFunc

Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

Warning

I'm not always able to get it to work with every window.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Warning

I'm not always able to get it to work with every window.

for the others do you use ControlClick() ? /smirk sorry, too many energy drinks today...

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...