help me with mouseclick drag while minimized

03/21/2012 12:23 sutansah#1
anyone know about mouseclick drag minimized?....

this my script about mouseclick and mousewheel while minimized...

Code:
Func _MouseClick($Window, $BUTTON, $x, $y, $CLICKS = 1, $delay = 15)
	Local $MK_LBUTTON = 0x0001
	Local $WM_LBUTTONDOWN = 0x0201
	Local $WM_LBUTTONUP = 0x0202
	Local $MK_RBUTTON = 0x0002
	Local $WM_RBUTTONDOWN = 0x0204
	Local $WM_RBUTTONUP = 0x205
	Local $WM_MOUSEMOVE = 0x200
	Local $i = 0
	Local $BUTTONDOWN = $WM_LBUTTONDOWN
	Local $BUTTONUP = $WM_LBUTTONUP
	$button = StringLower($button)
	local $MOUSECOORD = MouseGetPos()
	$X = $MOUSECOORD[0]
	$Y = $MOUSECOORD[1]
	
	Local $user32 = DllOpen("user32.dll")
		
	If $button = "left" Then
	For $i = 1 To $CLICKS
		DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $WM_MOUSEMOVE, "int", 0, "long", _MAKELONG($X, $Y))
		DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $WM_LBUTTONDOWN, "int", $MK_LBUTTON, "long", _MAKELONG($X, $Y))
		DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $WM_LBUTTONUP, "int", 0, "long", _MAKELONG($X, $Y))
		
		If $i < $CLICKS Then Sleep($delay)
	Next
	ElseIf $button = "right" Then
		For $i = 1 To $CLICKS
		DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $WM_MOUSEMOVE, "int", 0, "long", _MAKELONG($X, $Y))
		DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $WM_RBUTTONDOWN, "int", $MK_RBUTTON, "long", _MAKELONG($X, $Y))
		DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle($Window), "int", $WM_RBUTTONUP, "int", 0, "long", _MAKELONG($X, $Y))
		
		If $i < $CLICKS Then Sleep($delay)
	Next
	Else
		SetError(-2)
		If $user32 <> -1 Then DllClose($user32)
		Return
	    EndIf
	
	If $user32 <> -1 Then DllClose($user32)
EndFunc

Func _MouseWheel($Window, $direction , $clicks)
    Local $WM_MOUSEWHEEL  =  0x020A
    local $MouseCoord = MouseGetPos()
	local $X = $MouseCoord[0]
	local $Y = $MouseCoord[1]
	Local $user32 = DllOpen("user32.dll")
	
    If $direction = "up" then
	local $WheelDelta = 120
    Else
    local $WheelDelta = -120
    Endif
    For $i = 0 to $clicks
    DllCall($user32, "int", "SendMessage", "hwnd",  WinGetHandle( $Window ), "int",  $WM_MOUSEWHEEL, "long", _MakeLong(0,$WheelDelta), "long",  _MakeLong($X, $Y))
    Next
EndFunc

Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
thats my script about mouseclick and mousewheel while minimized

but when im make mousedrag while minimizd...it didnt work...this my script about mousedrag..
Code:
Func _MouseDrag($Window, $Button,  $x, $y, $xTo, $yTo, $Delay = 15)
	Local $MK_LBUTTON = 0x0001
	Local $WM_LBUTTONDOWN = 0x0201
	Local $WM_LBUTTONUP = 0x0202

	Local $MK_RBUTTON = 0x0002
	Local $WM_RBUTTONDOWN = 0x0204
	Local $WM_RBUTTONUP = 0x0205

	Local $WM_MOUSEMOVE = 0x0200
	Local $BUTTONDOWN = $WM_LBUTTONDOWN
	Local $BUTTONUP = $WM_LBUTTONUP
	$button = StringLower($button)
	local $MouseCoord = MouseGetPos()
	$X = $MouseCoord[0]
	$Y = $MouseCoord[1]
	$xTo = $MouseCoord[0]
	$yTo = $MouseCoord[1]
	
	Local $user32 = DllOpen("user32.dll")
	
	   
   If $button = "left" Then
	DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle( $Window ), "int", $WM_MOUSEMOVE, "int", 0, "long", _MakeLong($X, $Y))
	DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle( $Window ), "int", $WM_LBUTTONDOWN, "int", $MK_LBUTTON, "long", _MakeLong($X, $Y))
	sleep($delay)
	
	DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle( $Window ), "int", $WM_MOUSEMOVE, "int", 0, "long", _MakeLong($xTo, $yTo))
	DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle( $Window ), "int", $WM_LBUTTONUP, "int", 0, "long", _MakeLong($xTo, $yTo))
	sleep($delay)
	
    ElseIf $button = "right" Then
	DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle( $Window ), "int", $WM_MOUSEMOVE, "int", 0, "long", _MakeLong($X, $Y))
	DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle( $Window ), "int", $WM_RBUTTONDOWN, "int", $MK_RBUTTON, "long", _MakeLong($X, $Y))
	sleep($delay)
	
	DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle( $Window ), "int", $WM_MOUSEMOVE, "int", 0, "long", _MakeLong($xTo, $yTo))
	DllCall($user32, "int", "SendMessage", "hwnd", WinGetHandle( $Window ), "int", $WM_RBUTTONUP, "int", 0, "long", _MakeLong($xTo, $yTo))
	sleep($delay)
	Else
		SetError(-2)
		If $user32 <> -1 Then DllClose($user32)
		Return
	EndIf
	If $user32 <> -1 Then DllClose($user32)
EndFunc
Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
anyone knows about what wrong in that mousedrag script please tell me...
03/21/2012 18:23 KDeluxe#2
Code:
;=================================================================================================
; Function:			_PostMessage_ClickDrag($hWnd, $X1, $Y1, $X2, $Y2, $Button = "left")
; Description:		Sends a mouse click and drag command to a specified window.
; Parameter(s):		$hWnd - The handle or the title of the window.
;					$X1, $Y1 - The x/y position to start the drag operation from.
;					$X2, $Y2 - The x/y position to end the drag operation at.
;					$Button - (optional) The button to click, "left", "right", "middle". Default is the left button.
;					$Delay - (optional) Delay in milliseconds. Default is 50.
; Requirement(s):	A window handle/title.
; Return Value(s):	On Success - Returns true
;					On Failure - Returns false
;					@Error - 0 = No error.
;							 1 = Invalid window handle or title.
;							 2 = Invalid start position.
;							 3 = Invalid end position.
;							 4 = Failed to open the dll.
;							 5 = Failed to send a MouseDown command.
;							 5 = Failed to send a MouseMove command.
;							 7 = Failed to send a MouseUp command.
; Author(s):		KillerDeluxe
;=================================================================================================
Func _PostMessage_ClickDrag($hWnd, $X1, $Y1, $X2, $Y2, $Button = "left", $Delay = 50)
	If Not IsHWnd($hWnd) And $hWnd <> "" Then
		$hWnd = WinGetHandle($hWnd)
	EndIf

	If Not IsHWnd($hWnd) Then
		Return SetError(1, "", False)
	EndIf

	If Not IsInt($X1) Or Not IsInt($Y1) Then
		Return SetError(2, "", False)
	EndIf

	If Not IsInt($X2) Or Not IsInt($Y2) Then
		Return SetError(3, "", False)
	EndIf

	If StringLower($Button) == "left" Then
		$Button = $WM_LBUTTONDOWN
		$Pressed = 1
	ElseIf StringLower($Button) == "right" Then
		$Button = $WM_RBUTTONDOWN
		$Pressed = 2
	ElseIf StringLower($Button) == "middle" Then
		$Button = $WM_MBUTTONDOWN
		$Pressed = 10
		If $Delay == 10 Then $Delay = 100
	EndIf

	$User32 = DllOpen("User32.dll")
	If @error Then Return SetError(4, "", False)

	DllCall($User32, "bool", "PostMessage", "hwnd", $hWnd, "int", $Button, "int", "0", "long", _MakeLong($X1, $Y1))
	If @error Then Return SetError(5, "", False)

	Sleep($Delay / 2)

	DllCall($User32, "bool", "PostMessage", "hwnd", $hWnd, "int", $WM_MOUSEMOVE, "int", $Pressed, "long", _MakeLong($X2, $Y2))
	If @error Then Return SetError(6, "", False)

	Sleep($Delay / 2)

	DllCall($User32, "bool", "PostMessage", "hwnd", $hWnd, "int", $Button + 1, "int", "0", "long", _MakeLong($X2, $Y2))
	If @error Then Return SetError(7, "", False)

	DllClose($User32)
	Return SetError(0, 0, True)
EndFunc
03/21/2012 19:04 sutansah#3
Quote:
Originally Posted by KDeluxe View Post
Code:
;=================================================================================================
; Function:			_PostMessage_ClickDrag($hWnd, $X1, $Y1, $X2, $Y2, $Button = "left")
; Description:		Sends a mouse click and drag command to a specified window.
; Parameter(s):		$hWnd - The handle or the title of the window.
;					$X1, $Y1 - The x/y position to start the drag operation from.
;					$X2, $Y2 - The x/y position to end the drag operation at.
;					$Button - (optional) The button to click, "left", "right", "middle". Default is the left button.
;					$Delay - (optional) Delay in milliseconds. Default is 50.
; Requirement(s):	A window handle/title.
; Return Value(s):	On Success - Returns true
;					On Failure - Returns false
;					@Error - 0 = No error.
;							 1 = Invalid window handle or title.
;							 2 = Invalid start position.
;							 3 = Invalid end position.
;							 4 = Failed to open the dll.
;							 5 = Failed to send a MouseDown command.
;							 5 = Failed to send a MouseMove command.
;							 7 = Failed to send a MouseUp command.
; Author(s):		KillerDeluxe
;=================================================================================================
Func _PostMessage_ClickDrag($hWnd, $X1, $Y1, $X2, $Y2, $Button = "left", $Delay = 50)
	If Not IsHWnd($hWnd) And $hWnd <> "" Then
		$hWnd = WinGetHandle($hWnd)
	EndIf

	If Not IsHWnd($hWnd) Then
		Return SetError(1, "", False)
	EndIf

	If Not IsInt($X1) Or Not IsInt($Y1) Then
		Return SetError(2, "", False)
	EndIf

	If Not IsInt($X2) Or Not IsInt($Y2) Then
		Return SetError(3, "", False)
	EndIf

	If StringLower($Button) == "left" Then
		$Button = $WM_LBUTTONDOWN
		$Pressed = 1
	ElseIf StringLower($Button) == "right" Then
		$Button = $WM_RBUTTONDOWN
		$Pressed = 2
	ElseIf StringLower($Button) == "middle" Then
		$Button = $WM_MBUTTONDOWN
		$Pressed = 10
		If $Delay == 10 Then $Delay = 100
	EndIf

	$User32 = DllOpen("User32.dll")
	If @error Then Return SetError(4, "", False)

	DllCall($User32, "bool", "PostMessage", "hwnd", $hWnd, "int", $Button, "int", "0", "long", _MakeLong($X1, $Y1))
	If @error Then Return SetError(5, "", False)

	Sleep($Delay / 2)

	DllCall($User32, "bool", "PostMessage", "hwnd", $hWnd, "int", $WM_MOUSEMOVE, "int", $Pressed, "long", _MakeLong($X2, $Y2))
	If @error Then Return SetError(6, "", False)

	Sleep($Delay / 2)

	DllCall($User32, "bool", "PostMessage", "hwnd", $hWnd, "int", $Button + 1, "int", "0", "long", _MakeLong($X2, $Y2))
	If @error Then Return SetError(7, "", False)

	DllClose($User32)
	Return SetError(0, 0, True)
EndFunc
owh thanks kdeluxe....for func makelong its same with mine or not?....
Code:
Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
and for func mouse move...do u know the script?....i wanna make script like move cursor in game if that cursor like sword cursor it will mouseclick left(attack)...
03/21/2012 23:52 KDeluxe#4
Code:
Func _MakeLong($LowWORD, $HiWORD)
    Return BitOR($HiWORD * 0x10000, BitAND($LowWORD, 0xFFFF))
EndFunc
or

Code:
Func _MakeLong($LowWORD, $HiWORD)
	Return BitOR(BitShift($HiWORD, -16), BitAND($LowWORD, 0xFFFF))
EndFunc
The WM_MOUSEMOVE message won't change your cursor icon. Try to select something with the Tabulator-Key and attack it with some skills.
12/01/2012 07:36 bun_lope#5
@KDeluxe: Hi there. I use your UDF and save in ClickDrag.au3. Here is my script:

#include <ClickDrag.au3>
$hWnd='VNC Viewer'
_PostMessage_ClickDrag($hWnd, 43, 284, 245, 286, "right", 1000)
MsgBox(0,'',@error)

@error = 0 but anything happens when I run this script. Could you please tell me what wrong in my script? Thank you so much!
12/03/2012 16:49 bun_lope#6
Somebody helps me please :(
10/29/2016 11:33 SaidJan#7
Quote:
Originally Posted by bun_lope View Post
@KDeluxe: Hi there. I use your UDF and save in ClickDrag.au3. Here is my script:

#include <ClickDrag.au3>
$hWnd='VNC Viewer'
_PostMessage_ClickDrag($hWnd, 43, 284, 245, 286, "right", 1000)
MsgBox(0,'',@error)

@error = 0 but anything happens when I run this script. Could you please tell me what wrong in my script? Thank you so much!
I have the same problem, can anyone help please?