Ok, so I don't even know where to begin on this project really... Not near experienced enough to dip into trying this myself. What I would like is to make the first place you click after hitting the trigger the center for the circle and then when you drag the circle, have it be resized based on the distance from that center point without showing the line representing the radius.
For a circle I wrote this and it works:
;Circle Symbol !c:: ;Input my radius InputBox, Radius, Radius, Input Radius ;Draw my circle MouseGetPos, StartX, StartY MouseMove, 0, %Radius%, 0, R MouseClick, Left, , , , 0, D Loop 64 { xVar := Radius*Sin(A_Index/10) yVar := Radius*Cos(A_Index/10) DrawX := StartX+xVar DrawY := StartY+yVar MouseMove, %DrawX%, %DrawY%, } MouseClick, Left, , , , 0, U Return
However you don't see the circle before its drawn... you have to just have to guess the size of the radius based in pixels on the screen.
Now I want a way to draw a shape using the same techniques as this script preferably:
!d:: gosub, BeginDraw return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Special thanks to Print for the Square Shape draw.;;;;;;;;;;;;;;;;; BeginDraw: MouseGetPos, StartX, StartY prs = 1 Gui, 20: destroy Gui, 21: destroy line_c = 0x008000 frame_c = 0x000F00 frame_t = 5 Gui, 21: Color, white Gui, 21: +Lastfound +AlwaysOnTop +toolwindow WinSet, Transparent, 100 Gui, 21:-Caption Gui, 21: Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight% Hotkey, Lbutton, dragw Hotkey, Lbutton, on return dragw: MouseGetPos, MX, MY Gui, 20:Color, black Gui, 20:+Lastfound +AlwaysOnTop +toolwindow WinSet, TransColor, Black Gui, 20:-Caption Gui, 20: Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight% WinGet, hw_frame, id hdc_frame := DllCall( "GetDC", "uint", hw_frame ) hdc_buffer := DllCall( "gdi32.dll\CreateCompatibleDC", "uint", hdc_frame ) hbm_buffer := DllCall( "gdi32.dll\CreateCompatibleBitmap", "uint", hdc_frame, "int", A_ScreenWidth, "int", A_ScreenHeight ) DllCall( "gdi32.dll\SelectObject", "uint", hdc_buffer, "uint", hbm_buffer ) h_region := DllCall( "gdi32.dll\CreateRectRgn", "int", 0, "int", 0, "int", 0, "int", 0 ) h_brush := DllCall( "gdi32.dll\CreateSolidBrush", "uint", frame_c ) Loop { If GetKeyState("LButton", "P") { MouseGetPos, MXend, MYend If ( MXend <> MXend_old or MYend <> MYend_old) { w := abs(MX - MXend) h := abs(MY - MYend) X := Min( MX, MXend ) Y := Min( MY, MYend ) DrawFrame( X, Y, w, h, frame_t ) MXend_old = %MXend% MYend_old = %MYend% } } Else Break Sleep, 40 } Gui, 21:Destroy if (MY > MYend) { temp := MY MY := MYend MYend := temp } if (MX > MXend) { temp := MX MX := MXend - 1 MXend := temp } MYend-=2 MY+=2 MXend-=2 MX+=2 Hotkey, Lbutton , Off aa=%MX%, %MY%, %MXend%, %MYend% CaptureScreen(aa) GoSub, CleanUp loop { IfExist, %sFile% break sleep 100 } Gui, 21: destroy Hotkey, Lbutton, off prs = 0 ;~ MsgBox %MX% %MXend% %MY% %MYend% { MoveX := (MXend-MX) MoveY := (MYend-MY) MouseClick, Left, , , , , D MouseMove, 0, -%MoveY%, 2, R MouseMove, -%MoveX%, 0, 2, R MouseMove, 0, %MoveY%, 2, R MouseMove, %MoveX%, 0, 2, R MouseClick, Left, , , , , U } handle_exit: GoSub, CleanUp Return CleanUp: DeleteObject( h_brush ) DeleteObject( h_region ) DeleteObject( hbm_buffer ) DeleteDC( hdc_frame ) DeleteDC( hdc_buffer ) Gui, 20:Destroy prs = 0 Return DrawFrame( p_x, p_y, p_w, p_h, p_t ) { global hdc_frame, hdc_buffer, h_region, h_brush static buffer_state, old_x, old_y, old_w, old_h SRCCOPY = 0x00CC0020 if ( buffer_state = "full") DllCall( "gdi32.dll\BitBlt", "uint", hdc_frame, "int", old_x, "int", old_y, "int", old_w, "int", old_h, "uint", hdc_buffer, "int", 0, "int", 0, "uint", SRCCOPY ) else buffer_state = full old_x := p_x, old_y := p_y, old_w := p_w, old_h := p_h DllCall( "gdi32.dll\BitBlt", "uint", hdc_buffer, "int", 0, "int", 0, "int", p_w, "int", p_h, "uint", hdc_frame, "int", p_x, "int", p_y , "uint", SRCCOPY ) DllCall( "gdi32.dll\SetRectRgn" , "uint", h_region , "int", p_x , "int", p_y , "int", p_x+p_w , "int", p_y+p_h ) DllCall( "gdi32.dll\FrameRgn" , "uint", hdc_frame , "uint", h_region , "uint", h_brush , "int", p_t , "int", p_t ) } DeleteDC( p_dc ) { DllCall( "gdi32.dll\DeleteDC", "uint", p_dc ) } DeleteObject( p_object ) { DllCall( "gdi32.dll\DeleteObject", "uint", p_object ) } Min( value1, value2 ) { If ( value1 < value2 ) return value1 Else return value2 } CaptureScreen(aRect = 0) { global sFile sFile = %A_temp%\S%A_tickcount%.jpg nQuality = 95 If !aRect { SysGet, Mon, Monitor, 1 nL := MonLeft nT := MonTop nW := MonRight - MonLeft nH := MonBottom - MonTop } Else If aRect = 1 WinGetPos, nL, nT, nW, nH, A Else If aRect = 2 { WinGet, hWnd, ID, A VarSetCapacity(rt, 16, 0) DllCall("GetClientRect" , "Uint", hWnd, "Uint", &rt) DllCall("ClientToScreen", "Uint", hWnd, "Uint", &rt) nL := NumGet(rt, 0, "int") nT := NumGet(rt, 4, "int") nW := NumGet(rt, 8) nH := NumGet(rt,12) } Else { StringSplit, rt, aRect, `,, %A_Space%%A_Tab% nL := rt1 nT := rt2 nW := rt3 - rt1 nH := rt4 - rt2 znW := rt5 znH := rt6 } mDC := DllCall("CreateCompatibleDC", "Uint", 0) hBM := CreateDIBSection(mDC, nW, nH) oBM := DllCall("SelectObject", "Uint", mDC, "Uint", hBM) hDC := DllCall("GetDC", "Uint", 0) DllCall("BitBlt", "Uint", mDC, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", hDC, "int", nL, "int", nT, "Uint", 0x40000000 | 0x00CC0020) DllCall("ReleaseDC", "Uint", 0, "Uint", hDC) If bCursor CaptureCursor(mDC, nL, nT) DllCall("SelectObject", "Uint", mDC, "Uint", oBM) DllCall("DeleteDC", "Uint", mDC) If znW && znH hBM := Zoomer(hBM, nW, nH, znW, znH) If sFile = 0 SetClipboardData(hBM) Else Convert(hBM, sFile, nQuality), DllCall("DeleteObject", "Uint", hBM) } CaptureCursor(hDC, nL, nT) { VarSetCapacity(mi, 20, 0) mi := Chr(20) DllCall("GetCursorInfo", "Uint", &mi) bShow := NumGet(mi, 4) hCursor := NumGet(mi, 8) xCursor := NumGet(mi,12) yCursor := NumGet(mi,16) VarSetCapacity(ni, 20, 0) DllCall("GetIconInfo", "Uint", hCursor, "Uint", &ni) xHotspot := NumGet(ni, 4) yHotspot := NumGet(ni, 8) hBMMask := NumGet(ni,12) hBMColor := NumGet(ni,16) If bShow DllCall("DrawIcon", "Uint", hDC, "int", xCursor - xHotspot - nL, "int", yCursor - yHotspot - nT, "Uint", hCursor) If hBMMask DllCall("DeleteObject", "Uint", hBMMask) If hBMColor DllCall("DeleteObject", "Uint", hBMColor) } Zoomer(hBM, nW, nH, znW, znH) { mDC1 := DllCall("CreateCompatibleDC", "Uint", 0) mDC2 := DllCall("CreateCompatibleDC", "Uint", 0) zhBM := CreateDIBSection(mDC2, znW, znH) oBM1 := DllCall("SelectObject", "Uint", mDC1, "Uint", hBM) oBM2 := DllCall("SelectObject", "Uint", mDC2, "Uint", zhBM) DllCall("SetStretchBltMode", "Uint", mDC2, "int", 4) DllCall("StretchBlt", "Uint", mDC2, "int", 0, "int", 0, "int", znW, "int", znH, "Uint", mDC1, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", 0x00CC0020) DllCall("SelectObject", "Uint", mDC1, "Uint", oBM1) DllCall("SelectObject", "Uint", mDC2, "Uint", oBM2) DllCall("DeleteDC", "Uint", mDC1) DllCall("DeleteDC", "Uint", mDC2) DllCall("DeleteObject", "Uint", hBM) Return zhBM } Convert(sFileFr = "", sFileTo = "", nQuality = "") { If sFileTo = sFileTo := A_ScriptDir . "\screen.bmp" SplitPath, sFileTo, , sDirTo, sExtTo, sNameTo If Not hGdiPlus := DllCall("LoadLibrary", "str", "gdiplus.dll") Return sFileFr+0 ? SaveHBITMAPToFile(sFileFr, sDirTo . "\" . sNameTo . ".bmp") : "" VarSetCapacity(si, 16, 0), si := Chr(1) DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0) If !sFileFr { DllCall("OpenClipboard", "Uint", 0) If DllCall("IsClipboardFormatAvailable", "Uint", 2) && (hBM:=DllCall("GetClipboardData", "Uint", 2)) DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", hBM, "Uint", 0, "UintP", pImage) DllCall("CloseClipboard") } Else If sFileFr Is Integer DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "Uint", sFileFr, "Uint", 0, "UintP", pImage) Else DllCall("gdiplus\GdipLoadImageFromFile", "Uint", Unicode4Ansi(wFileFr,sFileFr), "UintP", pImage) DllCall("gdiplus\GdipGetImageEncodersSize", "UintP", nCount, "UintP", nSize) VarSetCapacity(ci,nSize,0) DllCall("gdiplus\GdipGetImageEncoders", "Uint", nCount, "Uint", nSize, "Uint", &ci) Loop, % nCount If InStr(Ansi4Unicode(NumGet(ci,76*(A_Index-1)+44)), "." . sExtTo) { pCodec := &ci+76*(A_Index-1) Break } If InStr(".JPG.JPEG.JPE.JFIF", "." . sExtTo) && nQuality<>"" && pImage && pCodec { DllCall("gdiplus\GdipGetEncoderParameterListSize", "Uint", pImage, "Uint", pCodec, "UintP", nSize) VarSetCapacity(pi,nSize,0) DllCall("gdiplus\GdipGetEncoderParameterList", "Uint", pImage, "Uint", pCodec, "Uint", nSize, "Uint", &pi) Loop, % NumGet(pi) If NumGet(pi,28*(A_Index-1)+20)=1 && NumGet(pi,28*(A_Index-1)+24)=6 { pParam := &pi+28*(A_Index-1) NumPut(nQuality,NumGet(NumPut(4,NumPut(1,pParam+0)+20))) Break } } If pImage pCodec ? DllCall("gdiplus\GdipSaveImageToFile", "Uint", pImage, "Uint", Unicode4Ansi(wFileTo,sFileTo), "Uint", pCodec, "Uint", pParam) : DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "Uint", pImage, "UintP", hBitmap, "Uint", 0) . SetClipboardData(hBitmap), DllCall("gdiplus\GdipDisposeImage", "Uint", pImage) DllCall("gdiplus\GdiplusShutdown" , "Uint", pToken) DllCall("FreeLibrary", "Uint", hGdiPlus) } CreateDIBSection(hDC, nW, nH, bpp = 32, ByRef pBits = "") { NumPut(VarSetCapacity(bi, 40, 0), bi) NumPut(nW, bi, 4) NumPut(nH, bi, 8) NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort") NumPut(0, bi,16) Return DllCall("gdi32\CreateDIBSection", "Uint", hDC, "Uint", &bi, "Uint", 0, "UintP", pBits, "Uint", 0, "Uint", 0) } SaveHBITMAPToFile(hBitmap, sFile) { DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi) hFile:= DllCall("CreateFile", "Uint", &sFile, "Uint", 0x40000000, "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "int64P", 0x4D42|14+40+NumGet(oi,44)<<16, "Uint", 6, "UintP", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "int64P", 54<<32, "Uint", 8, "UintP", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "Uint", &oi+24, "Uint", 40, "UintP", 0, "Uint", 0) DllCall("WriteFile", "Uint", hFile, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44), "UintP", 0, "Uint", 0) DllCall("CloseHandle", "Uint", hFile) } SetClipboardData(hBitmap) { DllCall("GetObject", "Uint", hBitmap, "int", VarSetCapacity(oi,84,0), "Uint", &oi) hDIB := DllCall("GlobalAlloc", "Uint", 2, "Uint", 40+NumGet(oi,44)) pDIB := DllCall("GlobalLock", "Uint", hDIB) DllCall("RtlMoveMemory", "Uint", pDIB, "Uint", &oi+24, "Uint", 40) DllCall("RtlMoveMemory", "Uint", pDIB+40, "Uint", NumGet(oi,20), "Uint", NumGet(oi,44)) DllCall("GlobalUnlock", "Uint", hDIB) DllCall("DeleteObject", "Uint", hBitmap) DllCall("OpenClipboard", "Uint", 0) DllCall("EmptyClipboard") DllCall("SetClipboardData", "Uint", 8, "Uint", hDIB) DllCall("CloseClipboard") } Unicode4Ansi(ByRef wString, sString) { nSize := DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0) VarSetCapacity(wString, nSize * 2) DllCall("MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize) Return &wString } Ansi4Unicode(pString) { nSize := DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int", 0, "Uint", 0, "Uint", 0) VarSetCapacity(sString, nSize) DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize, "Uint", 0, "Uint", 0) Return sString } return
Reading through that, I realize I am way over my head which is why I turn to you guys for help and hopefully someone will have time to help me out. Thanks for any help in advance!