Valkyrie Posted June 3, 2009 Share Posted June 3, 2009 Dear readers, Will I be able to make the mouse button click on a specified color? i.e. it should click on the screen where the color matches the #FFCC99 color code. Could someone provide me with some info or a link to a tutorial on how to do this? Best regards Link to comment Share on other sites More sharing options...
Azazash Posted June 3, 2009 Share Posted June 3, 2009 take a look at teh PixelSearch function in the help file. You can specify the screen as the search area, locate the color in question then pass the returned coordinates to a MouseClick function Link to comment Share on other sites More sharing options...
Valkyrie Posted June 3, 2009 Author Share Posted June 3, 2009 cool! I knew it was possible but couldnt find the function in the help anywhere lol, thanks a lot for the tip ill go and look it up right away Link to comment Share on other sites More sharing options...
fataly Posted June 3, 2009 Share Posted June 3, 2009 (edited) $pcolor = 0xFFCC99 $color = pixelsearch(x1,y1,x2,y2,$Pcolor) if not @error then tooltip("We can see " & $pcolor) elseif @error then tooltip("We cant see " & $pcolor) endif And if you want it click that pixel type this : mouseclick("left",$color[0],$color[1],1) Hope this help. Edited June 3, 2009 by fataly Link to comment Share on other sites More sharing options...
wolf9228 Posted June 3, 2009 Share Posted June 3, 2009 Dear readers, Will I be able to make the mouse button click on a specified color? i.e. it should click on the screen where the color matches the #FFCC99 color code. Could someone provide me with some info or a link to a tutorial on how to do this? Best regards expandcollapse popup#include <WinAPI.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> Const $WM_MOUSEFIRST = 0x0200 Const $WM_LBUTTONDOWN = 0x0201 Const $WM_LBUTTONDBLCLK = 0x0203 Const $WM_RBUTTONDOWN = 0x0204 Const $WM_RBUTTONUP = 0x0205 Const $WM_RBUTTONDBLCLK = 0x0206 Const $WM_MBUTTONDOWN = 0x0207 Const $WM_MBUTTONUP = 0x0208 Const $WM_MBUTTONDBLCLK = 0x0209 Const $WM_MOUSEWHEEL = 0x020A Const $WM_MOUSELAST = 0x020A Local $hmod $LowLevelMouseProc = DllCallbackRegister("_LowLevelMouseProc", "long", "int;wparam;lparam") $hmod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($LowLevelMouseProc), $hmod) $Form1 = GUICreate("") GUISetBkColor(0xFFCC99) GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Func _LowLevelMouseProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndIf Select Case $wParam = $WM_LBUTTONDOWN $pos = MouseGetPos() $var = PixelGetColor( $pos[0] , $pos[1] ) Select Case $var = 0xFFCC99 ToolTip("MouseClick ==> 0xFFCC99", $pos[0] , $pos[1]) EndSelect Case $wParam = $WM_LBUTTONUP Case $wParam = $WM_MOUSEMOVE Case $wParam = $WM_MOUSEWHEEL Case $wParam = $WM_RBUTTONDOWN Case $wParam = $WM_RBUTTONUP EndSelect Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc Func OnAutoItExit() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($LowLevelMouseProc) EndFunc صرح السماء كان هنا Link to comment Share on other sites More sharing options...
oMBRa Posted June 3, 2009 Share Posted June 3, 2009 expandcollapse popup#include <WinAPI.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> Const $WM_MOUSEFIRST = 0x0200 Const $WM_LBUTTONDOWN = 0x0201 Const $WM_LBUTTONDBLCLK = 0x0203 Const $WM_RBUTTONDOWN = 0x0204 Const $WM_RBUTTONUP = 0x0205 Const $WM_RBUTTONDBLCLK = 0x0206 Const $WM_MBUTTONDOWN = 0x0207 Const $WM_MBUTTONUP = 0x0208 Const $WM_MBUTTONDBLCLK = 0x0209 Const $WM_MOUSEWHEEL = 0x020A Const $WM_MOUSELAST = 0x020A Local $hmod $LowLevelMouseProc = DllCallbackRegister("_LowLevelMouseProc", "long", "int;wparam;lparam") $hmod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($LowLevelMouseProc), $hmod) $Form1 = GUICreate("") GUISetBkColor(0xFFCC99) GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Func _LowLevelMouseProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndIf Select Case $wParam = $WM_LBUTTONDOWN $pos = MouseGetPos() $var = PixelGetColor( $pos[0] , $pos[1] ) Select Case $var = 0xFFCC99 ToolTip("MouseClick ==> 0xFFCC99", $pos[0] , $pos[1]) EndSelect Case $wParam = $WM_LBUTTONUP Case $wParam = $WM_MOUSEMOVE Case $wParam = $WM_MOUSEWHEEL Case $wParam = $WM_RBUTTONDOWN Case $wParam = $WM_RBUTTONUP EndSelect Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc Func OnAutoItExit() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($LowLevelMouseProc) EndFunc that's not what the OP wants and... why use case for only 1 statement? Why you added these if you arent using they: Case $wParam = $WM_LBUTTONUP Case $wParam = $WM_MOUSEMOVE Case $wParam = $WM_MOUSEWHEEL Case $wParam = $WM_RBUTTONDOWN Case $wParam = $WM_RBUTTONUP Link to comment Share on other sites More sharing options...
Bruntale Posted June 3, 2009 Share Posted June 3, 2009 So I created my own. But I also looked at this as help. Will this READ the text there and choose what color to pick? Link to comment Share on other sites More sharing options...
wolf9228 Posted June 3, 2009 Share Posted June 3, 2009 that's not what the OP wants and... why use case for only 1 statement? Why you added these if you arent using they: Case $wParam = $WM_LBUTTONUP Case $wParam = $WM_MOUSEMOVE Case $wParam = $WM_MOUSEWHEEL Case $wParam = $WM_RBUTTONDOWN Case $wParam = $WM_RBUTTONUP http://msdn.microsoft.com/en-us/library/ms644986.aspx expandcollapse popup#include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Const $WM_MOUSEFIRST = 0x0200 Const $WM_LBUTTONDOWN = 0x0201 Const $WM_LBUTTONDBLCLK = 0x0203 Const $WM_RBUTTONDOWN = 0x0204 Const $WM_RBUTTONUP = 0x0205 Const $WM_RBUTTONDBLCLK = 0x0206 Const $WM_MBUTTONDOWN = 0x0207 Const $WM_MBUTTONUP = 0x0208 Const $WM_MBUTTONDBLCLK = 0x0209 Const $WM_MOUSEWHEEL = 0x020A Const $WM_MOUSELAST = 0x020A Local $hmod $LowLevelMouseProc = DllCallbackRegister("_LowLevelMouseProc", "long", "int;wparam;lparam") $hmod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($LowLevelMouseProc), $hmod) $Form2 = GUICreate("Form2", 320, 298, 303, 219) $Label1 = GUICtrlCreateLabel("", 17, 17, 100, 100) GUICtrlSetBkColor(-1, 0xA6CAF0) $Label2 = GUICtrlCreateLabel("", 200, 17, 100, 100) GUICtrlSetBkColor(-1, 0xFF0000) $Label3 = GUICtrlCreateLabel("", 17, 150, 100, 100) GUICtrlSetBkColor(-1, 0x008080) $Label4 = GUICtrlCreateLabel("", 200, 150, 100, 100) GUICtrlSetBkColor(-1, 0x000000) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _LowLevelMouseProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndIf Select Case $wParam = $WM_LBUTTONDOWN $pos = MouseGetPos() $var = PixelGetColor( $pos[0] , $pos[1] ) Select Case $var = 0xA6CAF0 ToolTip("MouseClick ==> 0xA6CAF0", $pos[0] , $pos[1]) Case $var = 0xFF0000 ToolTip("MouseClick ==> 0xFF0000", $pos[0] , $pos[1]) EndSelect Case $wParam = $WM_LBUTTONUP $pos = MouseGetPos() $var = PixelGetColor( $pos[0] , $pos[1] ) Select Case $var = 0x008080 ToolTip("MouseClick ==> 0x008080", $pos[0] , $pos[1]) Case $var = 0x000000 ToolTip("MouseClick ==> 0x000000", $pos[0] , $pos[1]) EndSelect Case $wParam = $WM_MOUSEMOVE Case $wParam = $WM_MOUSEWHEEL Case $wParam = $WM_RBUTTONDOWN Case $wParam = $WM_RBUTTONUP EndSelect Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc Func OnAutoItExit() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($LowLevelMouseProc) EndFunc صرح السماء كان هنا Link to comment Share on other sites More sharing options...
Bruntale Posted June 4, 2009 Share Posted June 4, 2009 Yes, that one will make a pop up with color. But will it allow us to click colors...like on a game without having to be there? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now