Jump to content

need some help


KevinO
 Share

Go to solution Solved by KevinO,

Recommended Posts

  • Solution

i found this code, but now i want it to follow a moving pixel on my screen

#include <GUIConstants.au3>

HotKeySet("{ESC}","bye")

$GUI = GUICreate("",30,30,-1,-1,$WS_POPUP,$WS_EX_TOPMOST)
GUISetBkColor(0xFF0000)

$a = CreateRoundRectRgn(0,0,30,30,30,30)
$b = CreateRoundRectRgn(4,4,22,22,26,26)

CombineRgn($a,$B)
SetWindowRgn($GUI,$a)

GUISetState()
GUISetState(@SW_DISABLE)

While 1
    Sleep(50)
    $pt = MouseGetPos()
    If Not @error Then WinMove($GUI,"",$pt[0] - 15,$pt[1] - 15)
WEnd

Func SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc

Func CreateRoundRectRgn($l, $t, $w, $h, $e1, $e2)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $l, "long", $t, "long", $l + $w, "long", $t + $h, "long", $e1, "long", $e2)
    Return $ret[0]
EndFunc

Func CombineRgn(ByRef $rgn1, ByRef $rgn2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 3)
EndFunc

Func bye()
    Exit
EndFunc

EDIT:

Found it working code is

#include <GUIConstants.au3>

HotKeySet("{ESC}","bye")

$GUI = GUICreate("",30,30,-1,-1,$WS_POPUP,$WS_EX_TOPMOST)
GUISetBkColor(0xFF0000)

$a = CreateRoundRectRgn(0,0,30,30,30,30)
$b = CreateRoundRectRgn(4,4,22,22,26,26)

CombineRgn($a,$B)
SetWindowRgn($GUI,$a)

GUISetState()
GUISetState(@SW_DISABLE)

While 1
    Sleep(50)
    $coord = PixelSearch( 0, 0, @DesktopWidth, @DesktopHeight,0xD8FFCF)
    If Not @error Then WinMove($GUI,"",$coord[0] - 15, $coord[1] - 15)
WEnd

Func SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc

Func CreateRoundRectRgn($l, $t, $w, $h, $e1, $e2)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $l, "long", $t, "long", $l + $w, "long", $t + $h, "long", $e1, "long", $e2)
    Return $ret[0]
EndFunc

Func CombineRgn(ByRef $rgn1, ByRef $rgn2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 3)
EndFunc

Func bye()
    Exit
EndFunc

This is solved

Edited by KevinO
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...