Custom Msgbox

Get help with using AutoHotkey and its commands and hotkeys
Hellbent
Posts: 503
Joined: 23 Sep 2017, 13:34

Custom Msgbox

16 Feb 2019, 08:34

I have this message box that I'm working on for a project
My problem is not with any code or anything like that, but rather it is that I have 1 computer (running windows 8.1),
and one screen resolution (1366,720). So my questions are
1. Does this run on windows (insert windows version)?
2. Do the graphics get displayed properly (No distortions etc)?

Here is the script:

Code: Select all

#SingleInstance,Force
SetBatchLines,-1
SetWorkingDir,%A_ScriptDir%
global pos:="9,17|17,9|23,8|69,8|75,3|142,6|152,14|179,14|183,18|201,18|252,18|258,11|269,12|280,2|285,2|288,6|329,6|334,2|360,3|364,0|374,0|393,19|395,43|391,49|390,185|393,190|393,200|397,208|396,229|376,247|370,247|360,243|327,243|324,246|254,246|222,212|207,212|183,234|158,234|144,248|111,248|107,243|67,243|59,248|27,248|11,232|13,219|2,205|2,190|8,181|8,52|10,17|17,9|"
,pos2:= "54,238|123,239|151,207|228,207|257,239|252,246|223,212|206,211|184,234|157,233|144,248|111,248|107,242|65,242|57,247|25,247|12,232|13,217|1,205|1,190|9,180|13,203|53,238|124,238|"
,pos3:= "20,12|139,12|149,22|252,23|254,26|269,29|286,7|364,7|385,30|386,207|373,221|371,230|363,237|258,241|229,208|151,207|124,237|52,238|14,204|13,131|18,126|18,41|13,36|13,22|19,11|"
,pos4:="20,13|141,13|149,22|252,22|252,28|268,28|285,10|366,10|384,30|384,207|373,220|373,230|365,238|256,238|231,208|150,208|124,237|51,237|13,205|13,131|17,127|17,40|12,38|12,21|20,12|"
;--------------------------------
global outer:= "10,8|278,8|293,0|386,0|394,9|417,9|417,32|426,41|426,85|408,103|408,122|399,131|399,163|417,181|417,210|363,210|352,201|114,201|101,210|82,210|71,219|42,219|33,210|10,210|10,163|19,154|19,104|1,86|1,42|10,32|10,9|"
,inner1:= "17,15|279,15|279,18|19,18|19,35|10,44|10,81|28,100|28,156|20,166|20,201|16,202|16,165|25,157|25,100|7,83|7,44|16,35|17,15|"
,inner2:= "411,17|411,35|420,44|420,81|402,100|402,119|392,129|392,166|411,184|411,203|385,204|385,204|385,201|408,201|408,184|390,167|390,128|399,118|399,100|417,82|417,44|408,35|408,17|"
,aquatop:= "281,17|298,8|382,8|391,17|410,17|392,36|354,36|335,17|281,17|"
,aquabottom:="17,203|36,184|85,184|89,188|98,188|105,183|360,183|384,202|365,202|354,194|111,194|99,203|80,203|68,212|45,212|36,203|17,203|"
NovaClicker:=New Window()
;~ Gui,2:+AlwaysOnTop -Caption
;~ Gui,2:Add,Picture,x0 y0 w427 h220 ,t2.png
;~ gui,2:Show,w427 h220
br1:=New_Brush("000000")
br2:=New_Brush("00ffff")
i:=0
return
GuiClose:
GuiContextMenu:
*^ESC::
	NovaClicker.Shut_Down()
	ExitApp
Move_Window:
	PostMessage,0xA1,2
	return
moving_Text:
	Fill_Box(NovaClicker.G ,br1,39,24,289,32)
	Fill_Box(NovaClicker.G ,b1,40,25,287,30)
	if(++i>NovaClicker.Bitmaps.Length())
		i:=1
	Gdip_DrawImage(NovaClicker.g,NovaClicker.Bitmaps[i],40,25,287,30)
	UpdateLayeredWindow( NovaClicker.hwnd , NovaClicker.hdc )
	return
/*
numpad1::
	position:=[],Index:=0
	while(!GetKeyState("ctrl")){
		ToolTip,% "Recording   " Position.Length()
		if(GetKeyState("LButton")&&!Pressed){
			Pressed:=1
			MouseGetPos,x,y
			position.Push({X:x,Y:y})
		}else if(!GetKeyState("LButton")&&Pressed){
			Pressed:=0
		}
	}
	temp:=""
	Loop,% Position.Length(){
		temp.= Position[A_Index].X "," Position[A_Index].Y "|"
	}
	FileDelete,temppositions.txt
	FileAppend,%temp%,temppositions.txt
	return
Up::
	MouseMove,0,-1,,R
	return
Down::
	MouseMove,0,1,,R
	return
Left::
	MouseMove,-1,0,,R
	return
Right::
	MouseMove,1,0,,R
	return	
*/
class Window	{
	__New(){
		This.GdipStart(),This.Create_Text_BitMaps(),This.W:=427,This.H:=220,This.Name:=1
		This.Window_SetUp(),This.Draw_Window()
	}
	Draw_Window(){
		global
		b1:=Gdip_CreateLineBrushFromRect(0, 0, 427, 220, "0xff08090F", "0xff00232C")
		This.b2:=This.New_Brush("6B6A73")
		This.b3:=This.New_Brush("01FFFE")
		This.p1:=New_Pen("293138",,2)
		This.p2:=New_Pen("000000",,1)
		This.p3:=New_Pen("00ffff",,1)
		Gdip_FillPolygon(This.G, b1, outer) 
		Gdip_FillPolygon(This.G, This.b2, inner1) 
		Gdip_FillPolygon(This.G, This.b2, inner2) 
		Gdip_DrawLines(This.G, This.p1, outer)
		Gdip_DrawLines(This.G, This.p2, inner1)
		Gdip_DrawLines(This.G, This.p2, inner2)
		;~ Gdip_DrawLines(This.G, This.p3, inner1)
		;~ Gdip_DrawLines(This.G, This.p3, inner2)
		Gdip_FillPolygon(This.G, This.b3, AquaTop)
		Gdip_DrawLines(This.G, This.p2, AquaTop)	
		Gdip_FillPolygon(This.G, This.b3, AquaBottom)
		Gdip_DrawLines(This.G, This.p2, AquaBottom)	
		Text:="`nThis is a little message box that I am trying out"
		Options:="cff666666 s24 x31 y51 Bold Center " 
		Gdip_TextToGraphics(This.G, Text, Options,"Arial", 367, 150) 
		Options:="cff00ffff s24 x29 y49 Bold Center "
		Gdip_TextToGraphics(This.G, Text, Options,"Arial", 367, 150) 
		Fill_Box(This.G,This.b3,70,150,120,20)
		Options:="cffaaaaaa s16 x71 y153 Bold Center vcenter "
		Gdip_TextToGraphics(This.G, "Ok", Options,"Arial", 120, 20) 
		Options:="cff000000 s16 x70 y152 Bold Center vcenter "
		Gdip_TextToGraphics(This.G, "Ok", Options,"Arial", 120, 20) 
		Gui,% This.Name ":Add",Text,x70 y150 w120 h20 gGuiClose
		Fill_Box(This.G,This.b3,220,150,120,20)
		Options:="cffaaaaaa s16 x221 y153 Bold Center vcenter "
		Gdip_TextToGraphics(This.G, "Cancel", Options,"Arial", 120, 20) 
		Options:="cff000000 s16 x220 y152 Bold Center vcenter "
		Gdip_TextToGraphics(This.G, "Cancel", Options,"Arial", 120, 20) 
		Gui,% This.Name ":Add",Text,x220 y150 w120 h20 gGuiClose
		UpdateLayeredWindow( This.hwnd , This.hdc ,0 , 0 , This.W , This.H )
		Gui,% This.Name ":Show",% "w" This.W " h" This.H " NA",HB Nova Clicker
		Gui,1:Add,Text,x0 y0 w400 h40 gMove_Window
		SetTimer,moving_Text,30
	}
	Window_SetUp(){
		Gui,% This.Name ":+AlwaysOnTop +E0x80000 +LastFound -Caption -DpiScale +Toolwindow"
		This.hwnd:=winExist()
		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,4)
	}
	GdipStart(){
		Ptr := A_PtrSize ? "UPtr" : "UInt"
		if !DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
			DllCall("LoadLibrary", "str", "gdiplus")
		VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
		DllCall("gdiplus\GdiplusStartup", A_PtrSize ? "UPtr*" : "uint*", This.Token, Ptr, &si, Ptr, 0)
	}
	New_Brush(colour:="000000",Alpha:="FF"){
		new_colour := "0x" Alpha colour 
		DllCall("gdiplus\GdipCreateSolidFill", "UInt", new_colour, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
		return pBrush
	}
	Shut_Down(){
		Ptr := A_PtrSize ? "UPtr" : "UInt"
		DllCall("gdiplus\GdiplusShutdown", Ptr, This.Token)
		if hModule := DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
			DllCall("FreeLibrary", Ptr, hModule)
		Loop,% This.BitMaps.Length()	{
			DeleteObject(This.BitMaps[A_Index])
		}
	}
	Create_Text_BitMaps(){
		TextMessage:="This is some crawling text"
		Options:="cffffffff s24  Bold "
		x:=300
		This.BitMaps:=[]
		While(X>-350){
			This.BitMaps[A_Index]:=Gdip_CreateBitmap(287,30),g:=Gdip_GraphicsFromImage(This.BitMaps[A_Index]),Gdip_SetSmoothingMode(g,1)
			Gdip_TextToGraphics(g, TextMessage, Options " x" x,"Arial",, 30)
			x-=2,Gdip_DeleteGraphics(g)
		}
	}
}
;                         GDIP LIB  (only required functions)
;############################################################################################################################################
;############################################################################################################################################
;############################################################################################################################################
;############################################################################################################################################
Layered_Window_SetUp(Smoothing,Window_X,Window_Y,Window_W,Window_H,Window_Name:=1,Window_Options:=""){
	Layered:={},Layered.W:=Window_W,Layered.H:=Window_H,Layered.X:=Window_X,Layered.Y:=Window_Y,Layered.Name:=Window_Name
	Layered.Options:=Window_Options,Layered.Token:=Gdip_Startup(),Create_Layered_GUI(Layered),Layered.hwnd:=winExist()
	Layered.hbm := CreateDIBSection(Window_W,Window_H),Layered.hdc := CreateCompatibleDC(),Layered.obm := SelectObject(Layered.hdc,Layered.hbm)
	Layered.G := Gdip_GraphicsFromHDC(Layered.hdc),Gdip_SetSmoothingMode(Layered.G,Smoothing)
	return Layered
}
Create_Layered_GUI(Layered){
	Gui,% Layered.Name ": +E0x80000 +LastFound " Layered.Options 
	Gui,% Layered.Name ":Show",% "x" Layered.X " y" Layered.Y " w" Layered.W " h" Layered.H " NA"
}	
Layered_Window_ShutDown(This){
	SelectObject(This.hdc,This.obm),DeleteObject(This.hbm),DeleteDC(This.hdc),gdip_deleteGraphics(This.g),Gdip_Shutdown(This.Token)
}
New_Brush(colour:="000000",Alpha:="FF"){
		new_colour := "0x" Alpha colour 
		DllCall("gdiplus\GdipCreateSolidFill", "UInt", new_colour, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
		return pBrush
	}
New_Pen(colour:="000000",Alpha:="FF",Width:= 5){
		new_colour := "0x" Alpha colour 
		return DllCall("gdiplus\GdipCreatePen1", "UInt", new_colour, "float", Width, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
	}	
Fill_Box(pGraphics,pBrush,x,y,w,h)	{
		Ptr := A_PtrSize ? "UPtr" : "UInt"
		return DllCall("gdiplus\GdipFillRectangle", Ptr, pGraphics, Ptr, pBrush, "float", x, "float", y, "float", w, "float", h)
}
Draw_Box(pGraphics, pPen, x, y, w, h){
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	return DllCall("gdiplus\GdipDrawRectangle", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h)
}	
UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255){
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	if ((x != "") && (y != ""))
		VarSetCapacity(pt, 8), NumPut(x, pt, 0, "UInt"), NumPut(y, pt, 4, "UInt")
	if (w = "") ||(h = "")
		WinGetPos,,, w, h, ahk_id %hwnd%
	return DllCall("UpdateLayeredWindow", Ptr, hwnd, Ptr, 0, Ptr, ((x = "") && (y = "")) ? 0 : &pt, "int64*", w|h<<32, Ptr, hdc, "int64*", 0, "uint", 0, "UInt*", Alpha<<16|1<<24, "uint", 2)
}
Gdip_DrawImage(pGraphics, pBitmap, dx="", dy="", dw="", dh="", sx="", sy="", sw="", sh="", Matrix=1){
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	if (Matrix&1 = "")
		ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
	else if (Matrix != 1)
		ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1")
	if (sx = "" && sy = "" && sw = "" && sh = ""){
		if (dx = "" && dy = "" && dw = "" && dh = ""){
			sx := dx := 0, sy := dy := 0
			sw := dw := Gdip_GetImageWidth(pBitmap)
			sh := dh := Gdip_GetImageHeight(pBitmap)
		}else	{
			sx := sy := 0
			sw := Gdip_GetImageWidth(pBitmap),sh := Gdip_GetImageHeight(pBitmap)
		}
	}

	E := DllCall("gdiplus\GdipDrawImageRectRect", Ptr, pGraphics, Ptr, pBitmap, "float", dx, "float", dy, "float", dw, "float", dh, "float", sx, "float", sy, "float", sw, "float", sh, "int", 2, Ptr, ImageAttr, Ptr, 0, Ptr, 0)
	if ImageAttr
		Gdip_DisposeImageAttributes(ImageAttr)
	return E
}
Gdip_CreateLineBrushFromRect(x, y, w, h, ARGB1, ARGB2, LinearGradientMode=1, WrapMode=1){
	CreateRectF(RectF, x, y, w, h)
	DllCall("gdiplus\GdipCreateLineBrushFromRect", A_PtrSize ? "UPtr" : "UInt", &RectF, "int", ARGB1, "int", ARGB2, "int", LinearGradientMode, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
	return LGpBrush
}
Gdip_FillPolygon(pGraphics, pBrush, Points, FillMode=0){
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	StringSplit, Points, Points, |
	VarSetCapacity(PointF, 8*Points0)   
	Loop, %Points0%
	{
		StringSplit, Coord, Points%A_Index%, `,
		NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
	}   
	return DllCall("gdiplus\GdipFillPolygon", Ptr, pGraphics, Ptr, pBrush, Ptr, &PointF, "int", Points0, "int", FillMode)
}
Gdip_DrawLines(pGraphics, pPen, Points){
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	StringSplit, Points, Points, |
	VarSetCapacity(PointF, 8*Points0)   
	Loop, %Points0%
	{
		StringSplit, Coord, Points%A_Index%, `,
		NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
	}
	return DllCall("gdiplus\GdipDrawLines", Ptr, pGraphics, Ptr, pPen, Ptr, &PointF, "int", Points0)
}
Gdip_TextToGraphics(pGraphics, Text, Options, Font="Arial", Width="", Height="", Measure=0){
	IWidth := Width, IHeight:= Height
	RegExMatch(Options, "i)X([\-\d\.]+)(p*)", xpos),RegExMatch(Options, "i)Y([\-\d\.]+)(p*)", ypos),RegExMatch(Options, "i)W([\-\d\.]+)(p*)", Width),RegExMatch(Options, "i)H([\-\d\.]+)(p*)", Height)
	RegExMatch(Options, "i)C(?!(entre|enter))([a-f\d]+)", Colour),RegExMatch(Options, "i)Top|Up|Bottom|Down|vCentre|vCenter", vPos),RegExMatch(Options, "i)NoWrap", NoWrap)
	RegExMatch(Options, "i)R(\d)", Rendering),RegExMatch(Options, "i)S(\d+)(p*)", Size)
	if !Gdip_DeleteBrush(Gdip_CloneBrush(Colour2))
		PassBrush := 1, pBrush := Colour2
	if !(IWidth && IHeight) && (xpos2 || ypos2 || Width2 || Height2 || Size2)
		return -1
	Style := 0, Styles := "Regular|Bold|Italic|BoldItalic|Underline|Strikeout"
	Loop, Parse, Styles, |
	{
		if RegExMatch(Options, "\b" A_loopField)
		Style |= (A_LoopField != "StrikeOut") ? (A_Index-1) : 8
	}
	Align := 0, Alignments := "Near|Left|Centre|Center|Far|Right"
	Loop, Parse, Alignments, |
	{
		if RegExMatch(Options, "\b" A_loopField)
			Align |= A_Index//2.1      ; 0|0|1|1|2|2
	}
	xpos := (xpos1 != "") ? xpos2 ? IWidth*(xpos1/100) : xpos1 : 0
	ypos := (ypos1 != "") ? ypos2 ? IHeight*(ypos1/100) : ypos1 : 0
	Width := Width1 ? Width2 ? IWidth*(Width1/100) : Width1 : IWidth
	Height := Height1 ? Height2 ? IHeight*(Height1/100) : Height1 : IHeight
	if !PassBrush
		Colour := "0x" (Colour2 ? Colour2 : "ff000000")
	Rendering := ((Rendering1 >= 0) && (Rendering1 <= 5)) ? Rendering1 : 4
	Size := (Size1 > 0) ? Size2 ? IHeight*(Size1/100) : Size1 : 12
	hFamily := Gdip_FontFamilyCreate(Font)
	hFont := Gdip_FontCreate(hFamily, Size, Style)
	FormatStyle := NoWrap ? 0x4000 | 0x1000 : 0x4000
	hFormat := Gdip_StringFormatCreate(FormatStyle)
	pBrush := PassBrush ? pBrush : Gdip_BrushCreateSolid(Colour)
	if !(hFamily && hFont && hFormat && pBrush && pGraphics)
		return !pGraphics ? -2 : !hFamily ? -3 : !hFont ? -4 : !hFormat ? -5 : !pBrush ? -6 : 0
	CreateRectF(RC, xpos, ypos, Width, Height),Gdip_SetStringFormatAlign(hFormat, Align),Gdip_SetTextRenderingHint(pGraphics, Rendering)
	ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC)
	if vPos
	{
		StringSplit, ReturnRC, ReturnRC, |
		if (vPos = "vCentre") || (vPos = "vCenter")
			ypos += (Height-ReturnRC4)//2
		else if (vPos = "Top") || (vPos = "Up")
			ypos := 0
		else if (vPos = "Bottom") || (vPos = "Down")
			ypos := Height-ReturnRC4
		CreateRectF(RC, xpos, ypos, Width, ReturnRC4),ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC)
	}
	if !Measure
		E := Gdip_DrawString(pGraphics, Text, hFont, hFormat, pBrush, RC)
	if !PassBrush
		Gdip_DeleteBrush(pBrush)
	Gdip_DeleteStringFormat(hFormat),Gdip_DeleteFont(hFont),Gdip_DeleteFontFamily(hFamily)
	return E ? E : ReturnRC
}
CreateDIBSection(w, h, hdc="", bpp=32, ByRef ppvBits=0){
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	hdc2 := hdc ? hdc : GetDC()
	VarSetCapacity(bi, 40, 0)
	NumPut(w, bi, 4, "uint"), NumPut(h, bi, 8, "uint"), NumPut(40, bi, 0, "uint"), NumPut(1, bi, 12, "ushort"), NumPut(0, bi, 16, "uInt"), NumPut(bpp, bi, 14, "ushort")
	hbm := DllCall("CreateDIBSection", Ptr, hdc2, Ptr, &bi, "uint", 0, A_PtrSize ? "UPtr*" : "uint*", ppvBits, Ptr, 0, "uint", 0, Ptr)
	if !hdc
		ReleaseDC(hdc2)
	return hbm
}
CreateCompatibleDC(hdc=0){
   return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
}
SelectObject(hdc, hgdiobj){
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
}
Gdip_GraphicsFromHDC(hdc){
    DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
    return pGraphics
}
Gdip_SetSmoothingMode(pGraphics, SmoothingMode){
   return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
}
DeleteObject(hObject){
   return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject)
}
Gdip_CreateBitmap(Width, Height, Format=0x26200A){
    DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", 0, "int", Format, A_PtrSize ? "UPtr" : "UInt", 0, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
    Return pBitmap
}
Gdip_GraphicsFromImage(pBitmap){
	DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
	return pGraphics
}
Gdip_DeleteGraphics(pGraphics){
   return DllCall("gdiplus\GdipDeleteGraphics", A_PtrSize ? "UPtr" : "UInt", pGraphics)
}
Gdip_Startup(){
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	if !DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
		DllCall("LoadLibrary", "str", "gdiplus")
	VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
	DllCall("gdiplus\GdiplusStartup", A_PtrSize ? "UPtr*" : "uint*", pToken, Ptr, &si, Ptr, 0)
	return pToken
}
Gdip_Shutdown(pToken){
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	DllCall("gdiplus\GdiplusShutdown", Ptr, pToken)
	if hModule := DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
		DllCall("FreeLibrary", Ptr, hModule)
	return 0
}
DeleteDC(hdc){
   return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc)
}
Gdip_SetImageAttributesColorMatrix(Matrix){
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	VarSetCapacity(ColourMatrix, 100, 0)
	Matrix := RegExReplace(RegExReplace(Matrix, "^[^\d-\.]+([\d\.])", "$1", "", 1), "[^\d-\.]+", "|")
	StringSplit, Matrix, Matrix, |
	Loop, 25	{
		Matrix := (Matrix%A_Index% != "") ? Matrix%A_Index% : Mod(A_Index-1, 6) ? 0 : 1
		NumPut(Matrix, ColourMatrix, (A_Index-1)*4, "float")
	}
	DllCall("gdiplus\GdipCreateImageAttributes", A_PtrSize ? "UPtr*" : "uint*", ImageAttr),DllCall("gdiplus\GdipSetImageAttributesColorMatrix", Ptr, ImageAttr, "int", 1, "int", 1, Ptr, &ColourMatrix, Ptr, 0, "int", 0)
	return ImageAttr
}
Gdip_GetImageWidth(pBitmap){
   DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width)
   return Width
}
Gdip_GetImageHeight(pBitmap){
   DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height)
   return Height
}
Gdip_DisposeImageAttributes(ImageAttr){
	return DllCall("gdiplus\GdipDisposeImageAttributes", A_PtrSize ? "UPtr" : "UInt", ImageAttr)
}
CreateRectF(ByRef RectF, x, y, w, h){
   VarSetCapacity(RectF, 16)
   NumPut(x, RectF, 0, "float"), NumPut(y, RectF, 4, "float"), NumPut(w, RectF, 8, "float"), NumPut(h, RectF, 12, "float")
}
Gdip_DeleteBrush(pBrush){
   return DllCall("gdiplus\GdipDeleteBrush", A_PtrSize ? "UPtr" : "UInt", pBrush)
}
Gdip_CloneBrush(pBrush){
	DllCall("gdiplus\GdipCloneBrush", A_PtrSize ? "UPtr" : "UInt", pBrush, A_PtrSize ? "UPtr*" : "UInt*", pBrushClone)
	return pBrushClone
}
Gdip_FontCreate(hFamily, Size, Style=0){
   DllCall("gdiplus\GdipCreateFont", A_PtrSize ? "UPtr" : "UInt", hFamily, "float", Size, "int", Style, "int", 0, A_PtrSize ? "UPtr*" : "UInt*", hFont)
   return hFont
}
Gdip_FontFamilyCreate(Font){
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	if (!A_IsUnicode){
		nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &Font, "int", -1, "uint", 0, "int", 0)
		VarSetCapacity(wFont, nSize*2)
		DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &Font, "int", -1, Ptr, &wFont, "int", nSize)
	}
	DllCall("gdiplus\GdipCreateFontFamilyFromName", Ptr, A_IsUnicode ? &Font : &wFont, "uint", 0, A_PtrSize ? "UPtr*" : "UInt*", hFamily)
	return hFamily
}
Gdip_StringFormatCreate(Format=0, Lang=0){
   DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat)
   return hFormat
}
Gdip_BrushCreateSolid(ARGB=0xff000000){
	DllCall("gdiplus\GdipCreateSolidFill", "UInt", ARGB, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
	return pBrush
}
Gdip_SetStringFormatAlign(hFormat, Align){
   return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align)
}
Gdip_SetTextRenderingHint(pGraphics, RenderingHint){
	return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint)
}
Gdip_MeasureString(pGraphics, sString, hFont, hFormat, ByRef RectF){
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	VarSetCapacity(RC, 16)
	if !A_IsUnicode
	{
		nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, "uint", 0, "int", 0)
		VarSetCapacity(wString, nSize*2)   
		DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, &wString, "int", nSize)
	}
	DllCall("gdiplus\GdipMeasureString", Ptr, pGraphics, Ptr, A_IsUnicode ? &sString : &wString, "int", -1, Ptr, hFont, Ptr, &RectF, Ptr, hFormat, Ptr, &RC, "uint*", Chars, "uint*", Lines)
	return &RC ? NumGet(RC, 0, "float") "|" NumGet(RC, 4, "float") "|" NumGet(RC, 8, "float") "|" NumGet(RC, 12, "float") "|" Chars "|" Lines : 0
}
Gdip_DrawString(pGraphics, sString, hFont, hFormat, pBrush, ByRef RectF)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	if (!A_IsUnicode)
	{
		nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, 0, "int", 0)
		VarSetCapacity(wString, nSize*2)
		DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, &wString, "int", nSize)
	}
	return DllCall("gdiplus\GdipDrawString", Ptr, pGraphics, Ptr, A_IsUnicode ? &sString : &wString, "int", -1, Ptr, hFont, Ptr, &RectF, Ptr, hFormat, Ptr, pBrush)
}
Gdip_DeleteStringFormat(hFormat){
   return DllCall("gdiplus\GdipDeleteStringFormat", A_PtrSize ? "UPtr" : "UInt", hFormat)
}
Gdip_DeleteFont(hFont){
   return DllCall("gdiplus\GdipDeleteFont", A_PtrSize ? "UPtr" : "UInt", hFont)
}
Gdip_DeleteFontFamily(hFamily){
   return DllCall("gdiplus\GdipDeleteFontFamily", A_PtrSize ? "UPtr" : "UInt", hFamily)
}
GetDC(hwnd=0){
	return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
}
ReleaseDC(hdc, hwnd=0){
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
}


Here is what it should look like.
SnapShot_550.png
msgbox
SnapShot_550.png (32.21 KiB) Viewed 622 times
Thanks.
gregster
Posts: 2393
Joined: 30 Sep 2013, 06:48

Re: Custom Msgbox

16 Feb 2019, 09:00

Very nice, looks good on Win10, resolution 1920*1080.
The crawling text is readable, doesn't run super-smooth and flickers a little bit, but reasonably smooth and like I have it seen before using Gdip.
I am not sure if it can get much better in this slow speed with Gdip.
Hellbent
Posts: 503
Joined: 23 Sep 2017, 13:34

Re: Custom Msgbox

16 Feb 2019, 09:25

gregster wrote:
16 Feb 2019, 09:00
Very nice, looks good on Win10, resolution 1920*1080.
The crawling text is readable, doesn't run super-smooth and flickers a little bit, but reasonably smooth and like I have it seen before using Gdip.
I am not sure if it can get much better in this slow speed with Gdip.
Thanks for running it for me.

I can probably improve it a bit by using a second child window for the text, but then that would mean only windows 8+ could run it.
Unless you know how to add a second layer of graphics to the same window? I could swear that when I was first playing around with gdip last year that I had stumbled across a way, but I was editing the code, just playing around with some things so I lost it, if I had found it to begin with.
AHKStudent
Posts: 462
Joined: 05 May 2018, 12:23

Re: Custom Msgbox

16 Feb 2019, 10:54

Windows 10 1920 x 1080 runs smooth no flicker and the edges are sharp
Hellbent
Posts: 503
Joined: 23 Sep 2017, 13:34

Re: Custom Msgbox

16 Feb 2019, 13:18

AHKStudent wrote:
16 Feb 2019, 10:54
Thank you.
DRocks
Posts: 441
Joined: 08 May 2018, 10:20

Re: Custom Msgbox

16 Feb 2019, 13:51

this is f-n nice Hellbent!! Really awesome.
Thanks for showing it here too!

Forgot: Win10 1920x1080 perfectly sharp, it does have almost not noticeable flicker on crawling text but nothing to disturb me
Hellbent
Posts: 503
Joined: 23 Sep 2017, 13:34

Re: Custom Msgbox

16 Feb 2019, 14:25

Thanks D.

DRocks wrote:
16 Feb 2019, 13:51
it does have almost not noticeable flicker on crawling text but nothing to disturb me
I would call it more of a stutter then a flicker. I reduced the increment to 1px per frame (found on line 158 x-=1 )and it seems to have improved it a bit (really have to look at the text to notice it).

Thanks again.
burque505
Posts: 957
Joined: 22 Jan 2017, 19:37

Re: Custom Msgbox

16 Feb 2019, 14:30

@Hellbent, no flicker at all for me on Win7 64-bit, AHK_L 1.1.30.01. Here's a 15fps GIF, even looks good at that speed. Looks MUCH better on my screen. Thanks!
HB-MsgBox.gif
HB-MsgBox.gif (143.61 KiB) Viewed 546 times
Hellbent
Posts: 503
Joined: 23 Sep 2017, 13:34

Re: Custom Msgbox

16 Feb 2019, 14:47

Thank you burque.
burque505 wrote:
16 Feb 2019, 14:30
no flicker at all for me
Yeah, flicker isn't the best way to describe it. slightly "jerky" or a slight "stutter" is probably a better description, but I get the point of the flicker comments so so they are equal more or less.
I was thinking about adding the text to a second window on top, but I don't really thing that will do anything because I am 99.9% sure that it is already running at max fps.
I might try changing the anti-alising, because the stutter could just be a optical illusion due to vision pertinence (talking out of my arse here lol).

Again, thanks for running the test for me.
DRocks
Posts: 441
Joined: 08 May 2018, 10:20

Re: Custom Msgbox

16 Feb 2019, 19:01

Yes I agree stutter is better word.
Man also whats super nice isbthat your class makes it very easy to customize.

I just dont understand your super custom box shape :D
hunter99
Posts: 118
Joined: 20 Jan 2014, 17:57

Re: Custom Msgbox

16 Feb 2019, 20:25

Perfect here, no stutter, crawling text smooth as silk. Nice job.

• Intel Core i7-4790 Processor 3.6GHz up to 4.0GHz Turbo Frequency, 8MB Cache , 16GB DDR3 (8GBx2 1600MHz), 2TB 7200 rpm Hard Drive
• Intel HD Graphics, Tray load DVD Drive (Reads and Writes to DVD/CD), 2 USB 3.0, 4 USB 2.0, HDMI
• DW 1705 802.11bgn + Bluetooth 4.0, 2.4 GHz, 1x1, Integrated 5.1 Audio, Inspiron 3847 Chassiss, MT, Black w/8:1 media card reader, Dell KB113 Wired Keyboard, Dell MS111 USB 3-Button Optical Mouse
• Windows 7 Professional, 64Bit, English.
hunter99
Hellbent
Posts: 503
Joined: 23 Sep 2017, 13:34

Re: Custom Msgbox

17 Feb 2019, 04:15

hunter99 wrote:
16 Feb 2019, 20:25
Thank you hunter.
DRocks wrote:
16 Feb 2019, 19:01
I just dont understand your super custom box shape :D
The shape and much of the design is not mine, it is someone else's window background that I used to do this test with. I just took the design and transferred it to gdip and added the controls etc.
Once I have a good sample of systems and resolutions i'll work on my own design (likely similar, but probably more symmetrical) in paint and then use the next evolution of the technique I came up with to transfer it into something that can be used with gdip (the commented gui at the top and the commented hotkey).


If you're referring to how the gui was rendered as any shape other than a rectangle, then that has to do with the gui option/style w/e +E0x80000.
It creates a transparent window (what is described as a layered window, not really clear on all it's properties, but know enough to use it for some applications) and only what is drawn using gdip gets displayed but the window itself is still a rectangle, as seen when the window is moved (you can move the window by dragging the window at the top) assuming that your windows settings show a outline of a window you are moving.

Normal gui controls don't get drawn, but can still be added and triggered (there might be a way to actually draw normal controls, but atm I'm not aware of how to go about doing it), so I normally use a normal gui text control as a trigger for buttons etc, and even gui edit controls, though there isn't the normal feedback you expect from a edit control (such as highlighting text when you drag your cursor over the text).
This script has examples of what i'm talking about, and was my first time playing around with the concept, which I think isn't too bad for a first attempt at what from my perspective is something I invented. (I'm not trying to say that I invented it, just that the process / concepts were derived by me independent of any outside influence or per-established methods, it works the way I want, but could be missing some "Best Practices" etc but w/e)

Everything in this gui is triggered by text controls except for the one edit that can take user input. You can highlight the contents of the edit, but you can't see it.

Code: Select all

/*
	Written By: Hellbent aka CivReborn (Youtube)
	Date Started: June 27th, 2018
	Date Of Last Edit: July 3rd, 2018
	Matrix Clicker v1.1
	Paste: https://pastebin.com/yCTyiXYx
*/
#SingleInstance,Force
SetBatchLines,-1
CoordMode,Mouse,Screen
SetMouseDelay,30ms
OnExit,GuiClose
global Win:={W:400,H:250},Brush:=[],Pen:=[],Button1:={},Win2:={},Win3:={},Win4:={},Checks:={},Radio1:={}
global BC:=["Black","White","Yellow","Lime","Maroon","Aqua","Purple","0077ff","000211"],IsOn,pButton:={},String:={},letter_Array:=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0","!","@","#","$","%","^","&","*","(",")","-","_","=","+","~","<",",",".","?",":",";",">","|","\"," "],colours:=["ff00ff00","ff036F19","ff086714","ff24D95B","ff0D8422","ff00bb00","ff00aa00","ff11ff11","ff22ff22","ff33aa33","ff33dd33"]
global MovWin:=0,Always:=1,Free_Mode:=0,No_Count:=1,GUI_Count:=0,ToolTip_Count:=0,Target_X,Target_Y,tgui,num:="",HovOn:=0,Click_Count:=0,Click_Forever:=1,Fixed_Amount:=0,Fixed_Click_Amount:=0,SPSLD,Speed:=10
global Delay:=1000/speed,Startkey:="numpad1",StopKey:="Numpad2",PauseKey:="Numpad3",PauseOn:=0,Stop:=1
Hotkey,%StartKey%,SCLer
Hotkey,%StopKey%,STCLer
Hotkey,%PauseKey%,PCLer
CGUI()
OnMessage(0x200,"Whv")
OnMessage(0x07,"Show_Win")
CGUI2(),CGUI3(),CGUI4(),DBG(),ACB(),ACH(),ARB(),SetSPos(),AddTag(),CL_CoU(),SetUp()
SetTimer,M_Loop,10
return
GuiClose:
	Loop,% Brush.Length()
		Gdip_DeleteBrush(Brush[A_Index])
		Gdip_DeletePen(Pen[A_Index])
	Loop,% Button.Length()
		Gdip_DisposeImage(Button1[A_Index].Bitmap)
	Loop,% Checks.Length()
		Gdip_DisposeImage(Checks[A_Index].Bitmap)
	Layered_Window_ShutDown(Win),Layered_Window_ShutDown(Win2),Layered_Window_ShutDown(Win3),Layered_Window_ShutDown(Win4)
	ExitApp
HotkeysGuiClose:
	Gui,Hotkeys:Destroy
	return
M_Loop:
	Critical
	Draw_Inner()
	Loop,% String.Length()
		String[A_Index].Update()
	UpdateLayeredWindow(Win2.hwnd, Win2.hdc, Win2.X, Win2.Y, Win2.W, Win2.H)
	return
Start:
	Button1[Num].Draw_Pressed()
	if(Free_Mode=1){
		MsgShow(1)
		return
	}
	gosub,SCLer
	return
MTAG:
	Try{
		Run,https://www.youtube.com/user/CivReborn
	}
	return		
Stop:	
	Button1[Num].Draw_Pressed()
	Stop:=1
	PauseOn:=0
	SetTimer,M_Loop,on
	return
Reload:	
	Button1[Num].Draw_Pressed()
	Reload
	return
Hotkeys:	
	Button1[Num].Draw_Pressed()
	Gui,Hotkeys:Destroy
	Gui,Hotkeys:+Owner1 +ToolWindow -Caption -DPIScale
	Gui,Hotkeys:Color,002200,00ff00
	Gui,Hotkeys:Font,cLime s10 Bold Q5,Microsoft YaHei UI
	Gui,Hotkeys:Add,Text,cLime x10 y10 w50,Start:
	Gui,Hotkeys:Add,Hotkey,x+10  w120 vStartKey,%StartKey%
	Gui,Hotkeys:Add,Button,x+10 w90 h25 -Theme gUDSTRK,Update
	Gui,Hotkeys:Add,Text,cLime x10 y+15 w50,Stop:
	Gui,Hotkeys:Add,Hotkey,x+10  w120 vStopKey,% StopKey
	Gui,Hotkeys:Add,Button,x+10 w90 h25 -Theme gUDSTPK,Update
	Gui,Hotkeys:Add,Text,cLime x10 y+15 w50 ,Pause:
	Gui,Hotkeys:Add,Hotkey,x+10  w120 vPauseKey,% PauseKey
	Gui,Hotkeys:Add,Button,x+10 w90 h25 -Theme gUDPK,Update
	Gui,Hotkeys:Add,Button,x30 y140 w240 h30 -Theme gHotkeysGuiClose,Done
	Add_Border_Trim("Hotkeys",0,0,300,180,"00aa00",2)
	Gui,Hotkeys:Show,w300 h180
	return
UDSTRK:
	GuiControlGet,newkey,,StartKey
	if(newkey!=Startkey&&newkey!=null){
		Hotkey,%StartKey%,SCLer,Off
		StartKey:=NewKey
		Hotkey,%StartKey%,SCLer,On
	}
	return	
Add_Border_Trim(Window,x,y,w,h,Color,Thickness:=1){
	y2:=y+h-Thickness,x2:=x+w-Thickness
	Gui,%Window%:Add,Progress,x%x% y%y% w%w% h%Thickness% Background%color%
	Gui,%Window%:Add,Progress,x%x% y%y% w%Thickness% h%h% Background%color%
	Gui,%Window%:Add,Progress,x%x% y%y2% w%w% h%Thickness% Background%color%
	Gui,%Window%:Add,Progress,x%x2% y%y% w%Thickness% h%h% Background%color%
}	
AddTag(){
	if(Stop=1){
		DeleteObject(pbit),pbit:=Gdip_CreateBitmap(20,20),g:=Gdip_GraphicsFromImage(pbit),Gdip_SetSmoothingMode(g,1)
		b1:=New_Brush("00aa00"),Fill_Box(g,b1,0,0,20,20),Gdip_DeleteBrush(b1),b1:=New_Brush("002200"),Fill_Box(g,b1,1,1,18,18)
		Gdip_DeleteBrush(b1),b1:=Gdip_CreateLineBrushFromRect(2, 2,16,16,"0x33ffffff", "0xff000000"),Fill_Box(g,b1,2,2,16,16)
		Gdip_DeleteBrush(b1),Gdip_TextToGraphics(g,"HB","y-1 s10 r5 cff00aa00 Bold vCenter Center","Microsoft YaHei UI",20,20)
		Gdip_DrawImage(Win.G,pbit,15,6,20,20),UpdateLayeredWindow(Win.hwnd, Win.hdc),Gdip_DeleteGraphics(g)
	}else if(Stop=0&&PauseOn=1){
		DeleteObject(pbit),pbit:=Gdip_CreateBitmap(20,20),g:=Gdip_GraphicsFromImage(pbit),Gdip_SetSmoothingMode(g,1),b1:=New_Brush("bb7700")
		Fill_Box(g,b1,0,0,20,20),Gdip_DeleteBrush(b1),b1:=New_Brush("002200"),Fill_Box(g,b1,1,1,18,18),Gdip_DeleteBrush(b1)
		b1:=Gdip_CreateLineBrushFromRect(2, 2,16,16,"0x33ffffff", "0xff000000"),Fill_Box(g,b1,2,2,16,16),Gdip_DeleteBrush(b1)
		Gdip_TextToGraphics(g,"HB","y-1 s10 r5 cff995500 Bold vCenter Center","Microsoft YaHei UI",20,20)
		Gdip_DrawImage(Win.G,pbit,15,6,20,20),UpdateLayeredWindow(Win.hwnd, Win.hdc),Gdip_DeleteGraphics(g)
	}else if(Stop=0&&PauseOn=0){
		DeleteObject(pbit),pbit:=Gdip_CreateBitmap(20,20),g:=Gdip_GraphicsFromImage(pbit),Gdip_SetSmoothingMode(g,1)
		b1:=New_Brush("ff0000"),Fill_Box(g,b1,0,0,20,20),Gdip_DeleteBrush(b1),b1:=New_Brush("002200"),Fill_Box(g,b1,1,1,18,18),Gdip_DeleteBrush(b1)
		b1:=Gdip_CreateLineBrushFromRect(2, 2,16,16,"0x33ffffff", "0xff000000"),Fill_Box(g,b1,2,2,16,16),Gdip_DeleteBrush(b1)
		Gdip_TextToGraphics(g,"HB","y-1 s10 r5 cffff0000 Bold vCenter Center","Microsoft YaHei UI",20,20)
		Gdip_DrawImage(Win.G,pbit,15,6,20,20),UpdateLayeredWindow(Win.hwnd, Win.hdc),Gdip_DeleteGraphics(g)
	}
}
SCLer:
	if(Free_mode=0&&Target_X=null){
		MsgShow(2)
		return
	}
	SetTimer,M_Loop,off
	Stop:=0,PauseOn:=0
	(Speed=20)?(Offset:=21):(Speed=19)?(Offset:=23):(Speed=18)?(Offset:=25):(Speed=17)?(Offset:=27):(Speed=16)?(Offset:=29):(Speed=15)?(Offset:=30):(Speed=14)?(Offset:=32)
	:(Speed=13)?(Offset:=35):(Speed=12)?(Offset:=37):(Speed=11)?(Offset:=39):(Speed=10)?(Offset:=41):(Speed=9)?(Offset:=43):(Speed=8)?(Offset:=50):(Speed=7)?(Offset:=58)
	:(Speed=6)?(Offset:=70):(Speed=5)?(Offset:=82):(Speed=4)?(Offset:=94):(Speed=3)?(Offset:=126):(Speed=2)?(Offset:=158):(Speed=1)?(Offset:=350)
	tca:=Fixed_Click_Amount,Start_Time:=A_TickCount
	if(Fixed_Amount=1)
		Click_Count:=0
	AddTag()
	
	DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)
	While(Stop=0){
		if(PauseOn!=1){
			DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
			if(((CounterAfter - CounterBefore)/1000)>Delay+Offset){
				DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)
				if(Free_Mode=1)
					Click,
				else if(Free_Mode=0)
					Click,%Target_X%,%Target_Y%
				if(GUI_Count=1){
					Click_Count++
					CL_CoU()
				}
				else if(Tooltip_Count=1)
					Tooltip,% ++Click_Count
				if(Fixed_Amount=1){
					if(--tca<=0)
						Stop:=1
				}	
			}
		}
	}
	Tooltip,
	PauseOn:=0
	AddTag()
	SetTimer,M_Loop,on
	return
UDSTPK:
	GuiControlGet,newkey,,StopKey
	if(newkey!=Stopkey&&newkey!=null){
			Hotkey,%StopKey%,STCLer,Off
			StopKey:=NewKey
			Hotkey,%StopKey%,STCLer,On
	}
	return
STCLer:
	Stop:=1
	SetTimer,M_Loop,on
	return
UDPK:
	GuiControlGet,newkey,,PauseKey
	if(newkey!=PauseKey&&newkey!=null){
		Hotkey,%PauseKey%,PCLer,Off
		PauseKey:=NewKey
		Hotkey,%PauseKey%,PCLer,On
	}
	return
PCLer:
	if(Stop=0){
		PauseOn:=!PauseOn
		if(PauseOn){
			SetTimer,M_Loop,on
			AddTag()
		}
		else	{
			SetTimer,M_Loop,off
			AddTag()
		}
	}
	return
Reset_Count:
	Button1[Num].Draw_Pressed()
	Click_Count:=0
	CL_CoU()
	return
Set_Position:
	Button1[Num].Draw_Pressed()
	Set_CP(Target_X,Target_Y)
	SetSPos()
	return
ADJSLD:
	CoordMode,Mouse,Client
	SetTimer,M_Loop,Off
	slider1.UpDate()
	SetTimer,M_Loop,on
	CoordMode,Mouse,Screen
	return
Counter:
	Loop,3	{
		if(Radio1[A_Index].Name=A_GuiControl){
			Radio1[A_Index].Draw_One()
			Radio1[A_Index].State:=1
		}else	{
			Radio1[A_Index].Draw_Zero()
			Radio1[A_Index].State:=0
		}
	}
	(A_GuiControl="No_Count")?(No_Count:=1,GUI_Count:=0,ToolTip_Count:=0):(A_GuiControl="GUI_Count")?(No_Count:=0,GUI_Count:=1,ToolTip_Count:=0):(A_GuiControl="ToolTip_Count")?(No_Count:=0,GUI_Count:=0,ToolTip_Count:=1)
	return
Duration:
	Loop,2	{
		if(Radio1[A_Index+3].Name=A_GuiControl){
			Radio1[A_Index+3].Draw_One()
			Radio1[A_Index+3].State:=1
		}else	{
			Radio1[A_Index+3].Draw_Zero()
			Radio1[A_Index+3].State:=0
		}
	}
	(A_GuiControl="Click_Forever")?(Click_Forever:=1,Fixed_Amount:=0):(A_GuiControl="Fixed_Amount")?(Click_Forever:=0,Fixed_Amount:=1)
	return
SubSl:
	Slider1.Subtract()
	return	
AddSl:
	slider1.Add()
	return
ARB(){
	Radio1[1]:=New Rad1(15,30,110,20,1,"33ff33","114411","No Count",12,"ff000000","ff777777","No_Count",1,"Counter")
	Radio1[2]:=New Rad1(135,30,110,20,0,"33ff33","114411","GUI Count",12,"ff000000","ff777777","GUI_Count",1,"Counter")
	Radio1[3]:=New Rad1(255,30,110,20,0,"33ff33","114411","ToolTip Count",12,"ff000000","ff777777","ToolTip_Count",1,"Counter")
	Radio1[4]:=New Rad1(35,55,110,20,1,"33ff33","114411","Click Forever",12,"ff000000","ff777777","Click_Forever",2,"Duration")
	Radio1[5]:=New Rad1(155,55,110,20,0,"33ff33","114411","Fixed Amount",12,"ff000000","ff777777","Fixed_Amount",2,"Duration")
	Gui,3:Add,Text,x15 y30 w110 h20 vNo_Count gCounter
	Gui,3:Add,Text,x135 y30 w110 h20 vGUI_Count gCounter
	Gui,3:Add,Text,x255 y30 w110 h20 vToolTip_Count gCounter
	Gui,3:Add,Text,x35 y55 w110 h20 vClick_Forever gDuration
	Gui,3:Add,Text,x155 y55 w110 h20 vFixed_Amount gDuration
	Gui,3:Add,Edit,x275 y56 w60 h18 Number Limit7 vFixed_Click_Amount gSetCAMOUNT,% Fixed_Click_Amount
	Gui,1:Add,Text,x15 y6 w20 h20 gMTAG,
	SetCAMOUNT()	
}
CGUI4(){
	global
	Win4:=Layered_Window_SetUp(4,0,0,Win2.W,Win2.H,4,"+Parent2 -Caption -DPIScale +LastFound")
	UpdateLayeredWindow(Win4.hwnd, Win4.hdc, Win4.X, Win4.Y, Win4.W, Win4.H)
	slider1:=New Slide()
	Gui, 4:Add, Text, x15 y110 w250 h36 vSPSLD gADJSLD
	Gui, 4:Add, Text, x275 y113 w30 h30 vSubSl gSubSl
	Gui, 4:Add, Text, x325 y113 w30 h30 vAddSl gAddSl
}
class Slide	{
	__New(){
		This.LX:=10,This.LY:=Ly,This.LW:=300,This.LH:=5,This.BX:=110
		This.BY:=118,This.BW:=Bw,This.BH:=Bh,This.Bitmap:="",This.Draw_Bottom(),This.Draw_Top(),This.Display()
	}
	Draw_Bottom(){
		DeleteObject(This.Bitmap)
		This.Bitmap2:=Gdip_CreateBitmap(250,36)
		g:=Gdip_GraphicsFromImage(This.Bitmap2)
		Gdip_SetSmoothingMode(g,1),This.Brush:=New_Brush("00aa00")
		Fill_Box(g,This.Brush,0,0,250,36),Gdip_DeleteBrush(This.Brush)
		This.Brush:=New_Brush("002200"),Fill_Box(g,This.Brush,1,1,248,34),Gdip_DeleteBrush(This.Brush)
		This.Brush:=Gdip_CreateLineBrushFromRect(0, 0,250,36,"0x33ffffff", "0xff000000"),Fill_Box(g,This.Brush,2,2,246,32)
		Gdip_SetSmoothingMode(g,2),This.Brush:=New_Brush("00aa00"),Fill_Box(g,This.Brush,10,15,230,6),Gdip_DeleteBrush(This.Brush)
		This.Brush:=New_Brush("000000","ff"),Fill_Box(g,This.Brush,12,17,226,2),Gdip_DeleteBrush(This.Brush)
		Gdip_DrawImage(Win4.G, This.BitMap2,15,110,250,36),UpdateLayeredWindow(Win4.hwnd, Win4.hdc)
		Gdip_DeleteBrush(This.Brush),Gdip_DeleteGraphics(g)
	}
	Draw_Top(){
		DeleteObject(This.Bitmap),This.Bitmap:=Gdip_CreateBitmap(50,20),g:=Gdip_GraphicsFromImage(This.Bitmap)
		Gdip_SetSmoothingMode(g,2),This.Brush:=New_Brush("00aa00"),Fill_Box(g,This.Brush,0,0,50,20),Gdip_DeleteBrush(This.Brush)
		Gdip_SetSmoothingMode(g,1),This.Brush:=New_Brush("000000"),Fill_Box(g,This.Brush,1,1,48,18),Gdip_DeleteBrush(This.Brush)
		This.Brush:=New_Brush("002200"),Fill_Box(g,This.Brush,2,2,46,16),Gdip_DeleteBrush(This.Brush)
		This.Brush:=Gdip_CreateLineBrushFromRect(2, 2,46,16,"0x33ffffff", "0xff000000"),Fill_Box(g,This.Brush,2,2,46,16),xt:=8
		Loop 4	{
			Gdip_SetSmoothingMode(g,1),This.Brush:=New_Brush("00aa00"),Fill_Box(g,This.Brush,xt,4,3,12)
			Gdip_DeleteBrush(This.Brush),Gdip_SetSmoothingMode(g,2),This.Brush:=New_Brush("000000")
			Fill_Box(g,This.Brush,xt+1,5,1,10),Gdip_DeleteBrush(This.Brush),xt+=10
		}
				
		Gdip_DrawImage(Win4.G, This.BitMap,This.BX,This.BY,50,20),UpdateLayeredWindow(Win4.hwnd, Win4.hdc),Gdip_DeleteBrush(This.Brush),Gdip_DeleteGraphics(g)
	}
	UpDate(){
		While(GetKeyState("LButton")){
			MouseGetPos,slx,
			if(slx>62&&slx<236)
				This.BX:=slx-34
			else if(slx<62)
				This.BX:=62-34
			else if(slx>236)
				This.BX:=236-34	
			Gdip_GraphicsClear(Win4.G),Gdip_DrawImage(Win4.G, This.BitMap2,15,110,250,36)
			Gdip_DrawImage(Win4.G, This.BitMap,This.BX,This.BY,50,20),speed:= Floor(This.BX/9.1578)-2
			This.Display(),UpdateLayeredWindow(Win4.hwnd, Win4.hdc)
			ToolTip,% speed 			
		}
		ToolTip,
		Delay:=1000/Speed
	}
	Add(){
		if(Speed<20){
			Speed++
			This.BX:=Speed*9.1578+16
			if(Speed=20)
				This.Bx:=236-34
			Gdip_GraphicsClear(Win4.G),Gdip_DrawImage(Win4.G, This.BitMap2,15,110,250,36)
			Gdip_DrawImage(Win4.G, This.BitMap,This.BX,This.BY,50,20),This.Display(),UpdateLayeredWindow(Win4.hwnd, Win4.hdc)
		}
		Delay:=1000/Speed	
	}
	Subtract(){
		if(Speed>1){
			Speed--
			This.BX:=Speed*9.1578+16
			if(Speed=1)
				This.Bx:=62-34
			Gdip_GraphicsClear(Win4.G),Gdip_DrawImage(Win4.G, This.BitMap2,15,110,250,36)
			Gdip_DrawImage(Win4.G, This.BitMap,This.BX,This.BY,50,20),This.Display(),UpdateLayeredWindow(Win4.hwnd, Win4.hdc)
		}
		Delay:=1000/Speed	
	}	
	Display(){
		DeleteObject(This.Bitmap3),This.Bitmap3:=Gdip_CreateBitmap(90,30),g:=Gdip_GraphicsFromImage(This.Bitmap3)
		Gdip_SetSmoothingMode(g,1),This.Brush:=New_Brush("00aa00"),Fill_Box(g,This.Brush,0,0,90,30),Gdip_DeleteBrush(This.Brush)
		Gdip_SetSmoothingMode(g,1),This.Brush:=New_Brush("000000"),Fill_Box(g,This.Brush,1,1,88,28),Gdip_DeleteBrush(This.Brush)
		This.Brush:=New_Brush("002200"),Fill_Box(g,This.Brush,2,2,86,26),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush("00ff00")
		Fill_Box(g,This.Brush,30,4,1,22),Fill_Box(g,This.Brush,60,4,1,22),Gdip_DeleteBrush(This.Brush),This.Brush:=Gdip_CreateLineBrushFromRect(2, 2,86,26,"0x33ffffff", "0xff000000")
		Fill_Box(g,This.Brush,2,2,86,26),Gdip_TextToGraphics(g,Speed," s12 r5 cff00ff00 Bold vCenter Center","Microsoft YaHei UI",90,30)
		Gdip_TextToGraphics(g,"-             +"," s12 r5 cff00ff00 Bold vCenter Center","Microsoft YaHei UI",90,30),Gdip_DrawImage(Win4.G, This.BitMap3,275,113,90,30)
		UpdateLayeredWindow(Win4.hwnd, Win4.hdc),Gdip_DeleteBrush(This.Brush),Gdip_DeleteGraphics(g)
	}
}
class Butt	{
	__New(x,y,w,h,font_Size,Text_Colour,Text,Name,Hover_Text_Colour,Hover_BC_Colour,Win_Number,Pressed_BC_Colour:="",Pressed_Text_Colour:="",Underline_Flag:=0){
		This.X:=x,This.Y:=y,This.W:=w,This.H:=h,This.Font_Size:=font_Size,This.Colour:=Text_Colour,This.Hover_Text_Colour:=Hover_Text_Colour
		This.Pressed_Text_Colour:=Pressed_Text_Colour,This.Text:=Text,This.Name:=Name,This.Hover_BC_Colour:=Hover_BC_Colour
		This.Pressed_BC_Colour:=Pressed_BC_Colour,This.Window_Number:=Win_Number,This.UnderLine_Flag:=Underline_Flag,This.Draw_Norm()
	}
	Draw_Norm(){
		global
		DeleteObject(This.Bitmap),This.Bitmap:=Gdip_CreateBitmap(This.W,This.H),g:=Gdip_GraphicsFromImage(This.Bitmap),Gdip_SetSmoothingMode(g,1)
		This.Brush:=New_Brush("00aa00"),Fill_Box(g,This.Brush,0,0,This.W,This.H),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush("000000")
		Fill_Box(g,This.Brush,1,1,This.W-2,This.H-2),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush("002200"),Fill_Box(g,This.Brush,2,2,This.W-4,This.H-4)
		Gdip_DeleteBrush(This.Brush),Gdip_TextToGraphics(g,This.Text,"s" This.Font_Size " r5 c" This.Colour " Bold vCenter Center","Microsoft YaHei UI",This.W,This.H)
		This.Brush:=Gdip_CreateLineBrushFromRect(2, 2,This.W-4,This.H-4,"0x33ffffff", "0xff000000"),Fill_Box(g,This.Brush,0,0,This.W,This.H)
		if(This.Window_Number=1)
			Gdip_DrawImage(Win.G, This.BitMap,This.X,This.Y,This.W,This.H),UpdateLayeredWindow(Win.hwnd, Win.hdc) 
		else if(This.Window_Number=3)
			Gdip_DrawImage(Win3.G, This.BitMap,This.X,This.Y,This.W,This.H),UpdateLayeredWindow(Win3.hwnd, Win3.hdc)
		Gdip_DeleteGraphics(g)	
	}
	Draw_Hover(){
		global
		DeleteObject(This.Bitmap),This.Bitmap:=Gdip_CreateBitmap(This.W,This.H),g:=Gdip_GraphicsFromImage(This.Bitmap),Gdip_SetSmoothingMode(g,1)
		This.Brush:=New_Brush("00aa00"),Fill_Box(g,This.Brush,0,0,This.W,This.H),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush("333333")
		Fill_Box(g,This.Brush,1,1,This.W-2,This.H-2),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush(This.Hover_BC_Colour),Fill_Box(g,This.Brush,2,2,This.W-4,This.H-4)
		Gdip_DeleteBrush(This.Brush)
		If(This.UnderLine_Flag=1)
			Gdip_TextToGraphics(g,This.Text,"s" This.Font_Size " r5 c" This.Hover_Text_Colour " Bold Underline vCenter Center","Microsoft YaHei UI",This.W,This.H)
		else	
			Gdip_TextToGraphics(g,This.Text,"s" This.Font_Size " r5 c" This.Hover_Text_Colour " Bold vCenter Center","Microsoft YaHei UI",This.W,This.H)
		This.Brush:=Gdip_CreateLineBrushFromRect(2, 2,This.W-4,This.H-4,"0x11ffffff", "0xff000000"),Fill_Box(g,This.Brush,0,0,This.W,This.H)
		if(This.Window_Number=1)
			Gdip_DrawImage(Win.G, This.BitMap,This.X,This.Y,This.W,This.H),UpdateLayeredWindow(Win.hwnd, Win.hdc) 
		else if(This.Window_Number=3)
			Gdip_DrawImage(Win3.G, This.BitMap,This.X,This.Y,This.W,This.H),UpdateLayeredWindow(Win3.hwnd, Win3.hdc)
		Gdip_DeleteBrush(This.Brush),Gdip_DeleteGraphics(g)	
	}
	Draw_Pressed(){
		global
		DeleteObject(This.Bitmap),This.Bitmap:=Gdip_CreateBitmap(This.W,This.H),g:=Gdip_GraphicsFromImage(This.Bitmap),Gdip_SetSmoothingMode(g,1)
		This.Brush:=New_Brush("00aa00"),Fill_Box(g,This.Brush,0,0,This.W,This.H),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush("333333")
		Fill_Box(g,This.Brush,1,1,This.W-2,This.H-2),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush(This.Pressed_BC_Colour)
		Fill_Box(g,This.Brush,2,2,This.W-4,This.H-4),Gdip_DeleteBrush(This.Brush)
		If(This.UnderLine_Flag=1)
			Gdip_TextToGraphics(g,This.Text,"s" This.Font_Size " r5 c" This.Pressed_Text_Colour " Bold Underline vCenter Center","Microsoft YaHei UI",This.W,This.H)
		else	
			Gdip_TextToGraphics(g,This.Text,"s" This.Font_Size " r5 c" This.Pressed_Text_Colour " Bold vCenter Center","Microsoft YaHei UI",This.W,This.H)
		This.Brush:=Gdip_CreateLineBrushFromRect(2, 2,This.W-4,This.H-4,"0x11ffffff", "0xff000000"),Fill_Box(g,This.Brush,0,0,This.W,This.H)
		if(This.Window_Number=1)
			Gdip_DrawImage(Win.G, This.BitMap,This.X,This.Y,This.W,This.H),UpdateLayeredWindow(Win.hwnd, Win.hdc) 
		else if(This.Window_Number=3)
			Gdip_DrawImage(Win3.G, This.BitMap,This.X,This.Y,This.W,This.H),UpdateLayeredWindow(Win3.hwnd, Win3.hdc)
		Gdip_DeleteBrush(This.Brush),Gdip_DeleteGraphics(g)
		SetTimer,OT,Off
		MouseGetPos,,,,ctrl1,2
		While(GetKeyState("LButton"))
			sleep,-1
		MouseGetPos,,,,ctrl2,2
		if(ctrl1=ctrl2)
			This.Draw_Hover()
		SetTimer,OT,On	
	}
}
class Rad1	{
	__New(x,y,w,h,State,On_Colour,Off_Colour,Text,Font_Size,On_Font_Colour,Off_Font_Colour,Name,Group_Name,Label){
		This.X:=x,This.Y:=y,This.W:=w,This.H:=h,This.Name:=Name,This.Label:=Label,This.Group_Name:=Group_Name,This.Text:=Text
		This.On_Font_Colour:=On_Font_Colour,This.Off_Font_Colour:=Off_Font_Colour,This.Font_Size:=Font_Size,This.On_Colour:=On_Colour
		This.Off_Colour:=Off_Colour,This.State:=State,This.Bitmap:=""
		if(This.State=1)
			This.Draw_One()
		else
			This.Draw_Zero()
	}
	Draw_One(){
		DeleteObject(This.Bitmap),This.Bitmap:=Gdip_CreateBitmap(This.W,This.H),g:=Gdip_GraphicsFromImage(This.Bitmap),Gdip_SetSmoothingMode(g,1)
		This.Brush:=New_Brush("00aa00"),Fill_Box(g,This.Brush,0,0,This.W,This.H),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush("000000")
		Fill_Box(g,This.Brush,1,1,This.W-2,This.H-2),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush(This.On_Colour),Fill_Box(g,This.Brush,2,2,This.W-4,This.H-4)
		Gdip_DeleteBrush(This.Brush),This.Brush:=Gdip_CreateLineBrushFromRect(0, 0,This.W-4,This.H-4,"0x11ffffff", "0xdd000000")
		Fill_Box(g,This.Brush,0,0,This.W,This.H),Gdip_TextToGraphics(g,This.Text,"s" This.Font_Size " r5 c" This.On_Font_Colour " Bold vCenter Center","Microsoft YaHei UI",This.W,This.H)
		Gdip_DrawImage(Win3.G, This.BitMap,This.X,This.Y,This.W,This.H),UpdateLayeredWindow(Win3.hwnd, Win3.hdc),Gdip_DeleteBrush(This.Brush),Gdip_DeleteGraphics(g)
	}
	Draw_Zero(){
		DeleteObject(This.Bitmap),This.Bitmap:=Gdip_CreateBitmap(This.W,This.H),g:=Gdip_GraphicsFromImage(This.Bitmap),Gdip_SetSmoothingMode(g,1)
		This.Brush:=New_Brush("00aa00"),Fill_Box(g,This.Brush,0,0,This.W,This.H),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush("000000")
		Fill_Box(g,This.Brush,1,1,This.W-2,This.H-2),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush(This.Off_Colour),Fill_Box(g,This.Brush,2,2,This.W-4,This.H-4)
		Gdip_DeleteBrush(This.Brush),This.Brush:=Gdip_CreateLineBrushFromRect(0, 0,This.W-4,This.H-4,"0x11ffffff", "0xdd000000"),Fill_Box(g,This.Brush,0,0,This.W,This.H)
		Gdip_TextToGraphics(g,This.Text,"s" This.Font_Size " r5 c" This.Off_Font_Colour " Bold vCenter Center","Microsoft YaHei UI",This.W,This.H)
		Gdip_DrawImage(Win3.G, This.BitMap,This.X,This.Y,This.W,This.H),UpdateLayeredWindow(Win3.hwnd, Win3.hdc),Gdip_DeleteBrush(This.Brush),Gdip_DeleteGraphics(g)
	}
}
class Check1	{
	__New(x,y,w,h,State,On_Colour,Off_Colour,Text,Font_Size,On_Font_Colour,Off_Font_Colour,Name){
		This.X:=x,This.Y:=y,This.W:=w,This.H:=h,This.Name:=Name,This.Text:=Text,This.On_Font_Colour:=On_Font_Colour,This.Off_Font_Colour:=Off_Font_Colour
		This.Font_Size:=Font_Size,This.On_Colour:=On_Colour,This.Off_Colour:=Off_Colour,This.State:=State,This.Bitmap:=""
		if(This.State=1)
			This.Draw_One()
		else
			This.Draw_Zero()
	}
	Draw_One(){
		DeleteObject(This.Bitmap),This.Bitmap:=Gdip_CreateBitmap(This.W,This.H),g:=Gdip_GraphicsFromImage(This.Bitmap),Gdip_SetSmoothingMode(g,1)
		This.Brush:=New_Brush("00aa00"),Fill_Box(g,This.Brush,0,0,This.W,This.H),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush("000000")
		Fill_Box(g,This.Brush,1,1,This.W-2,This.H-2),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush(This.On_Colour),Fill_Box(g,This.Brush,2,2,This.W-4,This.H-4)
		Gdip_DeleteBrush(This.Brush),This.Brush:=Gdip_CreateLineBrushFromRect(0, 0,This.W-4,This.H-4,"0x11ffffff", "0xdd000000"),Fill_Box(g,This.Brush,0,0,This.W,This.H)
		Gdip_TextToGraphics(g,This.Text,"s" This.Font_Size " r5 c" This.On_Font_Colour " Bold vCenter Center","Microsoft YaHei UI",This.W,This.H)
		Gdip_DrawImage(Win3.G, This.BitMap,This.X,This.Y,This.W,This.H),UpdateLayeredWindow(Win3.hwnd, Win3.hdc),Gdip_DeleteBrush(This.Brush),Gdip_DeleteGraphics(g)
	}
	Draw_Zero(){
		DeleteObject(This.Bitmap),This.Bitmap:=Gdip_CreateBitmap(This.W,This.H),g:=Gdip_GraphicsFromImage(This.Bitmap),Gdip_SetSmoothingMode(g,1)
		This.Brush:=New_Brush("00aa00"),Fill_Box(g,This.Brush,0,0,This.W,This.H),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush("000000")
		Fill_Box(g,This.Brush,1,1,This.W-2,This.H-2),Gdip_DeleteBrush(This.Brush),This.Brush:=New_Brush(This.Off_Colour),Fill_Box(g,This.Brush,2,2,This.W-4,This.H-4)
		Gdip_DeleteBrush(This.Brush),This.Brush:=Gdip_CreateLineBrushFromRect(0, 0,This.W-4,This.H-4,"0x11ffffff", "0xdd000000"),Fill_Box(g,This.Brush,0,0,This.W,This.H)
		Gdip_TextToGraphics(g,This.Text,"s" This.Font_Size " r5 c" This.Off_Font_Colour " Bold vCenter Center","Microsoft YaHei UI",This.W,This.H)
		Gdip_DrawImage(Win3.G, This.BitMap,This.X,This.Y,This.W,This.H),UpdateLayeredWindow(Win3.hwnd, Win3.hdc),Gdip_DeleteBrush(This.Brush),Gdip_DeleteGraphics(g)
	}
}	
Check_Pos(a1:="",a2:="",a3:="",a4:="",a5:="",a6:="",a7:="",a8:=""){
	WinGetPos,a2,a6,,,HB M-Clicker
	if(a1-a2<a3&&a1-a2>a4&&a5-a6>a7&&a5-a6<a8)
		return true
	else
		return false
}
MW(){
	SetTimer,M_Loop,Off
	PostMessage,0xA1,2
	MovWin:=1
	While(GetKeyState("LButton"))
		Sleep,10
	SetTimer,M_Loop,30
	MovWin:=0
}
MINW(){
	Gui,1:Minimize
}
CGUI(){
	global
	Win:=Layered_Window_SetUp(4,A_ScreenWidth//2-Win.W//2,A_ScreenHeight//2-Win.H//2,Win.W,Win.H,1,"+AlwaysOnTop -Caption -DPIScale")
	Gui,1:Add,Text,x70 y5 w260 h20 vtitle  gMW
	Gui,1:Add,Text,x350 y7 w15 h15 vWMB gMINW
	Gui,1:Add,Text,x370 y7 w15 h15 vWCB gGuiClose
	Gui,1:Show,,HB MC
}
CGUI2(){
	global
	Win2:=Layered_Window_SetUp(4,10,30,Win.W-20,Win.H-40,2,"+Parent1 -Caption -DPIScale")
}
CGUI3(){
	global
	Win3:=Layered_Window_SetUp(4,0,0,Win2.W,Win2.H,3,"+Parent2 -Caption -DPIScale +LastFound")	
	UpdateLayeredWindow(Win3.hwnd, Win3.hdc, Win3.X, Win3.Y, Win3.W, Win3.H)	
}
Set_CP(ByRef Target_X,ByRef Target_Y){
	While(!GetKeyState("LButton"))
		ToolTip, Click Somewhere.
	ToolTip,
	MouseGetPos,Target_X,Target_Y
}
SetSPos(){
	bitm:=Gdip_CreateBitmap(60,21),g:=Gdip_GraphicsFromImage(bitm),Gdip_SetSmoothingMode(g,2)
	tbr:=New_Brush("22aa22","ff"),Fill_Box(g,tbr,0,0,60,21),tpn:=New_Pen("004400","ff",1)
	Gdip_DrawRectangle(g, tpn,0,0,59,20),Gdip_DeletePen(tpn),Gdip_DeleteBrush(tbr)
	Gdip_TextToGraphics(g,Target_X " " Target_Y," s10 r5 cff000000 Bold vCenter Center","Microsoft YaHei UI",60,21)
	Gdip_DrawImage(Win3.G, bitm,100,81,60,21),UpdateLayeredWindow(Win3.hwnd, Win3.hdc),Gdip_DeleteGraphics(g),Gdip_DisposeImage(bitm)
}
CL_CoU(){
	bitm:=Gdip_CreateBitmap(60,21),g:=Gdip_GraphicsFromImage(bitm),Gdip_SetSmoothingMode(g,2),tbr:=New_Brush("22aa22","ff")
	Fill_Box(g,tbr,0,0,60,21),tpn:=New_Pen("004400","ff",1),Gdip_DrawRectangle(g, tpn,0,0,59,20),Gdip_DeletePen(tpn),Gdip_DeleteBrush(tbr)
	Gdip_TextToGraphics(g,Click_Count," s10 r5 cff000000 Bold vCenter Center","Microsoft YaHei UI",60,21)
	Gdip_DrawImage(Win3.G, bitm,290,81,60,21),UpdateLayeredWindow(Win3.hwnd, Win3.hdc),Gdip_DeleteGraphics(g),Gdip_DisposeImage(bitm)
}
ACB(){
	global
	Button1[1]:=New Butt(350,7,16,15,12,"ff33bb44","-","WMB","ff000000","22cc22",1),Button1[2]:=New Butt(370,7,16,15,12,"ff33bb55","X","WCB","ff000000","880000",1)
	Button1[3]:=New Butt(70,3,260,24,12,"ff00ff00","HB Matrix Clicker","Title","ff000000","aaccaa",1,,,1),Button1[4]:=New Butt(5,153,120,25,14,"ff00ff00","Start","Start","ff000000","22cc22",3,"115511","ff000000",1) 
	Button1[5]:=New Butt(130,153,120,25,14,"ff00ff00","Stop","Stop","ff000000","22cc22",3,"115511","ff000000",1),Button1[6]:=New Butt(255,153,120,25,14,"ff00ff00","Reload","Reload","ff000000","22cc22",3,"115511","ff000000",1)
	Button1[7]:=New Butt(20,182,340,25,14,"ff00ff00","HotKeys","Hotkeys","ff000000","22cc22",3,"115511","ff000000",1),Button1[8]:=New Butt(5,80,90,25,12,"ff00ff00","Set Position","Set_Position","ff000000","22cc22",3,"115511","ff000000",1)
	Button1[9]:=New Butt(190,80,90,25,12,"ff00ff00","Reset Count","Reset_Count","ff000000","22cc22",3,"115511","ff000000",1)
	Gui,3:Add,Text,x5 y153 w120 h25 gStart vStart 
	Gui,3:Add,Text,x130 y153 w120 h25 gStop vStop
	Gui,3:Add,Text,x255 y153 w120 h25 gReload vReload
	Gui,3:Add,Text,x20 y182 w340 h25 gHotkeys vHotkeys
	Gui,3:Add,Text,x5 y80 w90 h25 gSet_Position vSet_Position
	Gui,3:Add,Text,x190 y80 w90 h25 gReset_Count vReset_Count
}
SetCAMOUNT(){
	gui,3:Submit,NoHide
	bitm:=Gdip_CreateBitmap(60,21),g:=Gdip_GraphicsFromImage(bitm),Gdip_SetSmoothingMode(g,2),tbr:=New_Brush("22aa22","ff")
	Fill_Box(g,tbr,0,0,60,21),tpn:=New_Pen("004400","ff",1),Gdip_DrawRectangle(g, tpn,0,0,59,20),Gdip_DeletePen(tpn),Gdip_DeleteBrush(tbr)
	Gdip_TextToGraphics(g,Fixed_Click_Amount," s10 r5 cff000000 Bold vCenter Center","Microsoft YaHei UI",60,21)
	Gdip_DrawImage(Win3.G, bitm,275,56,60,18),UpdateLayeredWindow(Win3.hwnd, Win3.hdc),Gdip_DeleteGraphics(g),Gdip_DisposeImage(bitm)
}
DBG(){
	global
	Brush[1]:=New_Brush("000000"),Gdip_FillRoundedRectangle(Win.G,Brush[1],0,0, Win.w, Win.h, 15),Brush[2]:=Gdip_CreateLineBrushFromRect(0, 0, Win.w, 150,"0x44aaffaa", "0xff000000") 
	Gdip_FillRoundedRectangle(Win.G,Brush[2],0,0,win.w, 100, 15),Pen[1]:=New_Pen("00bb00","ff",2),Gdip_DrawRoundedRectangle(Win.G, Pen[1],0,0, Win.w-1, Win.h-1, 15)
	Gdip_DeletePen(Pen[1]),Pen[1]:=New_Pen("00bb00","ff",2),Gdip_DrawRoundedRectangle(Win.G, Pen[1],0,0, Win.w-1, Win.h, 15),Gdip_DeletePen(Pen[1])
	Brush[4]:=New_Brush("ffffff","11"),Gdip_FillEllipse(Win.G,Brush[4], 0, 30, 5,200),Gdip_FillEllipse(Win.G,Brush[4], 390, 30, 5,200),Gdip_FillEllipse(Win.G,Brush[4], 15, 235, 370,10)
	Pen[2]:=New_Pen("000000","ff",2),Gdip_DrawRectangle(Win1.G, Pen[2],9,29, Win.w-18, Win.h-38),Gdip_DeletePen(Pen[2]),Pen[2]:=New_Pen("00bb00","ff",1)
	Gdip_DrawRectangle(Win.G, Pen[2],9,29, Win.w-18, Win.h-38),Gdip_DeletePen(Pen[2]),Draw_Inner()	
	UpdateLayeredWindow(Win.hwnd, Win.hdc, Win.X, Win.Y, Win.W, Win.H),UpdateLayeredWindow(Win2.hwnd, Win2.hdc, Win2.X, Win2.Y, Win2.W, Win2.H)
}
RandomNumber(min,max){
	Random,out,Min,Max
	return out
}
Draw_Inner(){	
	Brush[2]:=New_Brush("001100","55"),Fill_Box(Win2.G,Brush[2],0,0, Win2.w, Win2.h)
}
Class Strings	{
	__New(x,y,w,h){
		This.X:=x,This.Y:=y,This.W:=w,This.H:=h,This.Font_Size:=RandomNumber(6,18),col:=RandomNumber(1,10),This.Counter:=RandomNumber(0,80),This.Colour:=colours[col]
		This.Speed:=floor(This.Font_Size/4),This.Create_Bitmap()
	}
	Create_Bitmap(){
		DeleteObject(This.Bitmap)
		Gdip_DisposeImage(This.Bitmap)
		This.Bitmap:=Gdip_CreateBitmap(This.W,This.H)
		temp_Array:="",This.Array1:=[]
		loop 70	{
			val:=RandomNumber(1,34)
			(val>30)?(temp_Array.=" `n",This.Array1[A_Index]:=" "):(temp_Array.=Letter_Array[val] "`n",This.Array1[A_Index]:=Letter_Array[val])
		}
		g:=Gdip_GraphicsFromImage(This.Bitmap),Gdip_SetSmoothingMode(g,4)
		Gdip_TextToGraphics(g,temp_array,"s" This.Font_Size " r5 c" This.Colour " Bold Center","Chiller",20,400)	
		Gdip_DeleteGraphics(g)	
	}
	Change_Things(){
		DeleteObject(This.Bitmap)
		Gdip_DisposeImage(This.Bitmap)
		;~ DeleteObject(This.Bitmap)
		This.Bitmap:=Gdip_CreateBitmap(This.W,This.H)
		temp_Array:=""
		loop 70	{
			rn:=RandomNumber(1,5)			
			(rn=3)?(val:=RandomNumber(1,61),temp_Array.=Letter_Array[val] "`n"):(temp_Array.=This.Array1[A_Index] "`n")
		}
		g:=Gdip_GraphicsFromImage(This.Bitmap),Gdip_SetSmoothingMode(g,4)
		Gdip_TextToGraphics(g,temp_array,"s" This.Font_Size " r5 c" This.Colour " Bold Center","Chiller",20,400)	
		Gdip_DeleteGraphics(g),DeleteObject(This.Bitmap)	
	}
	UpDate(){
		This.y+=This.Speed
		if(++This.Counter>85)
			This.Counter:=RandomNumber(0,80),This.Change_Things()
		if(This.Y>Win.H){
			This.Y:=RandomNumber(-400,-1150),This.X:=5*RandomNumber(0,Win.W//5-3)
			This.Font_Size:=RandomNumber(6,22),This.Speed:=floor(This.Font_Size/4)
			This.Create_Bitmap()
		}
		if(This.Y>-400&&This.Y<Win.H)
			Gdip_DrawImage(Win2.G, This.BitMap,This.X,This.Y,This.W,This.H)
	}
}
SetUp(){
	x:=5
	Loop, % Win2.W//5 - 3
		String[A_Index]:=New Strings(x,RandomNumber(-400,-1150),20,400),x+=5	
} 	
OT(){
	MouseGetPos,,,,ctrl,2
	GuiControlGet,name,%tgui%:Name,% ctrl
	if(name!=Button1[Num].Name&&MovWin!=1){
		Button1[Num].Draw_Norm(),Num:="",HovOn:=0,tgui:=""
		SetTimer,OT,Off
	}
}
Whv(){ 
	if(HovOn=0){
		MouseGetPos,,,,ctrl,2
		GuiControlGet,name,%A_Gui%:Name,% ctrl
		Loop, % Button1.Length()
			if(Button1[A_Index].Name=name){
				HovOn:=1,tgui:=A_Gui,Num:=A_Index
				Button1[A_Index].Draw_Hover()
				SetTimer,OT,30
			}
	}
	if(Stop=0&&PauseOn=0&&Free_Mode=1){
		Stop:=1
	}
}		
Show_Win(){
	Button1[3].Draw_Norm()
}	
ACH(){ 
	global
	Checks[1]:=New Check1(50,5,120,20,1,"33ff33","114411","AlwaysOnTop",12,"ff000000","ff777777","Always")
	Checks[3]:=New Check1(210,5,120,20,0,"33ff33","114411","Free Mode",12,"ff000000","ff777777","Free_Mode")
	Gui,3:Add,Text,x50 y5 w120 h25 gAOT vAlways
	Gui,3:Add,Text,x210 y5 w120 h25 gFM vFree_Mode
}
FM(){ 
	Free_Mode:=!Free_Mode
	if(Free_Mode){
		Checks[3].Draw_One()
	}else	{
		Checks[3].Draw_Zero()
	}
}
AOT(){ 
	Always:=!Always
	if(Always){
		Checks[1].Draw_One()
		Gui,1:+AlwaysOnTop
	}else	{
		Checks[1].Draw_Zero()
		Gui,1:-AlwaysOnTop
	}
}	
MsgShow(MsNum){
	Gui,1:+OwnDialogs
	if(MsNum=1)
		MsgBox, 262192,Use Hotkeys,Use hotkeys to start and stop the auto clicker when in free mode.
	else if(MsNum=2)
		MsgBox, 262192,Set a position to click,Set a click position or switch to ""Free Mode""
}
Gdip_DeleteBrush(pBrush)
{
   return DllCall("gdiplus\GdipDeleteBrush", A_PtrSize ? "UPtr" : "UInt", pBrush)
}
Gdip_DeletePen(pPen)
{
   return DllCall("gdiplus\GdipDeletePen", A_PtrSize ? "UPtr" : "UInt", pPen)
}
Gdip_DisposeImage(pBitmap)
{
   return DllCall("gdiplus\GdipDisposeImage", A_PtrSize ? "UPtr" : "UInt", pBitmap)
}
Layered_Window_ShutDown(This)
	{
		SelectObject(This.hdc,This.obm)
		DeleteObject(This.hbm)
		DeleteDC(This.hdc)
		gdip_deleteGraphics(This.g)
		Gdip_Shutdown(This.Token)
	}
UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	if ((x != "") && (y != ""))
		VarSetCapacity(pt, 8), NumPut(x, pt, 0, "UInt"), NumPut(y, pt, 4, "UInt")

	if (w = "") ||(h = "")
		WinGetPos,,, w, h, ahk_id %hwnd%
   
	return DllCall("UpdateLayeredWindow"
					, Ptr, hwnd
					, Ptr, 0
					, Ptr, ((x = "") && (y = "")) ? 0 : &pt
					, "int64*", w|h<<32
					, Ptr, hdc
					, "int64*", 0
					, "uint", 0
					, "UInt*", Alpha<<16|1<<24
					, "uint", 2)
}
DeleteObject(hObject)
{
   return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject)
}
Gdip_CreateBitmap(Width, Height, Format=0x26200A)
{
    DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", 0, "int", Format, A_PtrSize ? "UPtr" : "UInt", 0, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
    Return pBitmap
}
Gdip_GraphicsFromImage(pBitmap)
{
	DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
	return pGraphics
}
Gdip_SetSmoothingMode(pGraphics, SmoothingMode)
{
   return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
}
New_Brush(colour:="000000",Alpha:="FF")
	{
		static Hellbent_Brush:=[]
		new_colour := "0x" Alpha colour 
		Hellbent_Brush[Hellbent_Brush.Length()+1]:=Gdip_BrushCreateSolid(new_colour)
		return Hellbent_Brush[Hellbent_Brush.Length()]
	}
Fill_Box(pGraphics,pBrush,x,y,w,h)	
	{
		Ptr := A_PtrSize ? "UPtr" : "UInt"
		return DllCall("gdiplus\GdipFillRectangle"
					, Ptr, pGraphics
					, Ptr, pBrush
					, "float", x
					, "float", y
					, "float", w
					, "float", h)
	}
Gdip_CreateLineBrushFromRect(x, y, w, h, ARGB1, ARGB2, LinearGradientMode=1, WrapMode=1)
{
	CreateRectF(RectF, x, y, w, h)
	DllCall("gdiplus\GdipCreateLineBrushFromRect", A_PtrSize ? "UPtr" : "UInt", &RectF, "int", ARGB1, "int", ARGB2, "int", LinearGradientMode, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
	return LGpBrush
}
Gdip_TextToGraphics(pGraphics, Text, Options, Font="Arial", Width="", Height="", Measure=0)
{
	IWidth := Width, IHeight:= Height
	
	RegExMatch(Options, "i)X([\-\d\.]+)(p*)", xpos)
	RegExMatch(Options, "i)Y([\-\d\.]+)(p*)", ypos)
	RegExMatch(Options, "i)W([\-\d\.]+)(p*)", Width)
	RegExMatch(Options, "i)H([\-\d\.]+)(p*)", Height)
	RegExMatch(Options, "i)C(?!(entre|enter))([a-f\d]+)", Colour)
	RegExMatch(Options, "i)Top|Up|Bottom|Down|vCentre|vCenter", vPos)
	RegExMatch(Options, "i)NoWrap", NoWrap)
	RegExMatch(Options, "i)R(\d)", Rendering)
	RegExMatch(Options, "i)S(\d+)(p*)", Size)

	if !Gdip_DeleteBrush(Gdip_CloneBrush(Colour2))
		PassBrush := 1, pBrush := Colour2
	
	if !(IWidth && IHeight) && (xpos2 || ypos2 || Width2 || Height2 || Size2)
		return -1

	Style := 0, Styles := "Regular|Bold|Italic|BoldItalic|Underline|Strikeout"
	Loop, Parse, Styles, |
	{
		if RegExMatch(Options, "\b" A_loopField)
		Style |= (A_LoopField != "StrikeOut") ? (A_Index-1) : 8
	}
  
	Align := 0, Alignments := "Near|Left|Centre|Center|Far|Right"
	Loop, Parse, Alignments, |
	{
		if RegExMatch(Options, "\b" A_loopField)
			Align |= A_Index//2.1      ; 0|0|1|1|2|2
	}

	xpos := (xpos1 != "") ? xpos2 ? IWidth*(xpos1/100) : xpos1 : 0
	ypos := (ypos1 != "") ? ypos2 ? IHeight*(ypos1/100) : ypos1 : 0
	Width := Width1 ? Width2 ? IWidth*(Width1/100) : Width1 : IWidth
	Height := Height1 ? Height2 ? IHeight*(Height1/100) : Height1 : IHeight
	if !PassBrush
		Colour := "0x" (Colour2 ? Colour2 : "ff000000")
	Rendering := ((Rendering1 >= 0) && (Rendering1 <= 5)) ? Rendering1 : 4
	Size := (Size1 > 0) ? Size2 ? IHeight*(Size1/100) : Size1 : 12

	hFamily := Gdip_FontFamilyCreate(Font)
	hFont := Gdip_FontCreate(hFamily, Size, Style)
	FormatStyle := NoWrap ? 0x4000 | 0x1000 : 0x4000
	hFormat := Gdip_StringFormatCreate(FormatStyle)
	pBrush := PassBrush ? pBrush : Gdip_BrushCreateSolid(Colour)
	if !(hFamily && hFont && hFormat && pBrush && pGraphics)
		return !pGraphics ? -2 : !hFamily ? -3 : !hFont ? -4 : !hFormat ? -5 : !pBrush ? -6 : 0
   
	CreateRectF(RC, xpos, ypos, Width, Height)
	Gdip_SetStringFormatAlign(hFormat, Align)
	Gdip_SetTextRenderingHint(pGraphics, Rendering)
	ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC)

	if vPos
	{
		StringSplit, ReturnRC, ReturnRC, |
		
		if (vPos = "vCentre") || (vPos = "vCenter")
			ypos += (Height-ReturnRC4)//2
		else if (vPos = "Top") || (vPos = "Up")
			ypos := 0
		else if (vPos = "Bottom") || (vPos = "Down")
			ypos := Height-ReturnRC4
		
		CreateRectF(RC, xpos, ypos, Width, ReturnRC4)
		ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC)
	}

	if !Measure
		E := Gdip_DrawString(pGraphics, Text, hFont, hFormat, pBrush, RC)

	if !PassBrush
		Gdip_DeleteBrush(pBrush)
	Gdip_DeleteStringFormat(hFormat)   
	Gdip_DeleteFont(hFont)
	Gdip_DeleteFontFamily(hFamily)
	return E ? E : ReturnRC
}
Gdip_DrawImage(pGraphics, pBitmap, dx="", dy="", dw="", dh="", sx="", sy="", sw="", sh="", Matrix=1)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	if (Matrix&1 = "")
		ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
	else if (Matrix != 1)
		ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1")

	if (sx = "" && sy = "" && sw = "" && sh = "")
	{
		if (dx = "" && dy = "" && dw = "" && dh = "")
		{
			sx := dx := 0, sy := dy := 0
			sw := dw := Gdip_GetImageWidth(pBitmap)
			sh := dh := Gdip_GetImageHeight(pBitmap)
		}
		else
		{
			sx := sy := 0
			sw := Gdip_GetImageWidth(pBitmap)
			sh := Gdip_GetImageHeight(pBitmap)
		}
	}

	E := DllCall("gdiplus\GdipDrawImageRectRect"
				, Ptr, pGraphics
				, Ptr, pBitmap
				, "float", dx
				, "float", dy
				, "float", dw
				, "float", dh
				, "float", sx
				, "float", sy
				, "float", sw
				, "float", sh
				, "int", 2
				, Ptr, ImageAttr
				, Ptr, 0
				, Ptr, 0)
	if ImageAttr
		Gdip_DisposeImageAttributes(ImageAttr)
	return E
}
Gdip_DeleteGraphics(pGraphics)
{
   return DllCall("gdiplus\GdipDeleteGraphics", A_PtrSize ? "UPtr" : "UInt", pGraphics)
}
Layered_Window_SetUp(Smoothing,Window_X,Window_Y,Window_W,Window_H,Window_Name:=1,Window_Options:="")
	{
		Layered:={}
		Layered.W:=Window_W
		Layered.H:=Window_H
		Layered.X:=Window_X
		Layered.Y:=Window_Y
		Layered.Name:=Window_Name
		Layered.Options:=Window_Options
		Layered.Token:=Gdip_Startup()
		Create_Layered_GUI(Layered)
		Layered.hwnd:=winExist()
		Layered.hbm := CreateDIBSection(Window_W,Window_H)
		Layered.hdc := CreateCompatibleDC()
		Layered.obm := SelectObject(Layered.hdc,Layered.hbm)
		Layered.G := Gdip_GraphicsFromHDC(Layered.hdc)
		Gdip_SetSmoothingMode(Layered.G,Smoothing)
		return Layered
	}
Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff)
{
    return DllCall("gdiplus\GdipGraphicsClear", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", ARGB)
}
New_Pen(colour:="000000",Alpha:="FF",Width:= 5)
	{
		static Hellbent_Pen:=[]
		new_colour := "0x" Alpha colour 
		Hellbent_Pen[Hellbent_Pen.Length()+1]:=Gdip_CreatePen(New_Colour,Width)
		return Hellbent_Pen[Hellbent_Pen.Length()]
	}
Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	return DllCall("gdiplus\GdipDrawRectangle", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h)
}
Gdip_FillRoundedRectangle(pGraphics, pBrush, x, y, w, h, r)
{
	Region := Gdip_GetClipRegion(pGraphics)
	Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
	Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
	Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
	Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
	E := Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h)
	Gdip_SetClipRegion(pGraphics, Region, 0)
	Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
	Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
	Gdip_FillEllipse(pGraphics, pBrush, x, y, 2*r, 2*r)
	Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y, 2*r, 2*r)
	Gdip_FillEllipse(pGraphics, pBrush, x, y+h-(2*r), 2*r, 2*r)
	Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y+h-(2*r), 2*r, 2*r)
	Gdip_SetClipRegion(pGraphics, Region, 0)
	Gdip_DeleteRegion(Region)
	return E
}
Gdip_DrawRoundedRectangle(pGraphics, pPen, x, y, w, h, r)
{
	Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
	Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
	Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
	Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
	E := Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h)
	Gdip_ResetClip(pGraphics)
	Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
	Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
	Gdip_DrawEllipse(pGraphics, pPen, x, y, 2*r, 2*r)
	Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y, 2*r, 2*r)
	Gdip_DrawEllipse(pGraphics, pPen, x, y+h-(2*r), 2*r, 2*r)
	Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y+h-(2*r), 2*r, 2*r)
	Gdip_ResetClip(pGraphics)
	return E
}
Gdip_FillEllipse(pGraphics, pBrush, x, y, w, h)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	return DllCall("gdiplus\GdipFillEllipse", Ptr, pGraphics, Ptr, pBrush, "float", x, "float", y, "float", w, "float", h)
}
SelectObject(hdc, hgdiobj)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
}
DeleteDC(hdc)
{
   return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc)
}
Gdip_Shutdown(pToken)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	DllCall("gdiplus\GdiplusShutdown", Ptr, pToken)
	if hModule := DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
		DllCall("FreeLibrary", Ptr, hModule)
	return 0
}
Gdip_BrushCreateSolid(ARGB=0xff000000)
{
	DllCall("gdiplus\GdipCreateSolidFill", "UInt", ARGB, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
	return pBrush
}
CreateRectF(ByRef RectF, x, y, w, h)
{
   VarSetCapacity(RectF, 16)
   NumPut(x, RectF, 0, "float"), NumPut(y, RectF, 4, "float"), NumPut(w, RectF, 8, "float"), NumPut(h, RectF, 12, "float")
}
Gdip_CloneBrush(pBrush)
{
	DllCall("gdiplus\GdipCloneBrush", A_PtrSize ? "UPtr" : "UInt", pBrush, A_PtrSize ? "UPtr*" : "UInt*", pBrushClone)
	return pBrushClone
}
Gdip_FontFamilyCreate(Font)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	if (!A_IsUnicode)
	{
		nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &Font, "int", -1, "uint", 0, "int", 0)
		VarSetCapacity(wFont, nSize*2)
		DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &Font, "int", -1, Ptr, &wFont, "int", nSize)
	}
	
	DllCall("gdiplus\GdipCreateFontFamilyFromName"
					, Ptr, A_IsUnicode ? &Font : &wFont
					, "uint", 0
					, A_PtrSize ? "UPtr*" : "UInt*", hFamily)
	
	return hFamily
}
Gdip_FontCreate(hFamily, Size, Style=0)
{
   DllCall("gdiplus\GdipCreateFont", A_PtrSize ? "UPtr" : "UInt", hFamily, "float", Size, "int", Style, "int", 0, A_PtrSize ? "UPtr*" : "UInt*", hFont)
   return hFont
}
Gdip_StringFormatCreate(Format=0, Lang=0)
{
   DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat)
   return hFormat
}
Gdip_SetStringFormatAlign(hFormat, Align)
{
   return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align)
}
Gdip_SetTextRenderingHint(pGraphics, RenderingHint)
{
	return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint)
}
Gdip_MeasureString(pGraphics, sString, hFont, hFormat, ByRef RectF)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	VarSetCapacity(RC, 16)
	if !A_IsUnicode
	{
		nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, "uint", 0, "int", 0)
		VarSetCapacity(wString, nSize*2)   
		DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, &wString, "int", nSize)
	}
	
	DllCall("gdiplus\GdipMeasureString"
					, Ptr, pGraphics
					, Ptr, A_IsUnicode ? &sString : &wString
					, "int", -1
					, Ptr, hFont
					, Ptr, &RectF
					, Ptr, hFormat
					, Ptr, &RC
					, "uint*", Chars
					, "uint*", Lines)
	
	return &RC ? NumGet(RC, 0, "float") "|" NumGet(RC, 4, "float") "|" NumGet(RC, 8, "float") "|" NumGet(RC, 12, "float") "|" Chars "|" Lines : 0
}
Gdip_DrawString(pGraphics, sString, hFont, hFormat, pBrush, ByRef RectF)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	if (!A_IsUnicode)
	{
		nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, 0, "int", 0)
		VarSetCapacity(wString, nSize*2)
		DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, &wString, "int", nSize)
	}
	
	return DllCall("gdiplus\GdipDrawString"
					, Ptr, pGraphics
					, Ptr, A_IsUnicode ? &sString : &wString
					, "int", -1
					, Ptr, hFont
					, Ptr, &RectF
					, Ptr, hFormat
					, Ptr, pBrush)
}
Gdip_DeleteStringFormat(hFormat)
{
   return DllCall("gdiplus\GdipDeleteStringFormat", A_PtrSize ? "UPtr" : "UInt", hFormat)
}
Gdip_DeleteFont(hFont)
{
   return DllCall("gdiplus\GdipDeleteFont", A_PtrSize ? "UPtr" : "UInt", hFont)
}
Gdip_DeleteFontFamily(hFamily)
{
   return DllCall("gdiplus\GdipDeleteFontFamily", A_PtrSize ? "UPtr" : "UInt", hFamily)
}
Gdip_SetImageAttributesColorMatrix(Matrix)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	VarSetCapacity(ColourMatrix, 100, 0)
	Matrix := RegExReplace(RegExReplace(Matrix, "^[^\d-\.]+([\d\.])", "$1", "", 1), "[^\d-\.]+", "|")
	StringSplit, Matrix, Matrix, |
	Loop, 25
	{
		Matrix := (Matrix%A_Index% != "") ? Matrix%A_Index% : Mod(A_Index-1, 6) ? 0 : 1
		NumPut(Matrix, ColourMatrix, (A_Index-1)*4, "float")
	}
	DllCall("gdiplus\GdipCreateImageAttributes", A_PtrSize ? "UPtr*" : "uint*", ImageAttr)
	DllCall("gdiplus\GdipSetImageAttributesColorMatrix", Ptr, ImageAttr, "int", 1, "int", 1, Ptr, &ColourMatrix, Ptr, 0, "int", 0)
	return ImageAttr
}
Gdip_GetImageWidth(pBitmap)
{
   DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width)
   return Width
}
Gdip_GetImageHeight(pBitmap)
{
   DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height)
   return Height
}
Gdip_DisposeImageAttributes(ImageAttr)
{
	return DllCall("gdiplus\GdipDisposeImageAttributes", A_PtrSize ? "UPtr" : "UInt", ImageAttr)
}
Gdip_Startup()
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	if !DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
		DllCall("LoadLibrary", "str", "gdiplus")
	VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
	DllCall("gdiplus\GdiplusStartup", A_PtrSize ? "UPtr*" : "uint*", pToken, Ptr, &si, Ptr, 0)
	return pToken
}
Create_Layered_GUI(Layered)
	{
		Gui,% Layered.Name ": +E0x80000 +LastFound " Layered.Options 
		Gui,% Layered.Name ":Show",% "x" Layered.X " y" Layered.Y " w" Layered.W " h" Layered.H " NA"
	}
CreateDIBSection(w, h, hdc="", bpp=32, ByRef ppvBits=0)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	hdc2 := hdc ? hdc : GetDC()
	VarSetCapacity(bi, 40, 0)
	
	NumPut(w, bi, 4, "uint")
	, NumPut(h, bi, 8, "uint")
	, NumPut(40, bi, 0, "uint")
	, NumPut(1, bi, 12, "ushort")
	, NumPut(0, bi, 16, "uInt")
	, NumPut(bpp, bi, 14, "ushort")
	
	hbm := DllCall("CreateDIBSection"
					, Ptr, hdc2
					, Ptr, &bi
					, "uint", 0
					, A_PtrSize ? "UPtr*" : "uint*", ppvBits
					, Ptr, 0
					, "uint", 0, Ptr)

	if !hdc
		ReleaseDC(hdc2)
	return hbm
}
CreateCompatibleDC(hdc=0)
{
   return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
}
Gdip_GraphicsFromHDC(hdc)
{
    DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
    return pGraphics
}
Gdip_CreatePen(ARGB, w)
{
   DllCall("gdiplus\GdipCreatePen1", "UInt", ARGB, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
   return pPen
}
Gdip_GetClipRegion(pGraphics)
{
	Region := Gdip_CreateRegion()
	DllCall("gdiplus\GdipGetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics, "UInt*", Region)
	return Region
}
Gdip_SetClipRect(pGraphics, x, y, w, h, CombineMode=0)
{
   return DllCall("gdiplus\GdipSetClipRect",  A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "float", w, "float", h, "int", CombineMode)
}
Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	return DllCall("gdiplus\GdipFillRectangle"
					, Ptr, pGraphics
					, Ptr, pBrush
					, "float", x
					, "float", y
					, "float", w
					, "float", h)
}
Gdip_SetClipRegion(pGraphics, Region, CombineMode=0)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	return DllCall("gdiplus\GdipSetClipRegion", Ptr, pGraphics, Ptr, Region, "int", CombineMode)
}
Gdip_DeleteRegion(Region)
{
	return DllCall("gdiplus\GdipDeleteRegion", A_PtrSize ? "UPtr" : "UInt", Region)
}
Gdip_ResetClip(pGraphics)
{
   return DllCall("gdiplus\GdipResetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics)
}
Gdip_DrawEllipse(pGraphics, pPen, x, y, w, h)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	return DllCall("gdiplus\GdipDrawEllipse", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h)
}
GetDC(hwnd=0)
{
	return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
}
ReleaseDC(hdc, hwnd=0)
{
	Ptr := A_PtrSize ? "UPtr" : "UInt"
	
	return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
}
Gdip_CreateRegion()
{
	DllCall("gdiplus\GdipCreateRegion", "UInt*", Region)
	return Region
}
DRocks
Posts: 441
Joined: 08 May 2018, 10:20

Re: Custom Msgbox

18 Feb 2019, 00:33

Thank you Hellbent your awesome MsgBox.

You have motivated me to try doing my own after seeing yours and heres the result:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=62117&p=264061#p264061
Hellbent
Posts: 503
Joined: 23 Sep 2017, 13:34

Re: Custom Msgbox

18 Feb 2019, 00:55

DRocks wrote:
18 Feb 2019, 00:33
Thank you Hellbent your awesome MsgBox.

You have motivated me to try doing my own after seeing yours and heres the result:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=62117&p=264061#p264061
Cool stuff D!

One thing though, it would be nice to be able to move the window. You can do it easily by placing a text control under the progress bar you have as the title bar.

Like this:

Code: Select all


;=== Use a Progress Meter to fake a title bar.
	Gui, Font, s11 bold cWhite
	Gui, Add, Text           , % "x0 y0 w" GuiW " h" TitlebarHeight " gMove_Msg_Window"  ; <---------- Trigger
	Gui, Add, Progress	, % "x0 y0 w" GuiW " h" TitlebarHeight " Background" TitlebarColor
	Gui, Add, Text		, % "x0 y0 w" GuiW " h" TitlebarHeight " BackgroundTrans " CenterHorizontal " " CenterVertical,% GuiWinTitle

;=========================
; Place this at the end of your function (inside, but at the end just before the closing "}") ; outside the function is better, but then it's something that ; the user has to also copy etc if they paste you code into their script.
;----------------------------------
return  ; this will exit the normal part of your function so that the label only gets triggered by clicking the title bar
Move_Msg_Window:
	postmessage,0xA1,2
	return	
;----------------------------------	

Return to “Ask For Help”

Who is online

Users browsing this forum: roses21+ and 132 guests