Crop bitmap and export as Base64 string? ( Create Icons ) Topic is solved
Re: Crop bitmap and export as Base64 string? ( Create Icons )
Absolutely amazing!
Re: Crop bitmap and export as Base64 string? ( Create Icons )
@Hellbent, many many thanks for the examples. Immensely helpful to me and I imagine all other lesser skilled coders.
Most likely even those deemed as gurus on here. I will be picking at this for awhile trying to learn what does what. Brilliant work!!
Most likely even those deemed as gurus on here. I will be picking at this for awhile trying to learn what does what. Brilliant work!!
Re: Crop bitmap and export as Base64 string? ( Create Icons ) Topic is solved
**Update**
1. Added the ability to change the background color. Works with images that have transparency that are loaded from the clipboard.
2. Added the ability to draw text. Use `n to create a new line.
. .
Requires windows 8 or higher.
Replace the path to the gdip lib at the top of the script.
Paste the code from the next post at the bottom of the this script. ( contains extra classes and functions needed )
You can find some examples of how to use the icons in your scripts a few posts above this one. ( How To )
1. Added the ability to change the background color. Works with images that have transparency that are loaded from the clipboard.
2. Added the ability to draw text. Use `n to create a new line.
. .
Requires windows 8 or higher.
Replace the path to the gdip lib at the top of the script.
Paste the code from the next post at the bottom of the this script. ( contains extra classes and functions needed )
You can find some examples of how to use the icons in your scripts a few posts above this one. ( How To )
Code: Select all
;****************************************************************************************************************************************************************************
#Include <My Altered GDIP lib> ;GDIP: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=6517
;~ #Include <PopUpWindow_V2> ; At the bottom of the script
;~ #Include <Gen 3 Buttons> ;
;~ #Include <HB Vectors v2>
;~ #Include, <HB Icon Buttons ( LW Ani Buttons )>
;****************************************************************************************************************************************************************************
#SingleInstance, Force
SetBatchLines, -1
#NoEnv
SetWorkingDir, % A_ScriptDir
Gdip_Startup()
IfNotExist, % A_ScriptDir "\Saved Icon Images\"
FileCreateDir, % A_ScriptDir "\Saved Icon Images\"
IconB64 := "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAmRSURBVHhe7V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mpNP3qrAAAAAElFTkSuQmCC"
SetIcon( B64ToPBitmap( IconB64 ) )
Theme1 := NewTheme()
GuiButtonType1.SetSessionDefaults( Theme1.All , Theme1.Default , Theme1.Hover , Theme1.Pressed )
Gui1 := {}
Gui1.Controls := {}
Gui1.Handles := []
Gui1.Scale := 1
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
;~ Gui1.MainIcon := B64ToPBitmap( IconB64 )
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
Gui1.ImageBackgroundColor := "0xFF22262a" ;<<<<<========<
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
Gui1.SelectedShape := "Triangle"
Gui1.ShapesArray := [ "Rectangle" , "Rounded Rectangle" , "Circle" , "Triangle" , "Pentagon" , "Hexagon" , "Heptagon" , "Octagon" , "Hexadecagon" ]
Gui1.Display := {}
Gui1.Display.pBitmap := Gdip_CreateBitmap( 400 , 400 )
Gui1.Image := {}
Gui1.Image.BackupBitmap := Gui1.Image.pBitmap := Gdip_CreateBitmapFromFile( Gui1.FilePath )
Gui1.Image.Scale := 1
Gui1.Image.X := 0
Gui1.Image.Y := 0
;####################################################
Gui1.SavedImagePaths := []
Loop, % A_ScriptDir "\Saved Icon Images\*.png"
{
Gui1.SavedImagePaths.Push( A_LoopFileFullPath )
}
Gui1.SavedB64Bitmaps := []
Loop, % A_ScriptDir "\Saved Icon Images\*.txt"
{
FileRead, out , % A_LoopFileFullPath
if( out ){
Gui1.SavedB64Bitmaps.Push( B64ToPBitmap( out ) )
}
}
;**********************************************
Gui1.IconPages := []
page := 0
Loop, % Gui1.SavedB64Bitmaps.Length() {
if( A_Index = 1 || !mod( inDex , 10 ) ){
page++
Gui1.IconPages[ page ] := []
inDex := 0
}
Gui1.IconPages[ page ][ ++Index ] := Gui1.SavedB64Bitmaps[ A_Index ]
}
Gui1.CurrentPage := page
Gui1.NumberOfPages := page
;**********************************************
Gui, New, -DPIScale HwndHwnd ;+AlwaysOnTop
Gui1.Hwnd := hwnd
Gui, Font, % ( 12 / ( A_ScreenDPI / 96 ) ) * Gui1.Scale " cFFFFFF"
Gui, Color, % Background := "32363a" , 42464a
cc := Gui1.Controls.DisplayPicture := { X: 50 , Y: 50 , W: 400 , H: 400 , Method: "" }
Gui, Add, Picture, % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " 0xE hwndhwnd"
cc.Hwnd := hwnd
Gui1.Handles[ hwnd ] := cc
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
cc := Gui1.Controls.Image_Y_Slider := { X: 455 , Y: 50 , W: 20 , H: 400 }
Gui, Add, Progress , % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " hwndhwnd Background"
cc.Hwnd := hwnd
cc := Gui1.Controls.Image_Y_Thumb := { X: 455 , Y: 50 , W: 20 , H: 50 }
Gui, Add, Progress , % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " hwndhwnd BackgroundRed"
cc.Hwnd := hwnd
cc := Gui1.Controls.Image_X_Slider := { X: 50 , Y: 455 , W: 400 , H: 20 }
Gui, Add, Progress , % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " hwndhwnd Background"
cc.Hwnd := hwnd
cc := Gui1.Controls.Image_X_Thumb := { X: 50 , Y: 455 , W: 50 , H: 20 }
Gui, Add, Progress , % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " hwndhwnd BackgroundF0F0F0 cRed" , 100
cc.hwnd := hwnd
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
;~ Gui1.Controls.CaptureImageFromScreenButton := New HButton( { Owner: Gui1.Hwnd , X: 500 , Y: 30 , W: 300 , H: 40 , Text: "Capture A New Image From The Screen" , Label: "CaptureNewImageFromScreen" } )
Gui1.Controls.CaptureImageFromScreenButton := New HButton( { Owner: Gui1.Hwnd , X: 500 , Y: 35 , W: 300 , H: 40 , Text: "Capture A New Image From The Screen" , Label: "CaptureNewImageFromScreen" } )
;~ Gui1.Controls.LoadImageFromClipboardButton := New HButton( { Owner: Gui1.Hwnd , X: 500 , Y: 70 , W: 300 , H: 40 , Text: "Load Image From Clipboard" , Label: "LoadImageFromClipboard" } )
Gui1.Controls.LoadImageFromClipboardButton := New HButton( { Owner: Gui1.Hwnd , X: 500 , Y: 75 , W: 300 , H: 40 , Text: "Load Image From Clipboard" , Label: "LoadImageFromClipboard" } )
;~ Gui1.Controls.LoadImageFromFileButton := New HButton( { Owner: Gui1.Hwnd , X: 500 , Y: 110 , W: 300 , H: 40 , Text: "Load Image From File" , Label: "LoadImageFromFile" } )
Gui1.Controls.LoadImageFromFileButton := New HButton( { Owner: Gui1.Hwnd , X: 500 , Y: 115 , W: 300 , H: 40 , Text: "Load Image From File" , Label: "LoadImageFromFile" } )
;~ Gui, Add, Edit, % "x" 500 " y" 160 " w" 230 " r1 " " -VScroll "
Gui, Add, Edit, % "x" 500 " y" 165 " w" 230 " r1 " " -VScroll "
;~ Gui1.Controls.GetFilePathButton := New HButton( { Owner: Gui1.Hwnd , X: 740 , Y: 150 , W: 60 , H: 40 , Text: "Get" , Label: "GetImageFilePath" } )
Gui1.Controls.GetFilePathButton := New HButton( { Owner: Gui1.Hwnd , X: 740 , Y: 155 , W: 60 , H: 40 , Text: "Get" , Label: "GetImageFilePath" } )
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
Gui, Add, Text, x500 y200 Section , ScaleFactor
GlowRadio_1.Settings.FontSize := 12
GlowRadio_1.Settings.ButtonRestColor := "0xFF440000"
GlowRadio_1.Settings.RestColor := "0xFF82868a"
GlowRadio_1.Settings.ActiveColor := "0xFFFF0000"
GlowRadio_1.Settings.Scalefactor := 1
GlowRadio_1.Settings.Owner := Gui1.Hwnd
GlowRadio_1.Settings.BackgroundColor := "0xFF32363a"
GlowRadio_1.Settings.Y_Offset := 1
GlowRadio_1.Settings.X_Offset := 5
GlowRadio_1.Settings.Label := "SetImageScale"
Gui1.ScaleList := [ "0.5" , "1.0" , "1.5" , "2.0" , "3.0" , "5.0" ]
Gui1.Controls.ScaleRadios := []
Gui1.Controls.ScaleRadios[ 1 ] := New GlowRadio_1( { X: x := 500 , Y: 220 , W: w := 52 , State: 0 , Text: "0.5" } )
Gui1.Controls.ScaleRadios[ 2 ] := New GlowRadio_1( { X: x += w , Y: 220 , W: w , State: 1 , Text: "1.0" } )
Gui1.Controls.ScaleRadios[ 3 ] := New GlowRadio_1( { X: x += w , Y: 220 , W: w , State: 0 , Text: "1.5" } )
Gui1.Controls.ScaleRadios[ 4 ] := New GlowRadio_1( { X: x += w , Y: 220 , W: w , State: 0 , Text: "2.0" } )
Gui1.Controls.ScaleRadios[ 5 ] := New GlowRadio_1( { X: x += w , Y: 220 , W: w , State: 0 , Text: "3.0" } )
Gui1.Controls.ScaleRadios[ 6 ] := New GlowRadio_1( { X: x += w , Y: 220 , W: w , State: 0 , Text: "5.0" } )
;#################################################################################################
Gui, Add, Text, x500 y+10 Section , Shape
;#############################
Gui, Add, Text, x500 y315 Section , Border Thickness
GlowRadio_1.Settings.FontSize := "11"
GlowRadio_1.Settings.GroupName := "Group_2"
GlowRadio_1.Settings.Label := "SetBorderThickness"
Gui1.BorderThicknessList := [ "0" , "1" , "2" , "3" , "4" , "5" , "10" ]
Gui1.Controls.BorderThicknessRadios := []
Gui1.Controls.BorderThicknessRadios[ 1 ] := New GlowRadio_1( { X: x := 500 , Y: y := 335 , W: w := 45 , State: 0 , Text: "0" } )
Gui1.Controls.BorderThicknessRadios[ 2 ] := New GlowRadio_1( { X: x += w , Y: y , W: w , State: 1 , Text: "1" } )
Gui1.Controls.BorderThicknessRadios[ 3 ] := New GlowRadio_1( { X: x += w , Y: y , W: w , State: 0 , Text: "2" } )
Gui1.Controls.BorderThicknessRadios[ 4 ] := New GlowRadio_1( { X: x += w , Y: y , W: w , State: 0 , Text: "3" } )
Gui1.Controls.BorderThicknessRadios[ 5 ] := New GlowRadio_1( { X: x += w , Y: y , W: w , State: 0 , Text: "4" } )
Gui1.Controls.BorderThicknessRadios[ 6 ] := New GlowRadio_1( { X: x += w , Y: y , W: w , State: 0 , Text: "5" } )
Gui1.Controls.BorderThicknessRadios[ 7 ] := New GlowRadio_1( { X: x += w , Y: y , W: w , State: 0 , Text: "10" } )
;********************************************
Gui, Show, x700 w820 h600
;********************************************
BoundFunc := Func( "TestFunction" ).Bind( Gui1 )
Gui1.ShapeListDDL := New DropDownListv1( { rows: 3
, X: 500
, Y: 270
, Bind: BoundFunc
, ScaleFactor: 1
, W: 280
, FontSize: 14
, FontColor: "0xFFFF0000"
, Font: "Segoe UI"
, Parent: Gui1.Hwnd
, Selected: 4
, HighlightFontColor: "0xFFFFFFFF"
, List: Gui1.ShapesArray } )
;********************************************
Gui1.Controls.SaveB64 := New HButton( { Owner: Gui1.Hwnd , X: x := 635 , Y: 370 , W: w := 55 , H: 120 , Text: " B64" , Label: "SaveNewB64Icon" } , { FontOptions: "Top Center " } )
QuickIcon64x64 := "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAA5oSURBVHhe1VsHeFRVFn4zk8lkkkkPyaQnk55MJo2EdIoUyRISUCCwQEBCt0SFRbdYWRBEJKAClhVXV0SXxQYouiuoLNIDCBIsKDUJCUWlpR3Pucl7eTN5k0xmJoDn+/7v3nnv3Xfv+e+559zyhrtBEoboh5iBeAzxLGIrJ+M+F8Bxq9vulSPo2WTE71oy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hz8Dj4EEna2AbKb8Fr24piYQ8OhSN3RMMPOAzoXeQbTL08/UlCPL3lMTlCc7A8lfPHfI9LsquD3OivMwTaU+TPFqjBZLLk0MixkYOjMd0aunRwpS3lQddJUeYM8Xki0dQR0qzU9D8BBJrkTI5x+Sfmux/qbBGtUrEA19ZXMWvUIPIPtI7o6rDVEpDS5v46R1P10SGaqlk+2nz8fdPEI97LcS19l4/5Do0kP0EemkIUEUIwF0b5+zScKNyajm8xBmvV1csNXhZ9/HyjRBuokW9RK2QNmJdstClIQfE2VVfAcAw5vqpTD4S53oe/b12J9FaOT/JSbg1QK4T1hLXwVimahwaozpRGql+bE6r8/f2jXKvh8tO8Fauzeqm26tQO1QZP1UVHuawFb3VQNslLdRnvX8rzcD52m1a9ZXaC+r4xEU7BeK+HhON+A/nXtyPTzabuAAAAAElFTkSuQmCC"
FloppyDiskBitmap := B64ToPBitmap( QuickIcon64x64 )
G := Gdip_GraphicsFromImage( HButton.Button[ Gui1.Controls.SaveB64 ].Bitmaps.Default.pBitmap )
Gdip_DrawImage( G , FloppyDiskBitmap, 10 , 38 , 35 , 35 )
Gdip_DeleteGraphics( G )
G := Gdip_GraphicsFromImage( HButton.Button[ Gui1.Controls.SaveB64 ].Bitmaps.Hover.pBitmap )
Gdip_DrawImage( G , FloppyDiskBitmap, 5 , 35 , 45 , 45 )
Gdip_DeleteGraphics( G )
G := Gdip_GraphicsFromImage( HButton.Button[ Gui1.Controls.SaveB64 ].Bitmaps.Pressed.pBitmap )
Gdip_DrawImage( G , FloppyDiskBitmap, 7 , 36 , 41 , 41 )
Gdip_DeleteGraphics( G )
DeleteObject( HButton.Button[ Gui1.Controls.SaveB64 ].Bitmaps.Default.hBitmap )
DeleteObject( HButton.Button[ Gui1.Controls.SaveB64 ].Bitmaps.Hover.hBitmap )
DeleteObject( HButton.Button[ Gui1.Controls.SaveB64 ].Bitmaps.Pressed.hBitmap )
HButton.Button[ Gui1.Controls.SaveB64 ].Bitmaps.Default.hBitmap := Gdip_CreateHBITMAPFromBitmap( HButton.Button[ Gui1.Controls.SaveB64 ].Bitmaps.Default.pBitmap )
HButton.Button[ Gui1.Controls.SaveB64 ].Bitmaps.Hover.hBitmap := Gdip_CreateHBITMAPFromBitmap( HButton.Button[ Gui1.Controls.SaveB64 ].Bitmaps.Hover.pBitmap )
HButton.Button[ Gui1.Controls.SaveB64 ].Bitmaps.Pressed.hBitmap := Gdip_CreateHBITMAPFromBitmap( HButton.Button[ Gui1.Controls.SaveB64 ].Bitmaps.Pressed.pBitmap )
HButton._DisplayButton( Gui1.Controls.SaveB64 , HButton.Button[ Gui1.Controls.SaveB64 ].Bitmaps.Default.hBitmap )
Gui1.Controls.SavePng := New HButton( { Owner: Gui1.Hwnd , X: x += w + 5 , Y: 370 , W: w , H: 120 , Text: " .png" , Label: "SavePNGToFIle" } , { FontOptions: "Top Center " } )
PNGICON64x64 := "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABK7SURBVHhe1ZoJ9FfTFsd/CP+SlNIkyZwhMiUylERCUqFCkqgIGUKjZMq0qvX0rJSFJcNrEYUUiQalaPSkHinTe0mlQdJ43v7s/t/r/G6/f/2Lwl7rrHPPvfues+e9z7k3s5OgirXa1toVLVq0d9myZZ8rWbLkVGvTaaVKlZpeuXLlofvvv/8TxYsX75KPW93a3xpq7r777k8YwwvsOmxPK1GixNIDDjjgNeub2/hvAY2sPVekSJGV1udkanubCXN9hQoVJu66665tbPyXg5q77bbbeOtzEr/PPvuEs846K7Rr1y5069Yt3H///WHEiBHh/fff9zZ8+PDw2GOPhR49eoS77747nHnmmcHcJOdctNKlSy8yd2lp1386VDHGh1i/GZFVqlQJt9xyS3j77bfD8uXLw9q1a8OGDRvCr7/+6uNffvnFx+vXrw8rV670e+vWrUtwli1bFj744INw1113hapVq242f/4a880qatn1Toc8a32M+bXWZxGFlj///HNn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ENNAsDi2dNm1aPbvesWAmVsd8c4VdZhFAwKJOV7FEg4l0BYdVxDhxDgd4pqKLmkFA5elH2al1qRX69es32VJrBRvvPDj//PMHm+nyy1kWQfglJTDlrJjDKih4pHlcgDih3SKApsFRJkE4HIKi+XhHp0bhZNvn5SNGjNhxJr81sAKpSsOGDcdbDt9ow82IxK/5v+fhhx8Ob731lkdstItmEQrXxAoEgvmDww6ST+AUSrnmpNnuc43VA/+wkri0jf98sDRU3WrvGen4sKWG6WItuZ7lamjcSu1VL7zwwiCzjEp2768HFoiKW0boYdH4P5a6NnOPbW0IyXaPvz766KOTLMC1MF/f9Gvb3wEwTytZW1nuHmXb43mWxlZZW59OXWqkOWvrrOZYWqNGjTkdOnQYMHXq1Lqm7S3+4r79kMn8H0+ZZCja2NS6AAAAAElFTkSuQmCC"
PNG_ICON_Bitmap := B64ToPBitmap( PNGICON64x64 )
G := Gdip_GraphicsFromImage( HButton.Button[ Gui1.Controls.SavePng ].Bitmaps.Default.pBitmap )
Gdip_DrawImage( G , PNG_ICON_Bitmap, 10 , 38 , 35 , 35 )
Gdip_DeleteGraphics( G )
G := Gdip_GraphicsFromImage( HButton.Button[ Gui1.Controls.SavePng ].Bitmaps.Hover.pBitmap )
Gdip_DrawImage( G , PNG_ICON_Bitmap, 5 , 35 , 45 , 45 )
Gdip_DeleteGraphics( G )
G := Gdip_GraphicsFromImage( HButton.Button[ Gui1.Controls.SavePng ].Bitmaps.Pressed.pBitmap )
Gdip_DrawImage( G , PNG_ICON_Bitmap, 5 , 36 , 45 , 45 )
Gdip_DeleteGraphics( G )
DeleteObject( HButton.Button[ Gui1.Controls.SavePng ].Bitmaps.Default.hBitmap )
DeleteObject( HButton.Button[ Gui1.Controls.SavePng ].Bitmaps.Hover.hBitmap )
DeleteObject( HButton.Button[ Gui1.Controls.SavePng ].Bitmaps.Pressed.hBitmap )
HButton.Button[ Gui1.Controls.SavePng ].Bitmaps.Default.hBitmap := Gdip_CreateHBITMAPFromBitmap( HButton.Button[ Gui1.Controls.SavePng ].Bitmaps.Default.pBitmap )
HButton.Button[ Gui1.Controls.SavePng ].Bitmaps.Hover.hBitmap := Gdip_CreateHBITMAPFromBitmap( HButton.Button[ Gui1.Controls.SavePng ].Bitmaps.Hover.pBitmap )
HButton.Button[ Gui1.Controls.SavePng ].Bitmaps.Pressed.hBitmap := Gdip_CreateHBITMAPFromBitmap( HButton.Button[ Gui1.Controls.SavePng ].Bitmaps.Pressed.pBitmap )
HButton._DisplayButton( Gui1.Controls.SavePng , HButton.Button[ Gui1.Controls.SavePng ].Bitmaps.Default.hBitmap )
Gui1.Controls.ClipboardB64 := New HButton( { Owner: Gui1.Hwnd , X: x += w + 5 , Y: 370 , W: w , H: 120 , Text: " B64" , Label: "ClipboardBase64" } , { FontOptions: "Top Center " } )
ClipBoardIcon64x64 := "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAxGSURBVHhe3ZsJXFTVHseHYQYQROkpomkJuWRpqenD5bmgWFjmY0dETNJYXEBQzHxqkllkPUEYlpJyQT6mKGjvuaSv5aUlYgmoKA6IwKCCCiZuLCr//v+r93pn5jLOnRnE+n8+X87hztyz/O45/7PdkTwmc0RckDAkxkwuV0il0kNSqflhFnOZxXq8vgo/j3zw3UHIn9qGI/FmUmkJhmAIMrnFJZmlZTrGPZA/hVFBN0jMzOowFKyUoZhJze/ILKwOYDwIeeKMnvaPiGDhLW1s4Zn+Q2Cgmw+M8AsBl7cXgt/KdWpMCFnCfObsGcR818auk2BahNzCqhLDJ6JVUN/+GtEqZIcuT8OQNwOYyi3MOmYQAbEbGUH+1t1RK33CqoNdIYZt4iuskHhs6g0YqhWKnvLbiVmCFTKG4NT/Mi0E/YJafoTcpv0+DO2Qx2JdkRxErRC9nV1apeKahH11gBFZM3+LdjZXMWz11oB93ewShlzG3fq+pLuZZ+cZh1CaCLUIE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FhV0nqi5bnhc0EEnf5wnnhs+rt41etMEjLeOde7SLVhu1e4ORrlMqRBUGKFCtgb0Iwn+9JZlqPvMs4NWr+Y2OVrTXrGyteNOlFhoT1HX2YKx0KyUNmw086UHMNQ3lN5ykyOPzzo49VqL3aARo2oFMsVP5lio0i39dI7m9oPcfFQukatEvw5vSrNzGDBwF84c72Fcq5DkJ2gnlhYlJAjRks9gP6fuRL8M0+zffHqPGP+7W8xnizDObWu1tfXo0L3nT5r+QRdUQc3f+uiCFmc9B42oGRY8N0bSU/dLz21qjgOdQ3v0d/7V1r6b2q/MDAGHX+g7yq32FZ+QXSMWJ+m9mHlirI+r2yTHwcO29Bk5Ia/Ts71qu/QZcNtcbtGMH2lVls7qHPoOuO309zGqAa5vHhk7fXaM97qN/fEzKdIKJpH8AStnNnKcafsDAAAAAElFTkSuQmCC"
Clipboard_ICON_Bitmap := B64ToPBitmap( ClipBoardIcon64x64 )
G := Gdip_GraphicsFromImage( HButton.Button[ Gui1.Controls.ClipboardB64 ].Bitmaps.Default.pBitmap )
Gdip_DrawImage( G , Clipboard_ICON_Bitmap, 10 , 38 , 35 , 35 )
Gdip_DeleteGraphics( G )
G := Gdip_GraphicsFromImage( HButton.Button[ Gui1.Controls.ClipboardB64 ].Bitmaps.Hover.pBitmap )
Gdip_DrawImage( G , Clipboard_ICON_Bitmap, 5 , 35 , 45 , 45 )
Gdip_DeleteGraphics( G )
G := Gdip_GraphicsFromImage( HButton.Button[ Gui1.Controls.ClipboardB64 ].Bitmaps.Pressed.pBitmap )
Gdip_DrawImage( G , Clipboard_ICON_Bitmap, 5 , 36 , 45 , 45 )
Gdip_DeleteGraphics( G )
DeleteObject( HButton.Button[ Gui1.Controls.ClipboardB64 ].Bitmaps.Default.hBitmap )
DeleteObject( HButton.Button[ Gui1.Controls.ClipboardB64 ].Bitmaps.Hover.hBitmap )
DeleteObject( HButton.Button[ Gui1.Controls.ClipboardB64 ].Bitmaps.Pressed.hBitmap )
HButton.Button[ Gui1.Controls.ClipboardB64 ].Bitmaps.Default.hBitmap := Gdip_CreateHBITMAPFromBitmap( HButton.Button[ Gui1.Controls.ClipboardB64 ].Bitmaps.Default.pBitmap )
HButton.Button[ Gui1.Controls.ClipboardB64 ].Bitmaps.Hover.hBitmap := Gdip_CreateHBITMAPFromBitmap( HButton.Button[ Gui1.Controls.ClipboardB64 ].Bitmaps.Hover.pBitmap )
HButton.Button[ Gui1.Controls.ClipboardB64 ].Bitmaps.Pressed.hBitmap := Gdip_CreateHBITMAPFromBitmap( HButton.Button[ Gui1.Controls.ClipboardB64 ].Bitmaps.Pressed.pBitmap )
HButton._DisplayButton( Gui1.Controls.ClipboardB64 , HButton.Button[ Gui1.Controls.ClipboardB64 ].Bitmaps.Default.hBitmap )
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Gui1.Controls.SetBackgroundColorButton := New HButton( { Owner: Gui1.Hwnd , X: x := 100 , Y: 5 , W: w := 40 , H: 40 , Text: "" , Label: "SetBackgroundColor" } , { FontOptions: "Top Center " } )
QuickIcon64x64 := "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAA1LSURBVHhe7ZsHjFVFF8cfKEgNCNLUCOGLcRPEoCCCGkVjhIghWEJTEMUoNkRERRMBNWYtkRIFjAZRUSGAAgpSLMQCCCKrkIAdFXU1olgiWDnf+c2bebe8O/fdt8vy+SX+k5PdN3OmnLkzp829uX/xLw4MJJdrr9RHaaTS5H253FSlNTGaZetGW95Otvn/J1SACqUJKtB6/Ss1IW27XYnF6mW7/WdDJ91JJztLaUdcmNqS9rlbaY7+38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9BF+APw46KnIvT6DE9f/7bUdn4oU3A/AKmf74MziyjGJN8gDlxmzj5P390bkEe87bbbjNAffvih5UyHi0swi6lhduxCRGXL9j6hMgbBUYkcH1tYm0jXrl2NP54Vvhck0vDzzz+bpAvtiAhL7bzYlVj212WUsUIbBBbBkycE3BO6u/tDDz3UWIAsyOoHOHBb5G6B0A+pJg+E7L4l/6VoEnQBgkQpVOLlKN4J0maGiOU/+OADW5OMrAvA0UJBur6J7clBpgJPNvrGWBD5lQMauk7MWUrRB4BrKo6CNjXOEBqf1FYSnD9BrjEJn3zyiQms3OsxmNRHH33U1qaAOCRq80n3pSs+H2hoO8h3SMce0+jA9dX9999feMEJQkniEPFWCPcBXJm52xwWAEeJewfeIZiqWpu7BdcWc8t7BSWvwB2il6Ac427aT82hHUT1QUWFN1gKg7iAd3ncewRhateunYks+Z8nS7ot/tIE7wgQKeJLZAJPPhrtsQBDtK/aQzsLHCSI84WSyQiiNbbvZZddZlxododzc/EN8OTQ6ugOdgAxQJofUAQeCA8mNEcVPt3hKRfa4ejIToAyvjgZB1t+3jzuYvJ5xKSbnszgQYQUHrTfhXfQjnspBXkDiK9CSDaWiWXLlmnznAlmagS2fPSy05x5pf2z7X3QgXiNLvolGBYCpyNDJsihXD+gAHx7dl7xU0dZ107hZYUOROjMd36RSZhJ4TR53i8Io0YLQFIzZOIc6Vww1zUzdbWBDsyRKP4ukIUgucqEPYuReQFIvLC7YkoOsk+9PA+vLsAk7GSKJmkI88TOQBhIj8pi9SxpWnhDhIVy9WxxFjC2zR3pWHwLQB6sbr8RKgdMRic2NnUhYlSttKt588S6JEJwJS5xDvx2Lwc6QaIWvieMfmlSA9I+zOez+v8/74vRLNCJ4xO7j6bdh9JFH1pqGSbM1Vcq8dpOHX4dmsv9F9YpmBNpWErrAAAAAElFTkSuQmCC"
FloppyDiskBitmap := B64ToPBitmap( QuickIcon64x64 )
G := Gdip_GraphicsFromImage( HButton.Button[ Gui1.Controls.SetBackgroundColorButton ].Bitmaps.Default.pBitmap )
Gdip_DrawImage( G , FloppyDiskBitmap, 2 , 2 , 36 , 36 )
Gdip_DeleteGraphics( G )
G := Gdip_GraphicsFromImage( HButton.Button[ Gui1.Controls.SetBackgroundColorButton ].Bitmaps.Hover.pBitmap )
Gdip_DrawImage( G , FloppyDiskBitmap, 0 , 0 , 40 , 40 )
Gdip_DeleteGraphics( G )
G := Gdip_GraphicsFromImage( HButton.Button[ Gui1.Controls.SetBackgroundColorButton ].Bitmaps.Pressed.pBitmap )
Gdip_DrawImage( G , FloppyDiskBitmap, 1 , 1 , 38 , 38 )
Gdip_DeleteGraphics( G )
DeleteObject( HButton.Button[ Gui1.Controls.SetBackgroundColorButton ].Bitmaps.Default.hBitmap )
DeleteObject( HButton.Button[ Gui1.Controls.SetBackgroundColorButton ].Bitmaps.Hover.hBitmap )
DeleteObject( HButton.Button[ Gui1.Controls.SetBackgroundColorButton ].Bitmaps.Pressed.hBitmap )
HButton.Button[ Gui1.Controls.SetBackgroundColorButton ].Bitmaps.Default.hBitmap := Gdip_CreateHBITMAPFromBitmap( HButton.Button[ Gui1.Controls.SetBackgroundColorButton ].Bitmaps.Default.pBitmap )
HButton.Button[ Gui1.Controls.SetBackgroundColorButton ].Bitmaps.Hover.hBitmap := Gdip_CreateHBITMAPFromBitmap( HButton.Button[ Gui1.Controls.SetBackgroundColorButton ].Bitmaps.Hover.pBitmap )
HButton.Button[ Gui1.Controls.SetBackgroundColorButton ].Bitmaps.Pressed.hBitmap := Gdip_CreateHBITMAPFromBitmap( HButton.Button[ Gui1.Controls.SetBackgroundColorButton ].Bitmaps.Pressed.pBitmap )
HButton._DisplayButton( Gui1.Controls.SetBackgroundColorButton , HButton.Button[ Gui1.Controls.SetBackgroundColorButton ].Bitmaps.Default.hBitmap )
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;Add font DropDownList
FontList := []
testList := GetFontNames( 1 )
ddlList := ""
for k, v in testList {
if( inStr( k , "@" ) ){
FontList.Push( SubStr( k , 2 ) )
ddlList .= SubStr( k , 2 ) "|"
}else{
FontList.Push( k )
ddlList .= k "|"
}
if( FOntList.Length() = 250 ){
MsgBox, % "Max number of fonts reached"
break
}
}
fontsize := []
Loop, 200
FontSize.Push( A_Index + 7 )
;********************************************
BoundFunc := Func( "SetFontType" ).Bind( Gui1 )
Gui1.FontTypeDDL := New DropDownListv1( { rows: 15
, X: 150
, Y: 8
, Bind: BoundFunc
, ScaleFactor: 1
, W: 180
, FontSize: 16
;~ , FontColor: "0xFFFF0000"
, FontColor: "0xFFFFFFFF"
, Font: "Segoe UI"
, Parent: Gui1.Hwnd
, Selected: 1
, HighlightFontColor: "0xFFFFFFFF"
, MaxPanelWidth: 100
, List: FontList } )
;********************************************
;********************************************
BoundFunc := Func( "SetFontSize" ).Bind( Gui1 )
Gui1.FontSizeDDL := New DropDownListv1( { rows: 12
, X: 340
, Y: 8
, Bind: BoundFunc
, ScaleFactor: 1
, W: 80
, FontSize: 16
;~ , FontColor: "0xFFFF0000"
, FontColor: "0xFFFFFFFF"
, Font: "Segoe UI"
, Parent: Gui1.Hwnd
, Selected: 22
, HighlightFontColor: "0xFFFFFFFF"
, MaxPanelWidth: 100
, List: FontSize } )
;********************************************
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Gui1.TextDisplayString := ""
Gui, % Gui1.Hwnd ":Add", Edit, x430 y10 w380 r1 gUpdateText hwndTextStringEditHwnd , % Gui1.TextDisplayString
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Gui1.ShapeOutline := { X: 0 , Y: 0 , W: 100 , H: 100 , Radius: 50 , Type: "Rounded Rectangle" , Angle: 270 , Thickness: 1 }
Gui1.ShapeColor := "0xFFFF0000"
SetupNewImage( Gui1 , Gui1.Image.pBitmap )
cc := Gui1.OutputIconWindow := New PopUpWindow( { AutoShow: 1 , X: 500 , Y: 365 , W: 128 * Gui1.Scale , H: 128 * Gui1.Scale , Options: " +AlwaysOnTop -DPIScale Parent" Gui1.Hwnd } )
Brush := Gdip_BrushCreateHatch( "0x66000000" , "0x66ffffff" , 52 )
, Gdip_FillRoundedRectangle( Gui1.OutputIconWindow.G , Brush , 2 * Gui1.Scale , 2 * Gui1.Scale , ( cc.W - 4 ) * Gui1.Scale , ( cc.H - 4 ) * Gui1.Scale , 15 * Gui1.Scale )
, Gdip_DeleteBrush( Brush )
Gui1.OutputIconWindow.PaintBackground( { Color: "0xFFFF0000" , X: 32 , Y: 32 , W: 64 , H: 64 , Round: 10 } , AutoUpdate := 1 )
;********************************************************************************
cc := Gui1.IconStripWindow := New PopUpWindow( { AutoShow: 1 , X: 55 , Y: 500 , W: 750 * Gui1.Scale , H: 80 * Gui1.Scale , Options: " +AlwaysOnTop -DPIScale Parent" Gui1.Hwnd } )
Gui1.IconButtons := []
x := 7
Loop, % 10 {
obj := { Alpha: 255
, PulseLength: 5
, PulseRate: 1
, Animate: "Pulse"
, X: x
, Y: 8
, W: 64
, H: 64
, pBitmap: Gui1.IconPages[ Gui1.CurrentPage ][ A_Index ]
, Parent: cc.Hwnd
, Label: "IconButtonLabel" }
x += 70
Gui1.IconButtons[ A_Index ] := New IconButtons( obj )
bd := Func( "IconButtonLabel" ).Bind( Gui1 )
GuiControl, % Gui1.IconButtons[ A_Index ].Window.Hwnd ":+G" , % Gui1.IconButtons[ A_Index ].Control.Hwnd , IconButtonLabel
}
DrawSavedIcons( Gui1 )
Gui1.Controls.StripLeftButton := New HButton( { Owner: Gui1.Hwnd , X: 5 , Y:500 , W: 50 , H: 80 , Text: "3" , Label: "SavedIconPageDown" } , { Font: "WebDings" , FontSize: 26 } )
Gui1.Controls.StripRightButton := New HButton( { Owner: Gui1.Hwnd , X: 765 , Y:500 , W: 50 , H: 80 , Text: "4" , Label: "SavedIconPageUp" } , { Font: "WebDings" , FontSize: 26 } )
;********************************************************************************
GlowRadio_1.Settings.FontSize := "11"
GlowRadio_1.Settings.GroupName := "Group_3"
GlowRadio_1.Settings.Label := "SetDisplayType"
Gui1.Controls.TypeRadios := []
Gui1.Controls.TypeRadios[ 1 ] := New GlowRadio_1( { X: x := 50 , Y: y := 478 , W: w := 75 , State: 0 , Text: ".png" } )
Gui1.Controls.TypeRadios[ 2 ] := New GlowRadio_1( { X: x += w , Y: y , W: w , State: 1 , Text: "B64" } )
;********************************************************************************
OnMessage( 0x201 , Func( "ClickEvent" ).Bind( Gui1 ) )
OnMessage( 0x020A , Func( "WheelEvent" ).Bind( Gui1 ) )
Gui1.Controls.DirectionControl := New PositionButtons( { Scale: .4 , Parent: Gui1.Hwnd , X: 10 / 0.3 , Y: 3 / 0.3 , Bind: [ Func("MoveShapeUp").Bind( Gui1 ) , Func("MoveShapeDown").Bind( Gui1 ) , Func("MoveShapeLeft").Bind( Gui1 ) , Func("MoveShapeRight").Bind( Gui1 ) ] } )
cc := Gui1.ColorWheelWindow := New PopUpWindow( { AutoShow: 1 , X: 10 , Y: 60 , W: 30 , H: 380 , Options: " +AlwaysOnTop -DPIScale Parent" Gui1.Hwnd } )
cc.PaintBackground( color := "0xFF000000" , AutoUpdate := 0 )
cc.DrawBitmap( CreateColorWheelBitmap( Gui1 ) , { X: 0 , Y: 0 , W: cc.W , H: cc.H } , dispose := 1 , AutoUpdate := 1 )
return
GuiClose:
;~ GuiContextMenu:
;~ *ESC::
ExitApp
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
SetFontType( Gui1 ){
SetupNewImage( Gui1 , Gui1.Image.BackupBitmap , Gui1.Image.X , Gui1.Image.Y )
sleep, 30
}
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
SetFontSize( Gui1 ){
SetupNewImage( Gui1 , Gui1.Image.BackupBitmap , Gui1.Image.X , Gui1.Image.Y )
sleep, 30
}
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
UpdateText:
GuiControlGet, out , % Gui1.Hwnd ":" , % TextStringEditHwnd
Gui1.TextDisplayString := out
SetupNewImage( Gui1 , Gui1.Image.BackupBitmap , Gui1.Image.X , Gui1.Image.Y )
sleep, 30
return
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
SetBackgroundColor:
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
ColorGui := New PopUpWindow( { AutoShow: 1 , X: "Center" , Y: "Center" , W: 50 , H: 50 , Options: " +AlwaysOnTop -DPIScale +ToolWindow " } )
While( !GetkeyState( "ctrl" , "P" ) ){
ToolTip, Hover your cursor over the color you want to capture`nand then press "ctrl"
MouseGetPos, x , y
PixelGetColor, color , x , y , RGB
color := "0xFF" SubStr( color , 3 )
ColorGui.X := x + 30
ColorGui.Y := y - 70
ColorGui.ClearWindow()
ColorGui.PaintBackground( { Color: "0x99000000" , X: 2 , Y: 2 , W: ColorGui.W - 4 , H: ColorGui.H - 4 , Round: 15 } )
ColorGui.PaintBackground( { Color: color , X: 8 , Y: 8 , W: ColorGui.W - 16 , H: ColorGui.H - 16 , Round: 10 } , 1 )
sleep, 30
}
ToolTip,
ColorGui.DeleteWindow()
Gui1.ImageBackgroundColor := Color
SetupNewImage( Gui1 , Gui1.Image.BackupBitmap , Gui1.Image.X , Gui1.Image.Y )
return
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
SetIcon( pBitmap ){
hIcon := Gdip_CreateHICONFromBitmap( pBitmap )
Gdip_DisposeImage( pBitmap )
Menu, Tray, Icon, HICON:%hIcon%
}
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
CreateColorWheelBitmap( Gui1 ){
cc := Gui1.ColorWheelWindow
pBitmap := Gdip_CreateBitmap( w := cc.W * Gui1.Scale , h := cc.H * Gui1.Scale )
G := Gdip_GraphicsFromImage( pBitmap )
Gdip_SetSmoothingMode( G , 1 )
HueRate := 1 / Gui1.Scale
SatRate := 1 / h
Sat := 1
lum := 0.5
x := 1
Loop, % w {
y := 1 , Hue := 1
Loop, % h {
Gdip_SetPixel( pBitmap, x , y , "0xFF" SubStr( HSL_ToRGB( hue , sat , lum ) , 3 ) )
y++ , hue += HueRate
}
x++ , Sat -= SatRate
}
Gdip_DeleteGraphics( G )
return pBitmap
}
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
MoveShapeUp( Gui1 ){
ly := Gui1.ShapeOutline.Y
( GetKeyState( "Ctrl" ) ) ? ( Gui1.ShapeOutline.Y -= 100 ) : ( GetKeyState( "Shift" ) ) ? ( Gui1.ShapeOutline.Y -= 10 ) : ( Gui1.ShapeOutline.Y -= 1 )
( Gui1.ShapeOutline.Y < ( Gui1.ShapeOutline.H / 2 ) * -1 ) ? ( Gui1.ShapeOutline.Y := ( Gui1.ShapeOutline.H / 2 ) * -1 )
if( ly != Gui1.ShapeOutline.Y )
UpdateWindow( Gui1 )
return
}
MoveShapeDown( Gui1 ){
ly := Gui1.ShapeOutline.Y
( GetKeyState( "Ctrl" ) ) ? ( Gui1.ShapeOutline.Y += 100 ) : ( GetKeyState( "Shift" ) ) ? ( Gui1.ShapeOutline.Y += 10 ) : ( Gui1.ShapeOutline.Y += 1 )
( Gui1.ShapeOutline.Y > 400 - ( Gui1.ShapeOutline.H / 2 ) ) ? ( Gui1.ShapeOutline.Y := 400 - ( Gui1.ShapeOutline.H / 2 ) )
if( ly != Gui1.ShapeOutline.Y )
UpdateWindow( Gui1 )
return
}
MoveShapeLeft( Gui1 ){
lx := Gui1.ShapeOutline.X
( GetKeyState( "Ctrl" ) ) ? ( Gui1.ShapeOutline.X -= 100 ) : ( GetKeyState( "Shift" ) ) ? ( Gui1.ShapeOutline.X -= 10 ) : ( Gui1.ShapeOutline.X -= 1 )
( Gui1.ShapeOutline.X < ( Gui1.ShapeOutline.W / 2 ) * -1 ) ? ( Gui1.ShapeOutline.X := ( Gui1.ShapeOutline.W / 2 ) * -1 )
if( lx != Gui1.ShapeOutline.X )
UpdateWindow( Gui1 )
return
}
MoveShapeRight( Gui1 ){
lx := Gui1.ShapeOutline.X
( GetKeyState( "Ctrl" ) ) ? ( Gui1.ShapeOutline.X += 100 ) : ( GetKeyState( "Shift" ) ) ? ( Gui1.ShapeOutline.X += 10 ) : ( Gui1.ShapeOutline.X += 1 )
( Gui1.ShapeOutline.X > 400 - ( Gui1.ShapeOutline.W / 2 ) ) ? ( Gui1.ShapeOutline.X := 400 - ( Gui1.ShapeOutline.W / 2 ) )
if( lx != Gui1.ShapeOutline.X )
UpdateWindow( Gui1 )
return
}
LoadImageFromFile:
ToolTip, Currently Not Available
sleep, 2000
ToolTip
return
GetImageFilePath:
ToolTip, Currently Not Available
sleep, 2000
ToolTip
return
SetDisplayType:
ToolTip, Not enabled yet
sleep, 1500
ToolTip
return
ClipboardBase64:
Clipboard := ""
sleep, 500
out := Gdip_EncodeBitmapTo64string( Gui1.CroppedBitmap , "PNG" , 100 )
Clipboard := Out
SoundBeep
return
SaveNewB64Icon:
out := Gdip_EncodeBitmapTo64string( Gui1.CroppedBitmap , "PNG" , 100 )
name := "Icon_B64_" A_Now ".txt"
FileAppend, % out , % A_ScriptDir "\Saved Icon Images\" name
Gui1.SavedB64Bitmaps.push( Gdip_CloneBitmapArea( Gui1.CroppedBitmap , 0 , 0 , 64 , 64 ) )
;**********************************************
Gui1.IconPages := []
page := 0
Loop, % Gui1.SavedB64Bitmaps.Length() {
if( A_Index = 1 || !mod( inDex , 10 ) ){
page++
Gui1.IconPages[ page ] := []
inDex := 0
}
Gui1.IconPages[ page ][ ++Index ] := Gui1.SavedB64Bitmaps[ A_Index ]
}
Gui1.CurrentPage := page
Gui1.NumberOfPages := page
DrawSavedIcons( Gui1 )
;**********************************************
SoundBeep
return
SavedIconPageDown:
if( Gui1.CurrentPage > 1 ){
Gui1.CurrentPage--
DrawSavedIcons( Gui1 )
}
return
SavedIconPageUp:
if( Gui1.CurrentPage < Gui1.NumberOfPages ){
Gui1.CurrentPage++
DrawSavedIcons( Gui1 )
}
return
DrawSavedIcons( Gui1 ){
cc := Gui1.IconStripWindow
cc.ClearWindow()
cc.PaintBackground( { Color: "0xFF22262a" , X: 2 , Y: 2 , W: 705 , H: cc.H - 4 , Round: 10 } , AutoUpdate := 1 )
cc.PaintBackground( { Color: "0xFF12161a" , X: x := 7 , Y: 8 , W: 64 , H: cc.H - 16 , Round: 10 } , AutoUpdate := 1 )
cc.PaintBackground( { Color: "0xFF12161a" , X: x += 70 , Y: 8 , W: 64 , H: cc.H - 16 , Round: 10 } , AutoUpdate := 1 )
cc.PaintBackground( { Color: "0xFF12161a" , X: x += 70 , Y: 8 , W: 64 , H: cc.H - 16 , Round: 10 } , AutoUpdate := 1 )
cc.PaintBackground( { Color: "0xFF12161a" , X: x += 70 , Y: 8 , W: 64 , H: cc.H - 16 , Round: 10 } , AutoUpdate := 1 )
cc.PaintBackground( { Color: "0xFF12161a" , X: x += 70 , Y: 8 , W: 64 , H: cc.H - 16 , Round: 10 } , AutoUpdate := 1 )
cc.PaintBackground( { Color: "0xFF12161a" , X: x += 70 , Y: 8 , W: 64 , H: cc.H - 16 , Round: 10 } , AutoUpdate := 1 )
cc.PaintBackground( { Color: "0xFF12161a" , X: x += 70 , Y: 8 , W: 64 , H: cc.H - 16 , Round: 10 } , AutoUpdate := 1 )
cc.PaintBackground( { Color: "0xFF12161a" , X: x += 70 , Y: 8 , W: 64 , H: cc.H - 16 , Round: 10 } , AutoUpdate := 1 )
cc.PaintBackground( { Color: "0xFF12161a" , X: x += 70 , Y: 8 , W: 64 , H: cc.H - 16 , Round: 10 } , AutoUpdate := 1 )
cc.PaintBackground( { Color: "0xFF12161a" , X: x += 70 , Y: 8 , W: 64 , H: cc.H - 16 , Round: 10 } , AutoUpdate := 1 )
x := 7
Loop, % Gui1.IconPages[ Gui1.CurrentPage ].Length() {
Brush := Gdip_BrushCreateHatch( "0x66000000" , "0x66ffffff" , 52 )
, Gdip_FillRectangle( cc.G , Brush , x * Gui1.Scale , 8 * Gui1.Scale , 64 * Gui1.Scale , 64 * Gui1.Scale )
, Gdip_DeleteBrush( Brush )
x += 70
}
Loop, 10 {
Gui1.IconButtons[ A_Index ].Bitmap.pBitmap := Gui1.IconPages[ Gui1.CurrentPage ][ A_Index ]
Gui1.IconButtons[ A_Index ].Draw()
}
cc.UpdateWindow()
}
SavePNGToFIle:
SoundBeep
path := A_ScriptDir "\Saved Icon Images\Icon_" A_Now ".png"
Gdip_SaveBitmapToFile( Gui1.CroppedBitmap , path , 100 )
return
TestFunction( Gui1 ){
Gui1.SelectedShape := Gui1.ShapesArray[ Gui1.ShapeListDDL.Selected ]
Gui1.ShapeOutline.Type := Gui1.SelectedShape
if( Gui1.SelectedShape = "Rectangle" )
Gui1.ShapeOutline.Angle := 45
else
Gui1.ShapeOutline.Angle := 270
UpdateWindow( Gui1 )
return
}
CaptureNewImageFromScreen:
Target := New DrawTarget()
pBitmap := Gdip_BitmapFromScreen( Target.X "|" Target.Y "|" Target.W "|" Target.H )
SetupNewImage( Gui1 , pBitmap )
return
SetBorderThickness:
Gui1.ShapeOutline.Thickness := Gui1.BorderThicknessList[ Gui1.Controls.BorderThicknessRadios[ 1 ].GetSelected() ]
UpdateWindow( Gui1 )
return
SetImageScale:
Gui1.Image.Scale := Gui1.ScaleList[ Gui1.Controls.ScaleRadios[ 1 ].GetSelected() ]
SetupNewImage( Gui1 , Gui1.Image.BackupBitmap )
return
rotateShape:
Gui1.ShapeOutline.Angle += 3
UpdateWindow( Gui1 )
return
SetupNewImage( Gui1 , nBitmap , iX := "" , iY := "" ){
;~ Gdip_DisposeImage( Gui1.Image.BackupBitmap )
;~ Gdip_DisposeImage( Gui1.Image.pBitmap )
Gui1.Image.BackupBitmap := nBitmap
oW := W := Gdip_GetImageWidth( nBitmap )
oH := H := Gdip_GetImageHeight( nBitmap )
w += 600
h += 600
pBitmap := Gdip_CreateBitmap( w , h )
G := Gdip_GraphicsFromImage( pBitmap )
Gdip_SetInterpolationMode(G, 7)
Brush := Gdip_BrushCreateSolid( Gui1.ImageBackgroundColor )
Gdip_FillRectangle( G , Brush , -2 , -2 , w + 4 , h + 4 )
Gdip_DeleteBrush( Brush )
Gdip_DrawImage( G , nBitmap, 300 , 300 , w - 600 , h - 600 )
Gui1.Image.pBitmap := pBitmap
if( Gui1.TextDisplayString != "" ){
x := 300 , y := 300 , w := oW , h := oH
color := Gui1.ShapeColor
fs := Gui1.FontSizeDDL.Value
fontType := Gui1.FontTypeDDL.Value
string := strSplit( Gui1.TextDisplayString )
out := ""
for k , v in string {
if( broken ){
broken := 0
continue
}
if( v = "``" ){
if( string[ k + 1 ] = "n" ){
out .= "`n"
broken := 1
;~ MsgBox, % out
}else{
out .= v
}
}else{
out .= v
}
}
;~ ToolTip, % "Tip:`n" out
Brush := Gdip_BrushCreateSolid( color )
Gdip_TextToGraphics( G , out , "s" fs " Center vCenter Bold c" Brush " x" x " y" y , FontType , w , h )
Gdip_DeleteBrush( Brush )
}
Gdip_DeleteGraphics( G )
Gui1.Image.W := Gdip_GetImageWidth( Gui1.Image.pBitmap )
Gui1.Image.H := Gdip_GetImageHeight( Gui1.Image.pBitmap )
w := Gui1.Image.W *= Gui1.Image.Scale
h := Gui1.Image.H *= Gui1.Image.Scale
if( iX = "" )
Gui1.Image.X := -300 * Gui1.Image.Scale
if( iY = "" )
Gui1.Image.Y := -300 * Gui1.Image.Scale
G := Gdip_GraphicsFromImage( Gui1.Display.pBitmap )
Gdip_SetInterpolationMode(G, 7)
Brush := Gdip_BrushCreateSolid( "0xFF000000" )
Gdip_FillRectangle( G , Brush , -10 , -10 , 500 , 500 )
Gdip_DeleteBrush( Brush )
Gdip_DrawImage( G , pBitmap , Gui1.Image.X , Gui1.Image.Y , w , h )
DrawShape( Gui1 , G )
hBitmap := Gdip_CreateHBITMAPFromBitmap( Gui1.Display.pBitmap )
SetImage( Gui1.Controls.DisplayPicture.hwnd , hBitmap )
DeleteObject( hBitmap )
Gdip_DeleteGraphics( G )
cc := Gui1.Controls.Image_X_Thumb
cc.X := Gui1.Controls.Image_X_Slider.X
if( w <= 400 ){
cc.W := 400
GuiControl, % Gui1.Hwnd ":Move" , % Gui1.Controls.Image_X_Thumb.Hwnd , % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H
cc.TScale := 0
}else if( w <= 750 ){
cc.W := 800 - w
GuiControl, % Gui1.Hwnd ":Move" , % Gui1.Controls.Image_X_Thumb.Hwnd , % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H
cc.TScale := 1
}else{
cc.W := 50
cc.TScale := w / 400
GuiControl, % Gui1.Hwnd ":Move" , % Gui1.Controls.Image_X_Thumb.Hwnd , % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H
}
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
cc := Gui1.Controls.Image_Y_Thumb
cc.Y := Gui1.Controls.Image_Y_Slider.Y
if( h <= 400 ){
cc.H := 400
GuiControl, % Gui1.Hwnd ":Move" , % Gui1.Controls.Image_Y_Thumb.Hwnd , % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H
cc.TScale := 0
}else if( h <= 750 ){
cc.H := 800 - h
GuiControl, % Gui1.Hwnd ":Move" , % Gui1.Controls.Image_Y_Thumb.Hwnd , % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H
cc.TScale := 1
}else{
cc.H := 50
cc.TScale := h / 400
GuiControl, % Gui1.Hwnd ":Move" , % Gui1.Controls.Image_Y_Thumb.Hwnd , % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H
}
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
}
ClickEvent( Gui1 , w , l , msg , hwnd ){
CoordMode, Mouse, Client
MouseGetPos, x , y
x /= Gui1.Scale
y /= Gui1.Scale
for k , v in [ "Image_Y_Slider" , "Image_X_Slider" ] {
cc := Gui1.Controls[ v ]
str := SubStr( v , 1 , strlen( v ) - 6 ) "Thumb"
thumb := Gui1.Controls[ str ]
if( x >= cc.X && x <= cc.X + cc.W && y >= cc.Y && y <= cc.Y + cc.H ){
if( Thumb.TScale ){
SetThumbPosition( Gui1 , cc , Thumb , v )
Sleep, 30
return 1
}
}
}
cc := Gui1.Controls.DisplayPicture
if( x >= cc.X && x <= cc.X + cc.W && y >= cc.Y && y <= cc.Y + cc.H ){
x -= 50
y -= 50
MouseVector := New Vector( x , y )
ShapeVector := New Vector( Gui1.ShapeOutline.X + Gui1.ShapeOutline.W / 2 , Gui1.ShapeOutline.Y + Gui1.ShapeOutline.H / 2 )
Gui1.AngleVector := New Vector( Gui1.ShapeOutline.X - 20 + 7 , Gui1.ShapeOutline.Y + Gui1.ShapeOutline.H / 2 )
LeftVector := New Vector( Gui1.AngleVector )
Gui1.ColorVector := New Vector( Gui1.AngleVector.X , Gui1.ShapeOutline.Y + Gui1.ShapeOutline.H / 2 + 20 )
if( MouseVector.Dist( ShapeVector ) < Gui1.ShapeOutline.Radius ){
While( GetKeyState( "LButton" , "P" ) ){
MouseGetPos, x , y
x -= 50
y -= 50
if( x < 0 )
x := 0
else if( x > 400 * Gui1.Scale )
x := 400 * Gui1.Scale
if( y < 0 )
y := 0
else if( y > 400 * Gui1.Scale )
y := 400 * Gui1.Scale
Gui1.ShapeOutline.X := x - Gui1.ShapeOutline.Radius
Gui1.ShapeOutline.Y := y - Gui1.ShapeOutline.Radius
UpdateWindow( Gui1 )
Sleep, 30
}
}else if( MouseVector.Dist( LeftVector ) < 15 ){
While( GetKeyState( "LButton" , "P" ) ){
MouseGetPos, x , y
x -= 50
y -= 50
MouseVector := New Vector( x , y )
MouseVector.Sub( { X: Gui1.ShapeOutline.X + Gui1.ShapeOutline.W / 2 , Y: Gui1.ShapeOutline.Y + Gui1.ShapeOutline.H / 2 } )
Gui1.ShapeOutline.Angle := MouseVector.GetAngle()
UpdateWindow( Gui1 )
Sleep, 30
}
}else if( MouseVector.Dist( Gui1.ColorVector ) < 15 ){
colorGui := New PopUpWindow( { AutoShow: 1 , X: x + 100, Y: y - 25 , W: 50 , H: 50 , Options: " +AlwaysOnTop -DPIScale +Owner" Gui1.Hwnd } )
While( GetKeyState( "LButton" , "P" ) ){
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
MouseGetPos, x , y
PixelGetColor, OutColor , x , y , RGB
colorGui.X := x + 100
colorGui.Y := y - 25
colorGui.PaintBackground( { color: "0xFF" SubStr( OutColor , 3 ) , X: 2 , Y: 2 , W: colorGui.W - 4 , H: colorGui.H - 4 , Round: 10 } , AutoUpdate := 1 )
Gui1.ShapeColor := "0xFF" SubStr( OutColor , 3 )
UpdateWindow( Gui1 )
Sleep, 30
}
colorGui.DeleteWindow()
}
}
cc := Gui1.IconStripWindow
if( x >= cc.X && x <= cc.X + cc.W && y >= cc.Y && y <= cc.Y + cc.H ){
tx := x
ty := y
x -= cc.X
y -= cc.Y
Loop, 10 {
cc := Gui1.IconButtons[ A_Index ].Window
if( x >= cc.X && x <= cc.X + cc.W && y >= cc.Y && y <= cc.Y + cc.H ){
if( Gui1.IconPages[ Gui1.CurrentPage ][ A_Index ] ){
Clipboard := ""
sleep, 500
out := Gdip_EncodeBitmapTo64string( Gui1.SavedB64Bitmaps[ ( Gui1.CurrentPage * 10 - 10 ) + A_Index ] , "PNG" , 100 )
Clipboard := Out
SoundBeep
}
return 1
}
}
}
return
}
SetThumbPosition( Gui1 , Slider , Thumb , ControlName ){
CoordMode, Mouse, Client
While( GetKeyState( "LButton" , "P" ) ){
MouseGetPos, x , y
change := 0
if( ControlName = "Image_X_Slider" ){
if( x < Slider.X + Thumb.W / 2 && x != lx ){
lx := x
Thumb.X := Slider.X
change := 1
}else if( x > Slider.X + Slider.W - Thumb.W / 2 && x != lx ){
lx := x
Thumb.X := Slider.X + Slider.W - Thumb.W
change := 1
}else if( x != lx ){
lx := x
Thumb.X := x - Thumb.W / 2
change := 1
}
if( change ){
MoveSliderThumbControl( Gui1 , Thumb )
if( Gui1.Image.W >= 750 ){
Gui1.Image.X := ( Slider.X - Thumb.X )
Gui1.Image.X *= Thumb.TScale
}else{
Gui1.Image.X := ( Slider.X - Thumb.X )
}
UpdateWindow( Gui1 )
}
}else if( ControlName = "Image_Y_Slider" ){
if( y < Slider.Y + Thumb.H / 2 && y != ly ){
ly := y
Thumb.Y := Slider.Y
change := 1
}else if( y > Slider.Y + Slider.H - Thumb.H / 2 && y != ly ){
ly := y
Thumb.Y := Slider.Y + Slider.H - Thumb.H
change := 1
}else if( y != ly ){
ly := y
Thumb.Y := y - Thumb.H / 2
change := 1
}
if( change ){
MoveSliderThumbControl( Gui1 , Thumb )
if( Gui1.Image.H >= 750 ){
Gui1.Image.Y := ( Slider.Y - Thumb.Y )
Gui1.Image.Y *= Thumb.TScale
}else{
Gui1.Image.Y := ( Slider.Y - Thumb.Y )
}
UpdateWindow( Gui1 )
}
}
}
}
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
WheelEvent( Gui1 , input ){
static Busy
if( Busy )
return
Busy := 1
MouseGetPos,,,, ctrl , 2
cc := Gui1.Controls.DisplayPicture
if( cc.Hwnd != ctrl ){
busy := 0
return
}
Dir := ( (input >> 16 ) > 0x7FFF ) || ( ( input < 0 ) ? ( 1 ) : ( 0 ) )
cc := Gui1.ShapeOutline
if( Dir ){ ;wheel Up
if( GetKeyState( "Shift" ) ){
if( cc.W < Gui1.Controls.DisplayPicture.W - 10 ){
cc.X -= 5
cc.Y -= 5
cc.W += 10
cc.H += 10
cc.Radius += 5
UpdateWindow( Gui1 )
}
}else{
if( cc.W < Gui1.Controls.DisplayPicture.W ){
cc.X -= 1
cc.Y -= 1
cc.W += 2
cc.H += 2
cc.Radius += 1
UpdateWindow( Gui1 )
}
}
}else{ ;wheel down
if( GetKeyState( "Shift" ) ){
if( cc.W > 50 ){
cc.X += 5
cc.Y += 5
cc.W -= 10
cc.H -= 10
cc.Radius -= 5
}else if( cc.W != 50 ){
out := ( 50 - cc.W )
}
UpdateWindow( Gui1 )
}else{
if( cc.W > 50 ){
cc.X += 1
cc.Y += 1
cc.W -= 2
cc.H -= 2
cc.Radius -= 1
}
UpdateWindow( Gui1 )
}
}
Busy := 0
return 1
}
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
LoadImageFromClipboard:
clip := Clipboard
nStr := SubStr( Clip , StrLen( Clip ) - 2 )
tempStringBitmap := B64ToPBitmap( clip )
width := Gdip_GetImageWidth( tempStringBitmap )
if( width ){
Gui1.Image.pBitmap := tempStringBitmap
}else if( nStr = "png" || nStr = "jpg" ){
Gdip_DisposeImage( Gui1.Image.pBitmap )
Gui1.Image.pBitmap := Gdip_CreateBitmapFromFile( clip )
}else{
Gdip_DisposeImage( Gui1.Image.pBitmap )
Gui1.Image.pBitmap := Gdip_CreateBitmapFromClipboard()
}
SetupNewImage( Gui1 , Gui1.Image.pBitmap )
return
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
UpdateWindow( Gui1 ){
G := Gdip_GraphicsFromImage( Gui1.Display.pBitmap )
Gdip_SetSmoothingMode( G , 2 )
Gdip_SetInterpolationMode(G, 7)
Brush := Gdip_BrushCreateSolid( "0xFF000000" )
Gdip_FillEllipse( G , Brush , -500 , -500 , 1400 , 1400 )
Gdip_DeleteBrush( Brush )
Gdip_DrawImage( G , Gui1.Image.pBitmap , Gui1.Image.X , Gui1.Image.Y , Gui1.Image.W , Gui1.Image.H )
DrawShape( Gui1 , G )
hBitmap := Gdip_CreateHBITMAPFromBitmap( Gui1.Display.pBitmap )
SetImage( Gui1.Controls.DisplayPicture.hwnd , hBitmap )
DeleteObject( hBitmap )
Gdip_DeleteGraphics( G )
}
DrawShape( Gui1 , G ){
cc := Gui1.ShapeOutline
Pen := Gdip_CreatePen( "0xFF3399FF" , ceil( 1 * Gui1.Scale ) )
, Gdip_DrawRectangle( G , Pen , cc.X * Gui1.Scale , cc.Y * Gui1.Scale , cc.W * Gui1.Scale , cc.H * Gui1.Scale )
, Gdip_DeletePen( Pen )
;Angle vector
cc := Gui1.ShapeOutline
x := cc.X - 20
y := cc.Y + cc.H / 2 - 7
w := 15
h := 15
Pen := Gdip_CreatePen( "0xFF3399FF" , ceil( 2 * Gui1.Scale ) )
, Gdip_DrawEllipse( G , Pen , X * Gui1.Scale , Y * Gui1.Scale , W * Gui1.Scale , H * Gui1.Scale )
, Gdip_DeletePen( Pen )
;Color vector
cc := Gui1.ShapeOutline
x := Gui1.ShapeOutline.X - 20
y := Gui1.ShapeOutline.Y + Gui1.ShapeOutline.H / 2 + 20
w := 15
h := 15
Pen := Gdip_CreatePen( "0xFF3399FF" , ceil( 2 * Gui1.Scale ) )
, Gdip_DrawEllipse( G , Pen , X * Gui1.Scale , Y * Gui1.Scale , W * Gui1.Scale , H * Gui1.Scale )
, Gdip_DeletePen( Pen )
Color := Gui1.ShapeColor
if( Gui1.SelectedShape = "Triangle" ){
Radius := Floor( Gui1.ShapeOutline.W / 2 - Gui1.ShapeOutline.Thickness )
Gui1.MyShape := MyShape := PolygonShapes( New Vector( Gui1.ShapeOutline.X + Gui1.ShapeOutline.W / 2 , Gui1.ShapeOutline.Y + Gui1.ShapeOutline.H / 2 ) , Radius , Gui1.ShapeOutline.angle , Gui1.Sides := 3 , returnString := 1 , AddExtraWrapArm := 1 )
DrawPolygon( G , MyShape , Color , 1 )
}else if( Gui1.SelectedShape = "Pentagon" ){
Gui1.MyShape := MyShape := PolygonShapes( New Vector( Gui1.ShapeOutline.X + Gui1.ShapeOutline.W / 2 , Gui1.ShapeOutline.Y + Gui1.ShapeOutline.H / 2 ) , Gui1.ShapeOutline.W / 2 , Gui1.ShapeOutline.angle , Gui1.Sides := 5 , returnString := 1 , AddExtraWrapArm := 1 )
DrawPolygon( G , MyShape , Color , 1 )
}else if( Gui1.SelectedShape = "Hexagon" ){
Gui1.MyShape := MyShape := PolygonShapes( New Vector( Gui1.ShapeOutline.X + Gui1.ShapeOutline.W / 2 , Gui1.ShapeOutline.Y + Gui1.ShapeOutline.H / 2 ) , Gui1.ShapeOutline.W / 2 , Gui1.ShapeOutline.angle , Gui1.Sides := 6 , returnString := 1 , AddExtraWrapArm := 1 )
DrawPolygon( G , MyShape , Color , 1 )
}else if( Gui1.SelectedShape = "Heptagon" ){
Gui1.MyShape := MyShape := PolygonShapes( New Vector( Gui1.ShapeOutline.X + Gui1.ShapeOutline.W / 2 , Gui1.ShapeOutline.Y + Gui1.ShapeOutline.H / 2 ) , Gui1.ShapeOutline.W / 2 , Gui1.ShapeOutline.angle , Gui1.Sides := 7 , returnString := 1 , AddExtraWrapArm := 1 )
DrawPolygon( G , MyShape , Color , 1 )
}else if( Gui1.SelectedShape = "Octagon" ){
Gui1.MyShape := MyShape := PolygonShapes( New Vector( Gui1.ShapeOutline.X + Gui1.ShapeOutline.W / 2 , Gui1.ShapeOutline.Y + Gui1.ShapeOutline.H / 2 ) , Gui1.ShapeOutline.W / 2 , Gui1.ShapeOutline.angle , Gui1.Sides := 8 , returnString := 1 , AddExtraWrapArm := 1 )
DrawPolygon( G , MyShape , Color , 1 )
}else if( Gui1.SelectedShape = "Hexadecagon" ){
Gui1.MyShape := MyShape := PolygonShapes( New Vector( Gui1.ShapeOutline.X + Gui1.ShapeOutline.W / 2 , Gui1.ShapeOutline.Y + Gui1.ShapeOutline.H / 2 ) , Gui1.ShapeOutline.W / 2 , Gui1.ShapeOutline.angle , Gui1.Sides := 16 , returnString := 1 , AddExtraWrapArm := 1 )
DrawPolygon( G , MyShape , Color , 1 )
}else if( Gui1.SelectedShape = "Circle" ){
cc := Gui1.ShapeOutline
x := cc.X + ceil( Gui1.ShapeOutline.Thickness / 2 ) + 1
y := cc.Y + ceil( Gui1.ShapeOutline.Thickness / 2 ) + 1
w := cc.W - Gui1.ShapeOutline.Thickness - 2
h := cc.H - Gui1.ShapeOutline.Thickness - 2
Pen := Gdip_CreatePen( Color , ceil( 1 * Gui1.Scale ) )
, Gdip_DrawEllipse( G , Pen , X * Gui1.Scale , Y * Gui1.Scale , W * Gui1.Scale , H * Gui1.Scale )
, Gdip_DeletePen( Pen )
}else if( Gui1.SelectedShape = "Rectangle" ){
Radius := Floor( Gui1.ShapeOutline.W / 2 - Gui1.ShapeOutline.Thickness )
Gui1.MyShape := MyShape := PolygonShapes( New Vector( Gui1.ShapeOutline.X + Gui1.ShapeOutline.W / 2 , Gui1.ShapeOutline.Y + Gui1.ShapeOutline.H / 2 ) , Radius , Gui1.ShapeOutline.angle , Gui1.Sides := 4 , returnString := 1 , AddExtraWrapArm := 1 )
DrawPolygon( G , MyShape , Color , 1 )
}else if( Gui1.SelectedShape = "Rounded Rectangle" ){
cc := Gui1.ShapeOutline
x := cc.X + ceil( Gui1.ShapeOutline.Thickness / 2 ) + 1
y := cc.Y + ceil( Gui1.ShapeOutline.Thickness / 2 ) + 1
w := cc.W - Gui1.ShapeOutline.Thickness - 2
h := cc.H - Gui1.ShapeOutline.Thickness - 2
Pen := Gdip_CreatePen( Color , ceil( Gui1.ShapeOutline.Thickness * Gui1.Scale ) )
, Gdip_DrawRoundedRectangle( G , Pen , X * Gui1.Scale , Y * Gui1.Scale , W * Gui1.Scale , H * Gui1.Scale , 10 * Gui1.Scale )
, Gdip_DeletePen( Pen )
}
CreateCroppedIcon( Gui1 )
}
CreateCroppedIcon( Gui1 ){
pBitmap := Gdip_CreateBitmap( 64 , 64 )
G := Gdip_GraphicsFromImage( pBitmap )
Gdip_SetSmoothingMode( G , 2 )
Gdip_SetInterpolationMode(G, 7)
sx := ( Gui1.ShapeOutline.X - Gui1.Image.X ) / Gui1.Image.Scale
sy := ( Gui1.ShapeOutline.Y - Gui1.Image.Y ) / Gui1.Image.Scale
sw := Gui1.ShapeOutline.W / Gui1.Image.Scale
sh := Gui1.ShapeOutline.H / Gui1.Image.Scale
Gdip_DrawImage( G , Gui1.Image.pBitmap , 0 , 0 , 64 , 64 , sx , sy , sw , sh )
Gdip_DisposeImage( Gui1.CroppedBitmap )
Gui1.CroppedBitmap := CroppedBitmap := Gdip_CreateBitmap( 64 , 64 )
G2 := Gdip_GraphicsFromImage( CroppedBitmap )
Gdip_SetSmoothingMode( G2 , 2 )
TextureBrush := Gdip_CreateTextureBrush( pBitmap )
Gdip_DisposeImage( pBitmap )
Color := Gui1.ShapeColor
if( Gui1.SelectedShape = "Triangle" ){
w := 64
Radius := Floor( w / 2 - Gui1.ShapeOutline.Thickness )
MyShape := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius , Gui1.ShapeOutline.angle , Gui1.Sides := 3 , returnString := 1 , AddExtraWrapArm := 1 )
MyShape2 := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius + Gui1.ShapeOutline.Thickness , Gui1.ShapeOutline.angle , Gui1.Sides := 3 , returnString := 1 , AddExtraWrapArm := 1 )
Gdip_FillPolygon( G2 , TextureBrush , MyShape ) , Gdip_DeleteBrush( TextureBrush )
if( Gui1.ShapeOutline.Thickness )
DrawPolygon( G2 , MyShape , Color , Gui1.ShapeOutline.Thickness )
}else if( Gui1.SelectedShape = "Pentagon" ){
w := 64
Radius := Floor( w / 2 - Gui1.ShapeOutline.Thickness )
MyShape := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius , Gui1.ShapeOutline.angle , Gui1.Sides := 5 , returnString := 1 , AddExtraWrapArm := 1 )
MyShape2 := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius + Gui1.ShapeOutline.Thickness , Gui1.ShapeOutline.angle , Gui1.Sides := 3 , returnString := 1 , AddExtraWrapArm := 1 )
Gdip_FillPolygon( G2 , TextureBrush , MyShape ) , Gdip_DeleteBrush( TextureBrush )
if( Gui1.ShapeOutline.Thickness )
DrawPolygon( G2 , MyShape , Color , Gui1.ShapeOutline.Thickness )
}else if( Gui1.SelectedShape = "Hexagon" ){
w := 64
Radius := Floor( w / 2 - Gui1.ShapeOutline.Thickness )
MyShape := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius , Gui1.ShapeOutline.angle , Gui1.Sides := 6 , returnString := 1 , AddExtraWrapArm := 1 )
MyShape2 := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius + Gui1.ShapeOutline.Thickness , Gui1.ShapeOutline.angle , Gui1.Sides := 3 , returnString := 1 , AddExtraWrapArm := 1 )
Gdip_FillPolygon( G2 , TextureBrush , MyShape ) , Gdip_DeleteBrush( TextureBrush )
if( Gui1.ShapeOutline.Thickness )
DrawPolygon( G2 , MyShape , Color , Gui1.ShapeOutline.Thickness )
}else if( Gui1.SelectedShape = "Heptagon" ){
w := 64
Radius := Floor( w / 2 - Gui1.ShapeOutline.Thickness )
MyShape := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius , Gui1.ShapeOutline.angle , Gui1.Sides := 7 , returnString := 1 , AddExtraWrapArm := 1 )
MyShape2 := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius + Gui1.ShapeOutline.Thickness , Gui1.ShapeOutline.angle , Gui1.Sides := 3 , returnString := 1 , AddExtraWrapArm := 1 )
Gdip_FillPolygon( G2 , TextureBrush , MyShape ) , Gdip_DeleteBrush( TextureBrush )
if( Gui1.ShapeOutline.Thickness )
DrawPolygon( G2 , MyShape , Color , Gui1.ShapeOutline.Thickness )
}else if( Gui1.SelectedShape = "Octagon" ){
w := 64
Radius := Floor( w / 2 - Gui1.ShapeOutline.Thickness )
MyShape := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius , Gui1.ShapeOutline.angle , Gui1.Sides := 8 , returnString := 1 , AddExtraWrapArm := 1 )
MyShape2 := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius + Gui1.ShapeOutline.Thickness , Gui1.ShapeOutline.angle , Gui1.Sides := 3 , returnString := 1 , AddExtraWrapArm := 1 )
Gdip_FillPolygon( G2 , TextureBrush , MyShape ) , Gdip_DeleteBrush( TextureBrush )
if( Gui1.ShapeOutline.Thickness )
DrawPolygon( G2 , MyShape , Color , Gui1.ShapeOutline.Thickness )
}else if( Gui1.SelectedShape = "Hexadecagon" ){
w := 64
Radius := Floor( w / 2 - Gui1.ShapeOutline.Thickness )
MyShape := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius , Gui1.ShapeOutline.angle , Gui1.Sides := 16 , returnString := 1 , AddExtraWrapArm := 1 )
MyShape2 := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius + Gui1.ShapeOutline.Thickness , Gui1.ShapeOutline.angle , Gui1.Sides := 3 , returnString := 1 , AddExtraWrapArm := 1 )
Gdip_FillPolygon( G2 , TextureBrush , MyShape ) , Gdip_DeleteBrush( TextureBrush )
if( Gui1.ShapeOutline.Thickness )
DrawPolygon( G2 , MyShape , Color , Gui1.ShapeOutline.Thickness )
}else if( Gui1.SelectedShape = "Circle" ){
cc := Gui1.ShapeOutline
x := ceil( Gui1.ShapeOutline.Thickness / 2 ) + 1
y := ceil( Gui1.ShapeOutline.Thickness / 2 ) + 1
w := 64 - Gui1.ShapeOutline.Thickness - 2
h := 64 - Gui1.ShapeOutline.Thickness - 2
Gdip_FillEllipse( G2 , TextureBrush , X * Gui1.Scale , Y * Gui1.Scale , W * Gui1.Scale , H * Gui1.Scale )
if( Gui1.ShapeOutline.Thickness )
Pen := Gdip_CreatePen( Color , ceil( Gui1.ShapeOutline.Thickness * Gui1.Scale ) )
, Gdip_DrawEllipse( G2 , Pen , X * Gui1.Scale , Y * Gui1.Scale , W * Gui1.Scale , H * Gui1.Scale )
, Gdip_DeletePen( Pen )
}else if( Gui1.SelectedShape = "Rectangle" ){
w := 64
Radius := Floor( w / 2 - Gui1.ShapeOutline.Thickness )
MyShape := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius , Gui1.ShapeOutline.angle , Gui1.Sides := 4 , returnString := 1 , AddExtraWrapArm := 1 )
MyShape2 := PolygonShapes( New Vector( W / 2 , w / 2 ) , Radius + Gui1.ShapeOutline.Thickness , Gui1.ShapeOutline.angle , Gui1.Sides := 3 , returnString := 1 , AddExtraWrapArm := 1 )
Gdip_FillPolygon( G2 , TextureBrush , MyShape ) , Gdip_DeleteBrush( TextureBrush )
if( Gui1.ShapeOutline.Thickness )
DrawPolygon( G2 , MyShape , Color , Gui1.ShapeOutline.Thickness )
}else if( Gui1.SelectedShape = "Rounded Rectangle" ){
cc := Gui1.ShapeOutline
x := ceil( Gui1.ShapeOutline.Thickness / 2 ) + 1
y := ceil( Gui1.ShapeOutline.Thickness / 2 ) + 1
w := 64 - Gui1.ShapeOutline.Thickness - 2
h := 64 - Gui1.ShapeOutline.Thickness - 2
Gdip_FillRoundedRectangle( G2 , TextureBrush , X * Gui1.Scale , Y * Gui1.Scale , W * Gui1.Scale , H * Gui1.Scale , 10 * Gui1.Scale )
if( Gui1.ShapeOutline.Thickness )
Pen := Gdip_CreatePen( Color , ceil( Gui1.ShapeOutline.Thickness * Gui1.Scale ) )
, Gdip_DrawRoundedRectangle( G2 , Pen , X * Gui1.Scale , Y * Gui1.Scale , W * Gui1.Scale , H * Gui1.Scale , 10 * Gui1.Scale )
, Gdip_DeletePen( Pen )
}
Gui1.OutputIconWindow.ClearWindow()
Brush := Gdip_BrushCreateHatch( "0x33000000" , "0x33ffffff" , 52 )
, Gdip_FillRoundedRectangle( Gui1.OutputIconWindow.G , Brush , 2 * Gui1.Scale , 2 * Gui1.Scale , ( Gui1.OutputIconWindow.W - 4 ) * Gui1.Scale , ( Gui1.OutputIconWindow.H - 4 ) * Gui1.Scale , 15 * Gui1.Scale )
, Gdip_DeleteBrush( Brush )
Gui1.OutputIconWindow.DrawBitmap( CroppedBitmap , { X: 32 , Y: 32 , W: 64 , H: 64 } , dispose := 0 , AutoUpdate := 1 )
}
MoveSliderThumbControl( Gui1 , Thumb ){
GuiControl, % Gui1.Hwnd ":Move" , % Thumb.Hwnd , % "x" Thumb.X " y" Thumb.Y " w" Thumb.W " h" Thumb.H
}
NewTheme(){
local MyButtonDesign := {}
MyButtonDesign.All := {}
MyButtonDesign.Default := {}
MyButtonDesign.Hover := {}
MyButtonDesign.Pressed := {}
;********************************
;All
MyButtonDesign.All.W := 300 , MyButtonDesign.All.H := 40 , MyButtonDesign.All.Text := "Capture A New Image From The Screen" , MyButtonDesign.All.FontSize := "14" , MyButtonDesign.All.H := "0xff000000" , MyButtonDesign.All.TextBottomColor2 := "0xff52565a" , MyButtonDesign.All.BackgroundColor := "0xFF32363a" , MyButtonDesign.All.ButtonAddGlossy := "0" , MyButtonDesign.All.GlossTopColor := "0x03"
;********************************
;Default
MyButtonDesign.Default.W := 300 , MyButtonDesign.Default.H := 40 , MyButtonDesign.Default.Text := "Capture A New Image From The Screen" , MyButtonDesign.Default.Font := "Arial" , MyButtonDesign.Default.FontOptions := " Bold Center vCenter " , MyButtonDesign.Default.FontSize := "14" , MyButtonDesign.Default.H := "0xff000000" , MyButtonDesign.Default.TextBottomColor2 := "0xff52565a" , MyButtonDesign.Default.TextTopColor1 := "0xFFff0000" , MyButtonDesign.Default.TextTopColor2 := "0xFFff0000" , MyButtonDesign.Default.TextOffsetX := "0" , MyButtonDesign.Default.TextOffsetY := "0" , MyButtonDesign.Default.TextOffsetW := "0" , MyButtonDesign.Default.TextOffsetH := "0" , MyButtonDesign.Default.BackgroundColor := "0xFF32363a" , MyButtonDesign.Default.ButtonOuterBorderColor := "0xFF161B1F" , MyButtonDesign.Default.ButtonCenterBorderColor := "0xFF262B2F" , MyButtonDesign.Default.ButtonInnerBorderColor1 := "0xFF32363A" , MyButtonDesign.Default.ButtonInnerBorderColor2 := "0xFF24292D" , MyButtonDesign.Default.ButtonMainColor1 := "0xFF32363A" , MyButtonDesign.Default.ButtonMainColor2 := "0xFF22262a" , MyButtonDesign.Default.ButtonAddGlossy := "0" , MyButtonDesign.Default.GlossTopColor := "0x03FFFFFF" , MyButtonDesign.Default.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Default.GlossBottomColor := "33000000"
;********************************
;Hover
MyButtonDesign.Hover.W := 300 , MyButtonDesign.Hover.H := 40 , MyButtonDesign.Hover.Text := "Capture A New Image From The Screen" , MyButtonDesign.Hover.Font := "Arial" , MyButtonDesign.Hover.FontOptions := " Bold Center vCenter " , MyButtonDesign.Hover.FontSize := "14" , MyButtonDesign.Hover.H := "0xff000000" , MyButtonDesign.Hover.TextBottomColor2 := "0xff52565a" , MyButtonDesign.Hover.TextTopColor1 := "0xFFFFFFFF" , MyButtonDesign.Hover.TextTopColor2 := "0xFFff0000" , MyButtonDesign.Hover.TextOffsetX := "0" , MyButtonDesign.Hover.TextOffsetY := "0" , MyButtonDesign.Hover.TextOffsetW := "0" , MyButtonDesign.Hover.TextOffsetH := "0" , MyButtonDesign.Hover.BackgroundColor := "0xFF32363a" , MyButtonDesign.Hover.ButtonOuterBorderColor := "0x6622262a" , MyButtonDesign.Hover.ButtonCenterBorderColor := "0x33ff0000" , MyButtonDesign.Hover.ButtonInnerBorderColor1 := "0x00440000" , MyButtonDesign.Hover.ButtonInnerBorderColor2 := "0x00440000" , MyButtonDesign.Hover.ButtonMainColor1 := "0xFF880000" , MyButtonDesign.Hover.ButtonMainColor2 := "0xFFff0000" , MyButtonDesign.Hover.ButtonAddGlossy := "1" , MyButtonDesign.Hover.GlossTopColor := "0x03FFFFFF" , MyButtonDesign.Hover.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Hover.GlossBottomColor := "33000000"
;********************************
;Pressed
MyButtonDesign.Pressed.W := 300 , MyButtonDesign.Pressed.H := 40 , MyButtonDesign.Pressed.Text := "Capture A New Image From The Screen" , MyButtonDesign.Pressed.Font := "Arial" , MyButtonDesign.Pressed.FontOptions := " Bold Center vCenter " , MyButtonDesign.Pressed.FontSize := "14" , MyButtonDesign.Pressed.H := "0xff000000" , MyButtonDesign.Pressed.TextBottomColor2 := "0xff52565a" , MyButtonDesign.Pressed.TextTopColor1 := "0xFFff0000" , MyButtonDesign.Pressed.TextTopColor2 := "0xFFff0000" , MyButtonDesign.Pressed.TextOffsetX := "0" , MyButtonDesign.Pressed.TextOffsetY := "0" , MyButtonDesign.Pressed.TextOffsetW := "0" , MyButtonDesign.Pressed.TextOffsetH := "0" , MyButtonDesign.Pressed.BackgroundColor := "0xFF32363a" , MyButtonDesign.Pressed.ButtonOuterBorderColor := "0xFF62666a" , MyButtonDesign.Pressed.ButtonCenterBorderColor := "0xFF262B2F" , MyButtonDesign.Pressed.ButtonInnerBorderColor1 := "0xFF32363A" , MyButtonDesign.Pressed.ButtonInnerBorderColor2 := "0xFF151A20" , MyButtonDesign.Pressed.ButtonMainColor1 := "0xFF32363A" , MyButtonDesign.Pressed.ButtonMainColor2 := "0xFF22262a" , MyButtonDesign.Pressed.ButtonAddGlossy := "0" , MyButtonDesign.Pressed.GlossTopColor := "0x03FFFFFF" , MyButtonDesign.Pressed.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Pressed.GlossBottomColor := "33000000"
;********************************
return MyButtonDesign
}
Re: Crop bitmap and export as Base64 string? ( Create Icons )
continued from the last post.
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=101960&start=20#p534041
.
.
Extra Functions and classes.
Paste this at the end of the main script.
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=101960&start=20#p534041
.
.
Extra Functions and classes.
Paste this at the end of the main script.
Code: Select all
;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;***********************************************************************************************************************************************************************************************************
;Custom Radio Button Class
class GlowRadio_1 {
;Written By: Hellbent
;Date: Aprial 6th , 2022
;Creates new instances of gui Radio controls and groups
;New Instance Example: MyRadio := New GlowRadio_1( { Scalefactor: 1 , State: 1 , Y: 10 , Text: "Admin" , BackgroundColor: "0xFF22262A" , Y_Offset: 1 , X_Offset: 5 } )
;Get Selected Item From Group Example: MyRadio..GetSelected() ;(Returns the position of the selected radio in it's group )
;Get The State Of A Radio Example: MyRadio.State ;Or: MyRadio.GetState()
static init := GlowRadio_1._SetDefaults()
_SetDefaults(){
This.W := 11
This.H := 11
This.Groups := {}
This.Index := 0
This.Settings := {}
This.Settings.X := 10
This.Settings.Y := 10
This.Settings.W := 120
This.Settings.H := 20
This.Settings.Text := ""
This.Settings.ActiveColor := "0xFF67D5D6"
This.Settings.ButtonRestColor := "0xFF004444"
This.Settings.RestColor := "0xFF009999"
This.Settings.State := 0
This.Settings.Font := "Arial"
This.Settings.FontSize := 14
This.Settings.FontOptions := " vCenter Left "
This.Settings.BackgroundColor := "0xFF22262a"
This.Settings.GroupName := "Group1"
This.Settings.Owner := "1"
This.Settings.GroupIndex := 1
This.Settings.GroupSelected := 0
This.Settings.ScaleFactor := 1
This.Settings.Y_Offset := 5
This.Settings.X_Offset := 1
}
__New( obj := "" ){
This._CreateRadioObject( obj )
This._CreateControl()
if( This.State ){
Loop, % GlowRadio_1.Groups[ This.GroupName ].Members.Length() {
GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected
GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].State := 0
}
This.State := 1
}
Loop, % GlowRadio_1.Groups[ This.GroupName ].Members.Length()
GlowRadio_1.Groups[ This.GroupName ].Members[ A_Index ].Draw()
}
_CreateRadioObject( obj := "" ){
local k , v
for k , v in GlowRadio_1.Settings
This[ k ] := v
if( IsObject( obj ) ){
for k , v in obj
if( GlowRadio_1.Settings.HasKey( k ) )
This[ k ] := v
if( obj.HasKey( "GroupName" ) )
GlowRadio_1.Settings.GroupName := obj.GroupName
}
}
_CreateControl(){
local hwnd , bd
Gui, % This.Owner ":Add", Picture, % "x" This.X * This.ScaleFactor " y" This.Y * This.ScaleFactor " w" This.W * This.ScaleFactor " h" This.H * This.ScaleFactor " hwndhwnd 0xE"
This.Hwnd := hwnd
++GlowRadio_1.Index
If( !isObject( GlowRadio_1.Groups[ This.GroupName ] ) ){
GlowRadio_1.Groups[ This.GroupName ] := {}
This.Index := GlowRadio_1.Groups[ This.GroupName ].Index := 1
GlowRadio_1.Groups[ This.GroupName ].Members := []
( This.State ) ? ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := This.Index ) : ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := 0 )
}else{
This.Index := ++GlowRadio_1.Groups[ This.GroupName ].Index
( This.State ) ? ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := This.Index ) : ( This.GroupSelected := GlowRadio_1.Groups[ This.GroupName ].Selected := GlowRadio_1.Groups[ This.GroupName ].Selected )
}
GlowRadio_1.Groups[ This.GroupName ].Members[ This.Index ] := This
bd := This._SwitchStates.Bind( This )
GuiControl, % This.Owner ":+G" , % Hwnd , % bd
GlowRadio_1.Groups[ This.GroupName ].Selected := This.GroupSelected
GuiControl, % This.Owner ":Focus", % This.Hwnd
GlowRadio_1.Groups[ This.GroupName ].LastSelected := This.GroupSelected
}
_SwitchStates(){
local cc := GlowRadio_1.Groups[ This.GroupName ] , ls := cc.Selected
if( This.Index = GlowRadio_1.Groups[ This.GroupName ].LastSelected )
return
cc.Selected := This.Index
Loop, % cc.Members.Length() {
cc.Members[ A_Index ].GroupSelected := cc.Selected
cc.Members[ A_Index ].State := 0
}
This.State := 1
cc.Members[ GlowRadio_1.Groups[ This.GroupName ].LastSelected ].Draw()
This.Draw()
GlowRadio_1.Groups[ This.GroupName ].LastSelected := This.Index
GuiControl, % This.Owner ":Focus", % This.Hwnd
if( This.Label ){
Try{
goSub, % This.Label
}
}
}
GetState(){
return This.State
}
GetSelected(){
return This.GroupSelected
}
Draw(){
;Bitmap Created Using: HB Bitmap Maker
local ly := 0
ScaleFactor := This.ScaleFactor
pBitmap := Gdip_CreateBitmap( This.W * ScaleFactor , This.H * ScaleFactor ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( This.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -10 * ScaleFactor , -10 * ScaleFactor , 140 * ScaleFactor , 210 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
;Outer ring
Pen := Gdip_CreatePen( ( This.State ) ? ( This.ActiveColor ) : ( This.ButtonRestColor ) , 1 ) , Gdip_DrawRectangle( G , Pen , 2 * This.ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 1 ) * This.ScaleFactor , GlowRadio_1.W * This.ScaleFactor , GlowRadio_1.H * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;inner square
Brush := Gdip_BrushCreateSolid( ( This.ButtonRestColor ) ) , Gdip_FillRectangle( G , Brush , 4 * ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 3 ) * This.ScaleFactor , 7 * ScaleFactor , 7 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( ( This.State ) ? ( This.ActiveColor ) : ( This.ButtonRestColor ) ) , Gdip_FillRectangle( G , Brush , 5 * ScaleFactor , ( ( This.H / 2 ) - ( GlowRadio_1.H / 2 ) + 4 ) * This.ScaleFactor , 5 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
;bottom layer of text
if( This.State )
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" floor( ( GlowRadio_1.W + 5 + 1 + This.X_Offset ) * ScaleFactor ) " y" ly := Floor( ( ( 2 + This.Y_Offset ) * ScaleFactor ) ) , This.Font , Floor( This.W * ScaleFactor ) , Floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
else
Brush := Gdip_BrushCreateSolid( "0x000000" ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" Floor( ( GlowRadio_1.W + 5 + 2 + This.X_Offset ) * ScaleFactor ) " y" ly := Floor( ( ( 2 + This.Y_Offset ) * ScaleFactor ) ) , This.Font , Floor( This.W * ScaleFactor ) , floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
;top layer of text
Brush := Gdip_BrushCreateSolid( ( This.State ) ? ( This.ActiveColor ) : ( This.RestColor ) ) , Gdip_TextToGraphics( G , This.Text , "s" This.FontSize * ScaleFactor " " This.FontOptions " c" Brush " x" floor( ( GlowRadio_1.W + 5 + This.X_Offset ) * ScaleFactor ) " y" Floor( ( ly - 1 + This.Y_Offset ) ) , This.Font , Floor( ( This.W - GlowRadio_1.W ) * ScaleFactor ) , Floor( This.H * ScaleFactor ) ) , Gdip_DeleteBrush( Brush )
Gdip_DeleteGraphics( G )
hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
SetImage( This.Hwnd , hBitmap )
Gdip_DisposeImage( pBitmap )
DeleteObject( hBitmap )
}
}
;*******************&&&&&&&&&&&&&&&&&&&&&&&&************************************&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;*******************&&&&&&&&&&&&&&&&&&&&&&&&************************************&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;*******************&&&&&&&&&&&&&&&&&&&&&&&&************************************&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
class DropDownListv1 {
Value[]{
Get{
return This.List[ This.Selected ]
}
}
__New( obj := "" ){
This._SetDefaults()
This._UpdateDefaults( obj )
This._CreateWindows()
This._CreateControls()
This._DrawHeader()
This._SetTimer( This.HoverTimer , 100 )
;~ SoundBeep 777
}
_SetDefaults(){
This.Parent := ""
This.ScaleFactor := 1
This.X := 10
This.Y := 10
This.W := 300
This.HeaderMargin := 5
This.Font := "Arial"
This.FontSize := 12
;~ This.FontColor := "0xFF000000"
This.FontColor := "0xFFFFFFFF"
This.FontOptions := "Center vCenter NoWrap "
This.H := Floor( This._GetTextSize() + 2 * This.HeaderMargin )
This.PanelStartingPositionY := 9
This.Selected := 1
This.StartingPosition := 1
;~ This.MainColor := "0xFFFFFFFF"
This.MainColor := "0xFF32363a"
;~ This.ArrowColor := "0xFF000000"
This.ArrowColor := "0xFFFF0000"
This.Rows := 10
This.BodyMargin := 3
This.PanelTextPading := 1
This.PanelTextHeight := Floor( This._GetTextSize() )
This.PanelHeight := This.PanelTextHeight + 2 * This.PanelTextPading
This.BodyHeight := This.BodyMargin * 2 + ( This.PanelHeight * This.Rows ) + ( This.BodyMargin * ( This.Rows - 1 ) ) + This.PanelStartingPositionY
This.ThumbMinY := This.PanelStartingPositionY + 2
This.ThumbRange := This.BodyHeight - This.ThumbMinY - 6
This.ThumbY := This.ThumbMinY
This.Interval := Floor( This.ThumbRange / This.List.Length() )
;~ This.PanelColor1 := "0xFFCFCFCF"
This.PanelColor1 := "0xFF22262a"
;~ This.PanelColor2 := "0xFFEFEFEF"
This.PanelColor2 := "0xFF12161a"
;~ This.HighLightPanelColor := "0x3300AAFF"
This.HighLightPanelColor := "0x33ff0000"
;~ This.SelectedPanelColor := "0x990099FF"
This.SelectedPanelColor := "0x99ff2222"
This.SelectedFontColor := This.FontColor
;~ This.HighlightFontColor := This.FontColor
This.HighlightFontColor := "0xFFFFFFFF"
This.HeaderFontColor := This.FontColor
;~ This.SliderTrackColor := "0xFFDCDCDC"
This.SliderTrackColor := "0xFF12161a"
;~ This.SliderButtonColor := "0xFFFFFFFF"
This.SliderButtonColor := "0xFF22262a"
;~ This.SliderRidgeColor := "0x33333333"
This.SliderRidgeColor := "0x66ff0000"
This.BorderColor := "0x33000000"
;~ This.BorderColor := "0xff0000ff"
This.Hovered := ""
This.PanelControls := []
This.Active := 0
This.CallBind := This._CallBind.Bind( This )
This.HoverTimer := This._Hover.Bind( This )
;~ This.FocusColor := "0x990099FF"
This.FocusColor := "0x99ff0000"
This.Focused := 0
}
_UpdateDefaults( obj := "" ){
for k, v in obj
This[ k ] := obj[ k ]
This.H := Floor( This._GetTextSize() + 2 * This.HeaderMargin )
This.Roundness := This.H / 5
if( !IsObject( obj.Bind ) && obj.Bind )
This.Bind := func( obj.Bind ).Bind( This )
if( This.Rows < 5 )
This.Rows := 5
This.PanelTextHeight := Floor( This._GetTextSize() )
This.PanelHeight := This.PanelTextHeight + 2 * This.PanelTextPading
This.BodyHeight := This.BodyMargin * 2 + ( This.PanelHeight * This.Rows ) + ( This.BodyMargin * ( This.Rows - 1 ) ) + This.PanelStartingPositionY
This.ThumbMinY := This.PanelStartingPositionY + 2
This.ThumbRange := This.BodyHeight - This.ThumbMinY - 6 - 2
if( ( This.ThumbRange / 0.5 ) < This.List.Length() ){
Msgbox, 262144, Error, The list you are using exceeds the current maximum length. `n1
exitApp
}
This.Interval := Floor( ( This.ThumbRange * This.ScaleFactor) / This.List.Length() )
This.TotalInterval := This.Interval * This.List.Length()
This.ThumbHeight := This.ThumbRange - This.TotalInterval
While( This.Interval > 1 ){
;~ This.Interval -= 1
This.Interval -= 0.5
This.TotalInterval := This.Interval * This.List.Length()
This.ThumbHeight := This.ThumbRange - This.TotalInterval
}
if( ( This.ThumbHeight ) < 30 || !This.Interval ){
Msgbox, 262144, Error, % "The list you are using exceeds the current maximum length. `n2 "
exitApp
}
This.Thumb := { X: ( This.W - 32 ) , Y: This.ThumbMinY , W: 26 , H: This.ThumbHeight }
This._MoveThumbControl()
This.Panels := []
This.PanelHandles := []
temp := This.PanelStartingPositionY - 2
Loop, % This.Rows {
This.Panels[ A_Index ] := { X: 4 , Y: temp , W: ( This.W - 34 - 6 ) , H: This.PanelHeight , Hwnd: "" }
temp += This.PanelHeight + This.BodyMargin
}
This.ToggleButton := { X: 2 , Y: 2 , W: ( This.W - 4 ) , H: ( This.H - 4 ) , Hwnd: "" }
This.WheelActive := 0
This.FT := 0
OnMessage( 0x020A , This._WheelChange.Bind( This ) )
OnMessage( 0x201 , This._WatchFocus.Bind( This ) )
OnMessage( 0x100 , This._WatchKeyPress.Bind( This ) )
if( !obj.HasKey( "HeaderFontColor" ) )
This.HeaderFontColor := This.FontColor
if( !obj.HasKey( "HighlightFontColor" ) )
This.HighlightFontColor := This.FontColor
}
_CreateWindows(){
This.Gui1 := New PopUpWindow( { AutoShow: 1 , X: This.X * This.ScaleFactor , Y: This.Y * This.ScaleFactor , W: This.W * This.ScaleFactor , H: This.H * This.ScaleFactor , Options: " -DPIScale +AlwaysOnTop +Parent" This.Parent } )
This.Gui2 := New PopUpWindow( { AutoShow: 1 , X: This.X * This.ScaleFactor , Y: This.Y * This.ScaleFactor , W: This.W * This.ScaleFactor , H: This.BodyHeight * This.ScaleFactor , Options: " -DPIScale +AlwaysOnTop +Owner" This.Gui1.Hwnd } )
}
_CreateControls(){
Gui, % This.Gui2.Hwnd ":Add", Text, % "x" ( This.W - 34 ) * This.ScaleFactor " y" This.ThumbY * This.ScaleFactor " w" 30 * This.ScaleFactor " h" This.ThumbHeight * This.ScaleFactor " hwndhwnd"
This.ThumbHwnd := hwnd
bd := This._AdjustSlider.Bind( This )
GuiControl, % This.Gui2.Hwnd ":+G", % hwnd, % bd
Loop, % This.Rows {
Gui, % This.Gui2.Hwnd ":Add", Text, % "x" This.Panels[ A_Index ].X * This.ScaleFactor " y" This.Panels[ A_Index ].Y * This.ScaleFactor " w" This.Panels[ A_Index ].W * This.ScaleFactor " h" This.Panels[ A_Index ].H * This.ScaleFactor " hwndhwnd"
This.Panels[ A_Index ].Hwnd := hwnd
This.PanelHandles[ hwnd ] := A_Index
bd := This._SelectPanel.Bind( This )
GuiControl, % This.Gui2.Hwnd ":+G" , % hwnd , % bd
}
Gui, % This.Gui1.Hwnd ":Add", Text, % "x" This.ToggleButton.X * This.ScaleFactor " y" This.ToggleButton.Y * This.ScaleFactor " w" This.ToggleButton.W * This.ScaleFactor " h" This.ToggleButton.H * This.ScaleFactor " hwndhwnd"
This.ToggleButton.Hwnd := hwnd
This.HKBind := This._LButtonHK.Bind( This )
bd := This._ToggleBody.Bind( This )
GuiControl, % This.Gui1.Hwnd ":+G" , % hwnd , % bd
}
_MoveThumbControl(){
GuiControl, % This.Gui2.Hwnd ":Move" , % This.ThumbHwnd , % "y" This.Thumb.Y * This.ScaleFactor " h" This.ThumbHeight * This.ScaleFactor
}
_Hover(){
MouseGetPos,,, win , ctrl , 2
if( win = This.Gui2.Hwnd ){
if( !This.Hovered && This.PanelHandles[ ctrl ] ){
This.Hovered := ctrl
This._DrawBody()
}
}
if( This.Hovered && ctrl != This.Hovered ){
This.Hovered := ""
if( This.Active )
This._DrawBody()
}
}
_WheelChange( input ){
local ctrl , Dir , win
if( This.WheelActive )
return
if( This.ft := !This.ft )
return
This.WheelActive := 1
Dir := ( (input >> 16 ) > 0x7FFF ) || ( ( input < 0 ) ? ( 1 ) : ( 0 ) )
MouseGetPos,,, win, ctrl, 2
if( !Dir && ctrl = This.ToggleButton.Hwnd ){
( --This.Selected < 1 ) ? ( This.Selected := 1 )
This.StartingPosition := This.Selected
}else if( Dir && ctrl = This.ToggleButton.Hwnd ){
( ++This.Selected > This.List.Length() ) ? ( This.Selected := This.List.Length() )
This.StartingPosition := This.Selected
}else if( !Dir && win = This.Gui2.Hwnd ){
( --This.StartingPosition < 1 ) ? ( This.StartingPosition := 1 )
}else if( Dir && win = This.Gui2.Hwnd ){
( ++This.StartingPosition > This.List.Length() ) ? ( This.StartingPosition := This.List.Length() )
}
This.Thumb.Y := This.ThumbMinY + This.StartingPosition
This._MoveThumbControl()
This._DrawHeader()
if( This.Active )
This._DrawBody()
if( ctrl = This.ToggleButton.Hwnd )
This._SetTimer( This.CallBind , -30 )
This.WheelActive := 0
}
_WatchKeyPress( key ){
if( key = 9 && This.Focused )
This.SetFocus( 0 )
}
_WatchFocus(){
MouseGetPos,,, win, ctrl, 2
if( This.Focused && ctrl != This.ToggleButton.Hwnd && win != This.Gui2.Hwnd && ctrl )
This.SetFocus( 0 )
else if( !This.Focused && ( ctrl = This.ToggleButton.Hwnd || win = This.Gui2.Hwnd ) )
This.SetFocus( 1 )
}
SetFocus( value , option := 1 ){
if( This.Focused := value )
GuiControl, % This.Gui1.Hwnd ":Focus" , % This.ToggleButton.Hwnd
This._DrawHeader()
}
_SetTimer( Timer , Amount := 30 ){
SetTimer, % Timer, % Amount
}
_CallBind(){
Try
This.Bind.Call()
}
_SelectPanel(){
MouseGetPos,,,, ctrl, 2
if( This.List[ This.PanelHandles[ ctrl ] + This.StartingPosition - 1 ] != "" ){
This.Output := This.List[ This.PanelHandles[ ctrl ] + This.StartingPosition - 1 ]
This.Selected := This.PanelHandles[ ctrl ] + This.StartingPosition - 1
This._DrawBody()
bd := This.HKBind
HotKey, ~LButton, % bd , Off
This.Active := 0
This.Gui2.ClearWindow( 1 )
This._DrawHeader()
This._SetTimer( This.CallBind , -30 )
;~ This.Gui2.ClearWindow( 1 )
;~ ToolTip, % "Here`n" This.Gui2.hwnd
}
}
_ToggleBody(){
if( This.Active := !This.Active ){
WinGetPos, x, y,,, % "ahk_Id " This.Gui1.Hwnd
This.Gui2.UpdateSettings( { X: x , Y: y + ( This.Gui1.H ) } )
This.StartingPosition := This.Selected
This.Focused := 1
This._DrawBody()
bd := This.HKBind
Hotkey, ~LButton , % bd , On
}else{
This.Gui2.ClearWindow( 1 )
bd := This.HKBind
HotKey, ~LButton, % bd , Off
}
This._DrawHeader()
}
_LButtonHK(){
MouseGetPos,,, win, ctrl, 2
if( win != This.Gui2.Hwnd && ctrl != This.ToggleButton.Hwnd ){
bd := This.HKBind
HotKey, ~LButton, % bd , Off
This.Active := 0
This.Gui2.ClearWindow( 1 )
This._DrawHeader()
}
}
_AdjustSlider(){
local ly
CoordMode, Mouse, Client
While( GetKeyState( "LButton" ) ){
MouseGetPos,, y
if( ly != y ){
ly := y
y /= This.ScaleFactor
if( ( y - This.ThumbHeight / 2 ) < This.ThumbMinY ){
This.Thumb.Y := This.ThumbMinY
This.StartingPosition := 1
}else if( ( y + This.ThumbHeight / 2 ) > ( This.ThumbMinY + This.ThumbRange ) ){
This.Thumb.Y := This.ThumbMinY + This.ThumbRange - This.ThumbHeight
This.StartingPosition := This.List.Length()
}else{
This.Thumb.Y := y - This.ThumbHeight / 2
;~ This.StartingPosition := floor( This.Thumb.Y - This.ThumbMinY )
This.StartingPosition := floor( ( This.Thumb.Y - This.ThumbMinY ) / This.Interval )
}
This._MoveThumbControl()
This._DrawBody()
}
sleep, 10
}
}
_DrawHeader(){
local brush , pen
This.Gui1.ClearWindow()
Brush := Gdip_CreateLineBrushFromRect( 1 * This.ScaleFactor , 1 * This.ScaleFactor , ( This.W - 2 ) * This.ScaleFactor , ( This.H - 2 ) * This.ScaleFactor , This.MainColor , ( This.MainColor2 != "" ) ? ( This.MainColor2 ) : ( This.MainColor ) , 1 , 1 )
, Gdip_FillRoundedRectangle( This.Gui1.G , Brush , 2 * This.ScaleFactor , 2 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.H - 4 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrush( 1 * This.ScaleFactor , 1 * This.ScaleFactor , ( This.W / 2 ) * This.ScaleFactor , ( This.H - 2 ) * This.ScaleFactor , "0xaaaaaaaa" , "0xFF000000" , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.Gui1.G , Pen , 2 * This.ScaleFactor , 2 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.H - 4 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
if( This.Focused ){
Brush := Gdip_BrushCreateSolid( This.FocusColor )
, Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush )
, Gdip_DrawRoundedRectangle( This.Gui1.G , Pen , 4 * This.ScaleFactor , 4 * This.ScaleFactor , ( This.W - 8 ) * This.ScaleFactor , ( This.H - 8 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor )
, Gdip_DeletePen( Pen )
}
Brush := Gdip_BrushCreateSolid( This.HeaderFontColor ) , Gdip_TextToGraphics( This.Gui1.G , This.List[ This.Selected ] , "s" This.FontSize * This.ScaleFactor " " This.FontOptions " NoWrap c" Brush " x" 5 * This.ScaleFactor " y" 2 * This.ScaleFactor , This.Font , ( This.W - ( This.W / 4 ) ) * This.ScaleFactor , This.H * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.ArrowColor ) , Gdip_TextToGraphics( This.Gui1.G , ( !This.Active ) ? ( 6 ) : ( 5 ) , "s" ( s := 16 ) * This.ScaleFactor " " This.FontOptions " c" Brush " x" ( This.W - 30 ) * This.ScaleFactor " y" 1 * This.ScaleFactor , "WebDings" , 30 * This.ScaleFactor , This.H * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
This.Gui1.UpdateWindow()
}
_DrawBody(){
local temp , brush , pen , tog
This.Gui2.ClearWindow()
Brush := Gdip_BrushCreateSolid( This.MainColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
;**************************************
;~ ToolTip, % This.BorderColor
Pen := Gdip_CreatePen( This.BorderColor , 1 ) , Gdip_DrawRoundedRectangle( This.Gui2.G , Pen , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;~ Brush := Gdip_BrushCreateSolid( This.BorderColor ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.Gui2.G , Pen , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;~ Brush := Gdip_BrushCreateSolid( "0xFF0000FF" ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.Gui2.G , Pen , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;~ Bob := This.BorderColor
;~ Brush := Gdip_BrushCreateSolid( Bob ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.Gui2.G , Pen , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;**************************************
Brush := Gdip_BrushCreateSolid( This.MainColor ) , Gdip_FillPolygon( This.Gui2.G, Brush , ( This.W / 2 ) * This.ScaleFactor "," 0 * This.ScaleFactor "|" ( This.W - ( This.W / 5 ) ) * This.ScaleFactor "," 100 * This.ScaleFactor "|" ( This.W / 5 ) * This.ScaleFactor "," 100 * This.ScaleFactor "|" ) , Gdip_DeleteBrush( Brush )
temp := This.PanelStartingPositionY
Loop, % This.Rows {
tog := !tog
if( ( A_Index + This.StartingPosition - 1 ) = This.Selected ){
Brush := Gdip_BrushCreateSolid( This.SelectedPanelColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , 4 * This.ScaleFactor , temp * This.ScaleFactor , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SelectedFontColor ) , Gdip_TextToGraphics( This.Gui2.G, This.List[ A_Index + This.StartingPosition - 1 ] , "s" This.FontSize * This.ScaleFactor " NoWrap vCenter c" Brush " x" 4 * This.ScaleFactor " y" ( temp + 1 ) * This.ScaleFactor , This.Font , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
}else if( A_Index = This.PanelHandles[ This.Hovered ] ){
Brush := Gdip_BrushCreateSolid( This.HighLightPanelColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , 4 * This.ScaleFactor , temp * This.ScaleFactor , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.HighlightFontColor ) , Gdip_TextToGraphics( This.Gui2.G, This.List[ A_Index + This.StartingPosition - 1 ] , "s" This.FontSize * This.ScaleFactor " NoWrap vCenter c" Brush " x" 4 * This.ScaleFactor " y" ( temp + 1 ) * This.ScaleFactor , This.Font , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
}else{
Brush := Gdip_BrushCreateSolid( ( !tog ) ? ( This.PanelColor1 ) : ( This.PanelColor2 ) ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , 4 * This.ScaleFactor , temp * This.ScaleFactor , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.FontColor ) , Gdip_TextToGraphics( This.Gui2.G, This.List[ A_Index + This.StartingPosition - 1 ] , "s" This.FontSize * This.ScaleFactor " NoWrap vCenter c" Brush " x" 4 * This.ScaleFactor " y" ( temp + 1 ) * This.ScaleFactor , This.Font , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
}
temp += This.PanelHeight + This.BodyMargin
}
Brush := Gdip_BrushCreateSolid( This.SliderTrackColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , ( This.W - 34 ) * This.ScaleFactor , 9 * This.ScaleFactor , 30 * This.ScaleFactor , ( This.BodyHeight - 15 ) * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SliderButtonColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , ( This.W - 32 ) * This.ScaleFactor , This.Thumb.Y * This.ScaleFactor , 26 * This.ScaleFactor , This.ThumbHeight * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SliderRidgeColor ) , Gdip_FillRectangle( This.Gui2.G , Brush , ( This.Thumb.X + 3 ) * This.ScaleFactor , ( This.Thumb.Y + ( This.ThumbHeight / 2 ) - 5 ) * This.ScaleFactor , ( This.Thumb.W - 6 ) * This.ScaleFactor , 3 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SliderRidgeColor ) , Gdip_FillRectangle( This.Gui2.G , Brush , ( This.Thumb.X + 3 ) * This.ScaleFactor , ( This.Thumb.Y + ( This.ThumbHeight / 2 ) + 5 ) * This.ScaleFactor , ( This.Thumb.W - 6 ) * This.ScaleFactor , 3 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SliderRidgeColor ) , Gdip_FillRectangle( This.Gui2.G , Brush , ( This.Thumb.X + 3 ) * This.ScaleFactor , ( This.Thumb.Y + ( This.ThumbHeight / 2 ) ) * This.ScaleFactor , ( This.Thumb.W - 6 ) * This.ScaleFactor , 3 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
This.Gui2.UpdateWindow()
}
_GetTextSize( index := 4 ){
local pBitmap, G, Brush, temparr
pBitmap := Gdip_CreateBitmap( 10 , 10 ) , G := Gdip_GraphicsFromImage( pBitmap ), Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( "0xFF000000")
temparr := StrSplit( Gdip_TextToGraphics( G , ( This.Text ) ? ( This.Text ) : ( "Test String" ), " s" This.Fontsize " c" Brush " " This.FontOptions " x" 0 " y" 0 , This.Font , 10000, 10000 ),"|","|" ) , Gdip_DeleteBrush( Brush )
Gdip_DeleteGraphics( G ) , Gdip_DisposeImage( pBitmap )
return temparr[ index ]
}
Delete(){
This.Gui2.DeleteWindow()
This.Gui1.DeleteWindow()
}
}
;|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|
;|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|
;|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|
;Function: PolygonShapes
;Written By: Hellbent
;Date: Jan 16th, 2023
;Last Edit: Jan 18th, 2023
;Changes:
;Can now set it so that the return string has an extra wrap to close the shape. ( used for "DRAWLINES" or "DRAWPOLYGON" )
;Requires: Vectors class ( #Include <HB Vectors v2> )
;Returns a string or an array of points for a simple closed polygon shape.
;HomeVector: { X: x position , Y: y position } give an obj with x and y keys.
; This is the center of your shape.
;Radius: The radius to use for the shape. How big the shape will be
;StartAngle: The point for the first side of the shape. The rotaion of the shape.
;Sides: The number of sides the shape should have. 3 or more sides
;returnString: Set the fuction to return a "string" of points or an [ array ] of points
PolygonShapes( HomeVector , Radius := 100 , StartAngle := 0 , Sides := 4 , returnString := 1 , AddExtraWrapArm := 0 ){
local StartVector , points , SpacingAngle , OutputString
if( sides < 3 ){
MsgBox, 262192, Error , A shape requires 3 or more sides.`nWhat you're thinking of is a line or a point.
return
}
StartVector := New Vector( HomeVector )
StartVector.SetMag( Radius )
StartVector.SetAngle( StartAngle )
SpacingAngle := 360 / Sides
Points := []
Points[ 1 ] := New Vector( StartVector )
Points[ 1 ].Add( HomeVector )
if( returnString )
OutputString := Points[ 1 ].X "," Points[ 1 ].Y "|"
Loop, % Sides - 1 {
StartVector := StartVector.RotateAngle( SpacingAngle , 1 )
Points[ A_Index + 1 ] := New Vector( StartVector )
Points[ A_Index + 1 ].Add( HomeVector )
if( returnString )
OutputString .= Points[ A_Index + 1 ].X "," Points[ A_Index + 1 ].Y "|"
}
if( returnString ){
OutputString .= Points[ 1 ].X "," Points[ 1 ].Y "|"
if( AddExtraWrapArm ) ;Adds an extra overlap so that when you use "DrawLines" the shape fully closes regardless of the thickness of the lines.
OutputString .= Points[ 2 ].X "," Points[ 2 ].Y "|"
return OutputString
}
return Points
}
;|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|
;|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|
;|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|<( )>|
FillPolygon( G , Points := "50 , 50 | 100 , 100 | 150 , 50 | 50 , 50 " , Color := "0xFFFF0000" ){
Brush := Gdip_BrushCreateSolid( Color ) , Gdip_FillPolygon( G , Brush , Points ) , Gdip_DeleteBrush( Brush )
}
DrawPolygon( G , Points := "50 , 50 | 100 , 100 | 150 , 50 | 50 , 50 " , Color := "0xFF000000" , Thickness := 3 ){
Pen := Gdip_CreatePen( Color , Thickness ) , Gdip_DrawLines( G , Pen , Points ) , Gdip_DeletePen( Pen )
}
;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;
;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;
;| ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) | ((((()))))***^|^***((((())))) |;
;~ class Commands extends DockItDraw {
class Commands {
GetWinHwnd( option := "A" ){
return WinActive( option )
}
GetWinTitle( hwnd ){
local out
WinGetTitle, out , % "ahk_id " hwnd
return out
}
GetWinPos( hwnd ){
local x , y , w , h
WinGetPos, x , y , w , h , % "ahk_id " hwnd
return { X: x , Y: y , W: w , H: h }
}
GetMousePos( mode := "Screen" ){
local x , y
CoordMode, Mouse, % mode
MouseGetPos, x , y
return { X: x , Y: y }
}
}
class DrawTarget extends Commands {
__New(){
local pos := This.GetMousePos()
This.State := 0
This.Color := "0xFFFF0000"
This.X1 := pos.X
This.X2 := 0
This.Y1 := pos.Y
This.Y2 := 0
This.X := pos.X
This.Y := pos.Y
This.W := 0
This.H := 0
This.Gui1 := New PopUpWindow( { AutoShow: 1 , X: pos.X - 500 , Y: pos.Y - 500 , W: 1001 , H: 1001 , Options: " +AlwaysOnTop -DPIScale +ToolWindow +E0x20" } )
This._SetStartingPos()
This._SetEndingPos()
return { X: This.X , Y: This.Y , W: This.W , H: This.H }
}
_SetStartingPos(){
while( !GetKeyState( "ctrl" ) ){
ToolTip, Press "ctrl" to set the starting position. `n`nTop left corner.
pos := This.GetMousePos()
This.Gui1.UpdateSettings( { X: pos.X - 501 , Y: pos.Y - 501 } )
This.Draw()
sleep, 30
}
This.X1 := pos.X
This.Y1 := pos.Y
This.State := 1
While( GetKeyState( "ctrl" ) )
sleep, 30
}
_SetEndingPos(){
while( !GetKeyState( "ctrl" ) ){
ToolTip, Press "ctrl" to set the ending position. `n`nBottom Right corner.
pos := This.GetMousePos()
This.X2 := pos.X
This.Y2 := pos.Y
( This.X1 <= This.X2 ) ? ( This.X := This.X1 , This.W := This.X2 - This.X1 ) : ( This.X := This.X2 , This.W := This.X1 - This.X2 )
( This.Y1 <= This.Y2 ) ? ( This.Y := This.Y1 , This.H := This.Y2 - This.Y1 ) : ( This.Y := This.Y2 , This.H := This.Y1 - This.Y2 )
This.Gui1.UpdateSettings( { X: This.X - 1 , Y: This.Y - 1 , W: This.W + 2 , H: This.H + 2 } , 1 )
This.Draw()
sleep, 30
}
ToolTip,
While( GetKeyState( "ctrl" ) )
sleep, 30
This.Gui1.DeleteWindow()
}
Draw(){
This.Gui1.ClearWindow()
if( !This.State ){
Pen := Gdip_CreatePen( This.Color , 1 ) , Gdip_DrawLine( This.Gui1.G , Pen , 501 , 0 , 501 , 1001 ) , Gdip_DeletePen( Pen )
Pen := Gdip_CreatePen( This.Color , 1 ) , Gdip_DrawLine( This.Gui1.G , Pen , 0 , 501 , 1001 , 501 ) , Gdip_DeletePen( Pen )
}else if( This.State = 1 ){
Pen := Gdip_CreatePen( This.Color , 1 ) , Gdip_DrawRectangle( This.Gui1.G , Pen , 1 , 1 , This.W , This.H ) , Gdip_DeletePen( Pen )
}
This.Gui1.UpdateWindow()
}
}
B64ToPBitmap( Input ){
local ptr , uptr , pBitmap , pStream , hData , pData , Dec , DecLen , B64
VarSetCapacity( B64 , strlen( Input ) << !!A_IsUnicode )
B64 := Input
If !DllCall("Crypt32.dll\CryptStringToBinary" ( ( A_IsUnicode ) ? ( "W" ) : ( "A" ) ), Ptr := A_PtrSize ? "Ptr" : "UInt" , &B64, "UInt", 0, "UInt", 0x01, Ptr, 0, "UIntP", DecLen, Ptr, 0, Ptr, 0)
Return False
VarSetCapacity( Dec , DecLen , 0 )
If !DllCall("Crypt32.dll\CryptStringToBinary" (A_IsUnicode ? "W" : "A"), Ptr, &B64, "UInt", 0, "UInt", 0x01, Ptr, &Dec, "UIntP", DecLen, Ptr, 0, Ptr, 0)
Return False
DllCall("Kernel32.dll\RtlMoveMemory", Ptr, pData := DllCall("Kernel32.dll\GlobalLock", Ptr, hData := DllCall( "Kernel32.dll\GlobalAlloc", "UInt", 2, UPtr := A_PtrSize ? "UPtr" : "UInt" , DecLen, UPtr), UPtr) , Ptr, &Dec, UPtr, DecLen)
DllCall("Kernel32.dll\GlobalUnlock", Ptr, hData)
DllCall("Ole32.dll\CreateStreamOnHGlobal", Ptr, hData, "Int", True, Ptr "P", pStream)
DllCall("Gdiplus.dll\GdipCreateBitmapFromStream", Ptr, pStream, Ptr "P", pBitmap)
return pBitmap
}
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
;<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|<<<---#####--->>>|
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;######################################################### #Include, <HB Icon Buttons ( LW Ani Buttons )> #########################################################
;####################################################################################################################################################################################
;####################################################################################################################################################################################
class IconButtons {
;Written By: Hellbent
;Date: Apr 7th
;Create Layered Window Buttons From a pBitmap.
;Accepts a parent window but can also rest in a window sans parent.
static init := IconButtons._SetDefaults()
;#############################################
;>>>>> SET THE CLASS DEFAULTS.
;#############################################
_SetDefaults(){
;*****************************
;>>>>> Static class Data
This.Index := 0
This.Handles := []
This.CurrentIcon := ""
This.LastIcon := ""
This.HoverTimer := This._Hover.Bind( This )
This.FT := 1
This.Beep := 0
;*****************************
;>>>>> Window Data
This.Window := {}
This.Window.X := 10
This.Window.Y := 10
This.Window.W := 10
This.Window.H := 10
This.Window.Parent := ""
This.Window.Hwnd := ""
This.Window.HDC := ""
This.Window.OBM := ""
This.Window.Graphics := ""
This.Window.HBM := ""
This.Window.Smoothing := 2
This.Window.Options := " +AlwaysOnTop -DPIScale +ToolWindow "
;*****************************
;>>>>> Bitmap Data
This.Bitmap := {}
This.Bitmap.pBitmap := ""
This.Bitmap.Alpha := 255
This.Bitmap.X := 0
This.Bitmap.Y := 0
This.Bitmap.W := 10
This.Bitmap.H := 10
This.Bitmap.Animate := ""
This.Bitmap.PulseLength := 5
This.Bitmap.PulseRate := 1
;*****************************
;>>>>> Control Data
This.Control := {}
This.Control.X := 0
This.Control.Y := 0
This.Control.W := 10
This.Control.H := 10
This.Control.Hwnd := ""
This.Control.CanHover := 1
}
;#############################################
;>>>>> CREATE A NEW ICON BUTTON. Prototype: >>>>> Obj := { X: 494 , Y: 242 , W: 130 , H: 26 , Parent: ParentHwnd , pBitmap: pBitmap , Bind: "" , BoundObject: "" }
;#############################################
__New( obj := "" ){
This._GetDefaults()
This._UpdateDefaults( obj )
This._CreateWindow()
This._CreateWindowGraphics()
This._CreateControl()
This.Draw()
IconButtons.Handles[ This.Control.Hwnd ] := This
if( IconButtons.Beep )
SoundBeep, 500
if( This.Control.CanHover && IconButtons.FT && !IconButtons.FT := !IconButtons.FT )
IconButtons._SetHoverTimer( 60 )
}
;#############################################
;>>>>> LOAD NEW BUTTON WITH ITS DEFAULTS.
;#############################################
_GetDefaults(){
local k , v
This.Window := {}
for k , v in IconButtons.Window
This.Window[ k ] := v
This.Bitmap := {}
for k , v in IconButtons.Bitmap
This.Bitmap[ k ] := v
This.Control := {}
for k , v in IconButtons.Control
This.Control[ k ] := v
}
;#############################################
;>>>>> UPDATE THE NEW BUTTON WITH THE USER SUPPLIED DATA.
;#############################################
_UpdateDefaults( obj := "" ){
local k , v
if( !IsObject( obj ) )
return 2
for k , v in obj {
if( This[ "Window" ].HasKey( k ) )
This[ "Window" ][ k ] := obj[ k ]
}
for k , v in [ "W" , "H" , "pBitmap" , "Alpha" , "Animate" , "PulseLength" , "PulseRate" ] {
if( obj.HasKey( v ) )
This[ "Bitmap" ][ v ] := obj[ v ]
}
for k , v in [ "W" , "H" , "CanHover" ] {
if( obj.HasKey( v ) )
This[ "Control" ][ v ] := obj[ v ]
}
}
;#############################################
;>>>>> CREATE A NEW GUI ( LAYERED WINDOW ). USED AS THE CANVAS FOR THE NEW BUTTON.
;#############################################
_CreateWindow(){
local hwnd
if( This.Window.Parent ){
Gui , New, % " +LastFound +E0x80000 hwndhwnd -Caption " This.Window.Options " +Parent" This.Window.Parent
}else
Gui , New, % " +LastFound +E0x80000 hwndhwnd -Caption " This.Window.Options
This.Window.Hwnd := hwnd
This.ShowWindow()
}
;#############################################
;>>>>> CREATE A CONTROL TRIGGER. USED TO DETECT IF THE MOUSE IS OVER OR IS PRESSING THE BUTTON
;#############################################
_CreateControl(){
local hwnd , bd
Gui, % This.Window.Hwnd ":Add", Text, % "x" This.Control.X " y" This.Control.Y " w" This.Control.W " h" This.Control.H " hwndhwnd"
This.Control.Hwnd := hwnd
}
;#############################################
;>>>>> DESTROY THE GRAPHICS OBJECTS. USED WHEN A BUTTON IS DESTROYED OR WHEN IT IS RESIZED
;#############################################
_DestroyWindowsGraphics(){
Gdip_DeleteGraphics( This.Window.Graphics )
SelectObject( This.Window.HDC , This.Window.OBM )
DeleteObject( This.Window.hbm )
DeleteDC( This.Window.hdc )
}
;#############################################
;>>>>> CREATE THE GRAPHICS OBJECTS. DONE WHEN A NEW BUTTON IS CREATED AND WHEN IT IS RESIZED
;#############################################
_CreateWindowGraphics(){
This.Window.hbm := CreateDIBSection( This.Window.W , This.Window.H )
This.Window.hdc := CreateCompatibleDC()
This.Window.obm := SelectObject( This.Window.hdc , This.Window.hbm )
This.Window.Graphics := Gdip_GraphicsFromHDC( This.Window.hdc )
Gdip_SetSmoothingMode( This.Window.Graphics , This.Window.Smoothing )
}
;#############################################
;>>>>> SET A TIMER TO DETECT MOUSE HOVER.
;#############################################
_SetHoverTimer( State := "Off" ){
local bd := This.HoverTimer
SetTimer, % bd , % State
}
;#############################################
;>>>>> DETECT IF THE CURSOR IS OVER THE BUTTON
;#############################################
_Hover(){
local ctrl , cc
static bu := { X: "" , Y: "" , W: "" , H: "" } , index := 0
MouseGetPos,,,, ctrl, 2
if( !This.LastIcon && !This.Handles[ ctrl ].Control.CanHover )
return
if( This.Handles[ ctrl ].Bitmap.w && This.LastIcon != ctrl && !This.LastIcon ){
This.LastIcon := ctrl
cc := This.Handles[ ctrl ]
bu.X := cc.Window.X
bu.Y := cc.Window.Y
bu.W := cc.Window.W
bu.H := cc.Window.H
Index := 0
}else if( This.LastIcon && This.LastIcon = ctrl){
if( This.Handles[ This.LastIcon ].Bitmap.Animate = "Pulse" ){
cc := This.Handles[ This.LastIcon ]
if( ++Index <= This.Handles[ This.LastIcon ].Bitmap.PulseLength ){
cc.Set( { X: cc.Window.X -= This.Handles[ This.LastIcon ].Bitmap.PulseRate , Y: cc.Window.Y -= This.Handles[ This.LastIcon ].Bitmap.PulseRate , W: cc.Window.W += 2 * This.Handles[ This.LastIcon ].Bitmap.PulseRate , H: cc.Window.H += 2 * This.Handles[ This.LastIcon ].Bitmap.PulseRate } , 1 )
cc.Draw()
}else if( Index <= ( 2 * This.Handles[ This.LastIcon ].Bitmap.PulseLength ) ){
cc.Set( { X: cc.Window.X += This.Handles[ This.LastIcon ].Bitmap.PulseRate , Y: cc.Window.Y += This.Handles[ This.LastIcon ].Bitmap.PulseRate , W: cc.Window.W -= 2 * This.Handles[ This.LastIcon ].Bitmap.PulseRate , H: cc.Window.H -= 2 * This.Handles[ This.LastIcon ].Bitmap.PulseRate } , 1 )
cc.Draw()
}else
Index := 0
}else if( This.Handles[ This.LastIcon ].Bitmap.Animate = "Spin" ){
cc := This.Handles[ This.LastIcon ]
if( ++Index < 6 ){
cc.Set( { X: cc.Window.X -= 1 , Y: cc.Window.Y -= 1 , W: cc.Window.W += 2 , H: cc.Window.H += 2 } , 1 )
cc.Draw()
}else if( Index < 11 ){
cc.Set( { X: cc.Window.X += 1 , Y: cc.Window.Y += 1 , W: cc.Window.W -= 2 , H: cc.Window.H -= 2 } , 1 )
cc.Draw()
}else
Index := 0
}
}else if( This.LastIcon && This.LastIcon != ctrl ){
cc := This.Handles[ This.LastIcon ]
cc.Set( { X: bu.X , Y: bu.Y , W: bu.W , H: bu.H } , 1 )
cc.Draw()
This.LastIcon := ""
}
}
;#############################################
;>>>>> IN CLASS METHOD TO SHOW THE BUTTON
;#############################################
ShowWindow(){
Gui , % This.Window.Hwnd ":Show", NA
}
;#############################################
;>>>>> IN CLASS METHOD TO HIDE THE BUTTON
;#############################################
HideWindow(){
Gui , % This.Hwnd ":Hide",
}
;#############################################
;>>>>> SET THE BUTTON WITH NEW DATA AFTER IT HAS BEEN CREATED.
;#############################################
Set( obj := "" , updateGraphics := 0 ){
local k , v
if( !IsObject( obj ) )
return 2
for k , v in obj {
if( This[ "Window" ].HasKey( k ) )
This[ "Window" ][ k ] := obj[ k ]
}
for k , v in [ "W" , "H" , "pBitmap" , "Alpha" , "Animate" , "PulseLength" , "PulseRate" ] {
if( obj.HasKey( v ) )
This[ "Bitmap" ][ v ] := obj[ v ]
}
for k , v in [ "W" , "H" , "CanHover" ] {
if( obj.HasKey( v ) )
This[ "Control" ][ v ] := obj[ v ]
}
if( updateGraphics ){
This._DestroyWindowsGraphics()
This._CreateWindowGraphics()
This._MoveControl()
}
}
_MoveControl(){
GuiControl, % This.Window.Hwnd ":Move", % This.Control.Hwnd , % "w" This.Control.W " h" This.Control.H
}
;#############################################
;>>>>> UPDATE THE BUTTON WITH ITS NEW GRAPHHICS. ( UPDATE VISUAL CHANGES MADE )
;#############################################
UpdateWindow(){
UpdateLayeredWindow( This.Window.hwnd , This.Window.hdc , This.Window.X , This.Window.Y , This.Window.W , This.Window.H , This.Bitmap.Alpha )
}
;#############################################
;>>>>> CLEAR THE GRAPHICS. ( REQUIRES A UPDATE TO SHOW )
;#############################################
ClearWindow( AutoUpdate := 0 ){
Gdip_GraphicsClear( This.Window.Graphics )
if( Autoupdate )
This.UpdateWindow()
}
;#############################################
;>>>>> DRAW THE BUTTON
;#############################################
Draw(){
This.ClearWindow()
Gdip_DrawImage( This.Window.Graphics , This.Bitmap.pBitmap , This.Bitmap.X , This.Bitmap.Y , This.Bitmap.W , This.Bitmap.H )
This.UpdateWindow()
}
}
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;################################################### END OF CLASS YOU LOOK FAT IN THOSE GENES... ######################################################
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;******************************************************************************************************************
;******************************************************************************************************************
Gdip_EncodeBitmapTo64string(pBitmap, ext, Quality=75) { ;Excised from https://www.autohotkey.com/boards/viewtopic.php?t=36047
if Ext not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
return -1
Extension := "." Ext
DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
VarSetCapacity(ci, nSize)
DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
if !(nCount && nSize)
return -2
Loop, % nCount {
sString := StrGet(NumGet(ci, (idx := (48+7*A_PtrSize)*(A_Index-1))+32+3*A_PtrSize), "UTF-16")
if !InStr(sString, "*" Extension)
continue
pCodec := &ci+idx
break
}
if !pCodec
return -3
if (Quality != 75){
Quality := (Quality < 0) ? 0 : (Quality > 100) ? 100 : Quality
if Extension in .JPG,.JPEG,.JPE,.JFIF
{
DllCall("gdiplus\GdipGetEncoderParameterListSize", Ptr, pBitmap, Ptr, pCodec, "uint*", nSize)
VarSetCapacity(EncoderParameters, nSize, 0)
DllCall("gdiplus\GdipGetEncoderParameterList", Ptr, pBitmap, Ptr, pCodec, "uint", nSize, Ptr, &EncoderParameters)
Loop, % NumGet(EncoderParameters, "UInt") {
elem := (24+(A_PtrSize ? A_PtrSize : 4))*(A_Index-1) + 4 + (pad := A_PtrSize = 8 ? 4 : 0)
if (NumGet(EncoderParameters, elem+16, "UInt") = 1) && (NumGet(EncoderParameters, elem+20, "UInt") = 6){
p := elem+&EncoderParameters-pad-4
NumPut(Quality, NumGet(NumPut(4, NumPut(1, p+0)+20, "UInt")), "UInt")
break
}
}
}
}
DllCall("ole32\CreateStreamOnHGlobal", "ptr",0, "int",true, "ptr*",pStream)
DllCall("gdiplus\GdipSaveImageToStream", "ptr",pBitmap, "ptr",pStream, "ptr",pCodec, "uint",p ? p : 0)
DllCall("ole32\GetHGlobalFromStream", "ptr",pStream, "uint*",hData)
pData := DllCall("GlobalLock", "ptr",hData, "uptr")
nSize := DllCall("GlobalSize", "uint",pData)
VarSetCapacity(Bin, nSize, 0)
DllCall("RtlMoveMemory", "ptr",&Bin , "ptr",pData , "uint",nSize)
DllCall("GlobalUnlock", "ptr",hData)
DllCall(NumGet(NumGet(pStream + 0, 0, "uptr") + (A_PtrSize * 2), 0, "uptr"), "ptr",pStream)
DllCall("GlobalFree", "ptr",hData)
DllCall("Crypt32.dll\CryptBinaryToString", "ptr",&Bin, "uint",nSize, "uint",0x01, "ptr",0, "uint*",base64Length)
VarSetCapacity(base64, base64Length*2, 0)
;*************************
;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=101960&p=453367#p453387
DllCall("Crypt32.dll\CryptBinaryToString", "ptr",&Bin, "uint",nSize, "uint", 0x40000001 , "ptr",&base64, "uint*",base64Length) ; [ 0x40000001 = CRYPT_STRING_NOCRLF ( 0x40000000 ) And CRYPT_STRING_BASE64 ( 0x00000001 ) ]
;*************************
Bin := ""
VarSetCapacity(Bin, 0)
VarSetCapacity(base64, -1)
return base64
}
;******************************************************************************************************************
;******************************************************************************************************************
;************
;Vector Class
;**************************************************************************************************************************************************************************
;00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000
;00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000
;00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000
;**************************************************************************************************************************************************************************
Class Vector {
;Written By: HB
;Date: Sept 23rd, 2022
;Last Edit: Sept 24th, 2022
;Purpose: Vector math class
;Credit: Rohwedder
;Resources:
;Line intercept concepts and code: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=37175
;Create an Arrow: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92039&p=479129#p478944
;Getting an angle: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=108760&p=483661#p483678
;Setting an Angle: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=108760&p=483786#p483811
;
static RadToDeg := 45 / ATan( 1 )
, DegToRad := ATan( 1 ) / 45
__New( x := 0 , y := 0 , rotate := 0 ){
if( IsObject( x ) ){
if( rotate = 3 ){
This.X := x.X * -1
,This.Y := x.Y * -1
}else if( rotate = 2 ){
This.X := x.Y
,This.Y := x.X * -1
}else if( rotate = 1 ){
This.X := x.Y * -1
,This.Y := x.X
}else{
This.X := x.X
,This.Y := x.Y
}
}else{
if( rotate = 3 ){
This.X := X * -1
,This.Y := Y * -1
}else if( rotate = 2 ){
This.X := Y
,This.Y := X * -1
}else if( rotate = 1 ){
This.X := Y * -1
,This.Y := X
}else{
This.X := X
,This.Y := Y
}
}
}
Add( x , y := "" ){
if( IsObject( x ) ){
This.X += x.X
,This.Y += x.Y
}else if( y = "" ){
This.X += x
,This.Y += x
}else{
This.X += x
,This.Y += y
}
}
Sub( x , y := "" ){
if( IsObject( x ) ){
This.X -= x.X
,This.Y -= x.Y
}else if( y = "" ){
This.X -= X
,This.Y -= X
}else{
This.X -= X
,This.Y -= Y
}
}
Div( x , y := "" ){
if( IsObject( x ) ){
This.X /= x.X
,This.Y /= x.Y
}else if( x && y = "" ){
This.X /= x
,This.Y /= x
}else{
This.X /= X
,This.Y /= Y
}
}
Mult( x , y := "" ){
if( IsObject( x ) ){
This.X *= x.X
,This.Y *= x.Y
}else if( x && y = "" ){
This.X *= x
,This.Y *= x
}else{
This.X *= X
,This.Y *= Y
}
}
Dist( x , y := "" ){
if( IsObject( x ) )
return Sqrt( ( ( This.X - x.X ) **2 ) + ( ( This.Y - x.Y ) **2 ) )
else
return Sqrt( ( ( This.X - X ) **2 ) + ( ( This.Y - Y ) **2 ) )
}
GetMag(){
return Sqrt( This.X * This.X + This.Y * This.Y )
}
SetMag( magnitude ){
local m := This.GetMag()
This.X := This.X * magnitude / m
,This.Y := This.Y * magnitude / m
}
MagSq(){
return This.GetMag()**2
}
Dot( x , y := "" ){
if( IsObject( x ) )
return ( This.X * x.X ) + ( This.Y * x.Y )
else
return ( This.X * X ) + ( This.Y * Y )
}
Cross( x , y := "" ){
if( IsObject( x ) )
return This.X * x.Y - This.Y * x.X
else
return This.X * Y - This.Y * X
}
Norm(){
local m := This.GetMag()
This.X /= m
This.Y /= m
}
GetAngle(){
local angle
( ( angle := Vector.RadToDeg * DllCall( "msvcrt\atan2" , "Double" , This.Y , "Double" , This.X , "CDECL Double" ) ) < 0 ) ? ( angle += 360 )
return angle
}
SetAngle( newAngle := 0 , NewVector := 0 ){
local Angle := This.GetAngle()
, ChangeAngle := newAngle - Angle
, Co := Cos( Vector.DegToRad * ChangeAngle )
, Si := Sin( Vector.DegToRad * ChangeAngle )
, X := This.X
, Y := This.Y
, X2 := X * Co - Y * Si
, Y2 := X * Si + Y * Co
if( !NewVector )
This.X := X2 , This.Y := Y2
else
return New Vector( X2 , Y2 )
}
RotateAngle( rotationAmount := 90 , NewVector := 0 ){
local Co := Cos( Vector.DegToRad * rotationAmount )
, Si := Sin( Vector.DegToRad * rotationAmount )
, X := This.X
, Y := This.Y
, X2 := X * Co - Y * Si
, Y2 := X * Si + Y * Co
if( !NewVector )
This.X := X2 , This.Y := Y2
else
return New Vector( X2 , Y2 )
}
;********************************************
;class methods
TestLineInterceptPoint( interceptPoint , Line1 , Line2 ){ ; Line = { Start: { X: , Y: } , End: { X: , Y: } } , interceptPoint = { X: , Y: }
local
for k , v in [ "X" , "Y" ]
M%v%_Min := min( Line1.Start[ v ] , Line1.End[ v ] )
,M%v%_Max := max( Line1.Start[ v ] , Line1.End[ v ] )
,L%v%_Min := min( Line2.Start[ v ] , Line2.End[ v ] )
,L%v%_Max := max( Line2.Start[ v ] , Line2.End[ v ] )
if( !( interceptPoint.X < Mx_Min || interceptPoint.X > Mx_Max || interceptPoint.X < Lx_Min || interceptPoint.X > Lx_Max ) && !( interceptPoint.Y < My_Min || interceptPoint.Y > My_Max || interceptPoint.Y < Ly_Min || interceptPoint.Y > Ly_Max ) )
return 1
return 0
}
GetLineInterceptPoint( Line1 , Line2 ){ ; Line = { Start: { X: , Y: } , End: { X: , Y: } }
local A1 := Line1.End.Y - Line1.Start.Y
,B1 := Line1.Start.X - Line1.End.X
,C1 := A1 * Line1.Start.X + B1 * Line1.Start.Y
,A2 := Line2.End.Y - Line2.Start.Y
,B2 := Line2.Start.X - Line2.End.X
,C2 := A2 * Line2.Start.X + B2 * Line2.Start.Y
,Denominator := A1 * B2 - A2 * B1
return New Vector( { X: ( ( B2 * C1 - B1 * C2 ) / Denominator ) , Y: ( ( A1 * C2 - A2 * C1 ) / Denominator ) } )
}
;********************************************
}
;**************************************************************************************************************************************************************************
;00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000
;00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000
;00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000
;**************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
Class HButton {
;Gen 3 Button Class By Hellbent
static init , Button := [] , Active , LastControl , HoldCtrl
__New( Input := "" , All := "" , Default := "" , Hover := "" , Pressed := "" ){
local hwnd
;If this is the first time the class is being used.
if( !HButton.init && HButton.init := 1 )
;Set a timer to watch to see if the cursor goes over one of the controls.
HButton._SetHoverTimer()
This._CreateNewButtonObject( hwnd := This._CreateControl( Input ) , Input )
This._BindButton( hwnd , Input )
This._GetButtonBitmaps( hwnd , Input , All , Default , Hover , Pressed )
This._DisplayButton( hwnd , HButton.Button[hwnd].Bitmaps.Default.hBitmap )
return hwnd
}
_DisplayButton( hwnd , hBitmap){
SetImage( hwnd , hBitmap )
}
_GetButtonBitmaps( hwnd , Input := "" , All := "" , Default := "" , Hover := "" , Pressed := "" ){
HButton.Button[hwnd].Bitmaps := GuiButtonType1.CreateButtonBitmapSet( Input , All , Default , Hover , Pressed )
}
_CreateNewButtonObject( hwnd , Input ){
local k , v
HButton.Button[ hwnd ] := {}
for k , v in Input
HButton.Button[ hwnd ][ k ] := v
HButton.Button[ hwnd ].Hwnd := hwnd
}
_CreateControl( Input ){
local hwnd
Gui , % Input.Owner ":Add" , Pic , % "x" Input.X " y" Input.Y " w" Input.W " h" Input.H " hwndhwnd 0xE"
return hwnd
}
_BindButton( hwnd , Input ){
local bd
bd := This._OnClick.Bind( This )
GuiControl, % Input.Owner ":+G" , % hwnd , % bd
}
_SetHoverTimer( timer := "" ){
local HoverTimer
if( !HButton.HoverTimer )
HButton.HoverTimer := ObjBindMethod( HButton , "_OnHover" )
HoverTimer := HButton.HoverTimer
SetTimer , % HoverTimer , % ( Timer ) ? ( Timer ) : ( 100 )
}
_OnHover(){
local Ctrl
MouseGetPos,,,,ctrl,2
if( HButton.Button[ ctrl ] && !HButton.Active ){
HButton.Active := 1
HButton.LastControl := ctrl
HButton._DisplayButton( ctrl , HButton.Button[ ctrl ].Bitmaps.Hover.hBitmap )
}else if( HButton.Active && ctrl != HButton.LastControl ){
HButton.Active := 0
HButton._DisplayButton( HButton.LastControl , HButton.Button[ HButton.LastControl ].Bitmaps.Default.hBitmap )
}
}
_OnClick(){
local Ctrl, last
HButton._SetHoverTimer( "Off" )
MouseGetPos,,,, Ctrl , 2
last := ctrl
HButton._SetFocus( ctrl )
HButton._DisplayButton( last , HButton.Button[ last ].Bitmaps.Pressed.hBitmap )
While(GetKeyState("LButton"))
sleep, 60
HButton._SetHoverTimer()
loop, 2
This._OnHover()
MouseGetPos,,,, Ctrl , 2
if(ctrl!=last){
HButton._DisplayButton( last , HButton.Button[ last ].Bitmaps.Default.hBitmap )
}else{
HButton._DisplayButton( last , HButton.Button[ last ].Bitmaps.Hover.hBitmap )
if( HButton.Button[ last ].Label ){
if(IsFunc( HButton.Button[ last ].Label ) )
fn := Func( HButton.Button[ last ].Label )
, fn.Call()
else
gosub, % HButton.Button[ last ].Label
}
}
}
_SetFocus( ctrl ){
GuiControl, % HButton.Button[ ctrl ].Owner ":Focus" , % ctrl
}
DeleteButton( hwnd ){
for k , v in HButton.Button[ hwnd ].Bitmaps
Gdip_DisposeImage( HButton.Button[hwnd].Bitmaps[k].pBitmap )
, DeleteObject( HButton.Button[ hwnd ].Bitmaps[k].hBitmap )
GuiControl , % HButton.Button[ hwnd ].Owner ":Move", % hwnd , % "x-1 y-1 w0 h0"
HButton.Button[ hwnd ] := ""
}
}
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
Class GuiButtonType1 {
static List := [ "Default" , "Hover" , "Pressed" ]
_CreatePressedBitmap(){
local arr := [] , Bitmap := {} , fObj := This.CurrentBitmapData.Pressed
Bitmap.pBitmap := Gdip_CreateBitmap( fObj.W , fObj.H ) , G := Gdip_GraphicsFromImage( Bitmap.pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( fObj.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -1 , -1 , fObj.W+2 , fObj.H+2 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.ButtonOuterBorderColor ) , Gdip_FillRoundedRectangle( G , Brush , 3 , 4 , fObj.W-7 , fObj.H-7 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , fObj.W , fObj.H , fObj.ButtonInnerBorderColor1 , fObj.ButtonInnerBorderColor2 , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 2 , 3 , fObj.W-5 , fObj.H-8 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , fObj.W-7 , fObj.H-10 , fObj.ButtonMainColor1 , fObj.ButtonMainColor2 , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 5 , 5 , fObj.W-11 , fObj.H-12 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 2 , fObj.W , fObj.H , fObj.TextBottomColor1 , fObj.TextBottomColor2 , 1 , 1 )
arr := [ { X: -1 , Y: -1 } , { X: 0 , Y: -1 } , { X: 1 , Y: -1 } , { X: -1 , Y: 0 } , { X: 1 , Y: 0 } , { X: -1 , Y: 1 } , { X: 0 , Y: 1 } , { X: 1 , Y: 1 } ]
Loop, % 8
Gdip_TextToGraphics( G , fObj.Text , "s" fObj.FontSize " " fObj.FontOptions " c" Brush " x" 1 + arr[A_Index].X + fObj.TextOffsetX " y" 3 + arr[A_Index].Y + fObj.TextOffsetY , fObj.Font , fObj.W + fObj.TextOffsetW , fObj.H + fObj.TextOffsetH )
Brush := Gdip_CreateLineBrushFromRect( 0 , 2 , fObj.W , fObj.H , fObj.TextTopColor1 , fObj.TextTopColor2 , 1 , 1 )
Gdip_TextToGraphics( G , fObj.Text , "s" fObj.FontSize " " fObj.FontOptions " c" Brush " x" 1 + fObj.TextOffsetX " y" 3 + fObj.TextOffsetY , fObj.Font , fObj.W + fObj.TextOffsetW , fObj.H + fObj.TextOffsetH )
if( fObj.ButtonAddGlossy ){
Brush := Gdip_BrushCreateSolid( fObj.GlossTopColor ) , Gdip_FillRectangle( G , Brush , 5 , 10 , fObj.W-11 , ( fObj.H / 2 ) - 10 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.GlossTopAccentColor ) , Gdip_FillRectangle( G , Brush , 10 , 12 , fObj.W-21 , fObj.H / 15 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.GlossBottomColor ) , Gdip_FillRectangle( G , Brush , 5 , 10 + ( fObj.H / 2 ) - 10 , fObj.W-11 , ( fObj.H / 2 ) - 7 ) , Gdip_DeleteBrush( Brush )
}
Gdip_DeleteGraphics( G )
Bitmap.hBitmap := Gdip_CreateHBITMAPFromBitmap( Bitmap.pBitmap )
return Bitmap
}
_CreateHoverBitmap(){
local arr := [] , Bitmap := {} , fObj := This.CurrentBitmapData.Hover
Bitmap.pBitmap := Gdip_CreateBitmap( fObj.W , fObj.H ) , G := Gdip_GraphicsFromImage( Bitmap.pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( fObj.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -1 , -1 , fObj.W+2 , fObj.H+2 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.ButtonOuterBorderColor ) , Gdip_FillRoundedRectangle( G , Brush , 2 , 3 , fObj.W-5 , fObj.H-7 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.ButtonCenterBorderColor ) , Gdip_FillRoundedRectangle( G , Brush , 3 , 4 , fObj.W-7 , fObj.H-9 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , fObj.W , fObj.H-10 , fObj.ButtonInnerBorderColor1 , fObj.ButtonInnerBorderColor2 , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 4 , 5 , fObj.W-9 , fObj.H-11 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 5 , 7 , fObj.W-11 , fObj.H-14 , fObj.ButtonMainColor1 , fObj.ButtonMainColor2 , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 5 , 7 , fObj.W-11 , fObj.H-14 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 2 , fObj.W , fObj.H , fObj.TextBottomColor1 , fObj.TextBottomColor2 , 1 , 1 )
arr := [ { X: -1 , Y: -1 } , { X: 0 , Y: -1 } , { X: 1 , Y: -1 } , { X: -1 , Y: 0 } , { X: 1 , Y: 0 } , { X: -1 , Y: 1 } , { X: 0 , Y: 1 } , { X: 1 , Y: 1 } ]
Loop, % 8
Gdip_TextToGraphics( G , fObj.Text , "s" fObj.FontSize " " fObj.FontOptions " c" Brush " x" 0 + arr[A_Index].X + fObj.TextOffsetX " y" 2 + arr[A_Index].Y + fObj.TextOffsetY , fObj.Font , fObj.W + fObj.TextOffsetW , fObj.H + fObj.TextOffsetH )
Brush := Gdip_CreateLineBrushFromRect( 0 , 2 , fObj.W , fObj.H , fObj.TextTopColor1 , fObj.TextTopColor2 , 1 , 1 )
Gdip_TextToGraphics( G , fObj.Text , "s" fObj.FontSize " " fObj.FontOptions " c" Brush " x" 0 + fObj.TextOffsetX " y" 2 + fObj.TextOffsetY , fObj.Font , fObj.W + fObj.TextOffsetW , fObj.H + fObj.TextOffsetH )
if( fObj.ButtonAddGlossy = 1 ){
Brush := Gdip_BrushCreateSolid( fObj.GlossTopColor ) , Gdip_FillRectangle( G , Brush , 6 , 10 , fObj.W-13 , ( fObj.H / 2 ) - 10 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.GlossTopAccentColor ) , Gdip_FillRectangle( G , Brush , 10 , 12 , fObj.W-21 , fObj.H / 15 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.GlossBottomColor ) , Gdip_FillRectangle( G , Brush , 6 , 10 + ( fObj.H / 2 ) - 10 , fObj.W-13 , ( fObj.H / 2 ) - 7 ) , Gdip_DeleteBrush( Brush )
}
Gdip_DeleteGraphics( G )
Bitmap.hBitmap := Gdip_CreateHBITMAPFromBitmap( Bitmap.pBitmap )
return Bitmap
}
_CreateDefaultBitmap(){
local arr := [] , Bitmap := {} , fObj := This.CurrentBitmapData.Default
Bitmap.pBitmap := Gdip_CreateBitmap( fObj.W , fObj.H ) , G := Gdip_GraphicsFromImage( Bitmap.pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( fObj.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -1 , -1 , fObj.W+2 , fObj.H+2 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.ButtonOuterBorderColor ) , Gdip_FillRoundedRectangle( G , Brush , 2 , 3 , fObj.W-5 , fObj.H-7 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.ButtonCenterBorderColor ) , Gdip_FillRoundedRectangle( G , Brush , 3 , 4 , fObj.W-7 , fObj.H-9 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , fObj.W , fObj.H-10 , fObj.ButtonInnerBorderColor1 , fObj.ButtonInnerBorderColor2 , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 4 , 5 , fObj.W-9 , fObj.H-11 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 5 , 7 , fObj.W-11 , fObj.H-14 , fObj.ButtonMainColor1 , fObj.ButtonMainColor2 , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 5 , 7 , fObj.W-11 , fObj.H-14 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 2 , fObj.W , fObj.H , fObj.TextBottomColor1 , fObj.TextBottomColor2 , 1 , 1 )
arr := [ { X: -1 , Y: -1 } , { X: 0 , Y: -1 } , { X: 1 , Y: -1 } , { X: -1 , Y: 0 } , { X: 1 , Y: 0 } , { X: -1 , Y: 1 } , { X: 0 , Y: 1 } , { X: 1 , Y: 1 } ]
Loop, % 8
Gdip_TextToGraphics( G , fObj.Text , "s" fObj.FontSize " " fObj.FontOptions " c" Brush " x" 0 + arr[A_Index].X + fObj.TextOffsetX " y" 2 + arr[A_Index].Y + fObj.TextOffsetY , fObj.Font , fObj.W + fObj.TextOffsetW , fObj.H + fObj.TextOffsetH )
Brush := Gdip_CreateLineBrushFromRect( 0 , 2 , fObj.W , fObj.H , fObj.TextTopColor1 , fObj.TextTopColor2 , 1 , 1 )
Gdip_TextToGraphics( G , fObj.Text , "s" fObj.FontSize " " fObj.FontOptions " c" Brush " x" 0 + fObj.TextOffsetX " y" 2 + fObj.TextOffsetY , fObj.Font , fObj.W + fObj.TextOffsetW , fObj.H + fObj.TextOffsetH )
if( fObj.ButtonAddGlossy ){
Brush := Gdip_BrushCreateSolid( fObj.GlossTopColor ) , Gdip_FillRectangle( G , Brush , 6 , 10 , fObj.W-13 , ( fObj.H / 2 ) - 10 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.GlossTopAccentColor ) , Gdip_FillRectangle( G , Brush , 10 , 12 , fObj.W-21 , fObj.H / 15 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.GlossBottomColor ) , Gdip_FillRectangle( G , Brush , 6 , 10 + ( fObj.H / 2 ) - 10 , fObj.W-13 , ( fObj.H / 2 ) - 7 ) , Gdip_DeleteBrush( Brush )
}
Gdip_DeleteGraphics( G )
Bitmap.hBitmap := Gdip_CreateHBITMAPFromBitmap( Bitmap.pBitmap )
return Bitmap
}
_GetMasterDefaultValues(){ ;Default State
local Default := {}
Default.pBitmap := ""
, Default.hBitmap := ""
, Default.Font := "Arial"
, Default.FontOptions := " Bold Center vCenter "
, Default.FontSize := "12"
, Default.Text := "Button"
, Default.W := 10
, Default.H := 10
, Default.TextBottomColor1 := "0x0002112F"
, Default.TextBottomColor2 := Default.TextBottomColor1
, Default.TextTopColor1 := "0xFFFFFFFF"
, Default.TextTopColor2 := "0xFF000000"
, Default.TextOffsetX := 0
, Default.TextOffsetY := 0
, Default.TextOffsetW := 0
, Default.TextOffsetH := 0
, Default.BackgroundColor := "0xFF22262A"
, Default.ButtonOuterBorderColor := "0xFF161B1F"
, Default.ButtonCenterBorderColor := "0xFF262B2F"
, Default.ButtonInnerBorderColor1 := "0xFF3F444A"
, Default.ButtonInnerBorderColor2 := "0xFF24292D"
, Default.ButtonMainColor1 := "0xFF272C32"
, Default.ButtonMainColor2 := "" Default.ButtonMainColor1
, Default.ButtonAddGlossy := 0
, Default.GlossTopColor := "0x11FFFFFF"
, Default.GlossTopAccentColor := "0x05FFFFFF"
, Default.GlossBottomColor := "0x33000000"
return Default
}
_GetMasterHoverValues(){ ;Hover State
local Default := {}
Default.pBitmap := ""
, Default.hBitmap := ""
, Default.Font := "Arial"
, Default.FontOptions := " Bold Center vCenter "
, Default.FontSize := "12"
, Default.Text := "Button"
, Default.W := 10
, Default.H := 10
, Default.TextBottomColor1 := "0x0002112F"
, Default.TextBottomColor2 := Default.TextBottomColor1
, Default.TextTopColor1 := "0xFFFFFFFF"
, Default.TextTopColor2 := "0xFF000000"
, Default.TextOffsetX := 0
, Default.TextOffsetY := 0
, Default.TextOffsetW := 0
, Default.TextOffsetH := 0
, Default.BackgroundColor := "0xFF22262A"
, Default.ButtonOuterBorderColor := "0xFF161B1F"
, Default.ButtonCenterBorderColor := "0xFF262B2F"
, Default.ButtonInnerBorderColor1 := "0xFF3F444A"
, Default.ButtonInnerBorderColor2 := "0xFF24292D"
, Default.ButtonMainColor1 := "0xFF373C42"
, Default.ButtonMainColor2 := "" Default.ButtonMainColor1
, Default.ButtonAddGlossy := 0
, Default.GlossTopColor := "0x11FFFFFF"
, Default.GlossTopAccentColor := "0x05FFFFFF"
, Default.GlossBottomColor := "0x33000000"
return Default
}
_GetMasterPressedValues(){ ;Pressed State
local Default := {}
Default.pBitmap := ""
, Default.hBitmap := ""
, Default.Font := "Arial"
, Default.FontOptions := " Bold Center vCenter "
, Default.FontSize := "12"
, Default.Text := "Button"
, Default.W := 10
, Default.H := 10
, Default.TextBottomColor1 := "0x0002112F"
, Default.TextBottomColor2 := Default.TextBottomColor1
, Default.TextTopColor1 := "0xFFFFFFFF"
, Default.TextTopColor2 := "0xFF000000"
, Default.TextOffsetX := 0
, Default.TextOffsetY := 0
, Default.TextOffsetW := 0
, Default.TextOffsetH := 0
, Default.BackgroundColor := "0xFF22262A"
, Default.ButtonOuterBorderColor := "0xFF62666a"
, Default.ButtonCenterBorderColor := "0xFF262B2F"
, Default.ButtonInnerBorderColor1 := "0xFF151A20"
, Default.ButtonInnerBorderColor2 := "0xFF151A20"
, Default.ButtonMainColor1 := "0xFF12161a"
, Default.ButtonMainColor2 := "0xFF33383E"
, Default.ButtonAddGlossy := 0
, Default.GlossTopColor := "0x11FFFFFF"
, Default.GlossTopAccentColor := "0x05FFFFFF"
, Default.GlossBottomColor := "0x33000000"
return Default
}
SetSessionDefaults( All := "" , Default := "" , Hover := "" , Pressed := "" ){ ;Set the default values based on user input
This.SessionBitmapData := {}
, This.Preset := 1
, This.init := 0
This._LoadDefaults("SessionBitmapData")
This._SetSessionData( All , Default , Hover , Pressed )
}
_SetSessionData( All := "" , Default := "" , Hover := "" , Pressed := "" ){
local index , k , v , i , j
if( IsObject( All ) ){
Loop, % GuiButtonType1.List.Length() {
index := A_Index
For k , v in All
This.SessionBitmapData[ GuiButtonType1.List[ index ] ][ k ] := v
}
}
For k , v in GuiButtonType1.List
if( isObject( %v% ) )
For i , j in %v%
This.SessionBitmapData[ GuiButtonType1.List[ k ] ][ i ] := j
}
_LoadDefaults( input := "" ){
This.CurrentBitmapData := "" , This.CurrentBitmapData := {}
For k , v in This.SessionBitmapData
This.CurrentBitmapData[k] := {}
This[ input ].Default := This._GetMasterDefaultValues()
, This[ input ].Hover := This._GetMasterHoverValues()
, This[ input ].Pressed := This._GetMasterPressedValues()
}
_SetCurrentBitmapDataFromSessionData(){
local k , v , i , j
This.CurrentBitmapData := "" , This.CurrentBitmapData := {}
For k , v in This.SessionBitmapData
{
This.CurrentBitmapData[k] := {}
For i , j in This.SessionBitmapData[k]
This.CurrentBitmapData[k][i] := j
}
}
_UpdateCurrentBitmapData( All := "" , Default := "" , Hover := "" , Pressed := "" ){
local k , v , i , j
if( IsObject( All ) ){
Loop, % GuiButtonType1.List.Length() {
index := A_Index
For k , v in All
This.CurrentBitmapData[ GuiButtonType1.List[ index ] ][ k ] := v
}
}
For k , v in GuiButtonType1.List
if( isObject( %v% ) )
For i , j in %v%
This.CurrentBitmapData[ GuiButtonType1.List[ k ] ][ i ] := j
}
_UpdateInstanceData( obj := ""){
For k , v in GuiButtonType1.List
This.CurrentBitmapData[v].Text := obj.Text
, This.CurrentBitmapData[v].W := obj.W
, This.CurrentBitmapData[v].H := obj.H
}
CreateButtonBitmapSet( obj := "" , All := "" , Default := "" , Hover := "" , Pressed := "" ){ ;Create a new button
local Bitmaps := {}
if( This.Preset )
This._SetCurrentBitmapDataFromSessionData()
else
This._LoadDefaults( "CurrentBitmapData" )
This._UpdateCurrentBitmapData( All , Default , Hover , Pressed )
This._UpdateInstanceData( obj )
Bitmaps.Default := This._CreateDefaultBitmap()
, Bitmaps.Hover := This._CreateHoverBitmap()
, Bitmaps.Pressed := This._CreatePressedBitmap()
return Bitmaps
}
}
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;####################################################################################################################################################################################
class PopUpWindow {
;PopUpWindow v2.2
;Date Written: Oct 28th, 2021
;Last Edit: Feb 7th, 2022 :Changed the trigger method.
;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 := 10
This.Y := 10
This.W := 10
This.H := 10
This.Smoothing := 2
This.Options := " -DPIScale +AlwaysOnTop "
This.AutoShow := 0
This.GdipStartUp := 0
This.Title := ""
This.Controls := []
This.Handles := []
This.Index := 0
}
AddTrigger( obj ){
local k , v , cc , bd
This.Controls[ ++This.Index ] := { X: 10
, Y: 10
, W: 10
, H: 10 }
for k, v in obj
This.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.Index
This.Controls[ This.Index ].Hwnd := hwnd
if( IsObject( cc.Label ) ){
bd := cc.Label
GuiControl, % This.Hwnd ":+G" , % hwnd , % bd
}else{
bd := This._TriggerCall.Bind( This )
GuiControl, % This.Hwnd ":+G" , % hwnd , % bd
}
return hwnd
}
_TriggerCall(){
MouseGetPos,,,, ctrl, 2
Try
;~ SetTimer, % This.Controls[ This.Handles[ ctrl ] ].Label, -0
gosub, % This.Controls[ This.Handles[ ctrl ] ].Label
}
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 , v
if( IsObject( obj ) )
for k, v in obj
This[ 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 hwnd
Gui , New, % " +LastFound +E0x80000 hwndhwnd -Caption " This.Options
PopUpWindow.Index++
This.Index := PopUpWindow.Index
PopUpWindow.Windows[ PopUpWindow.Index ] := This
This.Hwnd := hwnd
PopUpWindow.Handles[ hwnd ] := PopUpWindow.Index
if( This.GdipStartUp && !PopUpWindow.pToken )
PopUpWindow.pToken := GDIP_STARTUP()
}
_DestroyWindowsGraphics(){
Gdip_DeleteGraphics( This.G )
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( alpha := 255 ){
UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H , alpha )
}
ClearWindow( AutoUpdate := 0 , Color := "" ){
if( color != "" )
Gdip_GraphicsClear( This.G , color )
else
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 )
else
Gdip_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.Hwnd
for 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 pCachedBitmap
if( This.CachedBitmap )
This.DisposeCachedbitmap()
DllCall( "gdiplus\GdipCreateCachedBitmap" , "Ptr" , pBitmap , "Ptr" , this.G , "PtrP" , pCachedBitmap )
This.CachedBitmap := pCachedBitmap
if( 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 +HwndHwnd
PopUpWindow.HelperHwnd := hwnd
Gui, Add, Edit, xm ym w250 r1 Center hwndhwnd, Gui1
PopUpWindow.EditHwnd := hwnd
loop, % 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.EditHwnd
ClipList := { __New: " := New PopUpWindow( { AutoShow: 1 , 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 , AutoUpdate := 0 )"
, PaintBackground: ".PaintBackground( color := ""0xFF000000"" , AutoUpdate := 0 ) " ";{ 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: """" } )"
, DrawTriggers: ".DrawTriggers( color := ""0xFFFF0000"" , AutoUpdate := 0 )"
, CreateCachedBitmap: ".CreateCachedBitmap( pBitmap , Dispose := 0 )"
, DrawCachedBitmap: ".DrawCachedBitmap( AutoUpdate := 0 )"
, DisposeCachedbitmap: ".DisposeCachedbitmap()" }
clipboard := Out ClipList[ A_GuiControl ]
}
}
;**************************************************************************************************************************************************************************************************************
;**************************************************************************************************************************************************************************************************************
;**************************************************************************************************************************************************************************************************************
;**************************************************************************************************************************************************************************************************************
;Written By: Hellbent
;Date: Jan 22nd, 2022
class PositionButtons {
__New( obj := "" ){
This._SetDefaults()
This._UpdateDefaults( obj )
This._CreateWindow()
This._GraphicsSetup()
This._AddControls()
This._BindControls()
This.ShowControl()
This.UpdateControl()
This._SetHoverTimer()
}
_SetDefaults(){
This.Smoothing := 2
This.InterpolationMode := 7
This.hbm := ""
This.Hwnd := ""
This.hdc := ""
This.obm := ""
This.G := ""
This.WindowOptions := " +LastFound +E0x80000 hwndhwnd -Caption "
This.Scale := 1
This.Width := 204
This.Height := 109
This.X := 10
This.Y := 10
This.Controls := []
This.Handles := []
This.Controls[ 1 ] := { X: 63 * This.Scale , Y: 15 * This.Scale , W: 78 * This.Scale , H: 40 * This.Scale }
This.Controls[ 2 ] := { X: 63 * This.Scale , Y: 56 * This.Scale , W: 78 * This.Scale , H: 40 * This.Scale }
This.Controls[ 3 ] := { X: 20 * This.Scale , Y: 28 * This.Scale , W: 40 * This.Scale , H: 56 * This.Scale }
This.Controls[ 4 ] := { X: 148 * This.Scale , Y: 28 * This.Scale , W: 40 * This.Scale , H: 56 * This.Scale }
This.Bind := []
This.XOffset := 38
This.YOffset := 18
This.ButtonTopHighlightColor := "0xFF3399FF"
This.ButtonBottomHighlightColor := "0x66336699"
This.HoverTimer := This._MouseHover.Bind( This )
}
_UpdateDefaults( obj := "" ){
local k , v , index := 0
for k, v in obj {
if( IsObject( obj[ k ] ) ){
for i, j in obj[ k ] {
This[ k , i ] := obj[ k , i ]
}
}else{
This[ k ] := obj[ k ]
}
}
This._Scale()
}
_Scale(){
This.Width := 204 * This.Scale
This.Height := 109 * This.Scale
This.X *= This.Scale
This.Y *= This.Scale
This.Controls[ 1 ] := { X: 63 * This.Scale , Y: 15 * This.Scale , W: 78 * This.Scale , H: 40 * This.Scale }
This.Controls[ 2 ] := { X: 63 * This.Scale , Y: 56 * This.Scale , W: 78 * This.Scale , H: 40 * This.Scale }
This.Controls[ 3 ] := { X: 20 * This.Scale , Y: 28 * This.Scale , W: 40 * This.Scale , H: 56 * This.Scale }
This.Controls[ 4 ] := { X: 148 * This.Scale , Y: 28 * This.Scale , W: 40 * This.Scale , H: 56 * This.Scale }
}
_SetHoverTimer( state := "" ){
local HoverTimer := This.HoverTimer
SetTimer, % HoverTimer , % ( state = "" ) ? ( 60 ) : ( State )
}
_MouseHover(){
static index := 0
MouseGetPos,,,, ctrl, 2
if( This.Handles[ ctrl ] && !This.Active ){
This.Active := This.Handles[ ctrl ]
This.UpdateControl()
}else if( This.Active && This.Handles[ ctrl ] != This.Active && !This.Active := "" ){
This.UpdateControl()
}
}
_OnClick(){
This._SetHoverTimer( "Off" )
This.Pressed := This.Handles[ This._GetControlHwnd() ]
This.Active := ""
This.UpdateControl()
While( GetKeyState( "LButton" ) )
sleep, 60
if( This.Pressed != This.Handles[ This._GetControlHwnd() ] ){
This.Pressed := ""
This.Active := This.Handles[ This._GetControlHwnd() ]
This.UpdateControl()
This._SetHoverTimer()
}else{
This.Pressed := ""
This.Active := This.Handles[ This._GetControlHwnd() ]
This.UpdateControl()
if( This.Bind[ This.Active ] ){
try{
This.Bind[ This.Active ].Call()
This._SetHoverTimer()
return
}
try{
This._SetHoverTimer()
gosub, % This.Bind[ This.Active ]
return
}
}
}
}
_GetControlHwnd(){
local ctrl
MouseGetPos,,,, ctrl, 2
return ctrl
}
_CreateWindow(){
local hwnd
Gui , New, % This.WindowOptions " +Parent" This.Parent
This.Hwnd := hwnd
}
_GraphicsSetup(){
This.hbm := CreateDIBSection( This.Width , This.Height )
This.hdc := CreateCompatibleDC()
This.obm := SelectObject( This.hdc , This.hbm )
This.G := Gdip_GraphicsFromHDC( This.hdc )
Gdip_SetSmoothingMode( This.G , This.Smoothing )
Gdip_SetInterpolationMode( This.G , This.InterpolationMode )
}
_AddControls(){
local hwnd
loop, 4 {
Gui, % This.Hwnd ":Add", Text, % "x" This.Controls[ A_Index ].X " y" This.Controls[ A_Index ].Y " w" This.Controls[ A_Index ].W " h" This.Controls[ A_Index ].H " hwndhwnd"
This.Controls[ A_Index ].Hwnd := hwnd
This.Handles[ hwnd ] := A_Index
}
}
_BindControls(){
local bd := This._OnClick.Bind( This )
Loop, 4
GuiControl, % This.Hwnd ":+G" , % This.Controls[ A_Index ].Hwnd , % bd
}
ShowControl(){
Gui, % This.Hwnd ":Show",
}
_ClearWindow(){
Gdip_GraphicsClear( This.G )
}
_UpdateWindow(){
UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.Width , This.Height )
}
UpdateControl(){
This._ClearWindow()
This.DrawControlBitmap()
This._UpdateWindow()
}
DrawControlBitmap(){
;background left
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_FillEllipse( This.G , Brush , ( 40 - This.XOffset ) * This.Scale , ( 20 - This.YOffset ) * This.Scale , 200 * This.Scale , 105 * This.Scale ) , Gdip_DeleteBrush( Brush )
;inner circle
Brush := Gdip_CreateLineBrushFromRect( ( 40 - This.XOffset ) * This.Scale , ( 25 - This.YOffset ) * This.Scale , 190 * This.Scale , 79 * This.Scale , "0xFF72767a" , "0xFF000000" , 1 , 1 ) , Gdip_FillEllipse( This.G , Brush , ( 45 - This.XOffset ) * This.Scale , ( 26 - This.YOffset ) * This.Scale , 190 * This.Scale , 94 * This.Scale ) , Gdip_DeleteBrush( Brush )
;***************************************************************************************************************************
;***************************************************************************************************************************
;Button 1
if( This.Pressed = 1 )
Brush := Gdip_CreateLineBrushFromRect( ( 102 - This.XOffset ) * This.Scale , ( 34 - This.YOffset ) * This.Scale , 77 * This.Scale , 33 * This.Scale , "0xFF12161a" , "0xFF22262a" , 1 , 1 ) , Gdip_FillRoundedRectangle( This.G , Brush , ( 103 - This.XOffset ) * This.Scale , ( 35 - This.YOffset ) * This.Scale , 74 * This.Scale , 36 * This.Scale , 5 * This.Scale ) , Gdip_DeleteBrush( Brush )
else
Brush := Gdip_CreateLineBrushFromRect( ( 102 - This.XOffset ) * This.Scale , ( 34 - This.YOffset ) * This.Scale , 77 * This.Scale , 33 * This.Scale , "0xFF32363a" , "0xFF22262a" , 1 , 1 ) , Gdip_FillRoundedRectangle( This.G , Brush , ( 103 - This.XOffset ) * This.Scale , ( 35 - This.YOffset ) * This.Scale , 74 * This.Scale , 36 * This.Scale , 5 * This.Scale ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( ( 103 - This.XOffset ) * This.Scale , ( 33 - This.YOffset ) * This.Scale , 77 * This.Scale , 36 * This.Scale , "0xFF3F4752" , "0xFF1C2024" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.G , Pen , ( 103 - This.XOffset ) * This.Scale , ( 35 - This.YOffset ) * This.Scale , 74 * This.Scale , 36 * This.Scale , 5 * This.Scale ) , Gdip_DeletePen( Pen )
if( This.Pressed = 1 ){
Brush := Gdip_BrushCreateSolid( "0xAA3399FF" ) , Gdip_FillRectangle( This.G , Brush , ( 106 - This.XOffset ) * This.Scale , ( 38 - This.YOffset ) * This.Scale , 68 * This.Scale , 15 * This.Scale ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99336699" ) , Gdip_FillRectangle( This.G , Brush , ( 106 - This.XOffset ) * This.Scale , ( 53 - This.YOffset ) * This.Scale , 68 * This.Scale , 15 * This.Scale ) , Gdip_DeleteBrush( Brush )
}else if( This.Active = 1 ){
Brush := Gdip_BrushCreateSolid( "0x993399FF" ) , Gdip_FillRectangle( This.G , Brush , ( 106 - This.XOffset ) * This.Scale , ( 38 - This.YOffset ) * This.Scale , 68 * This.Scale , 15 * This.Scale ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x66336699" ) , Gdip_FillRectangle( This.G , Brush , ( 106 - This.XOffset ) * This.Scale , ( 53 - This.YOffset ) * This.Scale , 68 * This.Scale , 15 * This.Scale ) , Gdip_DeleteBrush( Brush )
}else{
Brush := Gdip_BrushCreateSolid( "0x66F0F0F0" ) , Gdip_FillRectangle( This.G , Brush , ( 106 - This.XOffset ) * This.Scale , ( 38 - This.YOffset ) * This.Scale , 68 * This.Scale , 15 * This.Scale ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillRectangle( This.G , Brush , ( 106 - This.XOffset ) * This.Scale , ( 53 - This.YOffset ) * This.Scale , 68 * This.Scale , 15 * This.Scale ) , Gdip_DeleteBrush( Brush )
}
if( This.Pressed = 1 )
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( This.G , "5" , "s" 22 * This.Scale " Center vCenter c" Brush " x" ( 104 - This.XOffset ) * This.Scale " y" ( 37 - This.YOffset ) * This.Scale , "Webdings" , 74 * This.Scale , 36 * This.Scale ) , Gdip_DeleteBrush( Brush )
else
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( This.G , "5" , "s" 22 * This.Scale " Center vCenter c" Brush " x" ( 104 - This.XOffset ) * This.Scale " y" ( 36 - This.YOffset ) * This.Scale , "Webdings" , 74 * This.Scale , 36 * This.Scale ) , Gdip_DeleteBrush( Brush )
;***************************************************************************************************************************
;***************************************************************************************************************************
;Button 2
if( This.Pressed = 2 ){
Brush := Gdip_CreateLineBrushFromRect( ( 107 - This.XOffset ) * This.Scale , ( 78 - This.YOffset ) * This.Scale , 70 * This.Scale , 36 * This.Scale , "0xFF12161a" , "0xFF22262a" , 1 , 1 ) , Gdip_FillRoundedRectangle( This.G , Brush , ( 103 - This.XOffset ) * This.Scale , ( 76 - This.YOffset ) * This.Scale , 74 * This.Scale , 36 * This.Scale , 5 * This.Scale ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( ( 103 - This.XOffset ) * This.Scale , ( 79 - This.YOffset ) * This.Scale , 74 * This.Scale , 35 * This.Scale , "0xFF02050a" , "0xFF22262a" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.G , Pen , ( 103 - This.XOffset ) * This.Scale , ( 76 - This.YOffset ) * This.Scale , 74 * This.Scale , 36 * This.Scale , 5 * This.Scale ) , Gdip_DeletePen( Pen )
}else{
Brush := Gdip_CreateLineBrushFromRect( ( 107 - This.XOffset ) * This.Scale , ( 78 - This.YOffset ) * This.Scale , 70 * This.Scale , 36 * This.Scale , "0xFF32363a" , "0xFF22262a" , 1 , 1 ) , Gdip_FillRoundedRectangle( This.G , Brush , ( 103 - This.XOffset ) * This.Scale , ( 76 - This.YOffset ) * This.Scale , 74 * This.Scale , 36 * This.Scale , 5 * This.Scale ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( ( 103 - This.XOffset ) * This.Scale , ( 79 - This.YOffset ) * This.Scale , 74 * This.Scale , 35 * This.Scale , "0xFF3F4752" , "0xFF1C2024" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.G , Pen , ( 103 - This.XOffset ) * This.Scale , ( 76 - This.YOffset ) * This.Scale , 74 * This.Scale , 36 * This.Scale , 5 * This.Scale ) , Gdip_DeletePen( Pen )
}
if( This.Pressed = 2 ){
Brush := Gdip_BrushCreateSolid( "0xAA3399FF" ) , Gdip_FillRectangle( This.G , Brush , ( 106 - This.XOffset ) * This.Scale , ( 79 - This.YOffset ) * This.Scale , 68 * This.Scale , 15 * This.Scale ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99336699" ) , Gdip_FillRectangle( This.G , Brush , ( 106 - This.XOffset ) * This.Scale , ( 94 - This.YOffset ) * This.Scale , 68 * This.Scale , 15 * This.Scale ) , Gdip_DeleteBrush( Brush )
}else if( This.Active = 2 ){
Brush := Gdip_BrushCreateSolid( "0x993399FF" ) , Gdip_FillRectangle( This.G , Brush , ( 106 - This.XOffset ) * This.Scale , ( 79 - This.YOffset ) * This.Scale , 68 * This.Scale , 15 * This.Scale ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x66336699" ) , Gdip_FillRectangle( This.G , Brush , ( 106 - This.XOffset ) * This.Scale , ( 94 - This.YOffset ) * This.Scale , 68 * This.Scale , 15 * This.Scale ) , Gdip_DeleteBrush( Brush )
}else{
Brush := Gdip_BrushCreateSolid( "0x66F0F0F0" ) , Gdip_FillRectangle( This.G , Brush , ( 106 - This.XOffset ) * This.Scale , ( 79 - This.YOffset ) * This.Scale , 68 * This.Scale , 15 * This.Scale ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillRectangle( This.G , Brush , ( 106 - This.XOffset ) * This.Scale , ( 94 - This.YOffset ) * This.Scale , 68 * This.Scale , 15 * This.Scale ) , Gdip_DeleteBrush( Brush )
}
if( This.Pressed = 2 )
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( This.G , "6" , "s" 22 * This.Scale " Center vCenter c" Brush " x" ( 104 - This.XOffset ) * This.Scale " y" ( 77 - This.YOffset ) * This.Scale , "Webdings" , 74 * This.Scale , 36 * This.Scale ) , Gdip_DeleteBrush( Brush )
else
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( This.G , "6" , "s" 22 * This.Scale " Center vCenter c" Brush " x" ( 104 - This.XOffset ) * This.Scale " y" ( 76 - This.YOffset ) * This.Scale , "Webdings" , 74 * This.Scale , 36 * This.Scale ) , Gdip_DeleteBrush( Brush )
;***************************************************************************************************************************
;***************************************************************************************************************************
;Button 3
if( This.Pressed = 3 ){
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_FillPie( This.G , Brush , ( 49 - This.XOffset ) * This.Scale , ( 39 - This.YOffset ) * This.Scale , 95 * This.Scale , 70 * This.Scale , 90 , 180 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( ( 51 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 44 * This.Scale , 65 * This.Scale , "0xFF12161a" , "0xFF22262a" , 1 , 1 ) , Gdip_FillPie( This.G , Brush , ( 51 - This.XOffset ) * This.Scale , ( 41 - This.YOffset ) * This.Scale , 89 * This.Scale , 66 * This.Scale , 90 , 180 ) , Gdip_DeleteBrush( Brush )
}else{
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_FillPie( This.G , Brush , ( 49 - This.XOffset ) * This.Scale , ( 39 - This.YOffset ) * This.Scale , 95 * This.Scale , 70 * This.Scale , 90 , 180 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( ( 51 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 44 * This.Scale , 65 * This.Scale , "0xFF32363a" , "0xFF22262a" , 1 , 1 ) , Gdip_FillPie( This.G , Brush , ( 51 - This.XOffset ) * This.Scale , ( 41 - This.YOffset ) * This.Scale , 89 * This.Scale , 66 * This.Scale , 90 , 180 ) , Gdip_DeleteBrush( Brush )
}
if( This.Pressed = 3 )
Brush := Gdip_BrushCreateSolid( "0xAA3399FF" ) , Gdip_FillPie( This.G , Brush , ( 53 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 81 * This.Scale , 59 * This.Scale , 180 , 90 ) , Gdip_DeleteBrush( Brush )
else if( This.Active = 3 )
Brush := Gdip_BrushCreateSolid( "0x993399FF" ) , Gdip_FillPie( This.G , Brush , ( 53 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 81 * This.Scale , 59 * This.Scale , 180 , 90 ) , Gdip_DeleteBrush( Brush )
else
Brush := Gdip_BrushCreateSolid( "0x66F0F0F0" ) , Gdip_FillPie( This.G , Brush , ( 53 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 81 * This.Scale , 59 * This.Scale , 180 , 90 ) , Gdip_DeleteBrush( Brush )
if( This.Pressed = 3 )
Brush := Gdip_BrushCreateSolid( "0x99336699" ) , Gdip_FillPie( This.G , Brush , ( 53 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 81 * This.Scale , 59 * This.Scale , 90 , 90 ) , Gdip_DeleteBrush( Brush )
else if( This.Active = 3 )
Brush := Gdip_BrushCreateSolid( "0x66336699" ) , Gdip_FillPie( This.G , Brush , ( 53 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 81 * This.Scale , 59 * This.Scale , 90 , 90 ) , Gdip_DeleteBrush( Brush )
else
Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillPie( This.G , Brush , ( 53 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 81 * This.Scale , 59 * This.Scale , 90 , 90 ) , Gdip_DeleteBrush( Brush )
if( This.Pressed = 3 )
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( This.G , "3" , "s" 22 * This.Scale " Center vCenter c" Brush " x" ( 49 - This.XOffset ) * This.Scale " y" ( 40 - This.YOffset ) * This.Scale , "Webdings" , 55 * This.Scale , 70 * This.Scale ) , Gdip_DeleteBrush( Brush )
else
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( This.G , "3" , "s" 22 * This.Scale " Center vCenter c" Brush " x" ( 49 - This.XOffset ) * This.Scale " y" ( 39 - This.YOffset ) * This.Scale , "Webdings" , 55 * This.Scale , 70 * This.Scale ) , Gdip_DeleteBrush( Brush )
;***************************************************************************************************************************
;***************************************************************************************************************************
;Button 4
if( This.Pressed = 4 ){
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_FillPie( This.G , Brush , ( 136 - This.XOffset ) * This.Scale , ( 39 - This.YOffset ) * This.Scale , 95 * This.Scale , 70 * This.Scale , 90 , -180 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( ( 51 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 44 * This.Scale , 65 * This.Scale , "0xFF12161a" , "0xFF22262a" , 1 , 1 ) , Gdip_FillPie( This.G , Brush , ( 140 - This.XOffset ) * This.Scale , ( 41 - This.YOffset ) * This.Scale , 89 * This.Scale , 66 * This.Scale , 90 , -180 ) , Gdip_DeleteBrush( Brush )
}else{
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_FillPie( This.G , Brush , ( 136 - This.XOffset ) * This.Scale , ( 39 - This.YOffset ) * This.Scale , 95 * This.Scale , 70 * This.Scale , 90 , -180 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( ( 51 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 44 * This.Scale , 65 * This.Scale , "0xFF32363a" , "0xFF22262a" , 1 , 1 ) , Gdip_FillPie( This.G , Brush , ( 140 - This.XOffset ) * This.Scale , ( 41 - This.YOffset ) * This.Scale , 89 * This.Scale , 66 * This.Scale , 90 , -180 ) , Gdip_DeleteBrush( Brush )
}
if( This.Pressed = 4 ){
Brush := Gdip_BrushCreateSolid( "0xAA3399FF" ) , Gdip_FillPie( This.G , Brush , ( 146 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 81 * This.Scale , 59 * This.Scale , -90 , 90 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99336699" ) , Gdip_FillPie( This.G , Brush , ( 146 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 81 * This.Scale , 59 * This.Scale , 90 , -90 ) , Gdip_DeleteBrush( Brush )
}else if( This.Active = 4 ){
Brush := Gdip_BrushCreateSolid( "0x993399FF" ) , Gdip_FillPie( This.G , Brush , ( 146 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 81 * This.Scale , 59 * This.Scale , -90 , 90 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x66336699" ) , Gdip_FillPie( This.G , Brush , ( 146 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 81 * This.Scale , 59 * This.Scale , 90 , -90 ) , Gdip_DeleteBrush( Brush )
}else{
Brush := Gdip_BrushCreateSolid( "0x66F0F0F0" ) , Gdip_FillPie( This.G , Brush , ( 146 - This.XOffset ) * This.Scale , ( 44 - This.YOffset ) * This.Scale , 81 * This.Scale , 59 * This.Scale , -90 , 90 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillPie( This.G , Brush , ( 146 - This.XOffset ) * This.Scale , ( 46 - This.YOffset ) * This.Scale , 81 * This.Scale , 59 * This.Scale , 90 , -90 ) , Gdip_DeleteBrush( Brush )
}
if( This.Pressed = 4 )
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( This.G , "4" , "s" 22 * This.Scale " Center vCenter c" Brush " x" ( 179 - This.XOffset ) * This.Scale " y" ( 40 - This.YOffset ) * This.Scale , "Webdings" , 55 * This.Scale , 70 * This.Scale ) , Gdip_DeleteBrush( Brush )
else
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( This.G , "4" , "s" 22 * This.Scale " Center vCenter c" Brush " x" ( 179 - This.XOffset ) * This.Scale " y" ( 39 - This.YOffset ) * This.Scale , "Webdings" , 55 * This.Scale , 70 * This.Scale ) , Gdip_DeleteBrush( Brush )
;inner circle
;***************************************************************************************************************************
;***************************************************************************************************************************
;~ Brush := Gdip_BrushCreateSolid( "0x2266AAFF" ) , Gdip_FillEllipse( This.G , Brush , ( 45 - This.XOffset ) * This.Scale , ( 26 - This.YOffset ) * This.Scale , 190 * This.Scale , 94 * This.Scale ) , Gdip_DeleteBrush( Brush )
}
}
;**************************************************************************************************************************************************************************************************************
;**************************************************************************************************************************************************************************************************************
;**************************************************************************************************************************************************************************************************************
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;**************************************
HSL_ToRGB(hue, sat:=1, lum:=0.5 ) {
; Function by [VxE]. See > http://www.wikipedia.org/wiki/HSV_color_space
; HSL to/from RGB conversion functions by [VxE]. Freely avalable @ http://www.autohotkey.com/community/viewtopic.php?f=2&t=88707
; Converts a hue/sat/lum into a 24-bit RGB color code. Input: 0 <= hue <= 360, 0 <= sat <= 1, 0 <= lum <= 1.
Static i24 := 0xFFFFFF, i40 := 0xFFFFFF0000, hx := "0123456789ABCDEF"
; Transform the decimal inputs into 24-bit integers. Integer arithmetic is nice..
sat := ( sat * i24 ) & i24
lum := ( lum * i24 ) & i24
hue := ( hue * 0xB60B60 >> 8 ) & i24 ; conveniently, 360 * 0xB60B60 = 0xFFFFFF00
; Determine the chroma value and put it in the 'sat' var since the saturation value is not used after this.
sat := lum + Round( sat * ( i24 - Abs( i24 - lum - lum ) ) / 0x1FFFFFE )
; Calculate the base values for red and blue (green's base value is the hue)
red := hue < 0xAAAAAA ? hue + 0x555555 : hue - 0xAAAAAA
blu := hue < 0x555555 ? hue + 0xAAAAAA : hue - 0x555555
; Run the blue value through the cases
If ( blu < 0x2AAAAB )
blu := sat + 2 * ( i24 - 6 * blu ) * ( lum - sat ) / i24 >> 16
Else If ( blu < 0x800000 )
blu := sat >> 16
Else If ( blu < 0xAAAAAA )
blu := sat + 2 * ( i24 - 6 * ( 0xAAAAAA - blu ) ) * ( lum - sat ) / i24 >> 16
Else
blu := 2 * lum - sat >> 16
; Run the red value through the cases
If ( red < 0x2AAAAB )
red := sat + 2 * ( i24 - 6 * red ) * ( lum - sat ) / i24 >> 16
Else If ( red < 0x800000 )
red := sat >> 16
Else If ( red < 0xAAAAAA )
red := sat + 2 * ( i24 - 6 * ( 0xAAAAAA - red ) ) * ( lum - sat ) / i24 >> 16
Else
red := 2 * lum - sat >> 16
; Run the green value through the cases
If ( hue < 0x2AAAAB )
hue := sat + 2 * ( i24 - 6 * hue ) * ( lum - sat ) / i24 >> 16
Else If ( hue < 0x800000 )
hue := sat >> 16
Else If ( hue < 0xAAAAAA )
hue := sat + 2 * ( i24 - 6 * ( 0xAAAAAA - hue ) ) * ( lum - sat ) / i24 >> 16
Else
hue := 2 * lum - sat >> 16
; Return the values in RGB as a hex integer
Return "0x" SubStr( hx, ( red >> 4 ) + 1, 1 ) SubStr( hx, ( red & 15 ) + 1, 1 )
. SubStr( hx, ( hue >> 4 ) + 1, 1 ) SubStr( hx, ( hue & 15 ) + 1, 1 )
. SubStr( hx, ( blu >> 4 ) + 1, 1 ) SubStr( hx, ( blu & 15 ) + 1, 1 )
} ; END - HSL_ToRGB( hue, sat, lum )
;*****************************************************
;********************************************************
GetFontNames(charset){ ;https://www.autohotkey.com/boards/viewtopic.php?t=12416#p386353
hDC := DllCall("GetDC", "UInt", 0, "Ptr")
VarSetCapacity(LOGFONT, 92, 0)
NumPut(charset, &LOGFONT + 23, "UChar")
DllCall("EnumFontFamiliesEx", "Ptr", hDC, "Ptr", 0 , "Ptr", RegisterCallback("EnumFontFamExProc", "F", 4) , "Ptr", pFonts := Object(Fonts := {}), "UInt", 0)
ObjRelease(pFonts), DllCall("ReleaseDC", "Ptr", 0, "Ptr", hDC)
Return Fonts
}
EnumFontFamExProc(lpelfe, lpntme, FontType, lParam){
font := StrGet(lpelfe + 28)
Object(lParam)[font] := ""
Return true
}
;*****************************************************
;********************************************************
Re: Crop bitmap and export as Base64 string? ( Create Icons )
I created a tool to create rotated text B64 strings and .PNGS which can be used in the Icon Maker.
. .
. .
Windows 8 or higher
. .
. .
Windows 8 or higher
Code: Select all
;****************************************************************************************************************************************************************************
#Include <My Altered GDIP lib> ;GDIP: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=6517 ;<<<--- ( GDI+ lib )
#Include <Gen 3 Buttons> ;https://www.autohotkey.com/boards/viewtopic.php?f=6&t=88153 ;<<<--- ( Custom Gui Buttons )
;#Include <PopUpWindow_V2> ;Already added to the bottom of the script.
;#Include <HB Vectors v2> ;Already added to the bottom of the script.
;****************************************************************************************************************************************************************************
#SingleInstance, Force
SetBatchLines, -1
Gdip_Startup()
;********************************************
;set the scripts main icon
;********************************************
IconB64 := "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAB1WSURBVHhe7VsHdFTV2h1qMmmkEELoHRJaQpOAUgII+kBQigqRJJBAIEDovYYO0gklgHRI6ETpVZqKCoogShGeIjVlkulzy/73mUyUkEF9iq73r/XOyl53Zu6dc8+3v37uRPO/8b/xzww/v8BafgFlW/n4B061o1Tget9SZU49DfFZ3nlxbQn/MiGOr///HEIACjbbp1SZ6zziT8G/zB1f/8CVPv6lOzim/e8eJQICKokF2xfuTKC/hMAszr1dWIfjdv89w9/fv7RdcKcL/1tw6L/CRUqUqOjt8Fuzk0X+7RBxQ5DvWM4/O3wCyrxD/37gbGHOULNeE7zSKQZNOg9GWLexaB2bjGZ9khEWmYyWfXl8ezJe6hSP9t0TUP+lVk7ncAZBvlCCY1n/zOCNZz+7EGeoGdIMLXpN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SpIRtITBahFQe5GM4EVW1GI9ESS0u5TnlgmBgbrJNPH1ChpvpdA089YfKWhHS2snLO2wjE5HSUCaDc3TrNh6JR0x/foXWJ9AbmH3F381KuKBswpRIKThS0j9+EvEnzPi7RMS+p5TEXNGRsRpEvKxSkJUvHVKRsdjMtoeUCiMhKasJZpsldBkMwXcJKMpXzffLiGMaLpDXAO0JnFtDypoTxJfO0YyhYWdUPEm0fGYFa0OWdHzlBW7L914TqfnwNOPv/7KeF5qFBDZIXnjFiy+akLUWRtizikYcB7od0FFLI9RJOW98zJ6nlfQ/TyFOMOYccqGf5Gw109QmySo82nFfuwoXpO4N0lgt7NAj7Mkke/fOSOOjDknJXQ6acGsr03YdfCQ82jvQL5HXy9iiE2T51mCwCut22JF2klM+UrCwIsy4j5XeIQdAy6K1yoGfK6iH9/HfgbE8JqYixKiP1MQyfe9BT6F/XXUpyo/V9GH76M+AXpdoHudt2LEZTNWn7qEbj16Ol3DL3h6s+NFDuFPIqg4vakD7bq8jekffoaxX1ow5LKEoZeBEV8Bw4mhl1UMuQQHFDsGX1Ix+MtfMYTvB30Jfk7ieBzIz0ZfsmDJuTt4Oybe6T3zIBQkFOVY7t8zfu9n83mo3bQVuoxZgKhtl+kKJgonYcw3wJjrwISbxA1gPDGOGOvAmO9VjLyqIP4Lie5kRPS+79EjcR2avdHL6T2eRq5iXvDP5J837DtITjZQnofSdcJQ5e0JqDs6BY3G70TrNVfRfssPaL/1DjpsvYt2m35Ay3XfI2TSfl6zA9WiZqBso98Ibs9ApOs/ner+ysj9XdHvW8PzULJybZSqFur03B+BXesvKtL/lWHPEs+pF/4eiP3LwKF/uLb/p4bQBrXy5/9T9HcgNE5zn/qX/gfgnxjiPzXEQv+Ke/wCWpbI6f9YgHvRw5E1hjqC5ikRsAoI6YDj3ClxLV+PfSH/8vLcodH8H59HGxeeViVMAAAAAElFTkSuQmCC"
SetIcon( B64ToPBitmap( IconB64 ) )
;********************************************
;set the custom button design
;********************************************
Theme1 := NewTheme()
GuiButtonType1.SetSessionDefaults( Theme1.All , Theme1.Default , Theme1.Hover , Theme1.Pressed )
;********************************************
Main := {}
Main.LumColor := Main.SelectedColor := "0xFF000000"
;********************************************
CreateMainWindow( Main )
;********************************************
CreatePanelWindow( Main )
;********************************************
CreateDispalyWindow( Main )
;********************************************
CreateControls( Main )
;********************************************
goSub, UpdateDemo
;********************************************
return ;<<<---- End Of Auto-Exectue Section
;********************************************************************************************
;******************************************************************************************** GuiClose
GuiClose:
GuiContextMenu:
*ESC::ExitApp
;********************************************************************************************
;********************************************************************************************
ClipCustomB64String: ;{
GuiControlGet, EditOutput , % Main.Hwnd ":" , % Main.MessageEdit.Hwnd
obj := {}
obj.FontType := Main.FontTypeDDL.Value
obj.FontSize := Main.FontSizeDial.Value
obj.Color := "0x" Main.AlphaDial.Value . SubStr( Main.SelectedColor , 5 )
obj.FontOptions := Main.FontOptionsDDL.Value
obj.String := EditOutput
obj.Angle := Main.AngleDial.Value
obj.Scale := Main.ScaleDial.Value
obj.DebugMode := Main.DebugMode
PNGOutput := New RotatableText( obj )
outBitmap := PNGOutput.Bitmap
Clipboard := ""
outB64 := Gdip_EncodeBitmapTo64string( outBitmap , "PNG" , 100 )
cString := "MyB64String := """ outB64 """"
cString .= "`npBitmap := B64ToPBitmap( MyB64String )"
Clipboard := cString
Sleep, 100
cString := ""
SoundBeep
return
;}
;********************************************************************************************
;******************************************************************************************** ClipB64ToPBitmapFunction
ClipB64ToPBitmapFunction: ;{
Clipboard := ClipBitmapFunction()
SoundBeep
return
;}
;********************************************************************************************
;******************************************************************************************** ClipB64
ClipB64: ;{
GuiControlGet, EditOutput , % Main.Hwnd ":" , % Main.MessageEdit.Hwnd
obj := {}
obj.FontType := Main.FontTypeDDL.Value
obj.FontSize := Main.FontSizeDial.Value
obj.Color := "0x" Main.AlphaDial.Value . SubStr( Main.SelectedColor , 5 )
obj.FontOptions := Main.FontOptionsDDL.Value
obj.String := EditOutput
obj.Angle := Main.AngleDial.Value
obj.Scale := Main.ScaleDial.Value
obj.DebugMode := Main.DebugMode
PNGOutput := New RotatableText( obj )
outBitmap := PNGOutput.Bitmap
Clipboard := ""
sleep, 500
outB64 := Gdip_EncodeBitmapTo64string( outBitmap , "PNG" , 100 )
Clipboard := outB64
SoundBeep
return
;}
;********************************************************************************************
;******************************************************************************************** SavePNG
SavePNG: ;{
GuiControlGet, EditOutput , % Main.Hwnd ":" , % Main.MessageEdit.Hwnd
obj := {}
obj.FontType := Main.FontTypeDDL.Value
obj.FontSize := Main.FontSizeDial.Value
obj.Color := "0x" Main.AlphaDial.Value . SubStr( Main.SelectedColor , 5 )
obj.FontOptions := Main.FontOptionsDDL.Value
obj.String := EditOutput
obj.Angle := Main.AngleDial.Value
obj.Scale := Main.ScaleDial.Value
obj.DebugMode := Main.DebugMode
PNGOutput := New RotatableText( obj )
outBitmap := PNGOutput.Bitmap
SetWorkingDir, % A_ScriptDir
IfNotExist, % A_WorkingDir "\SavedTextImages"
FileCreateDir, % A_WorkingDir "\SavedTextImages"
name := A_Now
Gdip_SaveBitmapToFile( outBitmap , A_WorkingDir "\SavedTextImages\" name ".png" , 100 )
Gdip_DisposeImage( outBitmap )
PNGOutput := ""
Clipboard := A_WorkingDir "\SavedTextImages\" name ".png"
SoundBeep
return
;}
;********************************************************************************************
;******************************************************************************************** Show_Hide_Demo
Show_Hide_Demo: ;{
if( !Main.Tog := !Main.Tog ){
goSub, UpdateDemo
Main.DisplayWindow.ShowWindow()
}else{
Main.DisplayWindow.HideWindow()
}
return
;}
;********************************************************************************************
;******************************************************************************************** ToggleDebugMode
ToggleDebugMode: ;{
Main.DebugMode := !Main.DebugMode
gosub, UpdateDemo
return
;}
;********************************************************************************************
;******************************************************************************************** UpdateDemo
UpdateDemo: ;{
GuiControlGet, EditOutput , % Main.Hwnd ":" , % Main.MessageEdit.Hwnd
obj := {}
obj.FontType := Main.FontTypeDDL.Value
obj.FontSize := Main.FontSizeDial.Value
obj.Color := "0x" Main.AlphaDial.Value . SubStr( Main.SelectedColor , 5 )
obj.FontOptions := Main.FontOptionsDDL.Value
obj.String := EditOutput
obj.Angle := Main.AngleDial.Value
obj.Scale := Main.ScaleDial.Value
obj.DebugMode := Main.DebugMode
Main.Output := New RotatableText( obj )
DrawDemoWindow( Main )
return
;}
;********************************************************************************************
;******************************************************************************************** GetPixelUnderCursor
GetPixelUnderCursor: ;{
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
MouseGetPos, px , py
PixelGetColor, outColor , px , py , RGB Fast
if( ( "0xFF" SubStr( outColor , 3 ) ) != Main.SelectedColor ){
Main.SelectedColor := "0xFF" SubStr( outColor , 3 )
DrawPanelWindow( Main )
}
return
;}
;********************************************************************************************
;******************************************************************************************** ColorChoice
ColorChoice: ;{
HotKey, *ctrl , ColorChoice , Off
SetTimer, GetPixelUnderCursor , Off
Main.PanelWindow.HideWindow()
DrawColorDisplay( Main , Main.Scale )
goSub, UpdateDemo
return
;}
;********************************************************************************************
;******************************************************************************************** SetSelectedColor
SetSelectedColor: ;{
WinGetPos, x , y ,,, % "ahk_id " Main.Hwnd
Main.PanelWindow.X := x - 60
Main.PanelWindow.Y := y - 60
Main.PanelWindow.ShowWindow()
DrawPanelWindow( Main )
HotKey, *ctrl , ColorChoice , On
SetTimer, GetPixelUnderCursor , On
return
;}
;********************************************************************************************
;******************************************************************************************** SetColorWheel
SetColorWheel: ;{
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
MouseGetPos, x , y
PixelGetColor, out , x , y , RGB Fast
Main.LumColor := "0xFF" SubStr( out , 3 )
DrawPanelWindow( Main )
return
;}
;********************************************************************************************
;******************************************************************************************** MoveWindow
MoveWindow: ;{
Main.PanelWindow.HideWindow()
PostMessage, 0xA1, 2 ,,, % "ahk_id " Main.Hwnd
While( GetKeyState( "LButton" , "P" ) )
Sleep, 30
WinGetPos, x , y ,,, % "ahk_id " Main.Hwnd
Main.X := x , Main.Y := y
Main.PanelWindow.X := Main.X - 60
Main.PanelWindow.Y := Main.Y - 60
Main.PanelWindow.ShowWindow()
return
;}
;********************************************************************************************
;******************************************************************************************** CreateDispalyWindow
CreateDispalyWindow( Main ){
Main.DisplayWindow := New PopUpWindow( { AutoShow: 1 , X: "Center" , Y: "Center" , W: A_ScreenWidth , H: A_ScreenHeight , Options: " -DPIScale +AlwaysOnTop " } )
Gui, % Main.Hwnd ": +Owner" Main.DisplayWindow.Hwnd
}
;********************************************************************************************
;******************************************************************************************** CreatePanelWindow
CreatePanelWindow( Main ){
Main.PanelWindow := New PopUpWindow( { AutoShow: 1 , X: Main.X - 60 , Y: Main.Y - 60 , W: Main.W + 120 , H: Main.H + 220 , Options: " +AlwaysOnTop -DPIScale +Toolwindow +Owner" Main.Hwnd } )
cc := Main.ColorWheel := CreateColorWheelBitmap( 30 , 360 , Main.Scale )
Main.ColorWheel.X := 20
Main.ColorWheel.Y := ( Main.PanelWindow.H - ( Main.ColorWheel.H + 20 ) ) / 2 + 10
Gui, % Main.PanelWindow.Hwnd ":Add", Text, % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " hwndhwnd gSetColorWheel"
;~ cc := Main.PanelWindow.MoveButton := { X: 58 , Y: 58 , W: Main.W + 10 , H: Main.H + 40 }
cc := Main.PanelWindow.MoveButton := { X: 58 , Y: 58 , W: Main.W + 10 , H: 25 }
Gui, % Main.PanelWindow.Hwnd ":Add", Text, % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " hwndhwnd gMoveWindow"
Main.TipPanel := { X: 10 , Y: Main.H + 100 , W: Main.PanelWindow.W - 20 , H: 100 }
}
;********************************************************************************************
;******************************************************************************************** CreateMainWindow
CreateMainWindow( Main ){
Main.Scale := 1
Main.Color := "0xFF212B37"
Main.X := A_ScreenWidth - 340
;~ Main.X := ( A_ScreenWidth - 340 ) / 2
Main.Y := 130
Main.W := 325
;~ Main.H := 510
Main.H := 500
Gui, New, +AlwaysOnTop -DPIScale hwndhwnd , Rotate Text Editor v1
Main.Hwnd := hwnd
Gui, Color, % SubStr( Main.Color , 5 ) , 000000
Gui, Show, % "x" Main.X " y" Main.Y " w" Main.W " h" Main.H
}
;********************************************************************************************
;******************************************************************************************** DrawDemoWindow
DrawDemoWindow( Main ){
Main.DisplayWindow.ClearWindow()
Main.DisplayWindow.DrawBitmap( Main.Output.Bitmap , { X: A_ScreenWidth / 2 - Main.Output.Width / 2 , Y: A_ScreenHeight / 2 - Main.Output.Height / 2 , W: Main.Output.Width , H: Main.Output.Height } , dispose := 1 , AutoUpdate := 0 )
Main.DisplayWindow.UpdateWindow()
}
;********************************************************************************************
;******************************************************************************************** DrawPanelWindow
DrawPanelWindow( Main ){
static LastColor := ""
if( LastColor != Main.LumColor ){
LastColor := Main.LumColor
Gdip_DisposeImage( Main.LumStrip.Bitmap )
Main.LumStrip := CreateLumStripBitmap( SubStr( Main.LumColor , 5 ) , width := Main.W - 40 , height := 20 , scale := Main.Scale )
}
Main.PanelWindow.ClearWindow()
DrawColorWheelPanel( Main )
DrawLumStripPanel( Main )
cc := Main.PanelWindow.MoveButton
Main.PanelWindow.PaintBackground( { Color: "0x05000000" , X: cc.X , Y: cc.Y , W: cc.W , H: cc.H , Round: 8 } )
DrawTipPanel( Main )
Main.PanelWindow.UpdateWindow()
}
;********************************************************************************************
;******************************************************************************************** DrawTipPanel
DrawTipPanel( Main , Text := "" ){
if( Text = "" ){
Text := "Hover your cursor over a color and then`npress ""ctrl"" to lock it.`nClick on the color strip to update the`ngradient strip."
}
cc := Main.TipPanel
Main.PanelWindow.PaintBackground( { Color: "0xFF212B37" , X: cc.X , Y: cc.Y , W: cc.W , H: cc.H , Round: 8 } )
TextSizeObj := { X: cc.X + 41 , Y: cc.Y + 11 , W: cc.W - 50 , H: cc.H - 20 }
DrawText( Main.PanelWindow.G , TextSizeObj , Text , FontSize := 16 , FontType := "Segoe UI" , Options := " Center vCenter Bold " , Color := "0xFF000000" , Scale := Main.Scale )
TextSizeObj := { X: cc.X + 40 , Y: cc.Y + 10 , W: cc.W - 50 , H: cc.H - 20 }
DrawText( Main.PanelWindow.G , TextSizeObj , Text , FontSize := 16 , FontType := "Segoe UI" , Options := " Center vCenter Bold " , Color := "0xFFFFFFFF" , Scale := Main.Scale )
Main.PanelWindow.PaintBackground( { Color: "0xFF000000" , X: cc.X + 10 , Y: cc.Y + 10 , W: 30 , H: cc.H - 20 , Round: 8 } )
Main.PanelWindow.PaintBackground( { Color: Main.SelectedColor , X: cc.X + 12 , Y: cc.Y + 12 , W: 26 , H: cc.H - 24 , Round: 8 } )
}
;********************************************************************************************
;******************************************************************************************** DrawLumStripPanel
DrawLumStripPanel( Main ){
Main.PanelWindow.PaintBackground( { Color: "0x99000000" , X: 70 , Y: 15 , W: Main.LumStrip.W + 20 , H: Main.LumStrip.H + 20 , Round: 10 } )
Main.PanelWindow.PaintBackground( { Color: "0x99212B37" , X: 72 , Y: 17 , W: Main.LumStrip.W + 16 , H: Main.LumStrip.H + 16 , Round: 8 } )
Main.PanelWindow.DrawBitmap( Main.LumStrip.Bitmap , { X: 80 , Y: 25 , W: Main.LumStrip.W , H: Main.LumStrip.H } , dispose := 0 , AutoUpdate := 0 )
}
;********************************************************************************************
;******************************************************************************************** DrawColorWheelPanel
DrawColorWheelPanel( Main ){
Main.PanelWindow.PaintBackground( { Color: "0x99000000" , X: 10 , Y: ( Main.PanelWindow.H - ( Main.ColorWheel.H + 20 ) ) / 2 , W: Main.ColorWheel.W + 20 , H: Main.ColorWheel.H + 20 , Round: 10 } )
Main.PanelWindow.PaintBackground( { Color: "0x99212B37" , X: 12 , Y: ( Main.PanelWindow.H - ( Main.ColorWheel.H + 20 ) ) / 2 , W: Main.ColorWheel.W + 16 , H: Main.ColorWheel.H + 16 , Round: 8 } )
Main.PanelWindow.DrawBitmap( Main.ColorWheel.Bitmap , { X: 20 , Y: ( Main.PanelWindow.H - ( Main.ColorWheel.H + 20 ) ) / 2 + 10 , W: Main.ColorWheel.W , H: Main.ColorWheel.H } , dispose := 0 , AutoUpdate := 0 )
}
;********************************************************************************************
;******************************************************************************************** DrawColorDisplay
DrawColorDisplay( Main , ScaleFactor := 1 ){
;*******************************************
pBitmap := Gdip_CreateBitmap( 60 , 60 )
, G := Gdip_GraphicsFromImage( pBitmap )
, Gdip_SetSmoothingMode( G , 2 )
;*******************************************
Brush := Gdip_BrushCreateSolid( Main.Color ) , Gdip_FillRectangle( G , Brush , -10 * ScaleFactor , -10 * ScaleFactor , 80 * ScaleFactor , 90 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
;color display
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_FillEllipse( G , Brush , 2 * ScaleFactor , 0 * ScaleFactor , 56 * ScaleFactor , 56 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
;~ Brush := Gdip_BrushCreateSolid( "0x66" SubStr( Main.SelectedColor , 5 ) ) , Gdip_FillEllipse( G , Brush , 10 * ScaleFactor , 7 * ScaleFactor , 40 * ScaleFactor , 40 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x66" SubStr( Main.SelectedColor , 5 ) ) , Gdip_FillEllipse( G , Brush , 4 * ScaleFactor , 2 * ScaleFactor , 52 * ScaleFactor , 52 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_FillEllipse( G , Brush , 20 * ScaleFactor , 17 * ScaleFactor , 20 * ScaleFactor , 20 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 22 * ScaleFactor , 15 * ScaleFactor , 22 * ScaleFactor , 20 * ScaleFactor , "0xFFF0F0F0" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 2 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , 20 * ScaleFactor , 17 * ScaleFactor , 20 * ScaleFactor , 20 * ScaleFactor ) , Gdip_DeletePen( Pen )
Pen := Gdip_CreatePen( "0xFF444444" , 1 ) , Gdip_DrawEllipse( G , Pen , 21 * ScaleFactor , 17 * ScaleFactor , 18 * ScaleFactor , 18 * ScaleFactor ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0x33" SubStr( Main.SelectedColor , 5 ) ) , Gdip_FillEllipse( G , Brush , 21 * ScaleFactor , 18 * ScaleFactor , 18 * ScaleFactor , 17 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99" SubStr( Main.SelectedColor , 5 ) ) , Gdip_FillEllipse( G , Brush , 24 * ScaleFactor , 21 * ScaleFactor , 12 * ScaleFactor , 12 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 24 * ScaleFactor , 19 * ScaleFactor , 12 * ScaleFactor , 11 * ScaleFactor , "0xFF" SubStr( Main.SelectedColor , 5 ) , "0x66" SubStr( Main.SelectedColor , 5 ) , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 3 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , 24 * ScaleFactor , 21 * ScaleFactor , 12 * ScaleFactor , 11 * ScaleFactor ) , Gdip_DeletePen( Pen )
;*******************************************
Gdip_DeleteGraphics( G )
hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
Gdip_DisposeImage( pBitmap )
SetImage( Main.ColorDisplayControl.Hwnd , hBitmap )
DeleteObject( hBitmap )
}
;********************************************************************************************
;******************************************************************************************** CreateControls
CreateControls( Main ){
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** Font Type DropDownList *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
SizeList := []
fontList := GetFontNames( 1 )
for k, v in fontList {
if( inStr( k , "@" ) ){
SizeList.Push( SubStr( k , 2 ) )
}else{
SizeList.Push( k )
}
if( SizeList.Length() = 250 ){
MsgBox, % "Max number of fonts reached"
break
}
}
fontList := ""
Main.FontTypeDDL := New DropDownListv1( { X: 80 , Y: 15 , W: 235 , List: SizeList , Selected: 10 , Rows: 15 , FontSize: 14 , Label: "UpdateDemo" , MainColor: "0xFF212C38" , HighlightColor: "0xFFFFFFFF" } )
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** Font Options DropDownList *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
SizeList := [ "None" , "Bold" , "Underline" , "Center" , "Bold Underline" , "Bold Center" , "Bold Underline Center" , "Underline Center" ]
Main.FontOptionsDDL := New DropDownListv1( { X: 80 , Y: 50 , W: 235 , List: SizeList , Selected: 6 , Rows: 9 , FontSize: 14 , Label: "UpdateDemo" , MainColor: "0xFF212C38" , HighlightColor: "0xFFFFFFFF" } )
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** Alpha Dial *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
AlphaList := CreateAlphaList()
Main.AlphaDial := New DialControl_V4( { X: 10 , Y: 100 , Parent: Main.Hwnd , HeaderText: "Alpha" , List: AlphaList , Selected: 256 , Value: 270 , Label: "UpdateDemo" } )
;~ Main.AlphaDial.ForceUpdate()
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** FontSize Dial *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
TempList := []
Loop, 200
TempList.Push( A_Index )
Main.FontSizeDial := New DialControl_V4( { X: 90 , Y: 100 , Parent: Main.Hwnd , HeaderText: "Font Size" , List: TempList , Selected: 36 , Value: ( 270 / 200 ) * 36 - 1 , Label: "UpdateDemo" } )
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** Angle Dial *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
TempList := []
Loop, 360
TempList.Push( A_Index - 1 )
;~ Main.AngleDial := New DialControl_V4( { X: 170 , Y: 100 , Parent: Main.Hwnd , HeaderText: "Angle" , List: TempList , Selected: 270 , Value: 203 , Label: "UpdateDemo" } )
Main.AngleDial := New DialControl_V4( { X: 170 , Y: 100 , Parent: Main.Hwnd , HeaderText: "Angle" , List: TempList , Selected: 225 , Value: ( 270 / 360 ) * 225 + .5 , Label: "UpdateDemo" } )
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** Scale Dial *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
TempList := [ "0.1" , "0.2" , "0.3" , "0.4" , "0.5" , "0.6" , "0.7" , "0.8" , "0.9" , "1" , "1.1" , "1.2" , "1.3" , "1.4" , "1.5" , "2" , "2.5" , "3" , "5" , "10" ]
Main.ScaleDial := New DialControl_V4( { X: 250 , Y: 100 , Parent: Main.Hwnd , HeaderText: "Scale" , List: TempList , Selected: 10 , Value: 125 , Label: "UpdateDemo" } )
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** Rotated Text Edit *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
cc := Main.MessageEdit := { X: 10 , Y: 195 , W: 305 , H: "" }
Gui, % Main.Hwnd ":Font", s16 cWhite
Gui, % Main.Hwnd ":Add", Edit, % "x" cc.X " y" cc.Y " w" cc.W " r2 hwndhwnd -VScroll -Wrap -E0x200 Center gUpdateDemo" , % Main.Text := "Hello`nWorld"
cc.Hwnd := hwnd
GuiControlGet, pos , % Main.Hwnd ":pos" , % hwnd
Main.MessageEdit.H := posH
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** Show / Hide Button *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
ShowHideButton := New HButton( { Owner: Main.Hwnd , X: 10 , Y: 255 , W: 300 , H: h := 50 , Text: "Show/Hide" , Label: "Show_Hide_Demo" } )
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** Debug Mode Toggle Button *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
DebugModeButton := New HButton( { Owner: Main.Hwnd , X: 10 , Y: 305 , W: 300 , H: h , Text: "Toggle Debug Background" , Label: "ToggleDebugMode" } )
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** Save PNG Button *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
SavePNGButton := New HButton( { Owner: Main.Hwnd , X: 10 , Y: 355 , W: 300 , H: h := 35 , Text: "Save .png and Clipboard Path" , Label: "SavePNG" } )
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** Clip Base64 Button *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
ClipB64Button := New HButton( { Owner: Main.Hwnd , X: 10 , Y: 390 , W: 300 , H: h := 35 , Text: "Clipboard Base 64 String" , Label: "ClipB64" } )
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** Clip B64 to pBitmap Button *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
ClipB64ToBitmapButton := New HButton( { Owner: Main.Hwnd , X: 10 , Y: 425 , W: 300 , H: h := 35 , Text: "Clipboard [ B64 >>> pBitmap ] Function" , Label: "ClipB64ToPBitmapFunction" } )
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** Clip Custom B64 String *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
ClipCustomB64FunctionButton := New HButton( { Owner: Main.Hwnd , X: 10 , Y: 460 , W: 300 , H: h := 35 , Text: "Clipboard Custom B64 String" , Label: "ClipCustomB64String" } )
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;***** Color Display Control *****;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&;
;~ cc := Main.ColorDisplayControl := { X: 20 , Y: 25 , W: 60 , H: 60 }
cc := Main.ColorDisplayControl := { X: 10 , Y: 20 , W: 60 , H: 60 }
Gui, % Main.Hwnd ":Add", Picture, % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " hwndhwnd gSetSelectedColor 0xE"
cc.Hwnd := hwnd
DrawColorDisplay( Main , ScaleFactor := 1 )
}
;********************************************************************************************
;******************************************************************************************** CreateLumStripBitmap
CreateLumStripBitmap( Color := "0088FF" , width := 10 , height := 10 , scale := 1 ){
pBitmap := Gdip_CreateBitmap( width * scale , height * scale )
Graphics := Gdip_GraphicsFromImage( pBitmap )
Gdip_SetSmoothingMode( Graphics , 1 )
RGBDec := RGBtoHEXandBack( Color )
R := SubStr( RGBDec , 1 , 3 ) , G := SubStr( RGBDec , 4 , 3 ) , B := SubStr( RGBDec , 7 , 3 )
HSL := ConvertRGBtoHSL( R , G , B )
H := HSL[ 1 ] , S := HSL[ 2 ] , L := HSL[ 3 ]
x := 0
Loop, % width * scale {
RGB := ConvertHSLtoRGB( H , S , ( A_Index * ( 1 / ( ( width * scale ) ) ) ) )
Loop, 3
( StrLen( RGB[ A_Index ] ) = 1 ) ? ( RGB[ A_Index ] := "00" RGB[ A_Index ] ) : ( StrLen( RGB[ A_Index ] ) = 2 ) ? ( RGB[ A_Index ] := "0" RGB[ A_Index ] )
RGBHex := RGBtoHEXandBack( RGB[ 1 ] RGB[ 2 ] RGB[ 3 ] )
Brush := Gdip_BrushCreateSolid( "0xFF" RGBHex )
Gdip_FillRectangle( Graphics , Brush , x , ( 0 ) * scale , 1 * scale , ( height ) * scale )
Gdip_DeleteBrush( Brush )
x++
}
Gdip_DeleteGraphics( Graphics )
return { Bitmap: pBitmap , W: width , H: height , X: 0 , Y: 0 }
}
;********************************************************************************************
;******************************************************************************************** CreateColorWheelBitmap
CreateColorWheelBitmap( w := 30 , h := 300 , scale := 1 ){
pBitmap := Gdip_CreateBitmap( w * Scale , h * Scale )
G := Gdip_GraphicsFromImage( pBitmap )
Gdip_SetSmoothingMode( G , 1 )
HueRate := 1 / Scale
SatRate := 1 / h
Sat := 1
lum := 0.5
x := 1
Loop, % w {
y := 1 , Hue := 1
Loop, % h {
Gdip_SetPixel( pBitmap, x , y , "0xFF" SubStr( HSL_ToRGB( hue , sat , lum ) , 3 ) )
y++ , hue += HueRate
}
x++ , Sat -= SatRate
}
Gdip_DeleteGraphics( G )
return { Bitmap: pBitmap , W: w , H: h , X: 0 , Y: 0 }
}
;********************************************************************************************
;******************************************************************************************** SetIcon
SetIcon( pBitmap ){
hIcon := Gdip_CreateHICONFromBitmap( pBitmap )
Gdip_DisposeImage( pBitmap )
Menu, Tray, Icon, HICON:%hIcon%
}
;********************************************************************************************
;******************************************************************************************** CreateAlphaList
CreateAlphaList(){
local hexlist := [ "0" , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "A" , "B" , "C" , "D" , "E" , "F" ]
local SizeList := []
Loop, % hexlist.Length() {
index := A_Index
Loop, % hexlist.Length() {
SizeList.push( hexlist[ index ] hexlist[ A_Index ] )
}
}
return SizeList
}
;********************************************************************************************
;******************************************************************************************** RotatableText
class RotatableText {
;Written By: Hellbent
;Date: Aug 27th 2023
;Version: 1.1
;Create a bitmap of rotated text
static init := RotatableText._SetClassDefaults()
_SetClassDefaults(){
This.String := "Test String"
This.Bitmap := ""
This.FontType := "Segoe UI"
This.FontSize := 32
This.FontColor := "0xFF000000"
This.Scale := 1
This.Width := ""
This.Height := ""
This.FontOptions := " Center vCenter Bold NoWrap "
This.Angle := 225
}
__New( obj := "" ){
This._SetDefaults()
This._UpdateDefaults( obj )
}
_SetDefaults(){
for k , v in RotatableText {
This[ k ] := v
}
}
_UpdateDefaults( obj ){
if( This.Bitmap != "" ){
Gdip_DisposeImage( This.Bitmap )
This.Bitmap := ""
}
for k , v in obj
This[ k ] := v
w := floor( This._GetTextSize( 3 ) ) + 1 ;* .95
h := floor( This._GetTextSize( 4 ) ) + 1 ;* .95
tw := New Vector( w / 2 , h / 2 )
mag := tw.GetMag()
This.Width := This.Height := mag * 2
if( w >= h ){
y := ( w - h ) / 2
}else{
x := ( h - w ) / 2
}
pBitmap := Gdip_CreateBitmap( w , h )
G := Gdip_GraphicsFromImage( pBitmap )
Gdip_SetSmoothingMode( G , 2 )
;Debug testing
if( This.DebugMode ){
Brush := Gdip_BrushCreateSolid( "0xFFF00000")
Gdip_FillRectangle( G , Brush, 0, 0, w, h)
Gdip_DeleteBrush( Brush )
}
Brush := Gdip_BrushCreateSolid( This.Color )
Gdip_TextToGraphics( G , This.String , " s" This.Fontsize * This.Scale " c" Brush " " This.FontOptions " x" 0 " y" 0 , This.FontType , w , h )
Gdip_DeleteBrush( Brush )
Gdip_DeleteGraphics( G )
nBitmap := Gdip_CreateBitmap( This.Width , This.Height )
G := Gdip_GraphicsFromImage( nBitmap )
Gdip_SetSmoothingMode( G , 2 )
Gdip_DrawImage( G , pBitmap , ( This.Width - w ) / 2 , ( This.Height - h ) / 2 , w , h )
Gdip_DisposeImage( pBitmap )
Gdip_DeleteGraphics( G )
Center := New Vector( This.Width / 2 , This.Height / 2 )
tt := New Vector( 0 , 0 )
tt.Sub( Center )
TopLeft := New Vector( 10 , 10 )
TopLeft.SetMag( tt.GetMag() )
TopLeft.SetAngle( This.Angle )
TopRight := New Vector( TopLeft )
TopRight.SetAngle( This.Angle + 90 )
BottomLeft := New Vector( TopLeft )
BottomLeft.SetAngle( This.Angle - 90 )
BottomLeft.Add( Center )
TopRight.Add( Center )
TopLeft.Add( Center )
This.Bitmap := Gdip_CreateBitmap( This.Width , This.Height )
G := Gdip_GraphicsFromImage( This.Bitmap )
Gdip_SetSmoothingMode( G , 2 )
;Debug testing
if( This.DebugMode ){
Brush := Gdip_BrushCreateSolid( "0xFF000000")
Gdip_FillRectangle( G , Brush, 0, 0, This.Width , This.Height )
Gdip_DeleteBrush( Brush )
}
points := TopLeft.X " , " TopLeft.Y " | " TopRight.X " , " TopRight.Y " | " BottomLeft.X " , " BottomLeft.Y
Gdip_DrawImagePointsRect( G , nBitmap , points )
Gdip_DisposeImage( nBitmap )
Gdip_DeleteGraphics( G )
}
_GetTextSize( Index := 4 ){
local pBitmap, G, Brush, temparr
pBitmap := Gdip_CreateBitmap( 10 , 10 ) , G := Gdip_GraphicsFromImage( pBitmap ), Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( "0xFF000000")
temparr := StrSplit( Gdip_TextToGraphics( G , ( This.String ) ? ( This.String ) : ( "Error`nNo String`nWas Used" ), " s" This.Fontsize * This.Scale " c" Brush " " This.FontOptions " x" 0 " y" 0 , This.FontType , 10000, 10000 ),"|","|" ) , Gdip_DeleteBrush( Brush )
Gdip_DeleteGraphics( G ) , Gdip_DisposeImage( pBitmap )
return temparr[ index ]
}
}
;********************************************************************************************
;******************************************************************************************** FillRoundedRectangle
FillRoundedRectangle( G , RectObject := "" , Roundness := 5 , Color := "0xFF000000" , Scale := 1 ){
if( RectObject = "" )
RectObject := { X: 0 , Y: 0 , W: 100 , H: 100 }
cc := RectObject
Brush := Gdip_BrushCreateSolid( Color )
Gdip_FillRoundedRectangle( G , Brush , cc.X * Scale , cc.Y * Scale , cc.W * Scale , cc.H * Scale , Roundness * Scale )
Gdip_DeleteBrush( Brush )
}
;********************************************************************************************
;******************************************************************************************** DialControl_V4
;**************************************************************************************************************************************************
;**************************************************************************************************************************************************
;**************************************************************************************************************************************************
;Written By: Hellbent
;Date Started: Aug 24th , 2023
;Last Edit: Aug 25th, 2023
;Class: DialControl_V4
;example:
/*
FontSizeDial := New DialControl_V4( { Y: 10 , Value: 32 , Parent: "1" , UseBackground: 1 , MaxValue: 250 , HeaderText: "FontSize" } )
FontSizeDial.X := FontSizeDial.Gui1.X := 15 + FontSizeDial.W * 1
FontSizeDial.DrawControl()
*/
class DialControl_V4 {
static init := DialControl_V4._SetClassDefaults()
_SetClassDefaults( obj := "" ){
This.Defaults := {}
This.Defaults.X := 10
This.Defaults.Y := 10
This.Defaults.W := 70
This.Defaults.H := 90
This.Defaults.Scale := 1
This.Defaults.ControlOptions := " -DPIScale +AlwaysOnTop +ToolWindow "
This.Defaults.Value := 1
This.Defaults.Selected := 1
This.Defaults.UseBackground := 0
This.Defaults.UseHeader := 1
This.Defaults.List := ""
This.Defaults.MinValue := 1
This.Defaults.MaxValue := 100
This.Defaults.FontType := "Segoe UI"
This.Defaults.FontSize := 12
This.Defaults.HeaderText := ""
This.Defaults.SweepValue := 1
;##########################;
;<<<--- COLORS --->>>;
This.Defaults.HeaderFontColor := "0xFFFFFFFF"
This.Defaults.ValueFontColor := "0xFFFFFFFF"
This.Defaults.BackgroundColor := "0xFF212B37"
;##########################;
if( isObject( obj ) ){
for k , v in obj {
This.Defaults[ k ] := obj[ k ]
}
}
;##########################;
}
__New( obj := "" ){
This._SetDefaults()
This._UpdateDefaults( obj )
This._CreateControl()
This.Draw()
}
_SetDefaults(){
This.DebugList := ""
for k , v in DialControl_V4.Defaults {
This.DebugList .= k " : " v "`n"
This[ k ] := DialControl_V4.Defaults[ k ]
}
This.DrawTimer := This.DrawControl.Bind( This )
;~ ToolTip, % "Debug List:`n" This.DebugList
}
_UpdateDefaults( obj := "" ){
if( isObject( obj ) ){
for k , v in obj {
This[ k ] := obj[ k ]
}
}
This.Center := New Vector( This.W / 2 , This.H / 2 + 10 )
This.MouseVector := New Vector( 10 , 10 )
if( This.List.Length() >= 1 ){
This.MaxValue := This.List.Length()
}
This.SweepValue := This.Value
This.ForceUpdate()
}
_CreateControl(){
if( This.HasKey( "Parent" ) ){
This.ControlOptions .= " +Parent" This.Parent
}else if( This.HasKey( "Owner" ) ){
This.ControlOptions .= " +Owner" This.Owner
}
if( !This.HasKey( "AutoShow" ) )
This.AutoShow := 1
This.Gui1 := New PopUpWindow( { AutoShow: This.AutoShow , X: This.X , Y: This.Y , W: This.W , H: This.H , Options: This.ControlOptions } )
This.Hwnd := This.Gui1.Hwnd
Gui, % This.Gui1.Hwnd ":Add" , Text , % "x" 0 " y" 0 " w" This.W " h" This.H " hwndhwnd "
This.ControlHwnd := hwnd
bd := This._AdjustDial.Bind( This )
GuiControl, % This.Gui1.Hwnd ":+G" , % hwnd , % bd
}
Draw( value := -30 ){
local timer := This.DrawTimer
SetTimer, % timer , % value
}
DrawControl(){
This.Gui1.ClearWindow()
This.Gui1.DrawBitmap( This.CreateControlGraphics() , { X: 0 , Y: 0 , W: This.W * This.Scale , H: This.H * This.Scale } , dispose := 1 , AutoUpdate := 0 )
This.Gui1.UpdateWindow()
}
_GetMouseVector(){
CoordMode, Mouse, Client
MouseGetPos, x , y
if( This.Haskey( "Parent" ) )
return New Vector( ( x - This.X ) / This.Scale , ( y - This.Y ) / This.Scale )
else
return New Vector( x / This.Scale , y / This.Scale )
}
ForceUpdate(){
This.Value := Round( This.MinValue + ( ( ( This.MaxValue - This.MinValue ) / 270 ) * This.Sweepvalue ) )
if( This.List.Length() > 0 ){
This.Selected := This.Value
This.Value := SubStr( This.List[ This.Value ] , 1 , 3 )
}
This.Draw()
}
_AdjustDial(){
GuiControl, % This.Hwnd ":Focus" , % This.ControlHwnd
This.MouseVector := This._GetMouseVector()
if( This.MouseVector.Dist( This.Center ) > 30 )
return
index := 0
While( GetKeyState( "LButton" , "P" ) ){
This.MouseVector := This._GetMouseVector()
This.MouseVector.Sub( This.Center )
This.Angle := This.MouseVector.GetAngle()
if( This.Angle >= 135 && This.Angle < 180 ){
This.Sweepvalue := 0
}else if( This.Angle <= 135 && This.Angle >= 90 ){
This.Sweepvalue := 270
}else if( This.Angle < 90 ){
This.Sweepvalue := 180 + This.Angle
}else{
This.Sweepvalue := This.Angle - 180
}
This.Value := Round( This.MinValue + ( ( ( This.MaxValue - This.MinValue ) / 270 ) * This.Sweepvalue ) )
if( This.List.Length() > 0 ){
This.Selected := This.Value
This.Value := SubStr( This.List[ This.Value ] , 1 , 3 )
}
if( This.LastValue != This.Value && This.Value != "" ){
index++
This.LastValue := This.Value
This.Draw()
}
Sleep, 30
}
if( This.HasKey( "Label" ) ){
Try{
gosub, % This.Label
}
}
}
CreateControlGraphics(){
;Bitmap Created Using: HB Bitmap Maker
ScaleFactor := This.Scale
pBitmap := Gdip_CreateBitmap( 70 * ScaleFactor , 90 * ScaleFactor ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
if( This.UseBackground )
Brush := Gdip_BrushCreateSolid( "0xFF212B37" ) , Gdip_FillRectangle( G , Brush , -10 * ScaleFactor , -20 * ScaleFactor , 180 * ScaleFactor , 190 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
if( This.UseHeader ){
Brush := Gdip_CreateLineBrushFromRect( 2 * ScaleFactor , 2 * ScaleFactor , 96 * ScaleFactor , 20 * ScaleFactor , "0xFF577090" , "0xFF18212A" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 2 * ScaleFactor , 2 * ScaleFactor , 66 * ScaleFactor , 20 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , This.HeaderText , "s" This.FontSize * ScaleFactor " Center vCenter Bold c" Brush " x" 3 * ScaleFactor " y" 3 * ScaleFactor , This.FontType , 66 * ScaleFactor , 20 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFFd2d6da" ) , Gdip_TextToGraphics( G , This.HeaderText , "s" This.FontSize * ScaleFactor " Center vCenter Bold c" Brush " x" 2 * ScaleFactor " y" 2 * ScaleFactor , This.FontType , 66 * ScaleFactor , 20 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
}
Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillEllipse( G , Brush , 5 * ScaleFactor , 25 * ScaleFactor , 62 * ScaleFactor , 62 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF212C38" ) , Gdip_FillEllipse( G , Brush , 5 * ScaleFactor , 25 * ScaleFactor , 60 * ScaleFactor , 60 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 1 * ScaleFactor , 29 * ScaleFactor , 65 * ScaleFactor , 57 * ScaleFactor , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 2 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , 5 * ScaleFactor , 25 * ScaleFactor , 60 * ScaleFactor , 60 * ScaleFactor ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 6 * ScaleFactor , 29 * ScaleFactor , 51 * ScaleFactor , 49 * ScaleFactor , "0xFF4D6481" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 7 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawArc( G , Pen , 13 * ScaleFactor , 33 * ScaleFactor , 44 * ScaleFactor , 44 * ScaleFactor , 180 , 270 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 9 * ScaleFactor , 35 * ScaleFactor , 50 * ScaleFactor , 45 * ScaleFactor , "0xFF3e5168" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 5 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawArc( G , Pen , 13 * ScaleFactor , 33 * ScaleFactor , 44 * ScaleFactor , 44 * ScaleFactor , 180 , 270 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 17 * ScaleFactor , 43 * ScaleFactor , 34 * ScaleFactor , 23 * ScaleFactor , "0xFF577090" , "0xFF000000" , 2 , 1 ) , Gdip_FillEllipse( G , Brush , 20 * ScaleFactor , 40 * ScaleFactor , 30 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , This.Value , "s" This.FontSize * ScaleFactor " Center vCenter Bold c" Brush " x" 22 * ScaleFactor " y" 42 * ScaleFactor , This.FontType , 30 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFFd2d6da" ) , Gdip_TextToGraphics( G , This.Value , "s" This.FontSize * ScaleFactor " Center vCenter Bold c" Brush " x" 20 * ScaleFactor " y" 40 * ScaleFactor , This.FontType , 30 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Pen := Gdip_CreatePen( "0x99556E8D" , 3 ) , Gdip_DrawEllipse( G , Pen , 5 * ScaleFactor , 25 * ScaleFactor , 60 * ScaleFactor , 60 * ScaleFactor ) , Gdip_DeletePen( Pen )
Pen := Gdip_CreatePen( "0xFFd4dce5" , 3 ) , Gdip_DrawArc( G , Pen , 13 * ScaleFactor , 33 * ScaleFactor , 44 * ScaleFactor , 44 * ScaleFactor , 180 , This.Sweepvalue ) , Gdip_DeletePen( Pen )
Gdip_DeleteGraphics( G )
return pBitmap
}
}
;********************************************************************************************
;******************************************************************************************** GetFontNames | EnumFontFamExProc
GetFontNames(charset){ ;https://www.autohotkey.com/boards/viewtopic.php?t=12416#p386353
hDC := DllCall("GetDC", "UInt", 0, "Ptr")
VarSetCapacity(LOGFONT, 92, 0)
NumPut(charset, &LOGFONT + 23, "UChar")
DllCall("EnumFontFamiliesEx", "Ptr", hDC, "Ptr", 0 , "Ptr", RegisterCallback("EnumFontFamExProc", "F", 4) , "Ptr", pFonts := Object(Fonts := {}), "UInt", 0)
ObjRelease(pFonts), DllCall("ReleaseDC", "Ptr", 0, "Ptr", hDC)
Return Fonts
}
EnumFontFamExProc(lpelfe, lpntme, FontType, lParam){
font := StrGet(lpelfe + 28)
Object(lParam)[font] := ""
Return true
}
;********************************************************************************************
;******************************************************************************************** B64ToPBitmap
B64ToPBitmap( Input ){
local ptr , uptr , pBitmap , pStream , hData , pData , Dec , DecLen , B64
VarSetCapacity( B64 , strlen( Input ) << !!A_IsUnicode )
B64 := Input
If !DllCall("Crypt32.dll\CryptStringToBinary" ( ( A_IsUnicode ) ? ( "W" ) : ( "A" ) ), Ptr := A_PtrSize ? "Ptr" : "UInt" , &B64, "UInt", 0, "UInt", 0x01, Ptr, 0, "UIntP", DecLen, Ptr, 0, Ptr, 0)
Return False
VarSetCapacity( Dec , DecLen , 0 )
If !DllCall("Crypt32.dll\CryptStringToBinary" (A_IsUnicode ? "W" : "A"), Ptr, &B64, "UInt", 0, "UInt", 0x01, Ptr, &Dec, "UIntP", DecLen, Ptr, 0, Ptr, 0)
Return False
DllCall("Kernel32.dll\RtlMoveMemory", Ptr, pData := DllCall("Kernel32.dll\GlobalLock", Ptr, hData := DllCall( "Kernel32.dll\GlobalAlloc", "UInt", 2, UPtr := A_PtrSize ? "UPtr" : "UInt" , DecLen, UPtr), UPtr) , Ptr, &Dec, UPtr, DecLen)
DllCall("Kernel32.dll\GlobalUnlock", Ptr, hData)
DllCall("Ole32.dll\CreateStreamOnHGlobal", Ptr, hData, "Int", True, Ptr "P", pStream)
DllCall("Gdiplus.dll\GdipCreateBitmapFromStream", Ptr, pStream, Ptr "P", pBitmap)
return pBitmap
}
;********************************************************************************************
;******************************************************************************************** DropDownListv1
;*******************&&&&&&&&&&&&&&&&&&&&&&&&************************************&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;*******************&&&&&&&&&&&&&&&&&&&&&&&&************************************&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;*******************&&&&&&&&&&&&&&&&&&&&&&&&************************************&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
class DropDownListv1 {
Value[]{
Get{
return This.List[ This.Selected ]
}
}
__New( obj := "" ){
This._SetDefaults()
This._UpdateDefaults( obj )
This._CreateWindows()
This._CreateControls()
This._DrawHeader()
This._SetTimer( This.HoverTimer , 100 )
;~ SoundBeep 777
}
_SetDefaults(){
This.Parent := ""
This.ScaleFactor := 1
This.X := 10
This.Y := 10
This.W := 300
This.HeaderMargin := 5
This.Font := "Arial"
This.FontSize := 12
;~ This.FontColor := "0xFF000000"
This.FontColor := "0xFFFFFFFF"
This.FontOptions := "Center vCenter NoWrap "
This.H := Floor( This._GetTextSize() + 2 * This.HeaderMargin )
This.PanelStartingPositionY := 9
This.Selected := 1
This.StartingPosition := 1
;~ This.MainColor := "0xFFFFFFFF"
This.MainColor := "0xFF32363a"
;~ This.ArrowColor := "0xFF000000"
;~ This.ArrowColor := "0xFFFF0000"
This.ArrowColor := "0xFF6699aa"
This.Rows := 10
This.MinRows := 5
This.BodyMargin := 3
This.PanelTextPading := 1
This.PanelTextHeight := Floor( This._GetTextSize() )
This.PanelHeight := This.PanelTextHeight + 2 * This.PanelTextPading
This.BodyHeight := This.BodyMargin * 2 + ( This.PanelHeight * This.Rows ) + ( This.BodyMargin * ( This.Rows - 1 ) ) + This.PanelStartingPositionY
This.ThumbMinY := This.PanelStartingPositionY + 2
This.ThumbRange := This.BodyHeight - This.ThumbMinY - 6
This.ThumbY := This.ThumbMinY
This.Interval := Floor( This.ThumbRange / This.List.Length() )
;*******************************************************
;*******************************************************
;~ This.PanelColor1 := "0xFFCFCFCF"
;~ This.PanelColor1 := "0xFF22262a"
This.PanelColor1 := "0x99336699"
;~ This.PanelColor2 := "0xFFEFEFEF"
;~ This.PanelColor2 := "0xFF12161a"
This.PanelColor2 := "0x996699cc"
;*******************************************************
;*******************************************************
;~ This.HighLightPanelColor := "0x3300AAFF"
;~ This.HighLightPanelColor := "0x33ff0000"
;~ This.HighLightPanelColor := "0x3300FF00"
This.HighLightPanelColor := "0x663399FF"
;~ This.SelectedPanelColor := "0x990099FF"
;~ This.SelectedPanelColor := "0x99ff2222"
;~ This.SelectedPanelColor := "0x9922ff22"
This.SelectedPanelColor := "0x993399ff"
This.SelectedFontColor := This.FontColor
;~ This.HighlightFontColor := This.FontColor
This.HighlightFontColor := "0xFFFFFFFF"
This.HeaderFontColor := This.FontColor
;~ This.SliderTrackColor := "0xFFDCDCDC"
;~ This.SliderTrackColor := "0xFF12161a"
This.SliderTrackColor := "0xFF212C38"
;~ This.SliderTrackColor := "0xFF2C84DB"
;~ This.SliderButtonColor := "0xFFFFFFFF"
;~ This.SliderButtonColor := "0xFF22262a"
This.SliderButtonColor := "0x995256aa"
;~ This.SliderRidgeColor := "0x33333333"
;~ This.SliderRidgeColor := "0x66ff0000"
This.SliderRidgeColor := "0x66212C38"
This.BorderColor := "0x33000000"
;~ This.BorderColor := "0xff0000ff"
This.Hovered := ""
This.PanelControls := []
This.Active := 0
This.CallBind := This._CallBind.Bind( This )
This.HoverTimer := This._Hover.Bind( This )
;~ This.FocusColor := "0x990099FF"
;~ This.FocusColor := "0x99ff0000"
This.FocusColor := "0x993399ff"
This.Focused := 0
}
_UpdateDefaults( obj := "" ){
for k, v in obj
This[ k ] := obj[ k ]
This.H := Floor( This._GetTextSize() + 2 * This.HeaderMargin )
This.Roundness := This.H / 5
if( !IsObject( obj.Bind ) && obj.Bind )
This.Bind := func( obj.Bind ).Bind( This )
if( This.Rows < This.MinRows )
This.Rows := This.MinRows
This.PanelTextHeight := Floor( This._GetTextSize() )
This.PanelHeight := This.PanelTextHeight + 2 * This.PanelTextPading
This.BodyHeight := This.BodyMargin * 2 + ( This.PanelHeight * This.Rows ) + ( This.BodyMargin * ( This.Rows - 1 ) ) + This.PanelStartingPositionY
This.ThumbMinY := This.PanelStartingPositionY + 2
This.ThumbRange := This.BodyHeight - This.ThumbMinY - 6 - 2
if( ( This.ThumbRange / 0.5 ) < This.List.Length() ){
Msgbox, 262144, Error, The list you are using exceeds the current maximum length. `n1
exitApp
}
This.Interval := Floor( ( This.ThumbRange * This.ScaleFactor) / This.List.Length() )
This.TotalInterval := This.Interval * This.List.Length()
This.ThumbHeight := This.ThumbRange - This.TotalInterval
While( This.Interval > 1 ){
;~ This.Interval -= 1
This.Interval -= 0.5
This.TotalInterval := This.Interval * This.List.Length()
This.ThumbHeight := This.ThumbRange - This.TotalInterval
}
if( ( This.ThumbHeight ) < 30 || !This.Interval ){
Msgbox, 262144, Error, % "The list you are using exceeds the current maximum length. `n2 "
exitApp
}
This.Thumb := { X: ( This.W - 32 ) , Y: This.ThumbMinY , W: 26 , H: This.ThumbHeight }
This._MoveThumbControl()
This.Panels := []
This.PanelHandles := []
temp := This.PanelStartingPositionY - 2
Loop, % This.Rows {
This.Panels[ A_Index ] := { X: 4 , Y: temp , W: ( This.W - 34 - 6 ) , H: This.PanelHeight , Hwnd: "" }
temp += This.PanelHeight + This.BodyMargin
}
This.ToggleButton := { X: 2 , Y: 2 , W: ( This.W - 4 ) , H: ( This.H - 4 ) , Hwnd: "" }
This.WheelActive := 0
This.FT := 0
OnMessage( 0x020A , This._WheelChange.Bind( This ) )
OnMessage( 0x201 , This._WatchFocus.Bind( This ) )
OnMessage( 0x100 , This._WatchKeyPress.Bind( This ) )
if( !obj.HasKey( "HeaderFontColor" ) )
This.HeaderFontColor := This.FontColor
if( !obj.HasKey( "HighlightFontColor" ) )
This.HighlightFontColor := This.FontColor
}
_CreateWindows(){
This.Gui1 := New PopUpWindow( { AutoShow: 1 , X: This.X * This.ScaleFactor , Y: This.Y * This.ScaleFactor , W: This.W * This.ScaleFactor , H: This.H * This.ScaleFactor , Options: " -DPIScale +AlwaysOnTop +Parent" This.Parent } )
This.Gui2 := New PopUpWindow( { AutoShow: 1 , X: This.X * This.ScaleFactor , Y: This.Y * This.ScaleFactor , W: This.W * This.ScaleFactor , H: This.BodyHeight * This.ScaleFactor , Options: " -DPIScale +AlwaysOnTop +Owner" This.Gui1.Hwnd } )
}
_CreateControls(){
Gui, % This.Gui2.Hwnd ":Add", Text, % "x" ( This.W - 34 ) * This.ScaleFactor " y" This.ThumbY * This.ScaleFactor " w" 30 * This.ScaleFactor " h" This.ThumbHeight * This.ScaleFactor " hwndhwnd"
This.ThumbHwnd := hwnd
bd := This._AdjustSlider.Bind( This )
GuiControl, % This.Gui2.Hwnd ":+G", % hwnd, % bd
Loop, % This.Rows {
Gui, % This.Gui2.Hwnd ":Add", Text, % "x" This.Panels[ A_Index ].X * This.ScaleFactor " y" This.Panels[ A_Index ].Y * This.ScaleFactor " w" This.Panels[ A_Index ].W * This.ScaleFactor " h" This.Panels[ A_Index ].H * This.ScaleFactor " hwndhwnd"
This.Panels[ A_Index ].Hwnd := hwnd
This.PanelHandles[ hwnd ] := A_Index
bd := This._SelectPanel.Bind( This )
GuiControl, % This.Gui2.Hwnd ":+G" , % hwnd , % bd
}
Gui, % This.Gui1.Hwnd ":Add", Text, % "x" This.ToggleButton.X * This.ScaleFactor " y" This.ToggleButton.Y * This.ScaleFactor " w" This.ToggleButton.W * This.ScaleFactor " h" This.ToggleButton.H * This.ScaleFactor " hwndhwnd"
This.ToggleButton.Hwnd := hwnd
This.HKBind := This._LButtonHK.Bind( This )
bd := This._ToggleBody.Bind( This )
GuiControl, % This.Gui1.Hwnd ":+G" , % hwnd , % bd
}
_MoveThumbControl(){
GuiControl, % This.Gui2.Hwnd ":Move" , % This.ThumbHwnd , % "y" This.Thumb.Y * This.ScaleFactor " h" This.ThumbHeight * This.ScaleFactor
}
_Hover(){
MouseGetPos,,, win , ctrl , 2
if( win = This.Gui2.Hwnd ){
if( !This.Hovered && This.PanelHandles[ ctrl ] ){
This.Hovered := ctrl
This._DrawBody()
}
}
if( This.Hovered && ctrl != This.Hovered ){
This.Hovered := ""
if( This.Active )
This._DrawBody()
}
}
_WheelChange( input ){
local ctrl , Dir , win
if( This.WheelActive )
return
if( This.ft := !This.ft )
return
This.WheelActive := 1
Dir := ( (input >> 16 ) > 0x7FFF ) || ( ( input < 0 ) ? ( 1 ) : ( 0 ) )
MouseGetPos,,, win, ctrl, 2
if( !Dir && ctrl = This.ToggleButton.Hwnd ){
( --This.Selected < 1 ) ? ( This.Selected := 1 )
This.StartingPosition := This.Selected
}else if( Dir && ctrl = This.ToggleButton.Hwnd ){
( ++This.Selected > This.List.Length() ) ? ( This.Selected := This.List.Length() )
This.StartingPosition := This.Selected
}else if( !Dir && win = This.Gui2.Hwnd ){
( --This.StartingPosition < 1 ) ? ( This.StartingPosition := 1 )
}else if( Dir && win = This.Gui2.Hwnd ){
( ++This.StartingPosition > This.List.Length() ) ? ( This.StartingPosition := This.List.Length() )
}
This.Thumb.Y := This.ThumbMinY + This.StartingPosition
This._MoveThumbControl()
This._DrawHeader()
if( This.Active )
This._DrawBody()
if( ctrl = This.ToggleButton.Hwnd )
This._SetTimer( This.CallBind , -30 )
This.WheelActive := 0
}
_WatchKeyPress( key ){
if( key = 9 && This.Focused )
This.SetFocus( 0 )
}
_WatchFocus(){
MouseGetPos,,, win, ctrl, 2
if( This.Focused && ctrl != This.ToggleButton.Hwnd && win != This.Gui2.Hwnd && ctrl )
This.SetFocus( 0 )
else if( !This.Focused && ( ctrl = This.ToggleButton.Hwnd || win = This.Gui2.Hwnd ) )
This.SetFocus( 1 )
}
SetFocus( value , option := 1 ){
if( This.Focused := value )
GuiControl, % This.Gui1.Hwnd ":Focus" , % This.ToggleButton.Hwnd
This._DrawHeader()
}
_SetTimer( Timer , Amount := 30 ){
SetTimer, % Timer, % Amount
}
_CallBind(){
Try
This.Bind.Call()
Try
gosub, % This.Label
}
_SelectPanel(){
MouseGetPos,,,, ctrl, 2
if( This.List[ This.PanelHandles[ ctrl ] + This.StartingPosition - 1 ] != "" ){
This.Output := This.List[ This.PanelHandles[ ctrl ] + This.StartingPosition - 1 ]
This.Selected := This.PanelHandles[ ctrl ] + This.StartingPosition - 1
This._DrawBody()
bd := This.HKBind
HotKey, ~LButton, % bd , Off
This.Active := 0
This.Gui2.ClearWindow( 1 )
This._DrawHeader()
This._SetTimer( This.CallBind , -30 )
;~ This.Gui2.ClearWindow( 1 )
;~ ToolTip, % "Here`n" This.Gui2.hwnd
}
}
_ToggleBody(){
if( This.Active := !This.Active ){
WinGetPos, x, y,,, % "ahk_Id " This.Gui1.Hwnd
This.Gui2.UpdateSettings( { X: x , Y: y + ( This.Gui1.H ) } )
This.StartingPosition := This.Selected
This.Focused := 1
This._DrawBody()
bd := This.HKBind
Hotkey, ~LButton , % bd , On
}else{
This.Gui2.ClearWindow( 1 )
bd := This.HKBind
HotKey, ~LButton, % bd , Off
}
This._DrawHeader()
}
_LButtonHK(){
MouseGetPos,,, win, ctrl, 2
if( win != This.Gui2.Hwnd && ctrl != This.ToggleButton.Hwnd ){
bd := This.HKBind
HotKey, ~LButton, % bd , Off
This.Active := 0
This.Gui2.ClearWindow( 1 )
This._DrawHeader()
}
}
_AdjustSlider(){
local ly
CoordMode, Mouse, Client
While( GetKeyState( "LButton" ) ){
MouseGetPos,, y
if( ly != y ){
ly := y
y /= This.ScaleFactor
if( ( y - This.ThumbHeight / 2 ) < This.ThumbMinY ){
This.Thumb.Y := This.ThumbMinY
This.StartingPosition := 1
}else if( ( y + This.ThumbHeight / 2 ) > ( This.ThumbMinY + This.ThumbRange ) ){
This.Thumb.Y := This.ThumbMinY + This.ThumbRange - This.ThumbHeight
This.StartingPosition := This.List.Length()
}else{
This.Thumb.Y := y - This.ThumbHeight / 2
;~ This.StartingPosition := floor( This.Thumb.Y - This.ThumbMinY )
This.StartingPosition := floor( ( This.Thumb.Y - This.ThumbMinY ) / This.Interval )
}
This._MoveThumbControl()
This._DrawBody()
}
sleep, 10
}
}
_DrawHeader(){
local brush , pen
This.Gui1.ClearWindow()
Brush := Gdip_CreateLineBrushFromRect( 1 * This.ScaleFactor , 1 * This.ScaleFactor , ( This.W - 2 ) * This.ScaleFactor , ( This.H - 2 ) * This.ScaleFactor , This.MainColor , ( This.MainColor2 != "" ) ? ( This.MainColor2 ) : ( This.MainColor ) , 1 , 1 )
, Gdip_FillRoundedRectangle( This.Gui1.G , Brush , 2 * This.ScaleFactor , 2 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.H - 4 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
;***************************************
;~ Brush := Gdip_CreateLineBrush( 1 * This.ScaleFactor , 1 * This.ScaleFactor , ( This.W / 2 ) * This.ScaleFactor , ( This.H - 2 ) * This.ScaleFactor , "0xaaaaaaaa" , "0xFF000000" , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.Gui1.G , Pen , 2 * This.ScaleFactor , 2 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.H - 4 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;~ Brush := Gdip_BrushCreateSolid( This.FocusColor )
;~ Brush := Gdip_BrushCreateSolid( "0xFF585858" )
Brush := Gdip_BrushCreateSolid( "0xFF526e8c" )
, Pen := Gdip_CreatePenFromBrush( Brush , 1 )
, Gdip_DeleteBrush( Brush )
, Gdip_DrawRoundedRectangle( This.Gui1.G , Pen , 2 * This.ScaleFactor , 2 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.H - 4 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor )
, Gdip_DeletePen( Pen )
;***************************************
if( This.Focused ){
Brush := Gdip_BrushCreateSolid( This.FocusColor )
, Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush )
, Gdip_DrawRoundedRectangle( This.Gui1.G , Pen , 4 * This.ScaleFactor , 4 * This.ScaleFactor , ( This.W - 8 ) * This.ScaleFactor , ( This.H - 8 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor )
, Gdip_DeletePen( Pen )
}
Brush := Gdip_BrushCreateSolid( This.HeaderFontColor ) , Gdip_TextToGraphics( This.Gui1.G , This.List[ This.Selected ] , "s" This.FontSize * This.ScaleFactor " " This.FontOptions " NoWrap c" Brush " x" 5 * This.ScaleFactor " y" 2 * This.ScaleFactor , This.Font , ( This.W - ( This.W / 4 ) ) * This.ScaleFactor , This.H * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.ArrowColor ) , Gdip_TextToGraphics( This.Gui1.G , ( !This.Active ) ? ( 6 ) : ( 5 ) , "s" ( s := 16 ) * This.ScaleFactor " " This.FontOptions " c" Brush " x" ( This.W - 30 ) * This.ScaleFactor " y" 1 * This.ScaleFactor , "WebDings" , 30 * This.ScaleFactor , This.H * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
This.Gui1.UpdateWindow()
}
_DrawBody(){
local temp , brush , pen , tog
This.Gui2.ClearWindow()
Brush := Gdip_BrushCreateSolid( This.MainColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
;**************************************
;~ ToolTip, % This.BorderColor
Pen := Gdip_CreatePen( This.BorderColor , 1 ) , Gdip_DrawRoundedRectangle( This.Gui2.G , Pen , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;~ Brush := Gdip_BrushCreateSolid( This.BorderColor ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.Gui2.G , Pen , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;~ Brush := Gdip_BrushCreateSolid( "0xFF0000FF" ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.Gui2.G , Pen , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;~ Bob := This.BorderColor
;~ Brush := Gdip_BrushCreateSolid( Bob ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.Gui2.G , Pen , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;**************************************
Brush := Gdip_BrushCreateSolid( This.MainColor ) , Gdip_FillPolygon( This.Gui2.G, Brush , ( This.W / 2 ) * This.ScaleFactor "," 0 * This.ScaleFactor "|" ( This.W - ( This.W / 5 ) ) * This.ScaleFactor "," 100 * This.ScaleFactor "|" ( This.W / 5 ) * This.ScaleFactor "," 100 * This.ScaleFactor "|" ) , Gdip_DeleteBrush( Brush )
temp := This.PanelStartingPositionY
Loop, % This.Rows {
tog := !tog
if( ( A_Index + This.StartingPosition - 1 ) = This.Selected ){
Brush := Gdip_BrushCreateSolid( This.SelectedPanelColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , 4 * This.ScaleFactor , temp * This.ScaleFactor , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
;~ Brush := Gdip_BrushCreateSolid( This.SelectedFontColor ) , Gdip_TextToGraphics( This.Gui2.G, This.List[ A_Index + This.StartingPosition - 1 ] , "s" This.FontSize * This.ScaleFactor " NoWrap vCenter c" Brush " x" 4 * This.ScaleFactor " y" ( temp + 1 ) * This.ScaleFactor , This.Font , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SelectedFontColor ) , Gdip_TextToGraphics( This.Gui2.G, This.List[ A_Index + This.StartingPosition - 1 ] , "s" This.FontSize * This.ScaleFactor " " This.FontOptions " c" Brush " x" 4 * This.ScaleFactor " y" ( temp + 1 ) * This.ScaleFactor , This.Font , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
}else if( A_Index = This.PanelHandles[ This.Hovered ] ){
Brush := Gdip_BrushCreateSolid( This.HighLightPanelColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , 4 * This.ScaleFactor , temp * This.ScaleFactor , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
;~ Brush := Gdip_BrushCreateSolid( This.HighlightFontColor ) , Gdip_TextToGraphics( This.Gui2.G, This.List[ A_Index + This.StartingPosition - 1 ] , "s" This.FontSize * This.ScaleFactor " NoWrap vCenter c" Brush " x" 4 * This.ScaleFactor " y" ( temp + 1 ) * This.ScaleFactor , This.Font , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.HighlightFontColor ) , Gdip_TextToGraphics( This.Gui2.G, This.List[ A_Index + This.StartingPosition - 1 ] , "s" This.FontSize * This.ScaleFactor " " This.FontOptions " c" Brush " x" 4 * This.ScaleFactor " y" ( temp + 1 ) * This.ScaleFactor , This.Font , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
}else{
Brush := Gdip_BrushCreateSolid( ( !tog ) ? ( This.PanelColor1 ) : ( This.PanelColor2 ) ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , 4 * This.ScaleFactor , temp * This.ScaleFactor , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
;~ Brush := Gdip_BrushCreateSolid( This.FontColor ) , Gdip_TextToGraphics( This.Gui2.G, This.List[ A_Index + This.StartingPosition - 1 ] , "s" This.FontSize * This.ScaleFactor " NoWrap vCenter c" Brush " x" 4 * This.ScaleFactor " y" ( temp + 1 ) * This.ScaleFactor , This.Font , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.FontColor ) , Gdip_TextToGraphics( This.Gui2.G, This.List[ A_Index + This.StartingPosition - 1 ] , "s" This.FontSize * This.ScaleFactor " " This.FontOptions " c" Brush " x" 4 * This.ScaleFactor " y" ( temp + 1 ) * This.ScaleFactor , This.Font , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
}
temp += This.PanelHeight + This.BodyMargin
}
Brush := Gdip_BrushCreateSolid( This.SliderTrackColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , ( This.W - 34 ) * This.ScaleFactor , 9 * This.ScaleFactor , 30 * This.ScaleFactor , ( This.BodyHeight - 15 ) * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SliderButtonColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , ( This.W - 32 ) * This.ScaleFactor , This.Thumb.Y * This.ScaleFactor , 26 * This.ScaleFactor , This.ThumbHeight * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SliderRidgeColor ) , Gdip_FillRectangle( This.Gui2.G , Brush , ( This.Thumb.X + 3 ) * This.ScaleFactor , ( This.Thumb.Y + ( This.ThumbHeight / 2 ) - 5 ) * This.ScaleFactor , ( This.Thumb.W - 6 ) * This.ScaleFactor , 3 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SliderRidgeColor ) , Gdip_FillRectangle( This.Gui2.G , Brush , ( This.Thumb.X + 3 ) * This.ScaleFactor , ( This.Thumb.Y + ( This.ThumbHeight / 2 ) + 5 ) * This.ScaleFactor , ( This.Thumb.W - 6 ) * This.ScaleFactor , 3 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SliderRidgeColor ) , Gdip_FillRectangle( This.Gui2.G , Brush , ( This.Thumb.X + 3 ) * This.ScaleFactor , ( This.Thumb.Y + ( This.ThumbHeight / 2 ) ) * This.ScaleFactor , ( This.Thumb.W - 6 ) * This.ScaleFactor , 3 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
This.Gui2.UpdateWindow()
}
_GetTextSize( index := 4 ){
local pBitmap, G, Brush, temparr
pBitmap := Gdip_CreateBitmap( 10 , 10 ) , G := Gdip_GraphicsFromImage( pBitmap ), Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( "0xFF000000")
temparr := StrSplit( Gdip_TextToGraphics( G , ( This.Text ) ? ( This.Text ) : ( "Test String" ), " s" This.Fontsize " c" Brush " " This.FontOptions " x" 0 " y" 0 , This.Font , 10000, 10000 ),"|","|" ) , Gdip_DeleteBrush( Brush )
Gdip_DeleteGraphics( G ) , Gdip_DisposeImage( pBitmap )
return temparr[ index ]
}
Delete(){
This.Gui2.DeleteWindow()
This.Gui1.DeleteWindow()
}
}
;********************************************************************************************
;******************************************************************************************** NewTheme
NewTheme(){
local MyButtonDesign := {}
MyButtonDesign.All := {}
MyButtonDesign.Default := {}
MyButtonDesign.Hover := {}
MyButtonDesign.Pressed := {}
;********************************
;All
MyButtonDesign.All.W := 120 , MyButtonDesign.All.H := 35 , MyButtonDesign.All.Text := "Show / Hide" , MyButtonDesign.All.Font := "Cambria" , MyButtonDesign.All.FontSize := "14" , MyButtonDesign.All.BackgroundColor := "0xFF212B37" , MyButtonDesign.All.ButtonAddGlossy := "0"
;********************************
;Default
MyButtonDesign.Default.W := 120 , MyButtonDesign.Default.H := 35 , MyButtonDesign.Default.Text := "Show / Hide" , MyButtonDesign.Default.Font := "Cambria" , MyButtonDesign.Default.FontOptions := " Center vCenter Bold" , MyButtonDesign.Default.FontSize := "14" , MyButtonDesign.Default.H := "0xff02112F" , MyButtonDesign.Default.TextBottomColor2 := "0xff02112F" , MyButtonDesign.Default.TextTopColor1 := "0xFFFFFFFF" , MyButtonDesign.Default.TextTopColor2 := "0xFFFFFFFF" , MyButtonDesign.Default.TextOffsetX := "0" , MyButtonDesign.Default.TextOffsetY := "0" , MyButtonDesign.Default.TextOffsetW := "0" , MyButtonDesign.Default.TextOffsetH := "0" , MyButtonDesign.Default.BackgroundColor := "0xFF212B37" , MyButtonDesign.Default.ButtonOuterBorderColor := "0xFF3B4D63" , MyButtonDesign.Default.ButtonCenterBorderColor := "0xFF5C789A" , MyButtonDesign.Default.ButtonInnerBorderColor1 := "0xFF3F444A" , MyButtonDesign.Default.ButtonInnerBorderColor2 := "0xFF24292D" , MyButtonDesign.Default.ButtonMainColor1 := "0xFF212B37" , MyButtonDesign.Default.ButtonMainColor2 := "0xFF212B37" , MyButtonDesign.Default.ButtonAddGlossy := "0" , MyButtonDesign.Default.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Default.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Default.GlossBottomColor := "33000000"
;********************************
;Hover
MyButtonDesign.Hover.W := 120 , MyButtonDesign.Hover.H := 35 , MyButtonDesign.Hover.Text := "Show / Hide" , MyButtonDesign.Hover.Font := "Cambria" , MyButtonDesign.Hover.FontOptions := " Bold Center vCenter " , MyButtonDesign.Hover.FontSize := "14" , MyButtonDesign.Hover.H := "0xff02112F" , MyButtonDesign.Hover.TextBottomColor2 := "0xff02112F" , MyButtonDesign.Hover.TextTopColor1 := "0xFFFFFFFF" , MyButtonDesign.Hover.TextTopColor2 := "0xFFFFFFFF" , MyButtonDesign.Hover.TextOffsetX := "0" , MyButtonDesign.Hover.TextOffsetY := "0" , MyButtonDesign.Hover.TextOffsetW := "0" , MyButtonDesign.Hover.TextOffsetH := "0" , MyButtonDesign.Hover.BackgroundColor := "0xFF212B37" , MyButtonDesign.Hover.ButtonOuterBorderColor := "0xFF5E7B9D" , MyButtonDesign.Hover.ButtonCenterBorderColor := "0xFF262B2F" , MyButtonDesign.Hover.ButtonInnerBorderColor1 := "0xFF3F444A" , MyButtonDesign.Hover.ButtonInnerBorderColor2 := "0xFF24292D" , MyButtonDesign.Hover.ButtonMainColor1 := "0xFF5A7596" , MyButtonDesign.Hover.ButtonMainColor2 := "0xFF2E3C4C" , MyButtonDesign.Hover.ButtonAddGlossy := "0" , MyButtonDesign.Hover.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Hover.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Hover.GlossBottomColor := "33000000"
;********************************
;Pressed
MyButtonDesign.Pressed.W := 120 , MyButtonDesign.Pressed.H := 35 , MyButtonDesign.Pressed.Text := "Show / Hide" , MyButtonDesign.Pressed.Font := "Cambria" , MyButtonDesign.Pressed.FontOptions := " Bold Center vCenter " , MyButtonDesign.Pressed.FontSize := "14" , MyButtonDesign.Pressed.H := "0xffB0BFD0" , MyButtonDesign.Pressed.TextBottomColor2 := "0xffB0BFD0" , MyButtonDesign.Pressed.TextTopColor1 := "0xFF000000" , MyButtonDesign.Pressed.TextTopColor2 := "0xFF000000" , MyButtonDesign.Pressed.TextOffsetX := "0" , MyButtonDesign.Pressed.TextOffsetY := "0" , MyButtonDesign.Pressed.TextOffsetW := "0" , MyButtonDesign.Pressed.TextOffsetH := "0" , MyButtonDesign.Pressed.BackgroundColor := "0xFF212B37" , MyButtonDesign.Pressed.ButtonOuterBorderColor := "0xFF" , MyButtonDesign.Pressed.ButtonCenterBorderColor := "0xFF" , MyButtonDesign.Pressed.ButtonInnerBorderColor1 := "0xffA3B4C8" , MyButtonDesign.Pressed.ButtonInnerBorderColor2 := "0xff80FFFF" , MyButtonDesign.Pressed.ButtonMainColor1 := "0x99283442" , MyButtonDesign.Pressed.ButtonMainColor2 := "0x99597494" , MyButtonDesign.Pressed.ButtonAddGlossy := "0" , MyButtonDesign.Pressed.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Pressed.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Pressed.GlossBottomColor := "33000000"
;********************************
return MyButtonDesign
}
;********************************************************************************************
;********************************************************************************************DrawText
DrawText( G , RectObject := "" , Text := "Sample Text" , FontSize := 16 , FontType := "Segoe UI" , Options := " Center vCenter Bold " , Color := "0xFF000000" , Scale := 1 ){
if( RectObject = "" )
RectObject := { X: 0 , Y: 0 , W: 100 , H: 100 }
cc := RectObject
Brush := Gdip_BrushCreateSolid( Color )
Gdip_TextToGraphics( G , Text , "s" FontSize * Scale " " Options " c" Brush " x" cc.X * Scale " y" cc.Y * Scale , "Segoe UI" , cc.W * Scale , cc.H * Scale )
Gdip_DeleteBrush( Brush )
}
;********************************************************************************************
;******************************************************************************************** Gdip_EncodeBitmapTo64string
Gdip_EncodeBitmapTo64string(pBitmap, ext, Quality=75) { ;Excised from https://www.autohotkey.com/boards/viewtopic.php?t=36047
if Ext not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
return -1
Extension := "." Ext
DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
VarSetCapacity(ci, nSize)
DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
if !(nCount && nSize)
return -2
Loop, % nCount {
sString := StrGet(NumGet(ci, (idx := (48+7*A_PtrSize)*(A_Index-1))+32+3*A_PtrSize), "UTF-16")
if !InStr(sString, "*" Extension)
continue
pCodec := &ci+idx
break
}
if !pCodec
return -3
if (Quality != 75){
Quality := (Quality < 0) ? 0 : (Quality > 100) ? 100 : Quality
if Extension in .JPG,.JPEG,.JPE,.JFIF
{
DllCall("gdiplus\GdipGetEncoderParameterListSize", Ptr, pBitmap, Ptr, pCodec, "uint*", nSize)
VarSetCapacity(EncoderParameters, nSize, 0)
DllCall("gdiplus\GdipGetEncoderParameterList", Ptr, pBitmap, Ptr, pCodec, "uint", nSize, Ptr, &EncoderParameters)
Loop, % NumGet(EncoderParameters, "UInt") {
elem := (24+(A_PtrSize ? A_PtrSize : 4))*(A_Index-1) + 4 + (pad := A_PtrSize = 8 ? 4 : 0)
if (NumGet(EncoderParameters, elem+16, "UInt") = 1) && (NumGet(EncoderParameters, elem+20, "UInt") = 6){
p := elem+&EncoderParameters-pad-4
NumPut(Quality, NumGet(NumPut(4, NumPut(1, p+0)+20, "UInt")), "UInt")
break
}
}
}
}
DllCall("ole32\CreateStreamOnHGlobal", "ptr",0, "int",true, "ptr*",pStream)
DllCall("gdiplus\GdipSaveImageToStream", "ptr",pBitmap, "ptr",pStream, "ptr",pCodec, "uint",p ? p : 0)
DllCall("ole32\GetHGlobalFromStream", "ptr",pStream, "uint*",hData)
pData := DllCall("GlobalLock", "ptr",hData, "uptr")
nSize := DllCall("GlobalSize", "uint",pData)
VarSetCapacity(Bin, nSize, 0)
DllCall("RtlMoveMemory", "ptr",&Bin , "ptr",pData , "uint",nSize)
DllCall("GlobalUnlock", "ptr",hData)
DllCall(NumGet(NumGet(pStream + 0, 0, "uptr") + (A_PtrSize * 2), 0, "uptr"), "ptr",pStream)
DllCall("GlobalFree", "ptr",hData)
DllCall("Crypt32.dll\CryptBinaryToString", "ptr",&Bin, "uint",nSize, "uint",0x01, "ptr",0, "uint*",base64Length)
VarSetCapacity(base64, base64Length*2, 0)
;*************************
;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=101960&p=453367#p453387
DllCall("Crypt32.dll\CryptBinaryToString", "ptr",&Bin, "uint",nSize, "uint", 0x40000001 , "ptr",&base64, "uint*",base64Length) ; [ 0x40000001 = CRYPT_STRING_NOCRLF ( 0x40000000 ) And CRYPT_STRING_BASE64 ( 0x00000001 ) ]
;*************************
Bin := ""
VarSetCapacity(Bin, 0)
VarSetCapacity(base64, -1)
return base64
}
;********************************************************************************************
;******************************************************************************************** ClipBitmapFunction
ClipBitmapFunction(){
local abc
abc =
( `join`r`n
B64ToPBitmap( Input ){
local ptr , uptr , pBitmap , pStream , hData , pData , Dec , DecLen , B64
VarSetCapacity( B64 , strlen( Input ) << !!A_IsUnicode )
B64 := Input
If !DllCall("Crypt32.dll\CryptStringToBinary" ( ( A_IsUnicode ) ? ( "W" ) : ( "A" ) ), Ptr := A_PtrSize ? "Ptr" : "UInt" , &B64, "UInt", 0, "UInt", 0x01, Ptr, 0, "UIntP", DecLen, Ptr, 0, Ptr, 0)
Return False
VarSetCapacity( Dec , DecLen , 0 )
If !DllCall("Crypt32.dll\CryptStringToBinary" (A_IsUnicode ? "W" : "A"), Ptr, &B64, "UInt", 0, "UInt", 0x01, Ptr, &Dec, "UIntP", DecLen, Ptr, 0, Ptr, 0)
Return False
DllCall("Kernel32.dll\RtlMoveMemory", Ptr, pData := DllCall("Kernel32.dll\GlobalLock", Ptr, hData := DllCall( "Kernel32.dll\GlobalAlloc", "UInt", 2, UPtr := A_PtrSize ? "UPtr" : "UInt" , DecLen, UPtr), UPtr) , Ptr, &Dec, UPtr, DecLen)
DllCall("Kernel32.dll\GlobalUnlock", Ptr, hData)
DllCall("Ole32.dll\CreateStreamOnHGlobal", Ptr, hData, "Int", True, Ptr "P", pStream)
DllCall("Gdiplus.dll\GdipCreateBitmapFromStream", Ptr, pStream, Ptr "P", pBitmap)
return pBitmap
}
)
return abc
}
;********************************************************************************************
;******************************************************************************************** PopUpWindow
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;####################################################################################################################################################################################
class PopUpWindow {
;PopUpWindow v2.2
;Date Written: Oct 28th, 2021
;Last Edit: Feb 7th, 2022 :Changed the trigger method.
;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 := 10
This.Y := 10
This.W := 10
This.H := 10
This.Smoothing := 2
This.Options := " -DPIScale +AlwaysOnTop "
This.AutoShow := 0
This.GdipStartUp := 0
This.Title := ""
This.Controls := []
This.Handles := []
This.Index := 0
}
AddTrigger( obj ){
local k , v , cc , bd
This.Controls[ ++This.Index ] := { X: 10
, Y: 10
, W: 10
, H: 10 }
for k, v in obj
This.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.Index
This.Controls[ This.Index ].Hwnd := hwnd
if( IsObject( cc.Label ) ){
bd := cc.Label
GuiControl, % This.Hwnd ":+G" , % hwnd , % bd
}else{
bd := This._TriggerCall.Bind( This )
GuiControl, % This.Hwnd ":+G" , % hwnd , % bd
}
return hwnd
}
_TriggerCall(){
MouseGetPos,,,, ctrl, 2
Try
;~ SetTimer, % This.Controls[ This.Handles[ ctrl ] ].Label, -0
gosub, % This.Controls[ This.Handles[ ctrl ] ].Label
}
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 , v
if( IsObject( obj ) )
for k, v in obj
This[ 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 hwnd
Gui , New, % " +LastFound +E0x80000 hwndhwnd -Caption " This.Options
PopUpWindow.Index++
This.Index := PopUpWindow.Index
PopUpWindow.Windows[ PopUpWindow.Index ] := This
This.Hwnd := hwnd
PopUpWindow.Handles[ hwnd ] := PopUpWindow.Index
if( This.GdipStartUp && !PopUpWindow.pToken )
PopUpWindow.pToken := GDIP_STARTUP()
}
_DestroyWindowsGraphics(){
Gdip_DeleteGraphics( This.G )
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( alpha := 255 ){
UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H , alpha )
}
ClearWindow( AutoUpdate := 0 , Color := "" ){
if( color != "" )
Gdip_GraphicsClear( This.G , color )
else
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 )
else
Gdip_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.Hwnd
for 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 pCachedBitmap
if( This.CachedBitmap )
This.DisposeCachedbitmap()
DllCall( "gdiplus\GdipCreateCachedBitmap" , "Ptr" , pBitmap , "Ptr" , this.G , "PtrP" , pCachedBitmap )
This.CachedBitmap := pCachedBitmap
if( 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 +HwndHwnd
PopUpWindow.HelperHwnd := hwnd
Gui, Add, Edit, xm ym w250 r1 Center hwndhwnd, Gui1
PopUpWindow.EditHwnd := hwnd
loop, % 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.EditHwnd
ClipList := { __New: " := New PopUpWindow( { AutoShow: 1 , 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 , AutoUpdate := 0 )"
, PaintBackground: ".PaintBackground( color := ""0xFF000000"" , AutoUpdate := 0 ) " ";{ 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: """" } )"
, DrawTriggers: ".DrawTriggers( color := ""0xFFFF0000"" , AutoUpdate := 0 )"
, CreateCachedBitmap: ".CreateCachedBitmap( pBitmap , Dispose := 0 )"
, DrawCachedBitmap: ".DrawCachedBitmap( AutoUpdate := 0 )"
, DisposeCachedbitmap: ".DisposeCachedbitmap()" }
clipboard := Out ClipList[ A_GuiControl ]
}
}
;********************************************************************************************
;******************************************************************************************** Color Manipulation Functions
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
HSL_ToRGB(hue, sat:=1, lum:=0.5 ) {
; Function by [VxE]. See > http://www.wikipedia.org/wiki/HSV_color_space
; HSL to/from RGB conversion functions by [VxE]. Freely avalable @ http://www.autohotkey.com/community/viewtopic.php?f=2&t=88707
; Converts a hue/sat/lum into a 24-bit RGB color code. Input: 0 <= hue <= 360, 0 <= sat <= 1, 0 <= lum <= 1.
Static i24 := 0xFFFFFF, i40 := 0xFFFFFF0000, hx := "0123456789ABCDEF"
; Transform the decimal inputs into 24-bit integers. Integer arithmetic is nice..
sat := ( sat * i24 ) & i24
lum := ( lum * i24 ) & i24
hue := ( hue * 0xB60B60 >> 8 ) & i24 ; conveniently, 360 * 0xB60B60 = 0xFFFFFF00
; Determine the chroma value and put it in the 'sat' var since the saturation value is not used after this.
sat := lum + Round( sat * ( i24 - Abs( i24 - lum - lum ) ) / 0x1FFFFFE )
; Calculate the base values for red and blue (green's base value is the hue)
red := hue < 0xAAAAAA ? hue + 0x555555 : hue - 0xAAAAAA
blu := hue < 0x555555 ? hue + 0xAAAAAA : hue - 0x555555
; Run the blue value through the cases
If ( blu < 0x2AAAAB )
blu := sat + 2 * ( i24 - 6 * blu ) * ( lum - sat ) / i24 >> 16
Else If ( blu < 0x800000 )
blu := sat >> 16
Else If ( blu < 0xAAAAAA )
blu := sat + 2 * ( i24 - 6 * ( 0xAAAAAA - blu ) ) * ( lum - sat ) / i24 >> 16
Else
blu := 2 * lum - sat >> 16
; Run the red value through the cases
If ( red < 0x2AAAAB )
red := sat + 2 * ( i24 - 6 * red ) * ( lum - sat ) / i24 >> 16
Else If ( red < 0x800000 )
red := sat >> 16
Else If ( red < 0xAAAAAA )
red := sat + 2 * ( i24 - 6 * ( 0xAAAAAA - red ) ) * ( lum - sat ) / i24 >> 16
Else
red := 2 * lum - sat >> 16
; Run the green value through the cases
If ( hue < 0x2AAAAB )
hue := sat + 2 * ( i24 - 6 * hue ) * ( lum - sat ) / i24 >> 16
Else If ( hue < 0x800000 )
hue := sat >> 16
Else If ( hue < 0xAAAAAA )
hue := sat + 2 * ( i24 - 6 * ( 0xAAAAAA - hue ) ) * ( lum - sat ) / i24 >> 16
Else
hue := 2 * lum - sat >> 16
; Return the values in RGB as a hex integer
Return "0x" SubStr( hx, ( red >> 4 ) + 1, 1 ) SubStr( hx, ( red & 15 ) + 1, 1 )
. SubStr( hx, ( hue >> 4 ) + 1, 1 ) SubStr( hx, ( hue & 15 ) + 1, 1 )
. SubStr( hx, ( blu >> 4 ) + 1, 1 ) SubStr( hx, ( blu & 15 ) + 1, 1 )
} ; END - HSL_ToRGB( hue, sat, lum )
;*****************************************************
RGBtoHEXandBack(clr) {
If (StrLen(clr)=9)
{
R := SubStr(clr, 1, 3)
G := SubStr(clr, 4, 3)
B := SubStr(clr, 7, 3)
z := Format("{1:02x}", R) Format("{1:02x}", G) Format("{1:02x}", B)
} Else
{
R := "0x" SubStr(clr, 1, 2)
G := "0x" SubStr(clr, 3, 2)
B := "0x" SubStr(clr, 5, 2)
z := Format("{1:03d}", R) Format("{1:03d}", G) Format("{1:03d}", B)
}
Return z
}
;**********************************************************************
ConvertRGBtoHSL(R, G, B) {
; http://www.easyrgb.com/index.php?X=MATH&H=18#text18
SetFormat, float, 0.5 ; for some reason I need this for some colors to work.
R := (R / 255)
G := (G / 255)
B := (B / 255)
Min := min(R, G, B)
Max := max(R, G, B)
del_Max := Max - Min
L := (Max + Min) / 2
if (del_Max = 0)
{
H := S := 0
} else
{
if (L < 0.5)
S := del_Max / (Max + Min)
else
S := del_Max / (2 - Max - Min)
del_R := (((Max - R) / 6) + (del_Max / 2)) / del_Max
del_G := (((Max - G) / 6) + (del_Max / 2)) / del_Max
del_B := (((Max - B) / 6) + (del_Max / 2)) / del_Max
if (R = Max)
{
H := del_B - del_G
} else
{
if (G = Max)
H := (1 / 3) + del_R - del_B
else if (B = Max)
H := (2 / 3) + del_G - del_R
}
if (H < 0)
H += 1
if (H > 1)
H -= 1
}
; return round(h*360) "," s "," l
; return (h*360) "," s "," l
return [abs(round(h*360, 3)), abs(s), abs(l)]
}
;*******************************************************************
ConvertHSLtoRGB(H, S, L) {
; http://www.had2know.com/technology/hsl-rgb-color-converter.html
H := H/360
if (S == 0)
{
R := L*255
G := L*255
B := L*255
} else
{
if (L < 0.5)
var_2 := L * (1 + S)
else
var_2 := (L + S) - (S * L)
var_1 := 2 * L - var_2
R := 255 * ConvertHueToRGB(var_1, var_2, H + (1 / 3))
G := 255 * ConvertHueToRGB(var_1, var_2, H)
B := 255 * ConvertHueToRGB(var_1, var_2, H - (1 / 3))
}
; Return round(R) "," round(G) "," round(B)
; Return (R) "," (G) "," (B)
Return [round(R), round(G), round(B)]
}
;*******************************************************************
ConvertHueToRGB(v1, v2, vH) {
vH := ((vH<0) ? ++vH : vH)
vH := ((vH>1) ? --vH : vH)
return ((6 * vH) < 1) ? (v1 + (v2 - v1) * 6 * vH)
: ((2 * vH) < 1) ? (v2)
: ((3 * vH) < 2) ? (v1 + (v2 - v1) * ((2 / 3) - vH) * 6)
: v1
}
;**********************************************************************
;**************************************************************************************************************************************************
;**************************************************************************************************************************************************
;**************************************************************************************************************************************************
;********************************************************************************************
;******************************************************************************************** Vector
;************
;Vector Class
;**************************************************************************************************************************************************************************
;00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000
;00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000
;00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000
;**************************************************************************************************************************************************************************
Class Vector {
;Written By: HB
;Date: Sept 23rd, 2022
;Last Edit: Sept 24th, 2022
;Purpose: Vector math class
;Credit: Rohwedder
;Resources:
;Line intercept concepts and code: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=37175
;Create an Arrow: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=92039&p=479129#p478944
;Getting an angle: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=108760&p=483661#p483678
;Setting an Angle: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=108760&p=483786#p483811
;
static RadToDeg := 45 / ATan( 1 )
, DegToRad := ATan( 1 ) / 45
__New( x := 0 , y := 0 , rotate := 0 ){
if( IsObject( x ) ){
if( rotate = 3 ){
This.X := x.X * -1
,This.Y := x.Y * -1
}else if( rotate = 2 ){
This.X := x.Y
,This.Y := x.X * -1
}else if( rotate = 1 ){
This.X := x.Y * -1
,This.Y := x.X
}else{
This.X := x.X
,This.Y := x.Y
}
}else{
if( rotate = 3 ){
This.X := X * -1
,This.Y := Y * -1
}else if( rotate = 2 ){
This.X := Y
,This.Y := X * -1
}else if( rotate = 1 ){
This.X := Y * -1
,This.Y := X
}else{
This.X := X
,This.Y := Y
}
}
}
Add( x , y := "" ){
if( IsObject( x ) ){
This.X += x.X
,This.Y += x.Y
}else if( y = "" ){
This.X += x
,This.Y += x
}else{
This.X += x
,This.Y += y
}
}
Sub( x , y := "" ){
if( IsObject( x ) ){
This.X -= x.X
,This.Y -= x.Y
}else if( y = "" ){
This.X -= X
,This.Y -= X
}else{
This.X -= X
,This.Y -= Y
}
}
Div( x , y := "" ){
if( IsObject( x ) ){
This.X /= x.X
,This.Y /= x.Y
}else if( x && y = "" ){
This.X /= x
,This.Y /= x
}else{
This.X /= X
,This.Y /= Y
}
}
Mult( x , y := "" ){
if( IsObject( x ) ){
This.X *= x.X
,This.Y *= x.Y
}else if( x && y = "" ){
This.X *= x
,This.Y *= x
}else{
This.X *= X
,This.Y *= Y
}
}
Dist( x , y := "" ){
if( IsObject( x ) )
return Sqrt( ( ( This.X - x.X ) **2 ) + ( ( This.Y - x.Y ) **2 ) )
else
return Sqrt( ( ( This.X - X ) **2 ) + ( ( This.Y - Y ) **2 ) )
}
GetMag(){
return Sqrt( This.X * This.X + This.Y * This.Y )
}
SetMag( magnitude ){
local m := This.GetMag()
This.X := This.X * magnitude / m
,This.Y := This.Y * magnitude / m
}
MagSq(){
return This.GetMag()**2
}
Dot( x , y := "" ){
if( IsObject( x ) )
return ( This.X * x.X ) + ( This.Y * x.Y )
else
return ( This.X * X ) + ( This.Y * Y )
}
Cross( x , y := "" ){
if( IsObject( x ) )
return This.X * x.Y - This.Y * x.X
else
return This.X * Y - This.Y * X
}
Norm(){
local m := This.GetMag()
This.X /= m
This.Y /= m
}
GetAngle(){
local angle
( ( angle := Vector.RadToDeg * DllCall( "msvcrt\atan2" , "Double" , This.Y , "Double" , This.X , "CDECL Double" ) ) < 0 ) ? ( angle += 360 )
return angle
}
SetAngle( newAngle := 0 , NewVector := 0 ){
local Angle := This.GetAngle()
, ChangeAngle := newAngle - Angle
, Co := Cos( Vector.DegToRad * ChangeAngle )
, Si := Sin( Vector.DegToRad * ChangeAngle )
, X := This.X
, Y := This.Y
, X2 := X * Co - Y * Si
, Y2 := X * Si + Y * Co
if( !NewVector )
This.X := X2 , This.Y := Y2
else
return New Vector( X2 , Y2 )
}
RotateAngle( rotationAmount := 90 , NewVector := 0 ){
local Co := Cos( Vector.DegToRad * rotationAmount )
, Si := Sin( Vector.DegToRad * rotationAmount )
, X := This.X
, Y := This.Y
, X2 := X * Co - Y * Si
, Y2 := X * Si + Y * Co
if( !NewVector )
This.X := X2 , This.Y := Y2
else
return New Vector( X2 , Y2 )
}
;********************************************
;class methods
TestLineInterceptPoint( interceptPoint , Line1 , Line2 ){ ; Line = { Start: { X: , Y: } , End: { X: , Y: } } , interceptPoint = { X: , Y: }
local
for k , v in [ "X" , "Y" ]
M%v%_Min := min( Line1.Start[ v ] , Line1.End[ v ] )
,M%v%_Max := max( Line1.Start[ v ] , Line1.End[ v ] )
,L%v%_Min := min( Line2.Start[ v ] , Line2.End[ v ] )
,L%v%_Max := max( Line2.Start[ v ] , Line2.End[ v ] )
if( !( interceptPoint.X < Mx_Min || interceptPoint.X > Mx_Max || interceptPoint.X < Lx_Min || interceptPoint.X > Lx_Max ) && !( interceptPoint.Y < My_Min || interceptPoint.Y > My_Max || interceptPoint.Y < Ly_Min || interceptPoint.Y > Ly_Max ) )
return 1
return 0
}
GetLineInterceptPoint( Line1 , Line2 ){ ; Line = { Start: { X: , Y: } , End: { X: , Y: } }
local A1 := Line1.End.Y - Line1.Start.Y
,B1 := Line1.Start.X - Line1.End.X
,C1 := A1 * Line1.Start.X + B1 * Line1.Start.Y
,A2 := Line2.End.Y - Line2.Start.Y
,B2 := Line2.Start.X - Line2.End.X
,C2 := A2 * Line2.Start.X + B2 * Line2.Start.Y
,Denominator := A1 * B2 - A2 * B1
return New Vector( { X: ( ( B2 * C1 - B1 * C2 ) / Denominator ) , Y: ( ( A1 * C2 - A2 * C1 ) / Denominator ) } )
}
;********************************************
}
;**************************************************************************************************************************************************************************
;00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000
;00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000
;00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000 00000 <<<>>> 00000
;**************************************************************************************************************************************************************************
;********************************************************************************************
;********************************************************************************************
-
- Posts: 61
- Joined: 01 Sep 2020, 09:49
Re: Crop bitmap and export as Base64 string? ( Create Icons )
@Hellbent Is there any way that i can convert the Bs64 code and save it to an actual ico File format?
Re: Crop bitmap and export as Base64 string? ( Create Icons )
try this.vanheartnet098 wrote: ↑27 Dec 2023, 02:47@Hellbent Is there any way that i can convert the Bs64 code and save it to an actual ico File format?
viewtopic.php?t=93750#p415405
Code: Select all
;****************************************************************************************************************************************************************************
#Include <GDIP_ALL> ;GDIP: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=6517
;****************************************************************************************************************************************************************************
#SingleInstance, Force
SetBatchLines, -1
;-------------------
Gdip_Startup()
;-------------------
IconFilePath := A_Desktop "\test.ico"
B64String := "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwwAADsMBx2+oZAAAFZ1JREFUeF7tWwl4FOX534okIQFvbiF4gdZardrWWmzBqnjgVRHvf7VIQW65BAKIqCBWLg+UIwnhCBByBwhITAJJCDkgFwnkIDdJCDlIyO7OzO7m1/edmd3MbiY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rvh45du9RE1tvqrGlYm2QGKwf+k9QGVptojkAtXwoZgwP62MmqJT1BvkYO2JYiSfNeJci4X82IRqYx1ON1cgv7kMxRcqUG2qJ5LMqGmxIelsC1bnFmMcrfjY+HSMT8wmUosQWVYPo1W5j/a+vCC8MNo5dlrwXKpQAzFRawmM9ttn3PBSNULIa2jGurwzChFUMc6gsnl8Qi7GJ2VjdmoOlmcXUVArx3enKvFVbhk+PZ6PaUcz8dbh43g17hjePEwrTvHkA6ozfE9WoaixWVbcdeV5IbQBj/GjK28XLpLkakpzM/5ViOtWurJvSBOl3iC7vhlbCquxLINcgyxibsppzEzOl1PY+KQcvJtwgnw7G+NolSdQVTmVjs2hc5aTn+8qqqbgd4GyChPr/ASYTd7pYSdBXqAfy+w7EuW1eedfgnGG4KLD9X1CrswUaUWdWaCA1oQoCmZ++TX4mnx5FcWLlVkVWJVTjm9OVCKgoAb7ys8hu66Z3IHfOWFr4iTXNibX9mx57Vadg/WVBryuitw68+/8NBNg8KS4aHJ9v8BuEW3CDZUNLZTDmyWJ/kqQ5Lc97ISxtG9reVPTqa1VQXOJu+xUdyWiukS73wUyEby5yhN2JYPBhCjWocQLhvxY0+U8hv2HU65BjiGv+qVWeD+F8CSUyThP0A5OT46fyhFcXYXBRNmPs4kzga5mbgc/2JS38rta2/8cwpMhImZcjAhXcJ+uZ9IdgRXnCP9fMfdLEXmbXfk9YYaeIpcCiuzKz2d/ib8Y7Ypw1uA9eN6I5GCloP0PLTmFOY7LjRi/tvNT/jrUYPgPiaH7WFBDAjAAAAAASUVORK5CYII="
;-------------------
pBitmap := B64ToPBitmap( B64String )
hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
Gdip_DisposeImage( pBitmap )
;-------------------
hBitmap2Icon( hBitmap , IconFilePath )
;-------------------
ExitApp
*ESC::ExitApp
;********************;********************;********************;********************;********************;********************;********************
;********************;********************;********************;********************;********************;********************;********************
;********************;********************;********************;********************;********************;********************;********************
;https://www.autohotkey.com/boards/viewtopic.php?t=93750#p415405
hBitmap2Icon( hBitmap , destIco) {
;~ hBitmap := LoadPicture(sourcePng, "GDI+")
hIcon := HIconFromHBitmap(hBitmap)
HiconToFile(hIcon, destIco)
DllCall("DestroyIcon", "Ptr", hIcon), DllCall("DeleteObject", hBitmap)
}
HIconFromHBitmap(hBitmap) {
VarSetCapacity(BITMAP, size := 4*4 + A_PtrSize*2, 0)
DllCall("GetObject", "Ptr", hBitmap, "Int", size, "Ptr", &BITMAP)
width := NumGet(BITMAP, 4, "UInt"), height := NumGet(BITMAP, 8, "UInt")
hDC := DllCall("GetDC", "Ptr", 0, "Ptr")
hCBM := DllCall("CreateCompatibleBitmap", "Ptr", hDC, "Int", width, "Int", height, "Ptr")
VarSetCapacity(ICONINFO, 4*2 + A_PtrSize*3, 0)
NumPut(1, ICONINFO)
NumPut(hCBM, ICONINFO, 4*2 + A_PtrSize)
NumPut(hBitmap, ICONINFO, 4*2 + A_PtrSize*2)
hIcon := DllCall("CreateIconIndirect", "Ptr", &ICONINFO, "Ptr")
DllCall("DeleteObject", "Ptr", hCBM), DllCall("ReleaseDC", "Ptr", 0, "Ptr", hDC)
Return hIcon
}
HiconToFile(hIcon, destFile) {
static szICONHEADER := 6, szICONDIRENTRY := 16, szBITMAP := 16 + A_PtrSize*2, szBITMAPINFOHEADER := 40
, IMAGE_BITMAP := 0, flags := (LR_COPYDELETEORG := 0x8) | (LR_CREATEDIBSECTION := 0x2000)
, szDIBSECTION := szBITMAP + szBITMAPINFOHEADER + 8 + A_PtrSize*3
, copyImageParams := ["UInt", IMAGE_BITMAP, "Int", 0, "Int", 0, "UInt", flags, "Ptr"]
VarSetCapacity(ICONINFO, 8 + A_PtrSize*3, 0)
DllCall("GetIconInfo", "Ptr", hIcon, "Ptr", &ICONINFO)
if !hbmMask := DllCall("CopyImage", "Ptr", NumGet(ICONINFO, 8 + A_PtrSize), copyImageParams*) {
MsgBox, % "CopyImage failed. LastError: " . A_LastError
Return
}
hbmColor := DllCall("CopyImage", "Ptr", NumGet(ICONINFO, 8 + A_PtrSize*2), copyImageParams*)
VarSetCapacity(mskDIBSECTION, szDIBSECTION, 0)
VarSetCapacity(clrDIBSECTION, szDIBSECTION, 0)
DllCall("GetObject", "Ptr", hbmMask , "Int", szDIBSECTION, "Ptr", &mskDIBSECTION)
DllCall("GetObject", "Ptr", hbmColor, "Int", szDIBSECTION, "Ptr", &clrDIBSECTION)
clrWidth := NumGet(clrDIBSECTION, 4, "UInt")
clrHeight := NumGet(clrDIBSECTION, 8, "UInt")
clrBmWidthBytes := NumGet(clrDIBSECTION, 12, "UInt")
clrBmPlanes := NumGet(clrDIBSECTION, 16, "UShort")
clrBmBitsPixel := NumGet(clrDIBSECTION, 18, "UShort")
clrBits := NumGet(clrDIBSECTION, 16 + A_PtrSize)
colorCount := clrBmBitsPixel >= 8 ? 0 : 1 << (clrBmBitsPixel * clrBmPlanes)
clrDataSize := clrBmWidthBytes * clrHeight
mskHeight := NumGet(mskDIBSECTION, 8, "UInt")
mskBmWidthBytes := NumGet(mskDIBSECTION, 12, "UInt")
mskBits := NumGet(mskDIBSECTION, 16 + A_PtrSize)
mskDataSize := mskBmWidthBytes * mskHeight
iconDataSize := clrDataSize + mskDataSize
dwBytesInRes := szBITMAPINFOHEADER + iconDataSize
dwImageOffset := szICONHEADER + szICONDIRENTRY
VarSetCapacity(ICONHEADER, szICONHEADER, 0)
NumPut(1, ICONHEADER, 2, "UShort")
NumPut(1, ICONHEADER, 4, "UShort")
VarSetCapacity(ICONDIRENTRY, szICONDIRENTRY, 0)
NumPut(clrWidth , ICONDIRENTRY, 0, "UChar")
NumPut(clrHeight , ICONDIRENTRY, 1, "UChar")
NumPut(colorCount , ICONDIRENTRY, 2, "UChar")
NumPut(clrBmPlanes , ICONDIRENTRY, 4, "UShort")
NumPut(clrBmBitsPixel, ICONDIRENTRY, 6, "UShort")
NumPut(dwBytesInRes , ICONDIRENTRY, 8, "UInt")
NumPut(dwImageOffset , ICONDIRENTRY, 12, "UInt")
NumPut(clrHeight*2 , clrDIBSECTION, szBITMAP + 8, "UInt")
NumPut(iconDataSize, clrDIBSECTION, szBITMAP + 20, "UInt")
File := FileOpen(destFile, "w", "cp0")
File.RawWrite(ICONHEADER, szICONHEADER)
File.RawWrite(ICONDIRENTRY, szICONDIRENTRY)
File.RawWrite(&clrDIBSECTION + szBITMAP, szBITMAPINFOHEADER)
File.RawWrite(clrBits + 0, clrDataSize)
File.RawWrite(mskBits + 0, mskDataSize)
File.Close()
DllCall("DeleteObject", "Ptr", hbmColor)
DllCall("DeleteObject", "Ptr", hbmMask)
}
;********************;********************;********************;********************;********************;********************;********************
;********************;********************;********************;********************;********************;********************;********************
;********************;********************;********************;********************;********************;********************;********************
B64ToPBitmap( Input ){
local ptr , uptr , pBitmap , pStream , hData , pData , Dec , DecLen , B64
VarSetCapacity( B64 , strlen( Input ) << !!A_IsUnicode )
B64 := Input
If !DllCall("Crypt32.dll\CryptStringToBinary" ( ( A_IsUnicode ) ? ( "W" ) : ( "A" ) ), Ptr := A_PtrSize ? "Ptr" : "UInt" , &B64, "UInt", 0, "UInt", 0x01, Ptr, 0, "UIntP", DecLen, Ptr, 0, Ptr, 0)
Return False
VarSetCapacity( Dec , DecLen , 0 )
If !DllCall("Crypt32.dll\CryptStringToBinary" (A_IsUnicode ? "W" : "A"), Ptr, &B64, "UInt", 0, "UInt", 0x01, Ptr, &Dec, "UIntP", DecLen, Ptr, 0, Ptr, 0)
Return False
DllCall("Kernel32.dll\RtlMoveMemory", Ptr, pData := DllCall("Kernel32.dll\GlobalLock", Ptr, hData := DllCall( "Kernel32.dll\GlobalAlloc", "UInt", 2, UPtr := A_PtrSize ? "UPtr" : "UInt" , DecLen, UPtr), UPtr) , Ptr, &Dec, UPtr, DecLen)
DllCall("Kernel32.dll\GlobalUnlock", Ptr, hData)
DllCall("Ole32.dll\CreateStreamOnHGlobal", Ptr, hData, "Int", True, Ptr "P", pStream)
DllCall("Gdiplus.dll\GdipCreateBitmapFromStream", Ptr, pStream, Ptr "P", pBitmap)
return pBitmap
}