Sign in to follow this  
Followers 0
myspacee

Sticky mouse

1 post in this topic

hello to all,

in past days some student post this video on youtube:

i'm very impressed from this, and want to script somethig similar.

Open your mspaint, draw some black lines, run script and follow instructions

#include <Misc.au3>
$dll = DllOpen("user32.dll")


$gui = GUICreate("",100,20,-1,-1,0x80000000+0x00400000,0x00000008+0x00000080)
$label = GUICtrlCreateLabel("",10,5,80,15,-1,0x00100000)
GUISetState()
$oldcolor = 0
$master_color = 0


;//////////////////////////////////////////////////////////////////////
;//     set master color
;//////////////////////////////////////////////////////////////////////
while 1
    ToolTip("when ready press left mouse button",0,0)
    $pos = MouseGetPos()
    $mouse_X = $pos[0]
    $mouse_Y = $pos[1]
    
    $master_color = PixelGetColor($pos[0],$pos[1])
    
    If _IsPressed("01", $dll) Then ;when press left mouse button
        ToolTip("",0,0)
        ExitLoop
        
    EndIf
    sleep(10)
WEnd
    
;//////////////////////////////////////////////////////////////////////
;//    search for master color when <> move mouse and search 
;//////////////////////////////////////////////////////////////////////
while 1
    if _IsPressed("1B") then ExitLoop

    $pos = MouseGetPos()
    $mouse_X = $pos[0]
    $mouse_Y = $pos[1]

    $color = PixelGetColor($pos[0],$pos[1])
    
    if $color <> $oldcolor then ;if color under mouse change 
        GUISetBkColor(Execute("0x" &Hex($color,6)))
        GUICtrlSetData($label,"0x" & Hex($color,6))
        GUICtrlSetColor($label,"0x" & Hex(16777215-$color,6))
        
        
        ;start search for master color and move mouse in that direction
        ;----------------- CLOCKWISE
        if PixelGetColor($mouse_X + 1,$mouse_Y - 1) = $master_color then ;up-right
            MouseMove($mouse_X + 3,$mouse_Y - 3, 100)
            
        elseif PixelGetColor($mouse_X + 1, $mouse_Y)  = $master_color then ;right
            MouseMove($mouse_X + 3, $mouse_Y, 100)
            
        elseif PixelGetColor($mouse_X + 1, $mouse_Y + 1)  = $master_color then ;down-right
            MouseMove($mouse_X + 3, $mouse_Y + 3, 100)
            
        elseif PixelGetColor($mouse_X, $mouse_Y + 1)  = $master_color then ;down
            MouseMove($mouse_X, $mouse_Y + 3, 100)
            
        elseif PixelGetColor($mouse_X - 1, $mouse_Y + 1)  = $master_color then ;down-left
            MouseMove($mouse_X - 3, $mouse_Y + 3, 100)
            
        elseif PixelGetColor($mouse_X - 1, $mouse_Y)  = $master_color then ;left
            MouseMove($mouse_X - 3, $mouse_Y, 100)
            
        elseif PixelGetColor($mouse_X - 1, $mouse_Y - 1)  = $master_color then ;left-up
            MouseMove($mouse_X - 3, $mouse_Y - 3, 100)
            
        elseif PixelGetColor($mouse_X, $mouse_Y -1)  = $master_color then ;up
            MouseMove($mouse_X, $mouse_Y - 3, 100)
        
        EndIf

;~      $coord = PixelSearch( $mouse_X - 1, $mouse_Y - 1, $mouse_X + 1, $mouse_Y + 1, $master_color )
;~      If Not @error Then
;~          ToolTip("X and Y are : " & $coord[0] & "," & $coord[1],0,0)
;~          MouseMove($coord[0], $coord[1], 100)
;~      EndIf
        
        
        
        
        $oldcolor = $color
    Else
        ;if color not change fall down
        MouseMove($mouse_X, $mouse_Y + 1, 100)

    EndIf

    
    sleep(10)
WEnd

is funny but longer than be perfect, anyone can help me to improve it ?

Thank you,

m.

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