XZ3R0 Posted September 25, 2008 Posted September 25, 2008 I want to make a frame appear when running a script. I want 4 red lines to make a box, or frame. Can anyone point me in the right direction?
spudw2k Posted September 25, 2008 Posted September 25, 2008 (edited) Here's a modified version of something I threw together a little while back. It has more than you need but maybe you can learn more from it. Click and Drag to select a region on the screen. It will display co-ordinate info as you drag. When you release the mouse button it will draw a red box in the region you selected. I recommend just learning from this cause I don't like it very much. It leaves trails if windows move beneath it. There may be a way to avoid/fix that, but it's beyond my knowledge. expandcollapse popup$region = _GetMouseRegion() ;Captures Region as Array ([0][0-1]=Start X&Y [1][0-1]=End X&Y [2][0-1]=Distance Between While 1 Dim $start[2] $start[0] = $region[0][0] $start[1] = $region[0][1] Dim $current[2] $current[0] = $region[1][0] $current[1] = $region[1][1] _ShowRegionHighlight($start,$current) Wend Func _StartDrag($dll) Do sleep(10) Until _IsPressed(1,$dll) Return MouseGetPos() EndFunc Func _FinishDrag($dll,$start,$flags=3) While _IsPressed(1,$dll) $current = MouseGetPos() If BitOR($flags,1) = $flags Then _ShowRegionStats($start,$current) WEnd ToolTip("") Return MouseGetPos() EndFunc Func _GetMouseRegion() $dll = DllOpen("user32.dll") $start = _StartDrag($dll) $finish = _FinishDrag($dll,$start) DllClose($dll) Dim $box[3][2] For $i = 0 to 2 For $x = 0 to 1 If $i = 0 Then $box[$i][$x] = $start[$x] ElseIf $i = 1 Then $box[$i][$x] = $finish[$x] Else $box[$i][$x] = $finish[$x] - $start[$x] EndIf Next Next Return $box EndFunc Func _ShowRegionStats($start,$current) If $start[0] > $current[0] And $start[1] <> $current[1] Then ToolTip("X:" & $start[0] & @TAB & "X:" & $current[0] & @CRLF & "Y:" & $start[1] & @TAB & "Y:" & $current[1] & @CRLF & @CRLF & "Width = " & Abs($current[0]-$start[0]) & @CRLF & "Height = " & Abs($current[1]-$start[1]),$current[0]-74,$current[1]-70) ElseIf $start[0] < $current[0] And $start[1] <> $current[1] Then ToolTip("X:" & $start[0] & @TAB & "X:" & $current[0] & @CRLF & "Y:" & $start[1] & @TAB & "Y:" & $current[1] & @CRLF & @CRLF & "Width = " & Abs($current[0]-$start[0]) & @CRLF & "Height = " & Abs($current[1]-$start[1]),$current[0],$current[1]) EndIf EndFunc Func _ShowRegionHighlight($start,$current) $hd = DllCall("user32.dll", "int", "GetDC", "hwnd", 0) $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0, "int", 1, "int", 0x0000ff) DllCall("gdi32.dll", "int", "SelectObject", "int", $hd[0], "int", $pen[0]) DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int",$start[0], "int", $start[1], "int", 0) DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $start[0], "int", $current[1]) ;DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $current[0], "int", $start[1]) DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int",$current[0], "int", $start[1], "int", 0) DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $current[0], "int", $current[1]) ;DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $start[0], "int", $start[1]) DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int",$current[0], "int", $current[1], "int", 0) DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $start[0], "int", $current[1]) DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int",$start[0], "int", $start[1], "int", 0) DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $current[0], "int", $start[1]) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $hd[0]) sleep(50) EndFunc Func _IsPressed($sHexKey, $vDLL = 'user32.dll') Local $a_R = DllCall($vDLL, "int", "GetAsyncKeyState", "int", '0x' & $sHexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFunc edit: There are easier methods if you want to draw it within an AutoIt GUI. Search the help file for GUICtrlCreateGroup, and _GDIPlus_GraphicsDrawRect Edited September 25, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
XZ3R0 Posted September 25, 2008 Author Posted September 25, 2008 (edited) cool thx. my favorite way is to learn from more complicated stuff. edit: so i made this Dim $start[2] $start[0] = 475 $start[1] = 280 Dim $current[2] $current[0] = 1030 $current[1] = 630 Func targetframe($start,$current) $hd = DllCall("user32.dll", "int", "GetDC", "hwnd", 0) $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0, "int", 1, "int", 0x0000ff) DllCall("gdi32.dll", "int", "SelectObject", "int", $hd[0], "int", $pen[0]) DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int",$start[0], "int", $start[1], "int", 0) DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $start[0], "int", $current[1]) ;DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $current[0], "int", $start[1]) DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int",$current[0], "int", $start[1], "int", 0) DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $current[0], "int", $current[1]) ;DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $start[0], "int", $start[1]) DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int",$current[0], "int", $current[1], "int", 0) DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $start[0], "int", $current[1]) DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hd[0], "int",$start[0], "int", $start[1], "int", 0) DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hd[0], "int", $current[0], "int", $start[1]) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $hd[0]) sleep(50) EndFunc but once you move something on the screen the box disappears. how can i made it so it will stay for a set amount of time? Edited September 27, 2008 by XZ3R0
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