Jump to content

Recommended Posts

i almost have a working example... i found the example script online for drawing a simple square then i added MouseGetPos()

this almost works, but the rectangle changes size as your mouse moves around, im trying to keep a consistant size...


_WinAPI_DrawRect($left, $top, $bottem, $right, 0x0000CC)

I hate making the post and fixing my script a few minutes later... been a few years since i played with autoit... still love it ;-)


Global $tRect

While 1
$fov = MouseGetPos()
$top = $fov[1] - 100
$bottem = $fov[1] + 100
$left = $fov[0] - 50
$right = $fov[0] + 50
; refresh desktop
_WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), $tRect, 0, BitOR($RDW_INVALIDATE, $RDW_ALLCHILDREN))
_WinAPI_DrawRect($left, $top, $bottem, $right, 0x0000CC)

Func _WinAPI_DrawRect($start_x, $start_y, $iWidth, $iHeight, $iColor)
Local $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
$tRect = DllStructCreate($tagRECT)
DllStructSetData($tRect, 1, $start_x)
DllStructSetData($tRect, 2, $start_y)
DllStructSetData($tRect, 3, $iWidth) ; x-coordinate of the lower-right corner of the rectangle
DllStructSetData($tRect, 4, $iHeight) ; y-coordinate of the lower-right corner of the rectangle
Local $hBrush = _WinAPI_CreateSolidBrush($iColor)

_WinAPI_FrameRect($hDC, DllStructGetPtr($tRect), $hBrush)

; clear resources
_WinAPI_ReleaseDC(0, $hDC)
EndFunc ;==>_WinAPI_DrawRect
Edited by onedayillpay
Link to post
Share on other sites

Do you want somewhat like this

#include <WinAPI.au3>
#include <APIConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>

Global $hWin = _GUI_Transparent_Client(-1, -1, -1, -1, 5, 0x0000CC)
Global $aPos = WinGetPos($hWin)

$aMouse = MouseGetPos()
WinMove($hWin, "", $aMouse[0] - $aPos[2] / 2, $aMouse[1] - $aPos[3] / 2)


Func _GUI_Transparent_Client($iX, $iY, $iWidth, $iHeight, $iFrameWidth = 10, $iColor = 0)

$hGUI = GUICreate("", $iX, $iY, $iWidth, $iHeight, $WS_POPUP, $WS_EX_TOPMOST)
$aPos = WinGetPos($hGUI)
_GuiHole($hGUI, $iFrameWidth, $iFrameWidth, $aPos[2] - 2 * $iFrameWidth, $aPos[3] - 2 * $iFrameWidth, $aPos[2], $aPos[3])

Return $hGUI

EndFunc ;==>_GUI_Transparent_Client

Func _GuiHole($h_win, $i_x, $i_y, $i_sizew, $i_sizeh, $width, $height)

Local $outer_rgn, $inner_rgn, $combined_rgn

$outer_rgn = _WinAPI_CreateRectRgn(0, 0, $width, $height)
$inner_rgn = _WinAPI_CreateRectRgn($i_x, $i_y, $i_x + $i_sizew, $i_y + $i_sizeh)
$combined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0)

_WinAPI_CombineRgn($combined_rgn, $outer_rgn, $inner_rgn, $RGN_DIFF)


_WinAPI_SetWindowRgn($h_win, $combined_rgn)

EndFunc ;==>_GuiHole
If you paint on the Screen there would be obvious flickers, you can't help that. A GUI is a better choice

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to post
Share on other sites
  • 7 years later...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...