Draw Circle Like "Magic Formation" (2024)

@scriptor2016 I was playing around a bit with gestures.

The gestures can be added / changed on the fly. Currently only saves letters but this is just a first draft.

How to use.

Press Numpad1 (change to w/e you want) to start drawing a gesture. once you start drawing, stop moving your mouse for a short time to stop the gesture.

Press Numpad2 to save your last gesture (only save it as a letter [A,B,C,etc.] ) you can change a gesture too.

Code: Select all

/*[LEGEND]A=LDB=RDC=LDRDD=RDLDE=RULUF=DLURG=RLDH=URDI=DJ=DK=L=M=RURDRURDN=RURDRUO=LDRDRULUP=URDLQ=R=RURDLS=LDRDLDT=U=DRURUUV=RDRUW=RDRURDRUX=Y=RDRULDZ=RDLDR*/;***********************************************************************************************************#Include, <My Altered GDIP LIB> ; <<<<<------------- GDIP.AHK ;***********************************************************************************************************#SingleInstance, ForceSetBatchlines, -1ListLines, Off#NoEnvCoordMode, Mouse, ScreenGdip_Startup()Brush := Gdip_BrushCreateSolid( "0xFF336699" ) lit1 := ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]Pass := {}Loop, 26{IniRead, out, % A_ScriptFullPath , LEGEND , % lit1[ A_Index ]Pass[ out ] := lit1[ A_Index ]}Gui1 := New PopUpWindow( { X: 0 , Y: 0 , W: A_ScreenWidth , H: A_ScreenHeight , Options: " -DPIScale +AlwaysOnTop " } )Gui1.ShowWindow()tC := 10Gui, Display: New, +ALwaysOnTop +LastFound -CaptionGui, Color, 123456WinSet, TransColor, 123456Gui, Font, s42 cLIME BOLDGui, Add, Text, x0 y0 w100 hwndThwnd,Gui, DisPlay:Show, x700 y150 , 0returnGuiClose:GuiContextMenu:*ESC::ExitAppNumpad3::PopUpWindow.Helper()Numpad1::gosub, StartUpSetTimer, Gesture, 0returnNumpad2::InputBox, out, Add Gesture, What do you want call this gesture?Pass[ SEQ ] := outIniWrite, % SEQ , % A_ScriptFullPath , LEGEND , % outreturnStartUp:SEQ := ""MouseGetPos, cx, cylx := cx , ly := cyWhile( cx = lx && ly = cy ){MouseGetPos, cx, cysleep, 10}LXDIR := CXDIR := ( abs( cx ) < abs( lx ) ) ? ( "L" ) : ( ( abs( cx ) > abs( lx ) ) ? ( "R" ) : ( "N" ) ) LYDIR := CYDIR := ( abs( cy ) < abs( ly ) ) ? ( "U" ) : ( ( abs( cy ) > abs( ly ) ) ? ( "D" ) : ( "N" ) ) FREQX := { "L": 0 , "R": 0 , "N": 0 } , FREQY := { "U": 0 , "D": 0 , "N": 0 }FREQX[ CXDir ]++ , FREQY[ CYDir ]++SXPOS := CX , SYPOS := CYlx := cx , ly := cylCount := 0 , gCount := 0Gui, % ++gCount ":New", +AlwaysOnTop -Caption +ToolWindow Gui, Color, FF0000Gui, Show, % "x" CX - 10 " y" CY - 10 " w20 h20"returnGesture:lCount++MouseGetPos, cx, cyCXDIR := ( abs( cx ) < abs( lx ) ) ? ( "L" ) : ( ( abs( cx ) > abs( lx ) ) ? ( "R" ) : ( "N" ) )CYDIR := ( abs( cy ) < abs( ly ) ) ? ( "U" ) : ( ( abs( cy ) > abs( ly ) ) ? ( "D" ) : ( "N" ) ) FREQY[ CYDIR ]++FREQX[ CXDIR ]++if( ( CXDIR != LXDIR && CXDIR != "N" && LXDIR != "N" && FREQX[ LXDIR ] > ( lcount * 0.3 ) && lCount > tC ) || ( CYDIR != LYDIR && CYDIR != "N" && LYDIR != "N" && FREQY[ LYDIR ] > ( lcount * 0.3 ) && lCount > tC ) ){ for k, v in FREQXif( k != "N" && FREQX[ k ] > ( lcount * 0.3 ) )SEQ .= kfor k, v in FREQYif( k != "N" && FREQY[ k ] > ( lcount * 0.3 ) )SEQ .= klcount := 0FREQX := { "L": 0 , "R": 0 , "N": 0 } , FREQY := { "U": 0 , "D": 0 , "N": 0 }FREQX[ CXDir ]++ , FREQY[ CYDir ]++LXDIR := "N" , LYDIR := "N"Gui, % ++gCount ":New", +AlwaysOnTop -Caption +ToolWindow Gui, Color, FF0000Gui, Show, % "x" CX - 10 " y" CY - 10 " w20 h20"return}( cx = lx && cy = ly ) ? ( BreakCount++ ) : ( BreakCount := 0 )if( BreakCount >= 20 ){Loop, % gCount{gCount := 0Gui, % A_Index ":Destroy"}setTimer, Gesture, offfor k, v in FREQXif( k != "N" && FREQX[ k ] > ( lcount * 0.3 ) )SEQ .= kfor k, v in FREQYif( k != "N" && FREQY[ k ] > ( lcount * 0.3 ) )SEQ .= klcount := 0if( PASS[ SEQ ] ){GuiControl, Display:, % tHwnd , % PASS[ SEQ ]SoundBeep, 700}Gui1.ClearWindow( 1 )return}lx := cx , ly := cyLXDIR := ( LXDIR != "N" && CXDIR = "N" ) ? ( LXDIR ) : ( CXDIR )LYDIR := ( LYDIR != "N" && CYDIR = "N" ) ? ( LYDIR ) : ( CYDIR )Gdip_FillEllipse( Gui1.G , Brush , cx-5 , cy-5 , 10 , 10 )Gui1.UpdateWindow()return;####################################################################################################################################################################################;####################################################################################################################################################################################;####################################################################################################################################################################################;####################################################################################################################################################################################class PopUpWindow{;PopUpWindow v2;Date Written: Oct 28th, 2021;Written By: Hellbent aka CivReborn;SpcThanks: teadrinker , malcev static Index := 0 , Windows := [] , Handles := [] , EditHwnd , HelperHwnd__New( obj := "" ){This._SetDefaults()This.UpdateSettings( obj )This._CreateWindow()This._CreateWindowGraphics()if( This.AutoShow )This.ShowWindow( This.Title )}_SetDefaults(){This.X := 10This.Y := 10This.W := 10This.H := 10This.Smoothing := 2This.Options := " -DPIScale +AlwaysOnTop "This.AutoShow := 0This.GdipStartUp := 0This.Title := ""This.Controls := []This.Handles := []This.Index := 0 }AddTrigger( obj ){local k , v , cc , bdThis.Controls[ ++This.Index ] := { X:10,Y:10,W:10,H:10}for k, v in objThis.Controls[ This.Index ][ k ] := obj[ k ] cc := This.Controls[ This.Index ]Gui, % This.Hwnd ":Add", Text, % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " hwndhwnd"This.Handles[ hwnd ] := This.IndexThis.Controls[ This.Index ].Hwnd := hwndreturn hwnd}DrawTriggers( color := "0xFFFF0000" , AutoUpdate := 0 ){local brush , cc Brush := Gdip_BrushCreateSolid( color ) Gdip_SetSmoothingMode( This.G , 3 )loop, % This.Controls.Length(){cc := This.Controls[ A_Index ]Gdip_FillRectangle( This.G , Brush , cc.x , cc.y , cc.w , cc.h )}Gdip_DeleteBrush( Brush )Gdip_SetSmoothingMode( This.G , This.Smoothing )if( AutoUpdate )This.UpdateWindow()}UpdateSettings( obj := "" , UpdateGraphics := 0 ){local k , vif( IsObject( obj ) )for k, v in objThis[ k ] := obj[ k ]( This.X = "Center" ) ? ( This.X := ( A_ScreenWidth - This.W ) / 2 ) ( This.Y = "Center" ) ? ( This.Y := ( A_ScreenHeight - This.H ) / 2 ) if( UpdateGraphics ){This._DestroyWindowsGraphics()This._CreateWindowGraphics()}}_CreateWindow(){local hwndGui , New, % " +LastFound +E0x80000 hwndhwnd -Caption " This.OptionsPopUpWindow.Index++This.Index := PopUpWindow.IndexPopUpWindow.Windows[ PopUpWindow.Index ] := ThisThis.Hwnd := hwndPopUpWindow.Handles[ hwnd ] := PopUpWindow.Indexif( This.GdipStartUp && !PopUpWindow.pToken )PopUpWindow.pToken := GDIP_STARTUP()}_DestroyWindowsGraphics(){SelectObject( This.hdc , This.obm )DeleteObject( This.hbm )DeleteDC( This.hdc )}_CreateWindowGraphics(){This.hbm := CreateDIBSection( This.W , This.H )This.hdc := CreateCompatibleDC()This.obm := SelectObject( This.hdc , This.hbm )This.G := Gdip_GraphicsFromHDC( This.hdc )Gdip_SetSmoothingMode( This.G , This.Smoothing )}ShowWindow( Title := "" ){Gui , % This.Hwnd ":Show", % "x" This.X " y" This.Y " w" This.W " h" This.H " NA", % Title}HideWindow(){Gui , % This.Hwnd ":Hide",}UpdateWindow(){UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H )}ClearWindow( AutoUpdate := 0 ){Gdip_GraphicsClear( This.G )if( Autoupdate )This.UpdateWindow()}DrawBitmap( pBitmap , obj , dispose := 1 , AutoUpdate := 0 ){Gdip_DrawImage( This.G , pBitmap , obj.X , obj.Y , obj.W , obj.H )if( dispose )Gdip_DisposeImage( pBitmap )if( Autoupdate )This.UpdateWindow()}PaintBackground( color := "0xFF000000" , AutoUpdate := 0 ){if( isObject( color ) ){Brush := Gdip_BrushCreateSolid( ( color.HasKey( "Color" ) ) ? ( color.Color ) : ( "0xFF000000" ) ) if( color.Haskey( "Round" ) )Gdip_FillRoundedRectangle( This.G , Brush , color.X , color.Y , color.W , color.H , color.Round )elseGdip_FillRectangle( This.G , Brush , color.X , color.Y , color.W , color.H ) }else{Brush := Gdip_BrushCreateSolid( color ) Gdip_FillRectangle( This.G , Brush , -1 , -1 , This.W + 2 , This.H + 2 ) }Gdip_DeleteBrush( Brush )if( AutoUpdate )This.UpdateWindow()}DeleteWindow( GDIPShutdown := 0 ){Gui, % This.Hwnd ":Destroy"SelectObject( This.hdc , This.obm )DeleteObject( This.hbm )DeleteDC( This.hdc )Gdip_DeleteGraphics( This.G )hwnd := This.Hwndfor k, v in PopUpWindow.Windows[ Hwnd ]This[k] := ""PopUpWindow.Windows[ Hwnd ] := ""if( GDIPShutdown ){Gdip_Shutdown( PopUpWindow.pToken )PopUpWindow.pToken := ""}}_OnClose( wParam ){if( wParam = 0xF060 ){;SC_CLOSE ;[ clicking on the gui close button ]Try{Gui, % PopUpWindow.HelperHwnd ":Destroy"SoundBeep, 555}}}CreateCachedBitmap( pBitmap , Dispose := 0 ){local pCachedBitmapif( This.CachedBitmap )This.DisposeCachedbitmap()DllCall( "gdiplus\GdipCreateCachedBitmap" , "Ptr" , pBitmap , "Ptr" , this.G , "PtrP" , pCachedBitmap )This.CachedBitmap := pCachedBitmapif( Dispose )Gdip_DisposeImage( pBitmap )}DrawCachedBitmap( AutoUpdate := 0 ){DllCall( "gdiplus\GdipDrawCachedBitmap" , "Ptr" , this.G , "Ptr" , This.CachedBitmap , "Int" , 0 , "Int" , 0 )if( AutoUpdate )This.UpdateWindow()}DisposeCachedbitmap(){DllCall( "gdiplus\GdipDeleteCachedBitmap" , "Ptr" , This.CachedBitmap )}Helper(){local hwnd , MethodList := ["__New","UpdateSettings","ShowWindow","HideWindow","UpdateWindow","ClearWindow","DrawBitmap","PaintBackground","DeleteWindow" , "AddTrigger" , "DrawTriggers", "CreateCachedBitmap" , "DrawCachedBitmap" , "DisposeCachedbitmap" ]Gui, New, +AlwaysOnTop +ToolWindow +HwndHwndPopUpWindow.HelperHwnd := hwndGui, Add, Edit, xm ym w250 r1 Center hwndhwnd, Gui1PopUpWindow.EditHwnd := hwndloop, % MethodList.Length()Gui, Add, Button, xm y+1 w250 r1 gPopUpWindow._HelperClip, % MethodList[ A_Index ]Gui, Show,,OnMessage( 0x112 , This._OnClose.Bind( hwnd ) )}_HelperClip(){local ClipList GuiControlGet, out, % PopUpWindow.HelperHwnd ":", % PopUpWindow.EditHwndClipList := { __New: " := New PopUpWindow( { X: 0 , Y: 0 , W: A_ScreenWidth , H: A_ScreenHeight , Options: "" -DPIScale +AlwaysOnTop "" } )",UpdateSettings:".UpdateSettings( { X: """" , Y: """" , W: """" , H: """" } , UpdateGraphics := 0 )",ShowWindow:".ShowWindow( Title := """" )",HideWindow:".HideWindow()",UpdateWindow:".UpdateWindow()",ClearWindow:".ClearWindow( AutoUpdate := 0 )",DrawBitmap:".DrawBitmap( pBitmap := """" , { X: 0 , Y: 0 , W: " Out ".W , H: " Out ".H } , dispose := 1 )",PaintBackground:".PaintBackground( color := ""0xFF000000"" ) " ";{ Color: ""0xFF000000"" , X: 2 , Y: 2 , W: " Out ".W - 4 , H: " Out ".H - 4 , Round: 10 }",DeleteWindow:".DeleteWindow( GDIPShutdown := 0 )",AddTrigger:".AddTrigger( { X: """" , Y: """" , W: """" , H: """" , Value: """" , Label: """" , BoundClass: """" , BoundMethod: """" } )",DrawTriggers:".DrawTriggers( color := ""0xFFFF0000"" , AutoUpdate := 0 )",CreateCachedBitmap:".CreateCachedBitmap( pBitmap , Dispose := 0 )",DrawCachedBitmap: ".DrawCachedBitmap( AutoUpdate := 0 )",DisposeCachedbitmap:".DisposeCachedbitmap()"}clipboard := Out ClipList[ A_GuiControl ]}}
Draw Circle Like "Magic Formation" (2024)

References

Top Articles
Latest Posts
Article information

Author: Margart Wisoky

Last Updated:

Views: 5731

Rating: 4.8 / 5 (58 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Margart Wisoky

Birthday: 1993-05-13

Address: 2113 Abernathy Knoll, New Tamerafurt, CT 66893-2169

Phone: +25815234346805

Job: Central Developer

Hobby: Machining, Pottery, Rafting, Cosplaying, Jogging, Taekwondo, Scouting

Introduction: My name is Margart Wisoky, I am a gorgeous, shiny, successful, beautiful, adventurous, excited, pleasant person who loves writing and wants to share my knowledge and understanding with you.