diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.2/Lib/Gdip.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.2/Lib/Gdip.ahk
new file mode 100644
index 0000000..0b629d5
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.2/Lib/Gdip.ahk
@@ -0,0 +1,2698 @@
+; Gdip standard library v1.45 by tic (Tariq Porter) 07/09/11
+; Modifed by Rseding91 using fincs 64 bit compatible Gdip library 5/1/2013
+; Supports: Basic, _L ANSi, _L Unicode x86 and _L Unicode x64
+;
+;#####################################################################################
+;#####################################################################################
+; STATUS ENUMERATION
+; Return values for functions specified to have status enumerated return type
+;#####################################################################################
+;
+; Ok = = 0
+; GenericError = 1
+; InvalidParameter = 2
+; OutOfMemory = 3
+; ObjectBusy = 4
+; InsufficientBuffer = 5
+; NotImplemented = 6
+; Win32Error = 7
+; WrongState = 8
+; Aborted = 9
+; FileNotFound = 10
+; ValueOverflow = 11
+; AccessDenied = 12
+; UnknownImageFormat = 13
+; FontFamilyNotFound = 14
+; FontStyleNotFound = 15
+; NotTrueTypeFont = 16
+; UnsupportedGdiplusVersion = 17
+; GdiplusNotInitialized = 18
+; PropertyNotFound = 19
+; PropertyNotSupported = 20
+; ProfileNotFound = 21
+;
+;#####################################################################################
+;#####################################################################################
+; FUNCTIONS
+;#####################################################################################
+;
+; UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255)
+; BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+; StretchBlt(dDC, dx, dy, dw, dh, sDC, sx, sy, sw, sh, Raster="")
+; SetImage(hwnd, hBitmap)
+; Gdip_BitmapFromScreen(Screen=0, Raster="")
+; CreateRectF(ByRef RectF, x, y, w, h)
+; CreateSizeF(ByRef SizeF, w, h)
+; CreateDIBSection
+;
+;#####################################################################################
+
+; Function: UpdateLayeredWindow
+; Description: Updates a layered window with the handle to the DC of a gdi bitmap
+;
+; hwnd Handle of the layered window to update
+; hdc Handle to the DC of the GDI bitmap to update the window with
+; Layeredx x position to place the window
+; Layeredy y position to place the window
+; Layeredw Width of the window
+; Layeredh Height of the window
+; Alpha Default = 255 : The transparency (0-255) to set the window transparency
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If x or y omitted, then layered window will use its current coordinates
+; If w or h omitted then current width and height will be used
+
+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)
+}
+
+;#####################################################################################
+
+; Function BitBlt
+; Description The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle
+; of pixels from the specified source device context into a destination device context.
+;
+; dDC handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of the area to copy
+; dh height of the area to copy
+; sDC handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used, which copies the source directly to the destination rectangle
+;
+; BLACKNESS = 0x00000042
+; NOTSRCERASE = 0x001100A6
+; NOTSRCCOPY = 0x00330008
+; SRCERASE = 0x00440328
+; DSTINVERT = 0x00550009
+; PATINVERT = 0x005A0049
+; SRCINVERT = 0x00660046
+; SRCAND = 0x008800C6
+; MERGEPAINT = 0x00BB0226
+; MERGECOPY = 0x00C000CA
+; SRCCOPY = 0x00CC0020
+; SRCPAINT = 0x00EE0086
+; PATCOPY = 0x00F00021
+; PATPAINT = 0x00FB0A09
+; WHITENESS = 0x00FF0062
+; CAPTUREBLT = 0x40000000
+; NOMIRRORBITMAP = 0x80000000
+
+BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\BitBlt"
+ , Ptr, dDC
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sDC
+ , "int", sx
+ , "int", sy
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function StretchBlt
+; Description The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle,
+; stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary.
+; The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.
+;
+; ddc handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination rectangle
+; dh height of destination rectangle
+; sdc handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used. It uses the same raster operations as BitBlt
+
+StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\StretchBlt"
+ , Ptr, ddc
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sdc
+ , "int", sx
+ , "int", sy
+ , "int", sw
+ , "int", sh
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function SetStretchBltMode
+; Description The SetStretchBltMode function sets the bitmap stretching mode in the specified device context
+;
+; hdc handle to the DC
+; iStretchMode The stretching mode, describing how the target will be stretched
+;
+; return If the function succeeds, the return value is the previous stretching mode. If it fails it will return 0
+;
+; STRETCH_ANDSCANS = 0x01
+; STRETCH_ORSCANS = 0x02
+; STRETCH_DELETESCANS = 0x03
+; STRETCH_HALFTONE = 0x04
+
+SetStretchBltMode(hdc, iStretchMode=4)
+{
+ return DllCall("gdi32\SetStretchBltMode"
+ , A_PtrSize ? "UPtr" : "UInt", hdc
+ , "int", iStretchMode)
+}
+
+;#####################################################################################
+
+; Function SetImage
+; Description Associates a new image with a static control
+;
+; hwnd handle of the control to update
+; hBitmap a gdi bitmap to associate the static control with
+;
+; return If the function succeeds, the return value is nonzero
+
+SetImage(hwnd, hBitmap)
+{
+ SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
+ E := ErrorLevel
+ DeleteObject(E)
+ return E
+}
+
+;#####################################################################################
+
+; Function SetSysColorToControl
+; Description Sets a solid colour to a control
+;
+; hwnd handle of the control to update
+; SysColor A system colour to set to the control
+;
+; return If the function succeeds, the return value is zero
+;
+; notes A control must have the 0xE style set to it so it is recognised as a bitmap
+; By default SysColor=15 is used which is COLOR_3DFACE. This is the standard background for a control
+;
+; COLOR_3DDKSHADOW = 21
+; COLOR_3DFACE = 15
+; COLOR_3DHIGHLIGHT = 20
+; COLOR_3DHILIGHT = 20
+; COLOR_3DLIGHT = 22
+; COLOR_3DSHADOW = 16
+; COLOR_ACTIVEBORDER = 10
+; COLOR_ACTIVECAPTION = 2
+; COLOR_APPWORKSPACE = 12
+; COLOR_BACKGROUND = 1
+; COLOR_BTNFACE = 15
+; COLOR_BTNHIGHLIGHT = 20
+; COLOR_BTNHILIGHT = 20
+; COLOR_BTNSHADOW = 16
+; COLOR_BTNTEXT = 18
+; COLOR_CAPTIONTEXT = 9
+; COLOR_DESKTOP = 1
+; COLOR_GRADIENTACTIVECAPTION = 27
+; COLOR_GRADIENTINACTIVECAPTION = 28
+; COLOR_GRAYTEXT = 17
+; COLOR_HIGHLIGHT = 13
+; COLOR_HIGHLIGHTTEXT = 14
+; COLOR_HOTLIGHT = 26
+; COLOR_INACTIVEBORDER = 11
+; COLOR_INACTIVECAPTION = 3
+; COLOR_INACTIVECAPTIONTEXT = 19
+; COLOR_INFOBK = 24
+; COLOR_INFOTEXT = 23
+; COLOR_MENU = 4
+; COLOR_MENUHILIGHT = 29
+; COLOR_MENUBAR = 30
+; COLOR_MENUTEXT = 7
+; COLOR_SCROLLBAR = 0
+; COLOR_WINDOW = 5
+; COLOR_WINDOWFRAME = 6
+; COLOR_WINDOWTEXT = 8
+
+SetSysColorToControl(hwnd, SysColor=15)
+{
+ WinGetPos,,, w, h, ahk_id %hwnd%
+ bc := DllCall("GetSysColor", "Int", SysColor, "UInt")
+ pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc >> 16 | bc & 0xff00 | (bc & 0xff) << 16))
+ pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap)
+ Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h)
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ SetImage(hwnd, hBitmap)
+ Gdip_DeleteBrush(pBrushClear)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap)
+ return 0
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromScreen
+; Description Gets a gdi+ bitmap from the screen
+;
+; Screen 0 = All screens
+; Any numerical value = Just that screen
+; x|y|w|h = Take specific coordinates with a width and height
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1: one or more of x,y,w,h not passed properly
+;
+; notes If no raster operation is specified, then SRCCOPY is used to the returned bitmap
+
+Gdip_BitmapFromScreen(Screen=0, Raster="")
+{
+ if (Screen = 0)
+ {
+ Sysget, x, 76
+ Sysget, y, 77
+ Sysget, w, 78
+ Sysget, h, 79
+ }
+ else if (SubStr(Screen, 1, 5) = "hwnd:")
+ {
+ Screen := SubStr(Screen, 6)
+ if !WinExist( "ahk_id " Screen)
+ return -2
+ WinGetPos,,, w, h, ahk_id %Screen%
+ x := y := 0
+ hhdc := GetDCEx(Screen, 3)
+ }
+ else if (Screen&1 != "")
+ {
+ Sysget, M, Monitor, %Screen%
+ x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
+ }
+ else
+ {
+ StringSplit, S, Screen, |
+ x := S1, y := S2, w := S3, h := S4
+ }
+
+ if (x = "") || (y = "") || (w = "") || (h = "")
+ return -1
+
+ chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
+ BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
+ ReleaseDC(hhdc)
+
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromHWND
+; Description Uses PrintWindow to get a handle to the specified window and return a bitmap from it
+;
+; hwnd handle to the window to get a bitmap from
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+;
+; notes Window must not be not minimised in order to get a handle to it's client area
+
+Gdip_BitmapFromHWND(hwnd)
+{
+ WinGetPos,,, Width, Height, ahk_id %hwnd%
+ hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ PrintWindow(hwnd, hdc)
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function CreateRectF
+; Description Creates a RectF object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+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")
+}
+
+;#####################################################################################
+
+; Function CreateRect
+; Description Creates a Rect object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+CreateRect(ByRef Rect, x, y, w, h)
+{
+ VarSetCapacity(Rect, 16)
+ NumPut(x, Rect, 0, "uint"), NumPut(y, Rect, 4, "uint"), NumPut(w, Rect, 8, "uint"), NumPut(h, Rect, 12, "uint")
+}
+;#####################################################################################
+
+; Function CreateSizeF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreateSizeF(ByRef SizeF, w, h)
+{
+ VarSetCapacity(SizeF, 8)
+ NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreatePointF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreatePointF(ByRef PointF, x, y)
+{
+ VarSetCapacity(PointF, 8)
+ NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreateDIBSection
+; Description The CreateDIBSection function creates a DIB (Device Independent Bitmap) that applications can write to directly
+;
+; w width of the bitmap to create
+; h height of the bitmap to create
+; hdc a handle to the device context to use the palette from
+; bpp bits per pixel (32 = ARGB)
+; ppvBits A pointer to a variable that receives a pointer to the location of the DIB bit values
+;
+; return returns a DIB. A gdi bitmap
+;
+; notes ppvBits will receive the location of the pixels in the DIB
+
+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
+}
+
+;#####################################################################################
+
+; Function PrintWindow
+; Description The PrintWindow function copies a visual window into the specified device context (DC), typically a printer DC
+;
+; hwnd A handle to the window that will be copied
+; hdc A handle to the device context
+; Flags Drawing options
+;
+; return If the function succeeds, it returns a nonzero value
+;
+; PW_CLIENTONLY = 1
+
+PrintWindow(hwnd, hdc, Flags=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("PrintWindow", Ptr, hwnd, Ptr, hdc, "uint", Flags)
+}
+
+;#####################################################################################
+
+; Function DestroyIcon
+; Description Destroys an icon and frees any memory the icon occupied
+;
+; hIcon Handle to the icon to be destroyed. The icon must not be in use
+;
+; return If the function succeeds, the return value is nonzero
+
+DestroyIcon(hIcon)
+{
+ return DllCall("DestroyIcon", A_PtrSize ? "UPtr" : "UInt", hIcon)
+}
+
+;#####################################################################################
+
+PaintDesktop(hdc)
+{
+ return DllCall("PaintDesktop", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+CreateCompatibleBitmap(hdc, w, h)
+{
+ return DllCall("gdi32\CreateCompatibleBitmap", A_PtrSize ? "UPtr" : "UInt", hdc, "int", w, "int", h)
+}
+
+;#####################################################################################
+
+; Function CreateCompatibleDC
+; Description This function creates a memory device context (DC) compatible with the specified device
+;
+; hdc Handle to an existing device context
+;
+; return returns the handle to a device context or 0 on failure
+;
+; notes If this handle is 0 (by default), the function creates a memory device context compatible with the application's current screen
+
+CreateCompatibleDC(hdc=0)
+{
+ return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+; Function SelectObject
+; Description The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type
+;
+; hdc Handle to a DC
+; hgdiobj A handle to the object to be selected into the DC
+;
+; return If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced
+;
+; notes The specified object must have been created by using one of the following functions
+; Bitmap - CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection (A single bitmap cannot be selected into more than one DC at the same time)
+; Brush - CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush
+; Font - CreateFont, CreateFontIndirect
+; Pen - CreatePen, CreatePenIndirect
+; Region - CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirect
+;
+; notes If the selected object is a region and the function succeeds, the return value is one of the following value
+;
+; SIMPLEREGION = 2 Region consists of a single rectangle
+; COMPLEXREGION = 3 Region consists of more than one rectangle
+; NULLREGION = 1 Region is empty
+
+SelectObject(hdc, hgdiobj)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
+}
+
+;#####################################################################################
+
+; Function DeleteObject
+; Description This function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object
+; After the object is deleted, the specified handle is no longer valid
+;
+; hObject Handle to a logical pen, brush, font, bitmap, region, or palette to delete
+;
+; return Nonzero indicates success. Zero indicates that the specified handle is not valid or that the handle is currently selected into a device context
+
+DeleteObject(hObject)
+{
+ return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject)
+}
+
+;#####################################################################################
+
+; Function GetDC
+; Description This function retrieves a handle to a display device context (DC) for the client area of the specified window.
+; The display device context can be used in subsequent graphics display interface (GDI) functions to draw in the client area of the window.
+;
+; hwnd Handle to the window whose device context is to be retrieved. If this value is NULL, GetDC retrieves the device context for the entire screen
+;
+; return The handle the device context for the specified window's client area indicates success. NULL indicates failure
+
+GetDC(hwnd=0)
+{
+ return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
+}
+
+;#####################################################################################
+
+; DCX_CACHE = 0x2
+; DCX_CLIPCHILDREN = 0x8
+; DCX_CLIPSIBLINGS = 0x10
+; DCX_EXCLUDERGN = 0x40
+; DCX_EXCLUDEUPDATE = 0x100
+; DCX_INTERSECTRGN = 0x80
+; DCX_INTERSECTUPDATE = 0x200
+; DCX_LOCKWINDOWUPDATE = 0x400
+; DCX_NORECOMPUTE = 0x100000
+; DCX_NORESETATTRS = 0x4
+; DCX_PARENTCLIP = 0x20
+; DCX_VALIDATE = 0x200000
+; DCX_WINDOW = 0x1
+
+GetDCEx(hwnd, flags=0, hrgnClip=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("GetDCEx", Ptr, hwnd, Ptr, hrgnClip, "int", flags)
+}
+
+;#####################################################################################
+
+; Function ReleaseDC
+; Description This function releases a device context (DC), freeing it for use by other applications. The effect of ReleaseDC depends on the type of device context
+;
+; hdc Handle to the device context to be released
+; hwnd Handle to the window whose device context is to be released
+;
+; return 1 = released
+; 0 = not released
+;
+; notes The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common device context
+; An application cannot use the ReleaseDC function to release a device context that was created by calling the CreateDC function; instead, it must use the DeleteDC function.
+
+ReleaseDC(hdc, hwnd=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function DeleteDC
+; Description The DeleteDC function deletes the specified device context (DC)
+;
+; hdc A handle to the device context
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC
+
+DeleteDC(hdc)
+{
+ return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+;#####################################################################################
+
+; Function Gdip_LibraryVersion
+; Description Get the current library version
+;
+; return the library version
+;
+; notes This is useful for non compiled programs to ensure that a person doesn't run an old version when testing your scripts
+
+Gdip_LibraryVersion()
+{
+ return 1.45
+}
+
+;#####################################################################################
+
+; Function: Gdip_BitmapFromBRA
+; Description: Gets a pointer to a gdi+ bitmap from a BRA file
+;
+; BRAFromMemIn The variable for a BRA file read to memory
+; File The name of the file, or its number that you would like (This depends on alternate parameter)
+; Alternate Changes whether the File parameter is the file name or its number
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1 = The BRA variable is empty
+; -2 = The BRA has an incorrect header
+; -3 = The BRA has information missing
+; -4 = Could not find file inside the BRA
+
+Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate=0)
+{
+ Static FName = "ObjRelease"
+
+ if !BRAFromMemIn
+ return -1
+ Loop, Parse, BRAFromMemIn, `n
+ {
+ if (A_Index = 1)
+ {
+ StringSplit, Header, A_LoopField, |
+ if (Header0 != 4 || Header2 != "BRA!")
+ return -2
+ }
+ else if (A_Index = 2)
+ {
+ StringSplit, Info, A_LoopField, |
+ if (Info0 != 3)
+ return -3
+ }
+ else
+ break
+ }
+ if !Alternate
+ StringReplace, File, File, \, \\, All
+ RegExMatch(BRAFromMemIn, "mi`n)^" (Alternate ? File "\|.+?\|(\d+)\|(\d+)" : "\d+\|" File "\|(\d+)\|(\d+)") "$", FileInfo)
+ if !FileInfo
+ return -4
+
+ hData := DllCall("GlobalAlloc", "uint", 2, Ptr, FileInfo2, Ptr)
+ pData := DllCall("GlobalLock", Ptr, hData, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pData, Ptr, &BRAFromMemIn+Info2+FileInfo1, Ptr, FileInfo2)
+ DllCall("GlobalUnlock", Ptr, hData)
+ DllCall("ole32\CreateStreamOnHGlobal", Ptr, hData, "int", 1, A_PtrSize ? "UPtr*" : "UInt*", pStream)
+ DllCall("gdiplus\GdipCreateBitmapFromStream", Ptr, pStream, A_PtrSize ? "UPtr*" : "UInt*", pBitmap)
+ If (A_PtrSize)
+ %FName%(pStream)
+ Else
+ DllCall(NumGet(NumGet(1*pStream)+8), "uint", pStream)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRectangle
+; Description This function uses a pen to draw the outline of a rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRoundedRectangle
+; Description This function uses a pen to draw the outline of a rounded rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawEllipse
+; Description This function uses a pen to draw the outline of an ellipse into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle the ellipse will be drawn into
+; y y-coordinate of the top left of the rectangle the ellipse will be drawn into
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawBezier
+; Description This function uses a pen to draw the outline of a bezier (a weighted curve) into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the bezier
+; y1 y-coordinate of the start of the bezier
+; x2 x-coordinate of the first arc of the bezier
+; y2 y-coordinate of the first arc of the bezier
+; x3 x-coordinate of the second arc of the bezier
+; y3 y-coordinate of the second arc of the bezier
+; x4 x-coordinate of the end of the bezier
+; y4 y-coordinate of the end of the bezier
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawBezier"
+ , Ptr, pgraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2
+ , "float", x3
+ , "float", y3
+ , "float", x4
+ , "float", y4)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawArc
+; Description This function uses a pen to draw the outline of an arc into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the arc
+; y y-coordinate of the start of the arc
+; w width of the arc
+; h height of the arc
+; StartAngle specifies the angle between the x-axis and the starting point of the arc
+; SweepAngle specifies the angle between the starting and ending points of the arc
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawArc"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawPie
+; Description This function uses a pen to draw the outline of a pie into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the pie
+; y y-coordinate of the start of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawPie", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLine
+; Description This function uses a pen to draw a line into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the line
+; y1 y-coordinate of the start of the line
+; x2 x-coordinate of the end of the line
+; y2 y-coordinate of the end of the line
+;
+; return status enumeration. 0 = success
+
+Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawLine"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLines
+; Description This function uses a pen to draw a series of joined lines into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRectangle
+; Description This function uses a brush to fill a rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRoundedRectangle
+; Description This function uses a brush to fill a rounded rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPolygon
+; Description This function uses a brush to fill a polygon in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+;
+; notes Alternate will fill the polygon as a whole, wheras winding will fill each new "segment"
+; Alternate = 0
+; Winding = 1
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPie
+; Description This function uses a brush to fill a pie in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the pie
+; y y-coordinate of the top left of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPie"
+ , Ptr, pGraphics
+ , Ptr, pBrush
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillEllipse
+; Description This function uses a brush to fill an ellipse in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the ellipse
+; y y-coordinate of the top left of the ellipse
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRegion
+; Description This function uses a brush to fill a region in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Region
+;
+; return status enumeration. 0 = success
+;
+; notes You can create a region Gdip_CreateRegion() and then add to this
+
+Gdip_FillRegion(pGraphics, pBrush, Region)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillRegion", Ptr, pGraphics, Ptr, pBrush, Ptr, Region)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPath
+; Description This function uses a brush to fill a path in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Path
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPath(pGraphics, pBrush, Path)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPath", Ptr, pGraphics, Ptr, pBrush, Ptr, Path)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImagePointsRect
+; Description This function draws a bitmap into the Graphics of another bitmap and skews it
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; Points Points passed as x1,y1|x2,y2|x3,y3 (3 points: top left, top right, bottom left) describing the drawing of the bitmap
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter
+
+Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1)
+{
+ 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")
+ }
+
+ 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 = "")
+ {
+ sx := 0, sy := 0
+ sw := Gdip_GetImageWidth(pBitmap)
+ sh := Gdip_GetImageHeight(pBitmap)
+ }
+
+ E := DllCall("gdiplus\GdipDrawImagePointsRect"
+ , Ptr, pGraphics
+ , Ptr, pBitmap
+ , Ptr, &PointF
+ , "int", Points0
+ , "float", sx
+ , "float", sy
+ , "float", sw
+ , "float", sh
+ , "int", 2
+ , Ptr, ImageAttr
+ , Ptr, 0
+ , Ptr, 0)
+ if ImageAttr
+ Gdip_DisposeImageAttributes(ImageAttr)
+ return E
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImage
+; Description This function draws a bitmap into the Graphics of another bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination image
+; dh height of destination image
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source image
+; sh height of source image
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Gdip_DrawImage performs faster
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter. For example:
+; MatrixBright=
+; (
+; 1.5 |0 |0 |0 |0
+; 0 |1.5 |0 |0 |0
+; 0 |0 |1.5 |0 |0
+; 0 |0 |0 |1 |0
+; 0.05 |0.05 |0.05 |0 |1
+; )
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_SetImageAttributesColorMatrix
+; Description This function creates an image matrix ready for drawing
+;
+; Matrix a matrix used to alter image attributes when drawing
+; passed with any delimeter
+;
+; return returns an image matrix on sucess or 0 if it fails
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromImage
+; Description This function gets the graphics for a bitmap used for drawing functions
+;
+; pBitmap Pointer to a bitmap to get the pointer to its graphics
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes a bitmap can be drawn into the graphics of another bitmap
+
+Gdip_GraphicsFromImage(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromHDC
+; Description This function gets the graphics from the handle to a device context
+;
+; hdc This is the handle to the device context
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes You can draw a bitmap into the graphics of another bitmap
+
+Gdip_GraphicsFromHDC(hdc)
+{
+ DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDC
+; Description This function gets the device context of the passed Graphics
+;
+; hdc This is the handle to the device context
+;
+; return returns the device context for the graphics of a bitmap
+
+Gdip_GetDC(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDC", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", hdc)
+ return hdc
+}
+
+;#####################################################################################
+
+; Function Gdip_ReleaseDC
+; Description This function releases a device context from use for further use
+;
+; pGraphics Pointer to the graphics of a bitmap
+; hdc This is the handle to the device context
+;
+; return status enumeration. 0 = success
+
+Gdip_ReleaseDC(pGraphics, hdc)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipReleaseDC", Ptr, pGraphics, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsClear
+; Description Clears the graphics of a bitmap ready for further drawing
+;
+; pGraphics Pointer to the graphics of a bitmap
+; ARGB The colour to clear the graphics to
+;
+; return status enumeration. 0 = success
+;
+; notes By default this will make the background invisible
+; Using clipping regions you can clear a particular area on the graphics rather than clearing the entire graphics
+
+Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff)
+{
+ return DllCall("gdiplus\GdipGraphicsClear", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_BlurBitmap
+; Description Gives a pointer to a blurred bitmap from a pointer to a bitmap
+;
+; pBitmap Pointer to a bitmap to be blurred
+; Blur The Amount to blur a bitmap by from 1 (least blur) to 100 (most blur)
+;
+; return If the function succeeds, the return value is a pointer to the new blurred bitmap
+; -1 = The blur parameter is outside the range 1-100
+;
+; notes This function will not dispose of the original bitmap
+
+Gdip_BlurBitmap(pBitmap, Blur)
+{
+ if (Blur > 100) || (Blur < 1)
+ return -1
+
+ sWidth := Gdip_GetImageWidth(pBitmap), sHeight := Gdip_GetImageHeight(pBitmap)
+ dWidth := sWidth//Blur, dHeight := sHeight//Blur
+
+ pBitmap1 := Gdip_CreateBitmap(dWidth, dHeight)
+ G1 := Gdip_GraphicsFromImage(pBitmap1)
+ Gdip_SetInterpolationMode(G1, 7)
+ Gdip_DrawImage(G1, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight)
+
+ Gdip_DeleteGraphics(G1)
+
+ pBitmap2 := Gdip_CreateBitmap(sWidth, sHeight)
+ G2 := Gdip_GraphicsFromImage(pBitmap2)
+ Gdip_SetInterpolationMode(G2, 7)
+ Gdip_DrawImage(G2, pBitmap1, 0, 0, sWidth, sHeight, 0, 0, dWidth, dHeight)
+
+ Gdip_DeleteGraphics(G2)
+ Gdip_DisposeImage(pBitmap1)
+ return pBitmap2
+}
+
+;#####################################################################################
+
+; Function: Gdip_SaveBitmapToFile
+; Description: Saves a bitmap to a file in any supported format onto disk
+;
+; pBitmap Pointer to a bitmap
+; sOutput The name of the file that the bitmap will be saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG
+; Quality If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality
+;
+; return If the function succeeds, the return value is zero, otherwise:
+; -1 = Extension supplied is not a supported file format
+; -2 = Could not get a list of encoders on system
+; -3 = Could not find matching encoder for specified file format
+; -4 = Could not get WideChar name of output file
+; -5 = Could not save file to disk
+;
+; notes This function will use the extension supplied from the sOutput parameter to determine the output format
+
+Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=75)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ SplitPath, sOutput,,, Extension
+ if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
+ return -1
+ Extension := "." Extension
+
+ DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
+ VarSetCapacity(ci, nSize)
+ DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
+ if !(nCount && nSize)
+ return -2
+
+ If (A_IsUnicode){
+ StrGet_Name := "StrGet"
+ Loop, %nCount%
+ {
+ sString := %StrGet_Name%(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
+ }
+ } else {
+ Loop, %nCount%
+ {
+ Location := NumGet(ci, 76*(A_Index-1)+44)
+ nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(sString, nSize)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0)
+ if !InStr(sString, "*" Extension)
+ continue
+
+ pCodec := &ci+76*(A_Index-1)
+ 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
+ }
+ }
+ }
+ }
+
+ if (!A_IsUnicode)
+ {
+ nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, 0, "int", 0)
+ VarSetCapacity(wOutput, nSize*2)
+ DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, &wOutput, "int", nSize)
+ VarSetCapacity(wOutput, -1)
+ if !VarSetCapacity(wOutput)
+ return -4
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &wOutput, Ptr, pCodec, "uint", p ? p : 0)
+ }
+ else
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &sOutput, Ptr, pCodec, "uint", p ? p : 0)
+ return E ? -5 : 0
+}
+
+;#####################################################################################
+
+; Function Gdip_GetPixel
+; Description Gets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return Returns the ARGB value of the pixel
+
+Gdip_GetPixel(pBitmap, x, y)
+{
+ DllCall("gdiplus\GdipBitmapGetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "uint*", ARGB)
+ return ARGB
+}
+
+;#####################################################################################
+
+; Function Gdip_SetPixel
+; Description Sets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return status enumeration. 0 = success
+
+Gdip_SetPixel(pBitmap, x, y, ARGB)
+{
+ return DllCall("gdiplus\GdipBitmapSetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageWidth
+; Description Gives the width of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the width in pixels of the supplied bitmap
+
+Gdip_GetImageWidth(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width)
+ return Width
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageHeight
+; Description Gives the height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the height in pixels of the supplied bitmap
+
+Gdip_GetImageHeight(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height)
+ return Height
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDimensions
+; Description Gives the width and height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetImageDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ DllCall("gdiplus\GdipGetImageWidth", Ptr, pBitmap, "uint*", Width)
+ DllCall("gdiplus\GdipGetImageHeight", Ptr, pBitmap, "uint*", Height)
+}
+
+;#####################################################################################
+
+Gdip_GetDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+}
+
+;#####################################################################################
+
+Gdip_GetImagePixelFormat(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImagePixelFormat", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", Format)
+ return Format
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDpiX
+; Description Gives the horizontal dots per inch of the graphics of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetDpiX(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiX", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetDpiY(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiY", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_GetImageHorizontalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHorizontalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetImageVerticalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageVerticalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_BitmapSetResolution(pBitmap, dpix, dpiy)
+{
+ return DllCall("gdiplus\GdipBitmapSetResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float", dpix, "float", dpiy)
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromFile(sFile, IconNumber=1, IconSize="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ SplitPath, sFile,,, ext
+ if ext in exe,dll
+ {
+ Sizes := IconSize ? IconSize : 256 "|" 128 "|" 64 "|" 48 "|" 32 "|" 16
+ BufSize := 16 + (2*(A_PtrSize ? A_PtrSize : 4))
+
+ VarSetCapacity(buf, BufSize, 0)
+ Loop, Parse, Sizes, |
+ {
+ DllCall("PrivateExtractIcons", "str", sFile, "int", IconNumber-1, "int", A_LoopField, "int", A_LoopField, PtrA, hIcon, PtrA, 0, "uint", 1, "uint", 0)
+
+ if !hIcon
+ continue
+
+ if !DllCall("GetIconInfo", Ptr, hIcon, Ptr, &buf)
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+
+ hbmMask := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4))
+ hbmColor := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4) + (A_PtrSize ? A_PtrSize : 4))
+ if !(hbmColor && DllCall("GetObject", Ptr, hbmColor, "int", BufSize, Ptr, &buf))
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+ break
+ }
+ if !hIcon
+ return -1
+
+ Width := NumGet(buf, 4, "int"), Height := NumGet(buf, 8, "int")
+ hbm := CreateDIBSection(Width, -Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ if !DllCall("DrawIconEx", Ptr, hdc, "int", 0, "int", 0, Ptr, hIcon, "uint", Width, "uint", Height, "uint", 0, Ptr, 0, "uint", 3)
+ {
+ DestroyIcon(hIcon)
+ return -2
+ }
+
+ VarSetCapacity(dib, 104)
+ DllCall("GetObject", Ptr, hbm, "int", A_PtrSize = 8 ? 104 : 84, Ptr, &dib) ; sizeof(DIBSECTION) = 76+2*(A_PtrSize=8?4:0)+2*A_PtrSize
+ Stride := NumGet(dib, 12, "Int"), Bits := NumGet(dib, 20 + (A_PtrSize = 8 ? 4 : 0)) ; padding
+ DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", Stride, "int", 0x26200A, Ptr, Bits, PtrA, pBitmapOld)
+ pBitmap := Gdip_CreateBitmap(Width, Height)
+ G := Gdip_GraphicsFromImage(pBitmap)
+ , Gdip_DrawImage(G, pBitmapOld, 0, 0, Width, Height, 0, 0, Width, Height)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapOld)
+ DestroyIcon(hIcon)
+ }
+ else
+ {
+ if (!A_IsUnicode)
+ {
+ VarSetCapacity(wFile, 1024)
+ DllCall("kernel32\MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sFile, "int", -1, Ptr, &wFile, "int", 512)
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &wFile, PtrA, pBitmap)
+ }
+ else
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &sFile, PtrA, pBitmap)
+ }
+
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", Ptr, hBitmap, Ptr, Palette, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff)
+{
+ DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hbm, "int", Background)
+ return hbm
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHICON(hIcon)
+{
+ DllCall("gdiplus\GdipCreateBitmapFromHICON", A_PtrSize ? "UPtr" : "UInt", hIcon, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHICONFromBitmap(pBitmap)
+{
+ DllCall("gdiplus\GdipCreateHICONFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hIcon)
+ return hIcon
+}
+
+;#####################################################################################
+
+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_CreateBitmapFromClipboard()
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if !DllCall("OpenClipboard", Ptr, 0)
+ return -1
+ if !DllCall("IsClipboardFormatAvailable", "uint", 8)
+ return -2
+ if !hBitmap := DllCall("GetClipboardData", "uint", 2, Ptr)
+ return -3
+ if !pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap)
+ return -4
+ if !DllCall("CloseClipboard")
+ return -5
+ DeleteObject(hBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_SetBitmapToClipboard(pBitmap)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ off1 := A_PtrSize = 8 ? 52 : 44, off2 := A_PtrSize = 8 ? 32 : 24
+
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ DllCall("GetObject", Ptr, hBitmap, "int", VarSetCapacity(oi, A_PtrSize = 8 ? 96 : 84, 0), Ptr, &oi)
+ hdib := DllCall("GlobalAlloc", "uint", 2, Ptr, off1+NumGet(oi, off1, "UInt")-4, Ptr)
+ pdib := DllCall("GlobalLock", Ptr, hdib, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pdib, "uint", &oi+off2, Ptr, 40)
+ DllCall("RtlMoveMemory", Ptr, pdib+40, Ptr, NumGet(oi, off2 - (A_PtrSize ? A_PtrSize : 4)), Ptr, NumGet(oi, off1, "UInt"))
+ DllCall("GlobalUnlock", Ptr, hdib)
+ DllCall("DeleteObject", Ptr, hBitmap)
+ DllCall("OpenClipboard", Ptr, 0)
+ DllCall("EmptyClipboard")
+ DllCall("SetClipboardData", "uint", 8, Ptr, hdib)
+ DllCall("CloseClipboard")
+}
+
+;#####################################################################################
+
+Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format=0x26200A)
+{
+ DllCall("gdiplus\GdipCloneBitmapArea"
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "int", Format
+ , A_PtrSize ? "UPtr" : "UInt", pBitmap
+ , A_PtrSize ? "UPtr*" : "UInt*", pBitmapDest)
+ return pBitmapDest
+}
+
+;#####################################################################################
+; Create resources
+;#####################################################################################
+
+Gdip_CreatePen(ARGB, w)
+{
+ DllCall("gdiplus\GdipCreatePen1", "UInt", ARGB, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_CreatePenFromBrush(pBrush, w)
+{
+ DllCall("gdiplus\GdipCreatePen2", A_PtrSize ? "UPtr" : "UInt", pBrush, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_BrushCreateSolid(ARGB=0xff000000)
+{
+ DllCall("gdiplus\GdipCreateSolidFill", "UInt", ARGB, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; HatchStyleHorizontal = 0
+; HatchStyleVertical = 1
+; HatchStyleForwardDiagonal = 2
+; HatchStyleBackwardDiagonal = 3
+; HatchStyleCross = 4
+; HatchStyleDiagonalCross = 5
+; HatchStyle05Percent = 6
+; HatchStyle10Percent = 7
+; HatchStyle20Percent = 8
+; HatchStyle25Percent = 9
+; HatchStyle30Percent = 10
+; HatchStyle40Percent = 11
+; HatchStyle50Percent = 12
+; HatchStyle60Percent = 13
+; HatchStyle70Percent = 14
+; HatchStyle75Percent = 15
+; HatchStyle80Percent = 16
+; HatchStyle90Percent = 17
+; HatchStyleLightDownwardDiagonal = 18
+; HatchStyleLightUpwardDiagonal = 19
+; HatchStyleDarkDownwardDiagonal = 20
+; HatchStyleDarkUpwardDiagonal = 21
+; HatchStyleWideDownwardDiagonal = 22
+; HatchStyleWideUpwardDiagonal = 23
+; HatchStyleLightVertical = 24
+; HatchStyleLightHorizontal = 25
+; HatchStyleNarrowVertical = 26
+; HatchStyleNarrowHorizontal = 27
+; HatchStyleDarkVertical = 28
+; HatchStyleDarkHorizontal = 29
+; HatchStyleDashedDownwardDiagonal = 30
+; HatchStyleDashedUpwardDiagonal = 31
+; HatchStyleDashedHorizontal = 32
+; HatchStyleDashedVertical = 33
+; HatchStyleSmallConfetti = 34
+; HatchStyleLargeConfetti = 35
+; HatchStyleZigZag = 36
+; HatchStyleWave = 37
+; HatchStyleDiagonalBrick = 38
+; HatchStyleHorizontalBrick = 39
+; HatchStyleWeave = 40
+; HatchStylePlaid = 41
+; HatchStyleDivot = 42
+; HatchStyleDottedGrid = 43
+; HatchStyleDottedDiamond = 44
+; HatchStyleShingle = 45
+; HatchStyleTrellis = 46
+; HatchStyleSphere = 47
+; HatchStyleSmallGrid = 48
+; HatchStyleSmallCheckerBoard = 49
+; HatchStyleLargeCheckerBoard = 50
+; HatchStyleOutlinedDiamond = 51
+; HatchStyleSolidDiamond = 52
+; HatchStyleTotal = 53
+Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0)
+{
+ DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "UInt", ARGBfront, "UInt", ARGBback, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+Gdip_CreateTextureBrush(pBitmap, WrapMode=1, x=0, y=0, w="", h="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ if !(w && h)
+ DllCall("gdiplus\GdipCreateTexture", Ptr, pBitmap, "int", WrapMode, PtrA, pBrush)
+ else
+ DllCall("gdiplus\GdipCreateTexture2", Ptr, pBitmap, "int", WrapMode, "float", x, "float", y, "float", w, "float", h, PtrA, pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; WrapModeTile = 0
+; WrapModeTileFlipX = 1
+; WrapModeTileFlipY = 2
+; WrapModeTileFlipXY = 3
+; WrapModeClamp = 4
+Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2)
+ DllCall("gdiplus\GdipCreateLineBrush", Ptr, &PointF1, Ptr, &PointF2, "Uint", ARGB1, "Uint", ARGB2, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
+ return LGpBrush
+}
+
+;#####################################################################################
+
+; LinearGradientModeHorizontal = 0
+; LinearGradientModeVertical = 1
+; LinearGradientModeForwardDiagonal = 2
+; LinearGradientModeBackwardDiagonal = 3
+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_CloneBrush(pBrush)
+{
+ DllCall("gdiplus\GdipCloneBrush", A_PtrSize ? "UPtr" : "UInt", pBrush, A_PtrSize ? "UPtr*" : "UInt*", pBrushClone)
+ return pBrushClone
+}
+
+;#####################################################################################
+; Delete resources
+;#####################################################################################
+
+Gdip_DeletePen(pPen)
+{
+ return DllCall("gdiplus\GdipDeletePen", A_PtrSize ? "UPtr" : "UInt", pPen)
+}
+
+;#####################################################################################
+
+Gdip_DeleteBrush(pBrush)
+{
+ return DllCall("gdiplus\GdipDeleteBrush", A_PtrSize ? "UPtr" : "UInt", pBrush)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImage(pBitmap)
+{
+ return DllCall("gdiplus\GdipDisposeImage", A_PtrSize ? "UPtr" : "UInt", pBitmap)
+}
+
+;#####################################################################################
+
+Gdip_DeleteGraphics(pGraphics)
+{
+ return DllCall("gdiplus\GdipDeleteGraphics", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImageAttributes(ImageAttr)
+{
+ return DllCall("gdiplus\GdipDisposeImageAttributes", A_PtrSize ? "UPtr" : "UInt", ImageAttr)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFont(hFont)
+{
+ return DllCall("gdiplus\GdipDeleteFont", A_PtrSize ? "UPtr" : "UInt", hFont)
+}
+
+;#####################################################################################
+
+Gdip_DeleteStringFormat(hFormat)
+{
+ return DllCall("gdiplus\GdipDeleteStringFormat", A_PtrSize ? "UPtr" : "UInt", hFormat)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFontFamily(hFamily)
+{
+ return DllCall("gdiplus\GdipDeleteFontFamily", A_PtrSize ? "UPtr" : "UInt", hFamily)
+}
+
+;#####################################################################################
+
+Gdip_DeleteMatrix(Matrix)
+{
+ return DllCall("gdiplus\GdipDeleteMatrix", A_PtrSize ? "UPtr" : "UInt", Matrix)
+}
+
+;#####################################################################################
+; Text functions
+;#####################################################################################
+
+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_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_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
+}
+
+; Near = 0
+; Center = 1
+; Far = 2
+Gdip_SetStringFormatAlign(hFormat, Align)
+{
+ return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align)
+}
+
+; StringFormatFlagsDirectionRightToLeft = 0x00000001
+; StringFormatFlagsDirectionVertical = 0x00000002
+; StringFormatFlagsNoFitBlackBox = 0x00000004
+; StringFormatFlagsDisplayFormatControl = 0x00000020
+; StringFormatFlagsNoFontFallback = 0x00000400
+; StringFormatFlagsMeasureTrailingSpaces = 0x00000800
+; StringFormatFlagsNoWrap = 0x00001000
+; StringFormatFlagsLineLimit = 0x00002000
+; StringFormatFlagsNoClip = 0x00004000
+Gdip_StringFormatCreate(Format=0, Lang=0)
+{
+ DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat)
+ return hFormat
+}
+
+; Regular = 0
+; Bold = 1
+; Italic = 2
+; BoldItalic = 3
+; Underline = 4
+; Strikeout = 8
+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
+}
+
+;#####################################################################################
+; Matrix functions
+;#####################################################################################
+
+Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y)
+{
+ DllCall("gdiplus\GdipCreateMatrix2", "float", m11, "float", m12, "float", m21, "float", m22, "float", x, "float", y, A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+Gdip_CreateMatrix()
+{
+ DllCall("gdiplus\GdipCreateMatrix", A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+;#####################################################################################
+; GraphicsPath functions
+;#####################################################################################
+
+; Alternate = 0
+; Winding = 1
+Gdip_CreatePath(BrushMode=0)
+{
+ DllCall("gdiplus\GdipCreatePath", "int", BrushMode, A_PtrSize ? "UPtr*" : "UInt*", Path)
+ return Path
+}
+
+Gdip_AddPathEllipse(Path, x, y, w, h)
+{
+ return DllCall("gdiplus\GdipAddPathEllipse", A_PtrSize ? "UPtr" : "UInt", Path, "float", x, "float", y, "float", w, "float", h)
+}
+
+Gdip_AddPathPolygon(Path, 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\GdipAddPathPolygon", Ptr, Path, Ptr, &PointF, "int", Points0)
+}
+
+Gdip_DeletePath(Path)
+{
+ return DllCall("gdiplus\GdipDeletePath", A_PtrSize ? "UPtr" : "UInt", Path)
+}
+
+;#####################################################################################
+; Quality functions
+;#####################################################################################
+
+; SystemDefault = 0
+; SingleBitPerPixelGridFit = 1
+; SingleBitPerPixel = 2
+; AntiAliasGridFit = 3
+; AntiAlias = 4
+Gdip_SetTextRenderingHint(pGraphics, RenderingHint)
+{
+ return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint)
+}
+
+; Default = 0
+; LowQuality = 1
+; HighQuality = 2
+; Bilinear = 3
+; Bicubic = 4
+; NearestNeighbor = 5
+; HighQualityBilinear = 6
+; HighQualityBicubic = 7
+Gdip_SetInterpolationMode(pGraphics, InterpolationMode)
+{
+ return DllCall("gdiplus\GdipSetInterpolationMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", InterpolationMode)
+}
+
+; Default = 0
+; HighSpeed = 1
+; HighQuality = 2
+; None = 3
+; AntiAlias = 4
+Gdip_SetSmoothingMode(pGraphics, SmoothingMode)
+{
+ return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
+}
+
+; CompositingModeSourceOver = 0 (blended)
+; CompositingModeSourceCopy = 1 (overwrite)
+Gdip_SetCompositingMode(pGraphics, CompositingMode=0)
+{
+ return DllCall("gdiplus\GdipSetCompositingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", CompositingMode)
+}
+
+;#####################################################################################
+; Extra functions
+;#####################################################################################
+
+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
+}
+
+; Prepend = 0; The new operation is applied before the old operation.
+; Append = 1; The new operation is applied after the old operation.
+Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipRotateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", Angle, "int", MatrixOrder)
+}
+
+Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipScaleWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipTranslateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_ResetWorldTransform(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetRotatedTranslation(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+
+ Bound := (Angle >= 0) ? Mod(Angle, 360) : 360-Mod(-Angle, -360)
+ if ((Bound >= 0) && (Bound <= 90))
+ xTranslation := Height*Sin(TAngle), yTranslation := 0
+ else if ((Bound > 90) && (Bound <= 180))
+ xTranslation := (Height*Sin(TAngle))-(Width*Cos(TAngle)), yTranslation := -Height*Cos(TAngle)
+ else if ((Bound > 180) && (Bound <= 270))
+ xTranslation := -(Width*Cos(TAngle)), yTranslation := -(Height*Cos(TAngle))-(Width*Sin(TAngle))
+ else if ((Bound > 270) && (Bound <= 360))
+ xTranslation := 0, yTranslation := -Width*Sin(TAngle)
+}
+
+Gdip_GetRotatedDimensions(Width, Height, Angle, ByRef RWidth, ByRef RHeight)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+ if !(Width && Height)
+ return -1
+ RWidth := Ceil(Abs(Width*Cos(TAngle))+Abs(Height*Sin(TAngle)))
+ RHeight := Ceil(Abs(Width*Sin(TAngle))+Abs(Height*Cos(Tangle)))
+}
+
+; RotateNoneFlipNone = 0
+; Rotate90FlipNone = 1
+; Rotate180FlipNone = 2
+; Rotate270FlipNone = 3
+; RotateNoneFlipX = 4
+; Rotate90FlipX = 5
+; Rotate180FlipX = 6
+; Rotate270FlipX = 7
+; RotateNoneFlipY = Rotate180FlipX
+; Rotate90FlipY = Rotate270FlipX
+; Rotate180FlipY = RotateNoneFlipX
+; Rotate270FlipY = Rotate90FlipX
+; RotateNoneFlipXY = Rotate180FlipNone
+; Rotate90FlipXY = Rotate270FlipNone
+; Rotate180FlipXY = RotateNoneFlipNone
+; Rotate270FlipXY = Rotate90FlipNone
+
+Gdip_ImageRotateFlip(pBitmap, RotateFlipType=1)
+{
+ return DllCall("gdiplus\GdipImageRotateFlip", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", RotateFlipType)
+}
+
+; Replace = 0
+; Intersect = 1
+; Union = 2
+; Xor = 3
+; Exclude = 4
+; Complement = 5
+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_SetClipPath(pGraphics, Path, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ return DllCall("gdiplus\GdipSetClipPath", Ptr, pGraphics, Ptr, Path, "int", CombineMode)
+}
+
+Gdip_ResetClip(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetClipRegion(pGraphics)
+{
+ Region := Gdip_CreateRegion()
+ DllCall("gdiplus\GdipGetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", Region)
+ return Region
+}
+
+Gdip_SetClipRegion(pGraphics, Region, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipSetClipRegion", Ptr, pGraphics, Ptr, Region, "int", CombineMode)
+}
+
+Gdip_CreateRegion()
+{
+ DllCall("gdiplus\GdipCreateRegion", A_PtrSize ? "UPtr*" : "UInt*", Region)
+ return Region
+}
+
+Gdip_DeleteRegion(Region)
+{
+ return DllCall("gdiplus\GdipDeleteRegion", A_PtrSize ? "UPtr" : "UInt", Region)
+}
+
+;#####################################################################################
+; BitmapLockBits
+;#####################################################################################
+
+Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode = 3, PixelFormat = 0x26200a)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreateRect(Rect, x, y, w, h)
+ VarSetCapacity(BitmapData, 16+2*(A_PtrSize ? A_PtrSize : 4), 0)
+ E := DllCall("Gdiplus\GdipBitmapLockBits", Ptr, pBitmap, Ptr, &Rect, "uint", LockMode, "int", PixelFormat, Ptr, &BitmapData)
+ Stride := NumGet(BitmapData, 8, "Int")
+ Scan0 := NumGet(BitmapData, 16, Ptr)
+ return E
+}
+
+;#####################################################################################
+
+Gdip_UnlockBits(pBitmap, ByRef BitmapData)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("Gdiplus\GdipBitmapUnlockBits", Ptr, pBitmap, Ptr, &BitmapData)
+}
+
+;#####################################################################################
+
+Gdip_SetLockBitPixel(ARGB, Scan0, x, y, Stride)
+{
+ Numput(ARGB, Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_GetLockBitPixel(Scan0, x, y, Stride)
+{
+ return NumGet(Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_PixelateBitmap(pBitmap, ByRef pBitmapOut, BlockSize)
+{
+ static PixelateBitmap
+
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if (!PixelateBitmap)
+ {
+ if A_PtrSize != 8 ; x86 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 558BEC83EC3C8B4514538B5D1C99F7FB56578BC88955EC894DD885C90F8E830200008B451099F7FB8365DC008365E000894DC88955F08945E833FF897DD4
+ 397DE80F8E160100008BCB0FAFCB894DCC33C08945F88945FC89451C8945143BD87E608B45088D50028BC82BCA8BF02BF2418945F48B45E02955F4894DC4
+ 8D0CB80FAFCB03CA895DD08BD1895DE40FB64416030145140FB60201451C8B45C40FB604100145FC8B45F40FB604020145F883C204FF4DE475D6034D18FF
+ 4DD075C98B4DCC8B451499F7F98945148B451C99F7F989451C8B45FC99F7F98945FC8B45F899F7F98945F885DB7E648B450C8D50028BC82BCA83C103894D
+ C48BC82BCA41894DF48B4DD48945E48B45E02955E48D0C880FAFCB03CA895DD08BD18BF38A45148B7DC48804178A451C8B7DF488028A45FC8804178A45F8
+ 8B7DE488043A83C2044E75DA034D18FF4DD075CE8B4DCC8B7DD447897DD43B7DE80F8CF2FEFFFF837DF0000F842C01000033C08945F88945FC89451C8945
+ 148945E43BD87E65837DF0007E578B4DDC034DE48B75E80FAF4D180FAFF38B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945CC0F
+ B6440E030145140FB60101451C0FB6440F010145FC8B45F40FB604010145F883C104FF4DCC75D8FF45E4395DE47C9B8B4DF00FAFCB85C9740B8B451499F7
+ F9894514EB048365140033F63BCE740B8B451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB
+ 038975F88975E43BDE7E5A837DF0007E4C8B4DDC034DE48B75E80FAF4D180FAFF38B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955CC8A55
+ 1488540E038A551C88118A55FC88540F018A55F888140183C104FF4DCC75DFFF45E4395DE47CA68B45180145E0015DDCFF4DC80F8594FDFFFF8B451099F7
+ FB8955F08945E885C00F8E450100008B45EC0FAFC38365DC008945D48B45E88945CC33C08945F88945FC89451C8945148945103945EC7E6085DB7E518B4D
+ D88B45080FAFCB034D108D50020FAF4D18034DDC8BF08BF88945F403CA2BF22BFA2955F4895DC80FB6440E030145140FB60101451C0FB6440F010145FC8B
+ 45F40FB604080145F883C104FF4DC875D8FF45108B45103B45EC7CA08B4DD485C9740B8B451499F7F9894514EB048365140033F63BCE740B8B451C99F7F9
+ 89451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975103975EC7E5585DB7E468B4DD88B450C
+ 0FAFCB034D108D50020FAF4D18034DDC8BF08BF803CA2BF22BFA2BC2895DC88A551488540E038A551C88118A55FC88540F018A55F888140183C104FF4DC8
+ 75DFFF45108B45103B45EC7CAB8BC3C1E0020145DCFF4DCC0F85CEFEFFFF8B4DEC33C08945F88945FC89451C8945148945103BC87E6C3945F07E5C8B4DD8
+ 8B75E80FAFCB034D100FAFF30FAF4D188B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945C80FB6440E030145140FB60101451C0F
+ B6440F010145FC8B45F40FB604010145F883C104FF4DC875D833C0FF45108B4DEC394D107C940FAF4DF03BC874068B451499F7F933F68945143BCE740B8B
+ 451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975083975EC7E63EB0233F639
+ 75F07E4F8B4DD88B75E80FAFCB034D080FAFF30FAF4D188B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955108A551488540E038A551C8811
+ 8A55FC88540F018A55F888140883C104FF4D1075DFFF45088B45083B45EC7C9F5F5E33C05BC9C21800
+ )
+ else ; x64 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 4489442418488954241048894C24085355565741544155415641574883EC28418BC1448B8C24980000004C8BDA99488BD941F7F9448BD0448BFA8954240C
+ 448994248800000085C00F8E9D020000418BC04533E4458BF299448924244C8954241041F7F933C9898C24980000008BEA89542404448BE889442408EB05
+ 4C8B5C24784585ED0F8E1A010000458BF1418BFD48897C2418450FAFF14533D233F633ED4533E44533ED4585C97E5B4C63BC2490000000418D040A410FAF
+ C148984C8D441802498BD9498BD04D8BD90FB642010FB64AFF4403E80FB60203E90FB64AFE4883C2044403E003F149FFCB75DE4D03C748FFCB75D0488B7C
+ 24188B8C24980000004C8B5C2478418BC59941F7FE448BE8418BC49941F7FE448BE08BC59941F7FE8BE88BC69941F7FE8BF04585C97E4048639C24900000
+ 004103CA4D8BC1410FAFC94863C94A8D541902488BCA498BC144886901448821408869FF408871FE4883C10448FFC875E84803D349FFC875DA8B8C249800
+ 0000488B5C24704C8B5C24784183C20448FFCF48897C24180F850AFFFFFF8B6C2404448B2424448B6C24084C8B74241085ED0F840A01000033FF33DB4533
+ DB4533D24533C04585C97E53488B74247085ED7E42438D0C04418BC50FAF8C2490000000410FAFC18D04814863C8488D5431028BCD0FB642014403D00FB6
+ 024883C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC17CB28BCD410FAFC985C9740A418BC299F7F98BF0EB0233F685C9740B418BC3
+ 99F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585C97E4D4C8B74247885ED7E3841
+ 8D0C14418BC50FAF8C2490000000410FAFC18D04814863C84A8D4431028BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2413BD17CBD
+ 4C8B7424108B8C2498000000038C2490000000488B5C24704503E149FFCE44892424898C24980000004C897424100F859EFDFFFF448B7C240C448B842480
+ 000000418BC09941F7F98BE8448BEA89942498000000896C240C85C00F8E3B010000448BAC2488000000418BCF448BF5410FAFC9898C248000000033FF33
+ ED33F64533DB4533D24533C04585FF7E524585C97E40418BC5410FAFC14103C00FAF84249000000003C74898488D541802498BD90FB642014403D00FB602
+ 4883C2044403D80FB642FB03F00FB642FA03E848FFCB75DE488B5C247041FFC0453BC77CAE85C9740B418BC299F7F9448BE0EB034533E485C9740A418BC3
+ 99F7F98BD8EB0233DB85C9740A8BC699F7F9448BD8EB034533DB85C9740A8BC599F7F9448BD0EB034533D24533C04585FF7E4E488B4C24784585C97E3541
+ 8BC5410FAFC14103C00FAF84249000000003C74898488D540802498BC144886201881A44885AFF448852FE4883C20448FFC875E941FFC0453BC77CBE8B8C
+ 2480000000488B5C2470418BC1C1E00203F849FFCE0F85ECFEFFFF448BAC24980000008B6C240C448BA4248800000033FF33DB4533DB4533D24533C04585
+ FF7E5A488B7424704585ED7E48418BCC8BC5410FAFC94103C80FAF8C2490000000410FAFC18D04814863C8488D543102418BCD0FB642014403D00FB60248
+ 83C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC77CAB418BCF410FAFCD85C9740A418BC299F7F98BF0EB0233F685C9740B418BC399
+ F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585FF7E4E4585ED7E42418BCC8BC541
+ 0FAFC903CA0FAF8C2490000000410FAFC18D04814863C8488B442478488D440102418BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2
+ 413BD77CB233C04883C428415F415E415D415C5F5E5D5BC3
+ )
+
+ VarSetCapacity(PixelateBitmap, StrLen(MCode_PixelateBitmap)//2)
+ Loop % StrLen(MCode_PixelateBitmap)//2 ;%
+ NumPut("0x" SubStr(MCode_PixelateBitmap, (2*A_Index)-1, 2), PixelateBitmap, A_Index-1, "UChar")
+ DllCall("VirtualProtect", Ptr, &PixelateBitmap, Ptr, VarSetCapacity(PixelateBitmap), "uint", 0x40, A_PtrSize ? "UPtr*" : "UInt*", 0)
+ }
+
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+
+ if (Width != Gdip_GetImageWidth(pBitmapOut) || Height != Gdip_GetImageHeight(pBitmapOut))
+ return -1
+ if (BlockSize > Width || BlockSize > Height)
+ return -2
+
+ E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1)
+ E2 := Gdip_LockBits(pBitmapOut, 0, 0, Width, Height, Stride2, Scan02, BitmapData2)
+ if (E1 || E2)
+ return -3
+
+ E := DllCall(&PixelateBitmap, Ptr, Scan01, Ptr, Scan02, "int", Width, "int", Height, "int", Stride1, "int", BlockSize)
+
+ Gdip_UnlockBits(pBitmap, BitmapData1), Gdip_UnlockBits(pBitmapOut, BitmapData2)
+ return 0
+}
+
+;#####################################################################################
+
+Gdip_ToARGB(A, R, G, B)
+{
+ return (A << 24) | (R << 16) | (G << 8) | B
+}
+
+;#####################################################################################
+
+Gdip_FromARGB(ARGB, ByRef A, ByRef R, ByRef G, ByRef B)
+{
+ A := (0xff000000 & ARGB) >> 24
+ R := (0x00ff0000 & ARGB) >> 16
+ G := (0x0000ff00 & ARGB) >> 8
+ B := 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+Gdip_AFromARGB(ARGB)
+{
+ return (0xff000000 & ARGB) >> 24
+}
+
+;#####################################################################################
+
+Gdip_RFromARGB(ARGB)
+{
+ return (0x00ff0000 & ARGB) >> 16
+}
+
+;#####################################################################################
+
+Gdip_GFromARGB(ARGB)
+{
+ return (0x0000ff00 & ARGB) >> 8
+}
+
+;#####################################################################################
+
+Gdip_BFromARGB(ARGB)
+{
+ return 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+StrGetB(Address, Length=-1, Encoding=0)
+{
+ ; Flexible parameter handling:
+ if Length is not integer
+ Encoding := Length, Length := -1
+
+ ; Check for obvious errors.
+ if (Address+0 < 1024)
+ return
+
+ ; Ensure 'Encoding' contains a numeric identifier.
+ if Encoding = UTF-16
+ Encoding = 1200
+ else if Encoding = UTF-8
+ Encoding = 65001
+ else if SubStr(Encoding,1,2)="CP"
+ Encoding := SubStr(Encoding,3)
+
+ if !Encoding ; "" or 0
+ {
+ ; No conversion necessary, but we might not want the whole string.
+ if (Length == -1)
+ Length := DllCall("lstrlen", "uint", Address)
+ VarSetCapacity(String, Length)
+ DllCall("lstrcpyn", "str", String, "uint", Address, "int", Length + 1)
+ }
+ else if Encoding = 1200 ; UTF-16
+ {
+ char_count := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "uint", 0, "uint", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(String, char_count)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "str", String, "int", char_count, "uint", 0, "uint", 0)
+ }
+ else if Encoding is integer
+ {
+ ; Convert from target encoding to UTF-16 then to the active code page.
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", 0, "int", 0)
+ VarSetCapacity(String, char_count * 2)
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", &String, "int", char_count * 2)
+ String := StrGetB(&String, char_count, 1200)
+ }
+
+ return String
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.2/clubman.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.2/clubman.ahk
new file mode 100644
index 0000000..89f9d4c
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.2/clubman.ahk
@@ -0,0 +1,497 @@
+
+; https://github.com/berban/Gdip
+
+#HotkeyInterval 99000000
+#KeyHistory 0
+#MaxHotkeysPerInterval 99000000
+#NoEnv
+#Persistent
+#SingleInstance Force
+#Include Lib\Gdip.ahk
+
+CoordMode, Pixel, Client
+CoordMode, ToolTip, Client
+DetectHiddenWindows, On
+ListLines Off
+Process, priority, , High
+SendMode Input
+SetBatchLines, -1
+SetDefaultMouseSpeed, 0
+SetFormat, Float, 0.2
+; SetFormat, IntegerFast, Hex
+SetKeyDelay, 50
+SetMouseDelay, -1
+SetWorkingDir %A_ScriptDir%
+
+; Variables
+races_clean := 0
+races_clean_percent := 0
+races_completed := 0
+races_completed_check := 0
+credits_total := 0
+credits_average := 0
+
+time_start := A_TickCount
+time_current := A_TickCount
+
+window_width := 640
+window_height := 360
+
+; GUI
+Gui, New, -MaximizeBox -Resize, ClubmanPlus 0.2
+Gui, Font, S10
+Gui, Add, Button, w150 h40 Default gStart, Start
+Gui, Add, Button, w150 h40 x+10 gReset, Reset
+Gui, Show
+return
+
+; GUI events
+GuiClose:
+ Gosub, Release_All
+ SetTimer, Health, Off
+ SetTimer, Summary, Off
+ OutputDebug % "Clubman> Terminated"
+ExitApp
+
+; GUI buttons
+Start:
+ hwnd := 0
+
+ Gosub, Release_All
+ Gosub, GrabWindow
+
+ if (hwnd = 0) {
+ MsgBox, % "PS Remote Play not found"
+ return
+ }
+
+ SetTimer, Health, 600000
+ SetTimer, Summary, 3600000
+ time_start := A_TickCount
+
+ ; ** AFK Loop
+ Loop {
+
+ ; ** RACE
+ OutputDebug % "Clubman> Race: Waiting for position GUI to show"
+ while (!IsColor(hwnd, 0xFFFFFF, TuneCoordinateX(90), TuneCoordinateY(90), 4, 75)) {
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race: Starting race"
+ Gosub, Hold_X
+ Gosub, Hold_Down
+ OutputDebug % "Clubman> Race: Racing until position GUI disappears"
+ while (IsColor(hwnd, 0xFFFFFF, TuneCoordinateX(90), TuneCoordinateY(90), 4, 75)) {
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race: Race ended, releasing all buttons"
+ Gosub, Release_All
+
+ ; ** GO TO LEADERBOARDS
+ OutputDebug % "Clubman> End race: Waiting for continue X icon to show"
+ while (!IsColor(hwnd, 0xDEDCDA, TuneCoordinateX(475), TuneCoordinateY(563), 4, 10)) {
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> End race: Press X to continue"
+ while (IsColor(hwnd, 0xDEDCDA, TuneCoordinateX(475), TuneCoordinateY(563), 4, 10)) {
+ Gosub, Press_X
+ Sleep, 1000
+ }
+ OutputDebug % "Clubman> End race: Transitioning to leaderboard"
+
+ ; ** LEADERBOARD
+ Loop {
+ OutputDebug % "Clubman> Leaderboard: Checking positions"
+
+ if (IsColor(hwnd, 0xBADD3E, TuneCoordinateX(675), TuneCoordinateY(169), 10, 10)) {
+ OutputDebug % "Clubman> Leaderboard: 1st position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, TuneCoordinateX(675), TuneCoordinateY(198), 10, 10)) {
+ OutputDebug % "Clubman> Leaderboard: 2nd position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, TuneCoordinateX(675), TuneCoordinateY(227), 10, 10)) {
+ OutputDebug % "Clubman> Leaderboard: 3rd position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, TuneCoordinateX(675), TuneCoordinateY(256), 10, 10)) {
+ OutputDebug % "Clubman> Leaderboard: 4th position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, TuneCoordinateX(675), TuneCoordinateY(285), 10, 10)) {
+ OutputDebug % "Clubman> Leaderboard: 5th position"
+ Gosub, Press_X
+ break
+ }
+ else {
+ Sleep, 500
+ }
+ }
+
+ ; ** REWARDS
+ OutputDebug % "Clubman> Rewards: Waiting for Rewards screen to load (checking money earnt)"
+ while (!IsColor(hwnd, 0xBE140F, TuneCoordinateX(850), TuneCoordinateY(236), 10, 50)) {
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Rewards: Found Rewards screen"
+ races_completed++
+
+ Loop 100 {
+ if (IsColor(hwnd, 0x5C90FB, TuneCoordinateX(486), TuneCoordinateY(311), 4, 20)) {
+ OutputDebug % "Clubman> Rewards: Clean bonus"
+ races_clean++
+ PixelSearch(TuneCoordinateX(486), TuneCoordinateY(311), 1, hwnd, "clean")
+ break
+ }
+
+ if (A_Index == 100) {
+ OutputDebug % "Clubman> Rewards: No clean bonus"
+ PixelSearch(TuneCoordinateX(486), TuneCoordinateY(311), 1, hwnd, "no-clean")
+ }
+ }
+
+ ; ** REPLAY
+ OutputDebug % "Clubman> Replay: Waiting for Replay screen to load (checking exit button)"
+ while (!IsColor(hwnd, 0xFFFFFF, TuneCoordinateX(920), TuneCoordinateY(555), 4, 10)) {
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Replay: Pressing the Exit button"
+ while (IsColor(hwnd, 0xFFFFFF, TuneCoordinateX(920), TuneCoordinateY(555), 4, 10)) {
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Replay: Leaving the Replay screen"
+
+ ; ** RACE RESULTS
+ OutputDebug % "Clubman> Race Result: Waiting for Race Result screen to load (checking cursor)"
+ while (!IsColor(hwnd, 0xBB1C1A, TuneCoordinateX(664), TuneCoordinateY(540), 5, 10)) {
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Result: Moving cursor to the Retry button"
+ while (!IsColor(hwnd, 0xFFFFFF, TuneCoordinateX(525), TuneCoordinateY(550), 4, 10)) {
+ Gosub, Press_Right
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Result: Pressing the Retry button"
+ while (IsColor(hwnd, 0xFFFFFF, TuneCoordinateX(525), TuneCoordinateY(550), 4, 10)) {
+ Gosub, Press_X
+ Sleep, 500
+ }
+
+ ; ** RACE START
+ OutputDebug % "Clubman> Race Start: Waiting for Race Start screen to load (checking cursor)"
+ while (!IsColor(hwnd, 0xFFFFFF, TuneCoordinateX(300), TuneCoordinateY(550), 4, 10)) {
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Start: Pressing the Start button"
+ while (IsColor(hwnd, 0xFFFFFF, TuneCoordinateX(300), TuneCoordinateY(550), 4, 10)) {
+ Gosub, Press_X
+ Sleep, 500
+ }
+
+ OutputDebug % "--- Summary ---"
+ credits_total := (races_completed * 0.07 + races_clean * 0.035)
+ races_clean_percent := (races_clean / races_completed) * 100
+ time_current := A_TickCount
+ credits_average := credits_total / (time_current - time_start) * 3600000
+
+ OutputDebug % "Clubman> Summary: Races " races_completed
+ OutputDebug % "Clubman> Summary: Races Clean " races_clean
+ OutputDebug % "Clubman> Summary: Races Clean Rate " races_clean_percent "%"
+ OutputDebug % "Clubman> Summary: Earnings " credits_total "M"
+ OutputDebug % "Clubman> Summary: Earnings Rate " credits_average "M/Hr"
+ OutputDebug % "---------------"
+ }
+return
+
+; -------------------
+; Coordinate tuning
+; -------------------
+TuneCoordinateX(coord) {
+ ; 3840 because I used a 4K 16:9 monitor to get the values
+Return Round((A_ScreenWidth * coord) / 3840)
+}
+
+TuneCoordinateY(coord) {
+ ; 2160 because I used a 4K 16:9 monitor to get the values
+Return Round((A_ScreenHeight * coord) / 2160)
+}
+
+Reset:
+ ; Gosub, GrabWindow
+
+ ; ; PixelSearch(TuneCoordinateX(850), TuneCoordinateY(236), 10, WinExist("PS Remote Play"), "test1")
+ ; bolas := IsColor(hwnd, 0xBE140F, TuneCoordinateX(850), TuneCoordinateY(236), 10, 50)
+ ; OutputDebug % "Clubman> is color " bolas
+
+ ; OutputDebug % "Clubman> d1 " ColorDistance(0xBE140F, 0x87281D)
+ ; OutputDebug % "Clubman> d2 " ColorDistance(0xBE140F, 0x6C1F16)
+ ; OutputDebug % "Clubman> d2 " ColorDistance(0xBE140F, 0x862A1F)
+
+ ; Gosub, GrabWindow
+
+ ; X := (A_ScreenWidth / 2) + 1 ; X = 677 (On 1024) or 805 (On 1280)
+ ; Y := A_ScreenHeight - 25 ; Y = 743 (On 768) or 999 (On 1024)
+
+ ; OutputDebug % "Clubman> X " TuneCoordinateX(90)
+ ; OutputDebug % "Clubman> Y " TuneCoordinateY(90)
+
+ ; PixelSearch(90, 90, 10, WinExist("PS Remote Play"), "test1")
+ ; PixelSearch(675, 256, 10, WinExist("PS Remote Play"), "l4")
+ ; PixelSearch(675, 227, 10, WinExist("PS Remote Play"), "l3")
+ ; PixelSearch(675, 198, 10, WinExist("PS Remote Play"), "l2")
+ ; PixelSearch(675, 169, 10, WinExist("PS Remote Play"), "l1")
+return
+
+; -------------------
+; Health Check
+; -------------------
+Health:
+ FormatTime, current_date,, % "yyMMdd-HHmm-ss"
+ OutputDebug % "Clubman> Health: Checking health at " current_date
+ OutputDebug % "Clubman> Health: Races completed " races_completed
+ OutputDebug % "Clubman> Health: Races completed last time " races_completed_check
+
+ if (races_completed_check >= races_completed) {
+ OutputDebug % "Clubman> Health: Error dectected, sending notification"
+ SendNotification("ClubmanPlus", "Something went wrong", 2, "persistent")
+ } else {
+ OutputDebug % "Clubman> Health: Running healthy"
+ races_completed_check := races_completed
+ }
+Return
+
+; -------------------
+; Summary Check
+; -------------------
+Summary:
+ OutputDebug % "Clubman> Summary: Sending summary notification"
+ message := ""
+ message := message "Races " races_clean " / " races_completed " (" races_clean_percent ")`n"
+ message := message "Earnings " credits_total "M (" credits_average "M/Hr)"
+ SendNotification("ClubmanPlus", message, 0, "cashregister")
+Return
+
+; -------------------
+; Send Notification
+; -------------------
+SendNotification(title, message, level, sound) {
+
+ IniRead, token, %A_ScriptDir%\clubman.ini, pushover, token
+ IniRead, user, %A_ScriptDir%\clubman.ini, pushover, user_key
+
+ retries := 60
+ expires := 3600
+
+ url := "https://api.pushover.net/1/messages.json"
+ param := "token=" token "&user=" user "&title=" title "&message=" message "&sound=" sound "&priority=" level
+
+ if (level == 2) {
+ param := param "&retry=" retries "&expire=" expires
+ }
+
+ WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
+ WebRequest.Open("POST", url)
+ WebRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
+ WebRequest.Send(param)
+Return
+}
+
+; -------------------
+; Grab Window
+; -------------------
+GrabWindow:
+ OutputDebug % "Clubman> Looking for window"
+ hwnd := WinExist("PS Remote Play")
+
+ if (hwnd > 0) {
+ OutputDebug % "Clubman> Window found: " hwnd
+ WinMove, ahk_id %hwnd%,, 0, 0, %window_width%, %window_height%
+ WinActivate, ahk_id %hwnd%
+ ControlFocus,, ahk_id %hwnd%
+ }
+return
+
+; -------------------
+; Is Color
+; -------------------
+IsColor(hwnd, target_color, x, y, b, tolerance) {
+ for i, c in PixelSearch(x, y, b, hwnd) {
+ if (ColorDistance(c, target_color) <= tolerance) {
+ Return True
+ }
+ }
+Return False
+}
+
+; -------------------
+; Color Distance
+; -------------------
+ColorDistance( c1, c2 ) {
+ r1 := c1 >> 16
+ g1 := c1 >> 8 & 255
+ b1 := c1 & 255
+ r2 := c2 >> 16
+ g2 := c2 >> 8 & 255
+ b2 := c2 & 255
+return Sqrt( (r1-r2)**2 + (g1-g2)**2 + (b1-b2)**2 )
+}
+
+; -------------------
+; Pixel Search
+; -------------------
+PixelSearch(x, y, b, hwnd, debugsave := "") {
+ WinGetPos,,, width, height, ahk_id %hwnd%
+
+ pToken := Gdip_Startup()
+ hbm := CreateDIBSection(width, height),
+ hdc := CreateCompatibleDC(),
+ obm := SelectObject(hdc, hbm)
+
+ RegExMatch(A_OsVersion, "\d+", version)
+ PrintWindow(hwnd, hdc, version >= 8 ? 2 : 0)
+
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(hdc, obm),
+ DeleteObject(hbm),
+ DeleteDC(hdc)
+
+ pixs := []
+ Loop % b*2 + 1 {
+ i := (-1 * b) + (A_Index - 1)
+ Loop % b*2 + 1 {
+ j := (-1 * b) + (A_Index - 1)
+ pixs.Push(Gdip_GetPixel(pBitmap, x+i, y+j) & 0x00FFFFFF)
+ }
+ }
+
+ if (debugsave != "") {
+ FormatTime, current_date,, % "yyMMdd-HHmm-ss"
+ filename := A_ScriptDir . "\" . current_date . "-" . debugsave . ".bmp"
+
+ ; debugbitmap:=Gdip_CloneBitmapArea(pBitmap, x-b, y-b, b*2, b*2)
+ ; Gdip_SaveBitmapToFile(debugbitmap, filename)
+ Gdip_SaveBitmapToFile(pBitmap, filename)
+ Gdip_DisposeImage(debugbitmap)
+ ; Run % filename
+ }
+
+ Gdip_DisposeImage(pBitmap)
+ Gdip_Shutdown(pToken)
+return pixs
+}
+
+; -------------------
+; Release All
+; -------------------
+Release_All:
+ Gosub, Release_X
+ Gosub, Release_O
+return
+
+; -------------------
+; Press x
+; -------------------
+Press_X:
+ Gosub, Hold_X
+ Gosub, Release_x
+return
+
+Hold_X:
+ ControlSend,, {Enter down}, ahk_id %hwnd%
+return
+
+Release_X:
+ ControlSend,, {Enter up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press O
+; -------------------
+Press_O:
+ Gosub, Hold_O
+ Gosub, Release_O
+return
+
+Hold_O:
+ ControlSend,, {Esc down}, ahk_id %hwnd%
+return
+
+Release_O:
+ ControlSend,, {Esc up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press Right
+; -------------------
+Press_Right:
+ Gosub, Hold_Right
+ Gosub, Release_Right
+return
+
+Hold_Right:
+ ControlSend,, {Right down}, ahk_id %hwnd%
+return
+
+Release_Right:
+ ControlSend,, {Right up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press Left
+; -------------------
+Press_Left:
+ Gosub, Hold_Left
+ Gosub, Release_Left
+return
+
+Hold_Left:
+ ControlSend,, {Left down}, ahk_id %hwnd%
+return
+
+Release_Left:
+ ControlSend,, {Left up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press Up
+; -------------------
+Press_Up:
+ Gosub, Hold_Up
+ Gosub, Release_Up
+return
+
+Hold_Up:
+ ControlSend,, {Up down}, ahk_id %hwnd%
+return
+
+Release_Up:
+ ControlSend,, {Up up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press Down
+; -------------------
+Press_Down:
+ Gosub, Hold_Down
+ Gosub, Release_Down
+return
+
+Hold_Down:
+ ControlSend,, {Down down}, ahk_id %hwnd%
+return
+
+Release_Down:
+ ControlSend,, {Down up}, ahk_id %hwnd%
+return
+
+; Hotkeys
+^Esc::ExitApp
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.2/clubman.ini b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.2/clubman.ini
new file mode 100644
index 0000000..e70a764
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.2/clubman.ini
@@ -0,0 +1,3 @@
+[pushover]
+user_key=your_key
+token=your_token
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.3/Lib/Gdip.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.3/Lib/Gdip.ahk
new file mode 100644
index 0000000..0b629d5
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.3/Lib/Gdip.ahk
@@ -0,0 +1,2698 @@
+; Gdip standard library v1.45 by tic (Tariq Porter) 07/09/11
+; Modifed by Rseding91 using fincs 64 bit compatible Gdip library 5/1/2013
+; Supports: Basic, _L ANSi, _L Unicode x86 and _L Unicode x64
+;
+;#####################################################################################
+;#####################################################################################
+; STATUS ENUMERATION
+; Return values for functions specified to have status enumerated return type
+;#####################################################################################
+;
+; Ok = = 0
+; GenericError = 1
+; InvalidParameter = 2
+; OutOfMemory = 3
+; ObjectBusy = 4
+; InsufficientBuffer = 5
+; NotImplemented = 6
+; Win32Error = 7
+; WrongState = 8
+; Aborted = 9
+; FileNotFound = 10
+; ValueOverflow = 11
+; AccessDenied = 12
+; UnknownImageFormat = 13
+; FontFamilyNotFound = 14
+; FontStyleNotFound = 15
+; NotTrueTypeFont = 16
+; UnsupportedGdiplusVersion = 17
+; GdiplusNotInitialized = 18
+; PropertyNotFound = 19
+; PropertyNotSupported = 20
+; ProfileNotFound = 21
+;
+;#####################################################################################
+;#####################################################################################
+; FUNCTIONS
+;#####################################################################################
+;
+; UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255)
+; BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+; StretchBlt(dDC, dx, dy, dw, dh, sDC, sx, sy, sw, sh, Raster="")
+; SetImage(hwnd, hBitmap)
+; Gdip_BitmapFromScreen(Screen=0, Raster="")
+; CreateRectF(ByRef RectF, x, y, w, h)
+; CreateSizeF(ByRef SizeF, w, h)
+; CreateDIBSection
+;
+;#####################################################################################
+
+; Function: UpdateLayeredWindow
+; Description: Updates a layered window with the handle to the DC of a gdi bitmap
+;
+; hwnd Handle of the layered window to update
+; hdc Handle to the DC of the GDI bitmap to update the window with
+; Layeredx x position to place the window
+; Layeredy y position to place the window
+; Layeredw Width of the window
+; Layeredh Height of the window
+; Alpha Default = 255 : The transparency (0-255) to set the window transparency
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If x or y omitted, then layered window will use its current coordinates
+; If w or h omitted then current width and height will be used
+
+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)
+}
+
+;#####################################################################################
+
+; Function BitBlt
+; Description The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle
+; of pixels from the specified source device context into a destination device context.
+;
+; dDC handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of the area to copy
+; dh height of the area to copy
+; sDC handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used, which copies the source directly to the destination rectangle
+;
+; BLACKNESS = 0x00000042
+; NOTSRCERASE = 0x001100A6
+; NOTSRCCOPY = 0x00330008
+; SRCERASE = 0x00440328
+; DSTINVERT = 0x00550009
+; PATINVERT = 0x005A0049
+; SRCINVERT = 0x00660046
+; SRCAND = 0x008800C6
+; MERGEPAINT = 0x00BB0226
+; MERGECOPY = 0x00C000CA
+; SRCCOPY = 0x00CC0020
+; SRCPAINT = 0x00EE0086
+; PATCOPY = 0x00F00021
+; PATPAINT = 0x00FB0A09
+; WHITENESS = 0x00FF0062
+; CAPTUREBLT = 0x40000000
+; NOMIRRORBITMAP = 0x80000000
+
+BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\BitBlt"
+ , Ptr, dDC
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sDC
+ , "int", sx
+ , "int", sy
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function StretchBlt
+; Description The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle,
+; stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary.
+; The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.
+;
+; ddc handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination rectangle
+; dh height of destination rectangle
+; sdc handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used. It uses the same raster operations as BitBlt
+
+StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\StretchBlt"
+ , Ptr, ddc
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sdc
+ , "int", sx
+ , "int", sy
+ , "int", sw
+ , "int", sh
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function SetStretchBltMode
+; Description The SetStretchBltMode function sets the bitmap stretching mode in the specified device context
+;
+; hdc handle to the DC
+; iStretchMode The stretching mode, describing how the target will be stretched
+;
+; return If the function succeeds, the return value is the previous stretching mode. If it fails it will return 0
+;
+; STRETCH_ANDSCANS = 0x01
+; STRETCH_ORSCANS = 0x02
+; STRETCH_DELETESCANS = 0x03
+; STRETCH_HALFTONE = 0x04
+
+SetStretchBltMode(hdc, iStretchMode=4)
+{
+ return DllCall("gdi32\SetStretchBltMode"
+ , A_PtrSize ? "UPtr" : "UInt", hdc
+ , "int", iStretchMode)
+}
+
+;#####################################################################################
+
+; Function SetImage
+; Description Associates a new image with a static control
+;
+; hwnd handle of the control to update
+; hBitmap a gdi bitmap to associate the static control with
+;
+; return If the function succeeds, the return value is nonzero
+
+SetImage(hwnd, hBitmap)
+{
+ SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
+ E := ErrorLevel
+ DeleteObject(E)
+ return E
+}
+
+;#####################################################################################
+
+; Function SetSysColorToControl
+; Description Sets a solid colour to a control
+;
+; hwnd handle of the control to update
+; SysColor A system colour to set to the control
+;
+; return If the function succeeds, the return value is zero
+;
+; notes A control must have the 0xE style set to it so it is recognised as a bitmap
+; By default SysColor=15 is used which is COLOR_3DFACE. This is the standard background for a control
+;
+; COLOR_3DDKSHADOW = 21
+; COLOR_3DFACE = 15
+; COLOR_3DHIGHLIGHT = 20
+; COLOR_3DHILIGHT = 20
+; COLOR_3DLIGHT = 22
+; COLOR_3DSHADOW = 16
+; COLOR_ACTIVEBORDER = 10
+; COLOR_ACTIVECAPTION = 2
+; COLOR_APPWORKSPACE = 12
+; COLOR_BACKGROUND = 1
+; COLOR_BTNFACE = 15
+; COLOR_BTNHIGHLIGHT = 20
+; COLOR_BTNHILIGHT = 20
+; COLOR_BTNSHADOW = 16
+; COLOR_BTNTEXT = 18
+; COLOR_CAPTIONTEXT = 9
+; COLOR_DESKTOP = 1
+; COLOR_GRADIENTACTIVECAPTION = 27
+; COLOR_GRADIENTINACTIVECAPTION = 28
+; COLOR_GRAYTEXT = 17
+; COLOR_HIGHLIGHT = 13
+; COLOR_HIGHLIGHTTEXT = 14
+; COLOR_HOTLIGHT = 26
+; COLOR_INACTIVEBORDER = 11
+; COLOR_INACTIVECAPTION = 3
+; COLOR_INACTIVECAPTIONTEXT = 19
+; COLOR_INFOBK = 24
+; COLOR_INFOTEXT = 23
+; COLOR_MENU = 4
+; COLOR_MENUHILIGHT = 29
+; COLOR_MENUBAR = 30
+; COLOR_MENUTEXT = 7
+; COLOR_SCROLLBAR = 0
+; COLOR_WINDOW = 5
+; COLOR_WINDOWFRAME = 6
+; COLOR_WINDOWTEXT = 8
+
+SetSysColorToControl(hwnd, SysColor=15)
+{
+ WinGetPos,,, w, h, ahk_id %hwnd%
+ bc := DllCall("GetSysColor", "Int", SysColor, "UInt")
+ pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc >> 16 | bc & 0xff00 | (bc & 0xff) << 16))
+ pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap)
+ Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h)
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ SetImage(hwnd, hBitmap)
+ Gdip_DeleteBrush(pBrushClear)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap)
+ return 0
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromScreen
+; Description Gets a gdi+ bitmap from the screen
+;
+; Screen 0 = All screens
+; Any numerical value = Just that screen
+; x|y|w|h = Take specific coordinates with a width and height
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1: one or more of x,y,w,h not passed properly
+;
+; notes If no raster operation is specified, then SRCCOPY is used to the returned bitmap
+
+Gdip_BitmapFromScreen(Screen=0, Raster="")
+{
+ if (Screen = 0)
+ {
+ Sysget, x, 76
+ Sysget, y, 77
+ Sysget, w, 78
+ Sysget, h, 79
+ }
+ else if (SubStr(Screen, 1, 5) = "hwnd:")
+ {
+ Screen := SubStr(Screen, 6)
+ if !WinExist( "ahk_id " Screen)
+ return -2
+ WinGetPos,,, w, h, ahk_id %Screen%
+ x := y := 0
+ hhdc := GetDCEx(Screen, 3)
+ }
+ else if (Screen&1 != "")
+ {
+ Sysget, M, Monitor, %Screen%
+ x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
+ }
+ else
+ {
+ StringSplit, S, Screen, |
+ x := S1, y := S2, w := S3, h := S4
+ }
+
+ if (x = "") || (y = "") || (w = "") || (h = "")
+ return -1
+
+ chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
+ BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
+ ReleaseDC(hhdc)
+
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromHWND
+; Description Uses PrintWindow to get a handle to the specified window and return a bitmap from it
+;
+; hwnd handle to the window to get a bitmap from
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+;
+; notes Window must not be not minimised in order to get a handle to it's client area
+
+Gdip_BitmapFromHWND(hwnd)
+{
+ WinGetPos,,, Width, Height, ahk_id %hwnd%
+ hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ PrintWindow(hwnd, hdc)
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function CreateRectF
+; Description Creates a RectF object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+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")
+}
+
+;#####################################################################################
+
+; Function CreateRect
+; Description Creates a Rect object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+CreateRect(ByRef Rect, x, y, w, h)
+{
+ VarSetCapacity(Rect, 16)
+ NumPut(x, Rect, 0, "uint"), NumPut(y, Rect, 4, "uint"), NumPut(w, Rect, 8, "uint"), NumPut(h, Rect, 12, "uint")
+}
+;#####################################################################################
+
+; Function CreateSizeF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreateSizeF(ByRef SizeF, w, h)
+{
+ VarSetCapacity(SizeF, 8)
+ NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreatePointF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreatePointF(ByRef PointF, x, y)
+{
+ VarSetCapacity(PointF, 8)
+ NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreateDIBSection
+; Description The CreateDIBSection function creates a DIB (Device Independent Bitmap) that applications can write to directly
+;
+; w width of the bitmap to create
+; h height of the bitmap to create
+; hdc a handle to the device context to use the palette from
+; bpp bits per pixel (32 = ARGB)
+; ppvBits A pointer to a variable that receives a pointer to the location of the DIB bit values
+;
+; return returns a DIB. A gdi bitmap
+;
+; notes ppvBits will receive the location of the pixels in the DIB
+
+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
+}
+
+;#####################################################################################
+
+; Function PrintWindow
+; Description The PrintWindow function copies a visual window into the specified device context (DC), typically a printer DC
+;
+; hwnd A handle to the window that will be copied
+; hdc A handle to the device context
+; Flags Drawing options
+;
+; return If the function succeeds, it returns a nonzero value
+;
+; PW_CLIENTONLY = 1
+
+PrintWindow(hwnd, hdc, Flags=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("PrintWindow", Ptr, hwnd, Ptr, hdc, "uint", Flags)
+}
+
+;#####################################################################################
+
+; Function DestroyIcon
+; Description Destroys an icon and frees any memory the icon occupied
+;
+; hIcon Handle to the icon to be destroyed. The icon must not be in use
+;
+; return If the function succeeds, the return value is nonzero
+
+DestroyIcon(hIcon)
+{
+ return DllCall("DestroyIcon", A_PtrSize ? "UPtr" : "UInt", hIcon)
+}
+
+;#####################################################################################
+
+PaintDesktop(hdc)
+{
+ return DllCall("PaintDesktop", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+CreateCompatibleBitmap(hdc, w, h)
+{
+ return DllCall("gdi32\CreateCompatibleBitmap", A_PtrSize ? "UPtr" : "UInt", hdc, "int", w, "int", h)
+}
+
+;#####################################################################################
+
+; Function CreateCompatibleDC
+; Description This function creates a memory device context (DC) compatible with the specified device
+;
+; hdc Handle to an existing device context
+;
+; return returns the handle to a device context or 0 on failure
+;
+; notes If this handle is 0 (by default), the function creates a memory device context compatible with the application's current screen
+
+CreateCompatibleDC(hdc=0)
+{
+ return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+; Function SelectObject
+; Description The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type
+;
+; hdc Handle to a DC
+; hgdiobj A handle to the object to be selected into the DC
+;
+; return If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced
+;
+; notes The specified object must have been created by using one of the following functions
+; Bitmap - CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection (A single bitmap cannot be selected into more than one DC at the same time)
+; Brush - CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush
+; Font - CreateFont, CreateFontIndirect
+; Pen - CreatePen, CreatePenIndirect
+; Region - CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirect
+;
+; notes If the selected object is a region and the function succeeds, the return value is one of the following value
+;
+; SIMPLEREGION = 2 Region consists of a single rectangle
+; COMPLEXREGION = 3 Region consists of more than one rectangle
+; NULLREGION = 1 Region is empty
+
+SelectObject(hdc, hgdiobj)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
+}
+
+;#####################################################################################
+
+; Function DeleteObject
+; Description This function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object
+; After the object is deleted, the specified handle is no longer valid
+;
+; hObject Handle to a logical pen, brush, font, bitmap, region, or palette to delete
+;
+; return Nonzero indicates success. Zero indicates that the specified handle is not valid or that the handle is currently selected into a device context
+
+DeleteObject(hObject)
+{
+ return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject)
+}
+
+;#####################################################################################
+
+; Function GetDC
+; Description This function retrieves a handle to a display device context (DC) for the client area of the specified window.
+; The display device context can be used in subsequent graphics display interface (GDI) functions to draw in the client area of the window.
+;
+; hwnd Handle to the window whose device context is to be retrieved. If this value is NULL, GetDC retrieves the device context for the entire screen
+;
+; return The handle the device context for the specified window's client area indicates success. NULL indicates failure
+
+GetDC(hwnd=0)
+{
+ return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
+}
+
+;#####################################################################################
+
+; DCX_CACHE = 0x2
+; DCX_CLIPCHILDREN = 0x8
+; DCX_CLIPSIBLINGS = 0x10
+; DCX_EXCLUDERGN = 0x40
+; DCX_EXCLUDEUPDATE = 0x100
+; DCX_INTERSECTRGN = 0x80
+; DCX_INTERSECTUPDATE = 0x200
+; DCX_LOCKWINDOWUPDATE = 0x400
+; DCX_NORECOMPUTE = 0x100000
+; DCX_NORESETATTRS = 0x4
+; DCX_PARENTCLIP = 0x20
+; DCX_VALIDATE = 0x200000
+; DCX_WINDOW = 0x1
+
+GetDCEx(hwnd, flags=0, hrgnClip=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("GetDCEx", Ptr, hwnd, Ptr, hrgnClip, "int", flags)
+}
+
+;#####################################################################################
+
+; Function ReleaseDC
+; Description This function releases a device context (DC), freeing it for use by other applications. The effect of ReleaseDC depends on the type of device context
+;
+; hdc Handle to the device context to be released
+; hwnd Handle to the window whose device context is to be released
+;
+; return 1 = released
+; 0 = not released
+;
+; notes The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common device context
+; An application cannot use the ReleaseDC function to release a device context that was created by calling the CreateDC function; instead, it must use the DeleteDC function.
+
+ReleaseDC(hdc, hwnd=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function DeleteDC
+; Description The DeleteDC function deletes the specified device context (DC)
+;
+; hdc A handle to the device context
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC
+
+DeleteDC(hdc)
+{
+ return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+;#####################################################################################
+
+; Function Gdip_LibraryVersion
+; Description Get the current library version
+;
+; return the library version
+;
+; notes This is useful for non compiled programs to ensure that a person doesn't run an old version when testing your scripts
+
+Gdip_LibraryVersion()
+{
+ return 1.45
+}
+
+;#####################################################################################
+
+; Function: Gdip_BitmapFromBRA
+; Description: Gets a pointer to a gdi+ bitmap from a BRA file
+;
+; BRAFromMemIn The variable for a BRA file read to memory
+; File The name of the file, or its number that you would like (This depends on alternate parameter)
+; Alternate Changes whether the File parameter is the file name or its number
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1 = The BRA variable is empty
+; -2 = The BRA has an incorrect header
+; -3 = The BRA has information missing
+; -4 = Could not find file inside the BRA
+
+Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate=0)
+{
+ Static FName = "ObjRelease"
+
+ if !BRAFromMemIn
+ return -1
+ Loop, Parse, BRAFromMemIn, `n
+ {
+ if (A_Index = 1)
+ {
+ StringSplit, Header, A_LoopField, |
+ if (Header0 != 4 || Header2 != "BRA!")
+ return -2
+ }
+ else if (A_Index = 2)
+ {
+ StringSplit, Info, A_LoopField, |
+ if (Info0 != 3)
+ return -3
+ }
+ else
+ break
+ }
+ if !Alternate
+ StringReplace, File, File, \, \\, All
+ RegExMatch(BRAFromMemIn, "mi`n)^" (Alternate ? File "\|.+?\|(\d+)\|(\d+)" : "\d+\|" File "\|(\d+)\|(\d+)") "$", FileInfo)
+ if !FileInfo
+ return -4
+
+ hData := DllCall("GlobalAlloc", "uint", 2, Ptr, FileInfo2, Ptr)
+ pData := DllCall("GlobalLock", Ptr, hData, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pData, Ptr, &BRAFromMemIn+Info2+FileInfo1, Ptr, FileInfo2)
+ DllCall("GlobalUnlock", Ptr, hData)
+ DllCall("ole32\CreateStreamOnHGlobal", Ptr, hData, "int", 1, A_PtrSize ? "UPtr*" : "UInt*", pStream)
+ DllCall("gdiplus\GdipCreateBitmapFromStream", Ptr, pStream, A_PtrSize ? "UPtr*" : "UInt*", pBitmap)
+ If (A_PtrSize)
+ %FName%(pStream)
+ Else
+ DllCall(NumGet(NumGet(1*pStream)+8), "uint", pStream)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRectangle
+; Description This function uses a pen to draw the outline of a rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRoundedRectangle
+; Description This function uses a pen to draw the outline of a rounded rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawEllipse
+; Description This function uses a pen to draw the outline of an ellipse into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle the ellipse will be drawn into
+; y y-coordinate of the top left of the rectangle the ellipse will be drawn into
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawBezier
+; Description This function uses a pen to draw the outline of a bezier (a weighted curve) into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the bezier
+; y1 y-coordinate of the start of the bezier
+; x2 x-coordinate of the first arc of the bezier
+; y2 y-coordinate of the first arc of the bezier
+; x3 x-coordinate of the second arc of the bezier
+; y3 y-coordinate of the second arc of the bezier
+; x4 x-coordinate of the end of the bezier
+; y4 y-coordinate of the end of the bezier
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawBezier"
+ , Ptr, pgraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2
+ , "float", x3
+ , "float", y3
+ , "float", x4
+ , "float", y4)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawArc
+; Description This function uses a pen to draw the outline of an arc into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the arc
+; y y-coordinate of the start of the arc
+; w width of the arc
+; h height of the arc
+; StartAngle specifies the angle between the x-axis and the starting point of the arc
+; SweepAngle specifies the angle between the starting and ending points of the arc
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawArc"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawPie
+; Description This function uses a pen to draw the outline of a pie into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the pie
+; y y-coordinate of the start of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawPie", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLine
+; Description This function uses a pen to draw a line into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the line
+; y1 y-coordinate of the start of the line
+; x2 x-coordinate of the end of the line
+; y2 y-coordinate of the end of the line
+;
+; return status enumeration. 0 = success
+
+Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawLine"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLines
+; Description This function uses a pen to draw a series of joined lines into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRectangle
+; Description This function uses a brush to fill a rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRoundedRectangle
+; Description This function uses a brush to fill a rounded rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPolygon
+; Description This function uses a brush to fill a polygon in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+;
+; notes Alternate will fill the polygon as a whole, wheras winding will fill each new "segment"
+; Alternate = 0
+; Winding = 1
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPie
+; Description This function uses a brush to fill a pie in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the pie
+; y y-coordinate of the top left of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPie"
+ , Ptr, pGraphics
+ , Ptr, pBrush
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillEllipse
+; Description This function uses a brush to fill an ellipse in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the ellipse
+; y y-coordinate of the top left of the ellipse
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRegion
+; Description This function uses a brush to fill a region in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Region
+;
+; return status enumeration. 0 = success
+;
+; notes You can create a region Gdip_CreateRegion() and then add to this
+
+Gdip_FillRegion(pGraphics, pBrush, Region)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillRegion", Ptr, pGraphics, Ptr, pBrush, Ptr, Region)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPath
+; Description This function uses a brush to fill a path in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Path
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPath(pGraphics, pBrush, Path)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPath", Ptr, pGraphics, Ptr, pBrush, Ptr, Path)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImagePointsRect
+; Description This function draws a bitmap into the Graphics of another bitmap and skews it
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; Points Points passed as x1,y1|x2,y2|x3,y3 (3 points: top left, top right, bottom left) describing the drawing of the bitmap
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter
+
+Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1)
+{
+ 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")
+ }
+
+ 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 = "")
+ {
+ sx := 0, sy := 0
+ sw := Gdip_GetImageWidth(pBitmap)
+ sh := Gdip_GetImageHeight(pBitmap)
+ }
+
+ E := DllCall("gdiplus\GdipDrawImagePointsRect"
+ , Ptr, pGraphics
+ , Ptr, pBitmap
+ , Ptr, &PointF
+ , "int", Points0
+ , "float", sx
+ , "float", sy
+ , "float", sw
+ , "float", sh
+ , "int", 2
+ , Ptr, ImageAttr
+ , Ptr, 0
+ , Ptr, 0)
+ if ImageAttr
+ Gdip_DisposeImageAttributes(ImageAttr)
+ return E
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImage
+; Description This function draws a bitmap into the Graphics of another bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination image
+; dh height of destination image
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source image
+; sh height of source image
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Gdip_DrawImage performs faster
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter. For example:
+; MatrixBright=
+; (
+; 1.5 |0 |0 |0 |0
+; 0 |1.5 |0 |0 |0
+; 0 |0 |1.5 |0 |0
+; 0 |0 |0 |1 |0
+; 0.05 |0.05 |0.05 |0 |1
+; )
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_SetImageAttributesColorMatrix
+; Description This function creates an image matrix ready for drawing
+;
+; Matrix a matrix used to alter image attributes when drawing
+; passed with any delimeter
+;
+; return returns an image matrix on sucess or 0 if it fails
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromImage
+; Description This function gets the graphics for a bitmap used for drawing functions
+;
+; pBitmap Pointer to a bitmap to get the pointer to its graphics
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes a bitmap can be drawn into the graphics of another bitmap
+
+Gdip_GraphicsFromImage(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromHDC
+; Description This function gets the graphics from the handle to a device context
+;
+; hdc This is the handle to the device context
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes You can draw a bitmap into the graphics of another bitmap
+
+Gdip_GraphicsFromHDC(hdc)
+{
+ DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDC
+; Description This function gets the device context of the passed Graphics
+;
+; hdc This is the handle to the device context
+;
+; return returns the device context for the graphics of a bitmap
+
+Gdip_GetDC(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDC", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", hdc)
+ return hdc
+}
+
+;#####################################################################################
+
+; Function Gdip_ReleaseDC
+; Description This function releases a device context from use for further use
+;
+; pGraphics Pointer to the graphics of a bitmap
+; hdc This is the handle to the device context
+;
+; return status enumeration. 0 = success
+
+Gdip_ReleaseDC(pGraphics, hdc)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipReleaseDC", Ptr, pGraphics, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsClear
+; Description Clears the graphics of a bitmap ready for further drawing
+;
+; pGraphics Pointer to the graphics of a bitmap
+; ARGB The colour to clear the graphics to
+;
+; return status enumeration. 0 = success
+;
+; notes By default this will make the background invisible
+; Using clipping regions you can clear a particular area on the graphics rather than clearing the entire graphics
+
+Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff)
+{
+ return DllCall("gdiplus\GdipGraphicsClear", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_BlurBitmap
+; Description Gives a pointer to a blurred bitmap from a pointer to a bitmap
+;
+; pBitmap Pointer to a bitmap to be blurred
+; Blur The Amount to blur a bitmap by from 1 (least blur) to 100 (most blur)
+;
+; return If the function succeeds, the return value is a pointer to the new blurred bitmap
+; -1 = The blur parameter is outside the range 1-100
+;
+; notes This function will not dispose of the original bitmap
+
+Gdip_BlurBitmap(pBitmap, Blur)
+{
+ if (Blur > 100) || (Blur < 1)
+ return -1
+
+ sWidth := Gdip_GetImageWidth(pBitmap), sHeight := Gdip_GetImageHeight(pBitmap)
+ dWidth := sWidth//Blur, dHeight := sHeight//Blur
+
+ pBitmap1 := Gdip_CreateBitmap(dWidth, dHeight)
+ G1 := Gdip_GraphicsFromImage(pBitmap1)
+ Gdip_SetInterpolationMode(G1, 7)
+ Gdip_DrawImage(G1, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight)
+
+ Gdip_DeleteGraphics(G1)
+
+ pBitmap2 := Gdip_CreateBitmap(sWidth, sHeight)
+ G2 := Gdip_GraphicsFromImage(pBitmap2)
+ Gdip_SetInterpolationMode(G2, 7)
+ Gdip_DrawImage(G2, pBitmap1, 0, 0, sWidth, sHeight, 0, 0, dWidth, dHeight)
+
+ Gdip_DeleteGraphics(G2)
+ Gdip_DisposeImage(pBitmap1)
+ return pBitmap2
+}
+
+;#####################################################################################
+
+; Function: Gdip_SaveBitmapToFile
+; Description: Saves a bitmap to a file in any supported format onto disk
+;
+; pBitmap Pointer to a bitmap
+; sOutput The name of the file that the bitmap will be saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG
+; Quality If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality
+;
+; return If the function succeeds, the return value is zero, otherwise:
+; -1 = Extension supplied is not a supported file format
+; -2 = Could not get a list of encoders on system
+; -3 = Could not find matching encoder for specified file format
+; -4 = Could not get WideChar name of output file
+; -5 = Could not save file to disk
+;
+; notes This function will use the extension supplied from the sOutput parameter to determine the output format
+
+Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=75)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ SplitPath, sOutput,,, Extension
+ if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
+ return -1
+ Extension := "." Extension
+
+ DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
+ VarSetCapacity(ci, nSize)
+ DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
+ if !(nCount && nSize)
+ return -2
+
+ If (A_IsUnicode){
+ StrGet_Name := "StrGet"
+ Loop, %nCount%
+ {
+ sString := %StrGet_Name%(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
+ }
+ } else {
+ Loop, %nCount%
+ {
+ Location := NumGet(ci, 76*(A_Index-1)+44)
+ nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(sString, nSize)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0)
+ if !InStr(sString, "*" Extension)
+ continue
+
+ pCodec := &ci+76*(A_Index-1)
+ 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
+ }
+ }
+ }
+ }
+
+ if (!A_IsUnicode)
+ {
+ nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, 0, "int", 0)
+ VarSetCapacity(wOutput, nSize*2)
+ DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, &wOutput, "int", nSize)
+ VarSetCapacity(wOutput, -1)
+ if !VarSetCapacity(wOutput)
+ return -4
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &wOutput, Ptr, pCodec, "uint", p ? p : 0)
+ }
+ else
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &sOutput, Ptr, pCodec, "uint", p ? p : 0)
+ return E ? -5 : 0
+}
+
+;#####################################################################################
+
+; Function Gdip_GetPixel
+; Description Gets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return Returns the ARGB value of the pixel
+
+Gdip_GetPixel(pBitmap, x, y)
+{
+ DllCall("gdiplus\GdipBitmapGetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "uint*", ARGB)
+ return ARGB
+}
+
+;#####################################################################################
+
+; Function Gdip_SetPixel
+; Description Sets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return status enumeration. 0 = success
+
+Gdip_SetPixel(pBitmap, x, y, ARGB)
+{
+ return DllCall("gdiplus\GdipBitmapSetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageWidth
+; Description Gives the width of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the width in pixels of the supplied bitmap
+
+Gdip_GetImageWidth(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width)
+ return Width
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageHeight
+; Description Gives the height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the height in pixels of the supplied bitmap
+
+Gdip_GetImageHeight(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height)
+ return Height
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDimensions
+; Description Gives the width and height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetImageDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ DllCall("gdiplus\GdipGetImageWidth", Ptr, pBitmap, "uint*", Width)
+ DllCall("gdiplus\GdipGetImageHeight", Ptr, pBitmap, "uint*", Height)
+}
+
+;#####################################################################################
+
+Gdip_GetDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+}
+
+;#####################################################################################
+
+Gdip_GetImagePixelFormat(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImagePixelFormat", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", Format)
+ return Format
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDpiX
+; Description Gives the horizontal dots per inch of the graphics of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetDpiX(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiX", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetDpiY(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiY", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_GetImageHorizontalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHorizontalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetImageVerticalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageVerticalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_BitmapSetResolution(pBitmap, dpix, dpiy)
+{
+ return DllCall("gdiplus\GdipBitmapSetResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float", dpix, "float", dpiy)
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromFile(sFile, IconNumber=1, IconSize="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ SplitPath, sFile,,, ext
+ if ext in exe,dll
+ {
+ Sizes := IconSize ? IconSize : 256 "|" 128 "|" 64 "|" 48 "|" 32 "|" 16
+ BufSize := 16 + (2*(A_PtrSize ? A_PtrSize : 4))
+
+ VarSetCapacity(buf, BufSize, 0)
+ Loop, Parse, Sizes, |
+ {
+ DllCall("PrivateExtractIcons", "str", sFile, "int", IconNumber-1, "int", A_LoopField, "int", A_LoopField, PtrA, hIcon, PtrA, 0, "uint", 1, "uint", 0)
+
+ if !hIcon
+ continue
+
+ if !DllCall("GetIconInfo", Ptr, hIcon, Ptr, &buf)
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+
+ hbmMask := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4))
+ hbmColor := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4) + (A_PtrSize ? A_PtrSize : 4))
+ if !(hbmColor && DllCall("GetObject", Ptr, hbmColor, "int", BufSize, Ptr, &buf))
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+ break
+ }
+ if !hIcon
+ return -1
+
+ Width := NumGet(buf, 4, "int"), Height := NumGet(buf, 8, "int")
+ hbm := CreateDIBSection(Width, -Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ if !DllCall("DrawIconEx", Ptr, hdc, "int", 0, "int", 0, Ptr, hIcon, "uint", Width, "uint", Height, "uint", 0, Ptr, 0, "uint", 3)
+ {
+ DestroyIcon(hIcon)
+ return -2
+ }
+
+ VarSetCapacity(dib, 104)
+ DllCall("GetObject", Ptr, hbm, "int", A_PtrSize = 8 ? 104 : 84, Ptr, &dib) ; sizeof(DIBSECTION) = 76+2*(A_PtrSize=8?4:0)+2*A_PtrSize
+ Stride := NumGet(dib, 12, "Int"), Bits := NumGet(dib, 20 + (A_PtrSize = 8 ? 4 : 0)) ; padding
+ DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", Stride, "int", 0x26200A, Ptr, Bits, PtrA, pBitmapOld)
+ pBitmap := Gdip_CreateBitmap(Width, Height)
+ G := Gdip_GraphicsFromImage(pBitmap)
+ , Gdip_DrawImage(G, pBitmapOld, 0, 0, Width, Height, 0, 0, Width, Height)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapOld)
+ DestroyIcon(hIcon)
+ }
+ else
+ {
+ if (!A_IsUnicode)
+ {
+ VarSetCapacity(wFile, 1024)
+ DllCall("kernel32\MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sFile, "int", -1, Ptr, &wFile, "int", 512)
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &wFile, PtrA, pBitmap)
+ }
+ else
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &sFile, PtrA, pBitmap)
+ }
+
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", Ptr, hBitmap, Ptr, Palette, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff)
+{
+ DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hbm, "int", Background)
+ return hbm
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHICON(hIcon)
+{
+ DllCall("gdiplus\GdipCreateBitmapFromHICON", A_PtrSize ? "UPtr" : "UInt", hIcon, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHICONFromBitmap(pBitmap)
+{
+ DllCall("gdiplus\GdipCreateHICONFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hIcon)
+ return hIcon
+}
+
+;#####################################################################################
+
+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_CreateBitmapFromClipboard()
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if !DllCall("OpenClipboard", Ptr, 0)
+ return -1
+ if !DllCall("IsClipboardFormatAvailable", "uint", 8)
+ return -2
+ if !hBitmap := DllCall("GetClipboardData", "uint", 2, Ptr)
+ return -3
+ if !pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap)
+ return -4
+ if !DllCall("CloseClipboard")
+ return -5
+ DeleteObject(hBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_SetBitmapToClipboard(pBitmap)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ off1 := A_PtrSize = 8 ? 52 : 44, off2 := A_PtrSize = 8 ? 32 : 24
+
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ DllCall("GetObject", Ptr, hBitmap, "int", VarSetCapacity(oi, A_PtrSize = 8 ? 96 : 84, 0), Ptr, &oi)
+ hdib := DllCall("GlobalAlloc", "uint", 2, Ptr, off1+NumGet(oi, off1, "UInt")-4, Ptr)
+ pdib := DllCall("GlobalLock", Ptr, hdib, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pdib, "uint", &oi+off2, Ptr, 40)
+ DllCall("RtlMoveMemory", Ptr, pdib+40, Ptr, NumGet(oi, off2 - (A_PtrSize ? A_PtrSize : 4)), Ptr, NumGet(oi, off1, "UInt"))
+ DllCall("GlobalUnlock", Ptr, hdib)
+ DllCall("DeleteObject", Ptr, hBitmap)
+ DllCall("OpenClipboard", Ptr, 0)
+ DllCall("EmptyClipboard")
+ DllCall("SetClipboardData", "uint", 8, Ptr, hdib)
+ DllCall("CloseClipboard")
+}
+
+;#####################################################################################
+
+Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format=0x26200A)
+{
+ DllCall("gdiplus\GdipCloneBitmapArea"
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "int", Format
+ , A_PtrSize ? "UPtr" : "UInt", pBitmap
+ , A_PtrSize ? "UPtr*" : "UInt*", pBitmapDest)
+ return pBitmapDest
+}
+
+;#####################################################################################
+; Create resources
+;#####################################################################################
+
+Gdip_CreatePen(ARGB, w)
+{
+ DllCall("gdiplus\GdipCreatePen1", "UInt", ARGB, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_CreatePenFromBrush(pBrush, w)
+{
+ DllCall("gdiplus\GdipCreatePen2", A_PtrSize ? "UPtr" : "UInt", pBrush, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_BrushCreateSolid(ARGB=0xff000000)
+{
+ DllCall("gdiplus\GdipCreateSolidFill", "UInt", ARGB, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; HatchStyleHorizontal = 0
+; HatchStyleVertical = 1
+; HatchStyleForwardDiagonal = 2
+; HatchStyleBackwardDiagonal = 3
+; HatchStyleCross = 4
+; HatchStyleDiagonalCross = 5
+; HatchStyle05Percent = 6
+; HatchStyle10Percent = 7
+; HatchStyle20Percent = 8
+; HatchStyle25Percent = 9
+; HatchStyle30Percent = 10
+; HatchStyle40Percent = 11
+; HatchStyle50Percent = 12
+; HatchStyle60Percent = 13
+; HatchStyle70Percent = 14
+; HatchStyle75Percent = 15
+; HatchStyle80Percent = 16
+; HatchStyle90Percent = 17
+; HatchStyleLightDownwardDiagonal = 18
+; HatchStyleLightUpwardDiagonal = 19
+; HatchStyleDarkDownwardDiagonal = 20
+; HatchStyleDarkUpwardDiagonal = 21
+; HatchStyleWideDownwardDiagonal = 22
+; HatchStyleWideUpwardDiagonal = 23
+; HatchStyleLightVertical = 24
+; HatchStyleLightHorizontal = 25
+; HatchStyleNarrowVertical = 26
+; HatchStyleNarrowHorizontal = 27
+; HatchStyleDarkVertical = 28
+; HatchStyleDarkHorizontal = 29
+; HatchStyleDashedDownwardDiagonal = 30
+; HatchStyleDashedUpwardDiagonal = 31
+; HatchStyleDashedHorizontal = 32
+; HatchStyleDashedVertical = 33
+; HatchStyleSmallConfetti = 34
+; HatchStyleLargeConfetti = 35
+; HatchStyleZigZag = 36
+; HatchStyleWave = 37
+; HatchStyleDiagonalBrick = 38
+; HatchStyleHorizontalBrick = 39
+; HatchStyleWeave = 40
+; HatchStylePlaid = 41
+; HatchStyleDivot = 42
+; HatchStyleDottedGrid = 43
+; HatchStyleDottedDiamond = 44
+; HatchStyleShingle = 45
+; HatchStyleTrellis = 46
+; HatchStyleSphere = 47
+; HatchStyleSmallGrid = 48
+; HatchStyleSmallCheckerBoard = 49
+; HatchStyleLargeCheckerBoard = 50
+; HatchStyleOutlinedDiamond = 51
+; HatchStyleSolidDiamond = 52
+; HatchStyleTotal = 53
+Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0)
+{
+ DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "UInt", ARGBfront, "UInt", ARGBback, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+Gdip_CreateTextureBrush(pBitmap, WrapMode=1, x=0, y=0, w="", h="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ if !(w && h)
+ DllCall("gdiplus\GdipCreateTexture", Ptr, pBitmap, "int", WrapMode, PtrA, pBrush)
+ else
+ DllCall("gdiplus\GdipCreateTexture2", Ptr, pBitmap, "int", WrapMode, "float", x, "float", y, "float", w, "float", h, PtrA, pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; WrapModeTile = 0
+; WrapModeTileFlipX = 1
+; WrapModeTileFlipY = 2
+; WrapModeTileFlipXY = 3
+; WrapModeClamp = 4
+Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2)
+ DllCall("gdiplus\GdipCreateLineBrush", Ptr, &PointF1, Ptr, &PointF2, "Uint", ARGB1, "Uint", ARGB2, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
+ return LGpBrush
+}
+
+;#####################################################################################
+
+; LinearGradientModeHorizontal = 0
+; LinearGradientModeVertical = 1
+; LinearGradientModeForwardDiagonal = 2
+; LinearGradientModeBackwardDiagonal = 3
+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_CloneBrush(pBrush)
+{
+ DllCall("gdiplus\GdipCloneBrush", A_PtrSize ? "UPtr" : "UInt", pBrush, A_PtrSize ? "UPtr*" : "UInt*", pBrushClone)
+ return pBrushClone
+}
+
+;#####################################################################################
+; Delete resources
+;#####################################################################################
+
+Gdip_DeletePen(pPen)
+{
+ return DllCall("gdiplus\GdipDeletePen", A_PtrSize ? "UPtr" : "UInt", pPen)
+}
+
+;#####################################################################################
+
+Gdip_DeleteBrush(pBrush)
+{
+ return DllCall("gdiplus\GdipDeleteBrush", A_PtrSize ? "UPtr" : "UInt", pBrush)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImage(pBitmap)
+{
+ return DllCall("gdiplus\GdipDisposeImage", A_PtrSize ? "UPtr" : "UInt", pBitmap)
+}
+
+;#####################################################################################
+
+Gdip_DeleteGraphics(pGraphics)
+{
+ return DllCall("gdiplus\GdipDeleteGraphics", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImageAttributes(ImageAttr)
+{
+ return DllCall("gdiplus\GdipDisposeImageAttributes", A_PtrSize ? "UPtr" : "UInt", ImageAttr)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFont(hFont)
+{
+ return DllCall("gdiplus\GdipDeleteFont", A_PtrSize ? "UPtr" : "UInt", hFont)
+}
+
+;#####################################################################################
+
+Gdip_DeleteStringFormat(hFormat)
+{
+ return DllCall("gdiplus\GdipDeleteStringFormat", A_PtrSize ? "UPtr" : "UInt", hFormat)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFontFamily(hFamily)
+{
+ return DllCall("gdiplus\GdipDeleteFontFamily", A_PtrSize ? "UPtr" : "UInt", hFamily)
+}
+
+;#####################################################################################
+
+Gdip_DeleteMatrix(Matrix)
+{
+ return DllCall("gdiplus\GdipDeleteMatrix", A_PtrSize ? "UPtr" : "UInt", Matrix)
+}
+
+;#####################################################################################
+; Text functions
+;#####################################################################################
+
+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_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_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
+}
+
+; Near = 0
+; Center = 1
+; Far = 2
+Gdip_SetStringFormatAlign(hFormat, Align)
+{
+ return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align)
+}
+
+; StringFormatFlagsDirectionRightToLeft = 0x00000001
+; StringFormatFlagsDirectionVertical = 0x00000002
+; StringFormatFlagsNoFitBlackBox = 0x00000004
+; StringFormatFlagsDisplayFormatControl = 0x00000020
+; StringFormatFlagsNoFontFallback = 0x00000400
+; StringFormatFlagsMeasureTrailingSpaces = 0x00000800
+; StringFormatFlagsNoWrap = 0x00001000
+; StringFormatFlagsLineLimit = 0x00002000
+; StringFormatFlagsNoClip = 0x00004000
+Gdip_StringFormatCreate(Format=0, Lang=0)
+{
+ DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat)
+ return hFormat
+}
+
+; Regular = 0
+; Bold = 1
+; Italic = 2
+; BoldItalic = 3
+; Underline = 4
+; Strikeout = 8
+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
+}
+
+;#####################################################################################
+; Matrix functions
+;#####################################################################################
+
+Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y)
+{
+ DllCall("gdiplus\GdipCreateMatrix2", "float", m11, "float", m12, "float", m21, "float", m22, "float", x, "float", y, A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+Gdip_CreateMatrix()
+{
+ DllCall("gdiplus\GdipCreateMatrix", A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+;#####################################################################################
+; GraphicsPath functions
+;#####################################################################################
+
+; Alternate = 0
+; Winding = 1
+Gdip_CreatePath(BrushMode=0)
+{
+ DllCall("gdiplus\GdipCreatePath", "int", BrushMode, A_PtrSize ? "UPtr*" : "UInt*", Path)
+ return Path
+}
+
+Gdip_AddPathEllipse(Path, x, y, w, h)
+{
+ return DllCall("gdiplus\GdipAddPathEllipse", A_PtrSize ? "UPtr" : "UInt", Path, "float", x, "float", y, "float", w, "float", h)
+}
+
+Gdip_AddPathPolygon(Path, 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\GdipAddPathPolygon", Ptr, Path, Ptr, &PointF, "int", Points0)
+}
+
+Gdip_DeletePath(Path)
+{
+ return DllCall("gdiplus\GdipDeletePath", A_PtrSize ? "UPtr" : "UInt", Path)
+}
+
+;#####################################################################################
+; Quality functions
+;#####################################################################################
+
+; SystemDefault = 0
+; SingleBitPerPixelGridFit = 1
+; SingleBitPerPixel = 2
+; AntiAliasGridFit = 3
+; AntiAlias = 4
+Gdip_SetTextRenderingHint(pGraphics, RenderingHint)
+{
+ return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint)
+}
+
+; Default = 0
+; LowQuality = 1
+; HighQuality = 2
+; Bilinear = 3
+; Bicubic = 4
+; NearestNeighbor = 5
+; HighQualityBilinear = 6
+; HighQualityBicubic = 7
+Gdip_SetInterpolationMode(pGraphics, InterpolationMode)
+{
+ return DllCall("gdiplus\GdipSetInterpolationMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", InterpolationMode)
+}
+
+; Default = 0
+; HighSpeed = 1
+; HighQuality = 2
+; None = 3
+; AntiAlias = 4
+Gdip_SetSmoothingMode(pGraphics, SmoothingMode)
+{
+ return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
+}
+
+; CompositingModeSourceOver = 0 (blended)
+; CompositingModeSourceCopy = 1 (overwrite)
+Gdip_SetCompositingMode(pGraphics, CompositingMode=0)
+{
+ return DllCall("gdiplus\GdipSetCompositingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", CompositingMode)
+}
+
+;#####################################################################################
+; Extra functions
+;#####################################################################################
+
+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
+}
+
+; Prepend = 0; The new operation is applied before the old operation.
+; Append = 1; The new operation is applied after the old operation.
+Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipRotateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", Angle, "int", MatrixOrder)
+}
+
+Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipScaleWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipTranslateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_ResetWorldTransform(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetRotatedTranslation(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+
+ Bound := (Angle >= 0) ? Mod(Angle, 360) : 360-Mod(-Angle, -360)
+ if ((Bound >= 0) && (Bound <= 90))
+ xTranslation := Height*Sin(TAngle), yTranslation := 0
+ else if ((Bound > 90) && (Bound <= 180))
+ xTranslation := (Height*Sin(TAngle))-(Width*Cos(TAngle)), yTranslation := -Height*Cos(TAngle)
+ else if ((Bound > 180) && (Bound <= 270))
+ xTranslation := -(Width*Cos(TAngle)), yTranslation := -(Height*Cos(TAngle))-(Width*Sin(TAngle))
+ else if ((Bound > 270) && (Bound <= 360))
+ xTranslation := 0, yTranslation := -Width*Sin(TAngle)
+}
+
+Gdip_GetRotatedDimensions(Width, Height, Angle, ByRef RWidth, ByRef RHeight)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+ if !(Width && Height)
+ return -1
+ RWidth := Ceil(Abs(Width*Cos(TAngle))+Abs(Height*Sin(TAngle)))
+ RHeight := Ceil(Abs(Width*Sin(TAngle))+Abs(Height*Cos(Tangle)))
+}
+
+; RotateNoneFlipNone = 0
+; Rotate90FlipNone = 1
+; Rotate180FlipNone = 2
+; Rotate270FlipNone = 3
+; RotateNoneFlipX = 4
+; Rotate90FlipX = 5
+; Rotate180FlipX = 6
+; Rotate270FlipX = 7
+; RotateNoneFlipY = Rotate180FlipX
+; Rotate90FlipY = Rotate270FlipX
+; Rotate180FlipY = RotateNoneFlipX
+; Rotate270FlipY = Rotate90FlipX
+; RotateNoneFlipXY = Rotate180FlipNone
+; Rotate90FlipXY = Rotate270FlipNone
+; Rotate180FlipXY = RotateNoneFlipNone
+; Rotate270FlipXY = Rotate90FlipNone
+
+Gdip_ImageRotateFlip(pBitmap, RotateFlipType=1)
+{
+ return DllCall("gdiplus\GdipImageRotateFlip", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", RotateFlipType)
+}
+
+; Replace = 0
+; Intersect = 1
+; Union = 2
+; Xor = 3
+; Exclude = 4
+; Complement = 5
+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_SetClipPath(pGraphics, Path, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ return DllCall("gdiplus\GdipSetClipPath", Ptr, pGraphics, Ptr, Path, "int", CombineMode)
+}
+
+Gdip_ResetClip(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetClipRegion(pGraphics)
+{
+ Region := Gdip_CreateRegion()
+ DllCall("gdiplus\GdipGetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", Region)
+ return Region
+}
+
+Gdip_SetClipRegion(pGraphics, Region, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipSetClipRegion", Ptr, pGraphics, Ptr, Region, "int", CombineMode)
+}
+
+Gdip_CreateRegion()
+{
+ DllCall("gdiplus\GdipCreateRegion", A_PtrSize ? "UPtr*" : "UInt*", Region)
+ return Region
+}
+
+Gdip_DeleteRegion(Region)
+{
+ return DllCall("gdiplus\GdipDeleteRegion", A_PtrSize ? "UPtr" : "UInt", Region)
+}
+
+;#####################################################################################
+; BitmapLockBits
+;#####################################################################################
+
+Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode = 3, PixelFormat = 0x26200a)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreateRect(Rect, x, y, w, h)
+ VarSetCapacity(BitmapData, 16+2*(A_PtrSize ? A_PtrSize : 4), 0)
+ E := DllCall("Gdiplus\GdipBitmapLockBits", Ptr, pBitmap, Ptr, &Rect, "uint", LockMode, "int", PixelFormat, Ptr, &BitmapData)
+ Stride := NumGet(BitmapData, 8, "Int")
+ Scan0 := NumGet(BitmapData, 16, Ptr)
+ return E
+}
+
+;#####################################################################################
+
+Gdip_UnlockBits(pBitmap, ByRef BitmapData)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("Gdiplus\GdipBitmapUnlockBits", Ptr, pBitmap, Ptr, &BitmapData)
+}
+
+;#####################################################################################
+
+Gdip_SetLockBitPixel(ARGB, Scan0, x, y, Stride)
+{
+ Numput(ARGB, Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_GetLockBitPixel(Scan0, x, y, Stride)
+{
+ return NumGet(Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_PixelateBitmap(pBitmap, ByRef pBitmapOut, BlockSize)
+{
+ static PixelateBitmap
+
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if (!PixelateBitmap)
+ {
+ if A_PtrSize != 8 ; x86 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 558BEC83EC3C8B4514538B5D1C99F7FB56578BC88955EC894DD885C90F8E830200008B451099F7FB8365DC008365E000894DC88955F08945E833FF897DD4
+ 397DE80F8E160100008BCB0FAFCB894DCC33C08945F88945FC89451C8945143BD87E608B45088D50028BC82BCA8BF02BF2418945F48B45E02955F4894DC4
+ 8D0CB80FAFCB03CA895DD08BD1895DE40FB64416030145140FB60201451C8B45C40FB604100145FC8B45F40FB604020145F883C204FF4DE475D6034D18FF
+ 4DD075C98B4DCC8B451499F7F98945148B451C99F7F989451C8B45FC99F7F98945FC8B45F899F7F98945F885DB7E648B450C8D50028BC82BCA83C103894D
+ C48BC82BCA41894DF48B4DD48945E48B45E02955E48D0C880FAFCB03CA895DD08BD18BF38A45148B7DC48804178A451C8B7DF488028A45FC8804178A45F8
+ 8B7DE488043A83C2044E75DA034D18FF4DD075CE8B4DCC8B7DD447897DD43B7DE80F8CF2FEFFFF837DF0000F842C01000033C08945F88945FC89451C8945
+ 148945E43BD87E65837DF0007E578B4DDC034DE48B75E80FAF4D180FAFF38B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945CC0F
+ B6440E030145140FB60101451C0FB6440F010145FC8B45F40FB604010145F883C104FF4DCC75D8FF45E4395DE47C9B8B4DF00FAFCB85C9740B8B451499F7
+ F9894514EB048365140033F63BCE740B8B451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB
+ 038975F88975E43BDE7E5A837DF0007E4C8B4DDC034DE48B75E80FAF4D180FAFF38B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955CC8A55
+ 1488540E038A551C88118A55FC88540F018A55F888140183C104FF4DCC75DFFF45E4395DE47CA68B45180145E0015DDCFF4DC80F8594FDFFFF8B451099F7
+ FB8955F08945E885C00F8E450100008B45EC0FAFC38365DC008945D48B45E88945CC33C08945F88945FC89451C8945148945103945EC7E6085DB7E518B4D
+ D88B45080FAFCB034D108D50020FAF4D18034DDC8BF08BF88945F403CA2BF22BFA2955F4895DC80FB6440E030145140FB60101451C0FB6440F010145FC8B
+ 45F40FB604080145F883C104FF4DC875D8FF45108B45103B45EC7CA08B4DD485C9740B8B451499F7F9894514EB048365140033F63BCE740B8B451C99F7F9
+ 89451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975103975EC7E5585DB7E468B4DD88B450C
+ 0FAFCB034D108D50020FAF4D18034DDC8BF08BF803CA2BF22BFA2BC2895DC88A551488540E038A551C88118A55FC88540F018A55F888140183C104FF4DC8
+ 75DFFF45108B45103B45EC7CAB8BC3C1E0020145DCFF4DCC0F85CEFEFFFF8B4DEC33C08945F88945FC89451C8945148945103BC87E6C3945F07E5C8B4DD8
+ 8B75E80FAFCB034D100FAFF30FAF4D188B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945C80FB6440E030145140FB60101451C0F
+ B6440F010145FC8B45F40FB604010145F883C104FF4DC875D833C0FF45108B4DEC394D107C940FAF4DF03BC874068B451499F7F933F68945143BCE740B8B
+ 451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975083975EC7E63EB0233F639
+ 75F07E4F8B4DD88B75E80FAFCB034D080FAFF30FAF4D188B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955108A551488540E038A551C8811
+ 8A55FC88540F018A55F888140883C104FF4D1075DFFF45088B45083B45EC7C9F5F5E33C05BC9C21800
+ )
+ else ; x64 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 4489442418488954241048894C24085355565741544155415641574883EC28418BC1448B8C24980000004C8BDA99488BD941F7F9448BD0448BFA8954240C
+ 448994248800000085C00F8E9D020000418BC04533E4458BF299448924244C8954241041F7F933C9898C24980000008BEA89542404448BE889442408EB05
+ 4C8B5C24784585ED0F8E1A010000458BF1418BFD48897C2418450FAFF14533D233F633ED4533E44533ED4585C97E5B4C63BC2490000000418D040A410FAF
+ C148984C8D441802498BD9498BD04D8BD90FB642010FB64AFF4403E80FB60203E90FB64AFE4883C2044403E003F149FFCB75DE4D03C748FFCB75D0488B7C
+ 24188B8C24980000004C8B5C2478418BC59941F7FE448BE8418BC49941F7FE448BE08BC59941F7FE8BE88BC69941F7FE8BF04585C97E4048639C24900000
+ 004103CA4D8BC1410FAFC94863C94A8D541902488BCA498BC144886901448821408869FF408871FE4883C10448FFC875E84803D349FFC875DA8B8C249800
+ 0000488B5C24704C8B5C24784183C20448FFCF48897C24180F850AFFFFFF8B6C2404448B2424448B6C24084C8B74241085ED0F840A01000033FF33DB4533
+ DB4533D24533C04585C97E53488B74247085ED7E42438D0C04418BC50FAF8C2490000000410FAFC18D04814863C8488D5431028BCD0FB642014403D00FB6
+ 024883C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC17CB28BCD410FAFC985C9740A418BC299F7F98BF0EB0233F685C9740B418BC3
+ 99F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585C97E4D4C8B74247885ED7E3841
+ 8D0C14418BC50FAF8C2490000000410FAFC18D04814863C84A8D4431028BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2413BD17CBD
+ 4C8B7424108B8C2498000000038C2490000000488B5C24704503E149FFCE44892424898C24980000004C897424100F859EFDFFFF448B7C240C448B842480
+ 000000418BC09941F7F98BE8448BEA89942498000000896C240C85C00F8E3B010000448BAC2488000000418BCF448BF5410FAFC9898C248000000033FF33
+ ED33F64533DB4533D24533C04585FF7E524585C97E40418BC5410FAFC14103C00FAF84249000000003C74898488D541802498BD90FB642014403D00FB602
+ 4883C2044403D80FB642FB03F00FB642FA03E848FFCB75DE488B5C247041FFC0453BC77CAE85C9740B418BC299F7F9448BE0EB034533E485C9740A418BC3
+ 99F7F98BD8EB0233DB85C9740A8BC699F7F9448BD8EB034533DB85C9740A8BC599F7F9448BD0EB034533D24533C04585FF7E4E488B4C24784585C97E3541
+ 8BC5410FAFC14103C00FAF84249000000003C74898488D540802498BC144886201881A44885AFF448852FE4883C20448FFC875E941FFC0453BC77CBE8B8C
+ 2480000000488B5C2470418BC1C1E00203F849FFCE0F85ECFEFFFF448BAC24980000008B6C240C448BA4248800000033FF33DB4533DB4533D24533C04585
+ FF7E5A488B7424704585ED7E48418BCC8BC5410FAFC94103C80FAF8C2490000000410FAFC18D04814863C8488D543102418BCD0FB642014403D00FB60248
+ 83C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC77CAB418BCF410FAFCD85C9740A418BC299F7F98BF0EB0233F685C9740B418BC399
+ F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585FF7E4E4585ED7E42418BCC8BC541
+ 0FAFC903CA0FAF8C2490000000410FAFC18D04814863C8488B442478488D440102418BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2
+ 413BD77CB233C04883C428415F415E415D415C5F5E5D5BC3
+ )
+
+ VarSetCapacity(PixelateBitmap, StrLen(MCode_PixelateBitmap)//2)
+ Loop % StrLen(MCode_PixelateBitmap)//2 ;%
+ NumPut("0x" SubStr(MCode_PixelateBitmap, (2*A_Index)-1, 2), PixelateBitmap, A_Index-1, "UChar")
+ DllCall("VirtualProtect", Ptr, &PixelateBitmap, Ptr, VarSetCapacity(PixelateBitmap), "uint", 0x40, A_PtrSize ? "UPtr*" : "UInt*", 0)
+ }
+
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+
+ if (Width != Gdip_GetImageWidth(pBitmapOut) || Height != Gdip_GetImageHeight(pBitmapOut))
+ return -1
+ if (BlockSize > Width || BlockSize > Height)
+ return -2
+
+ E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1)
+ E2 := Gdip_LockBits(pBitmapOut, 0, 0, Width, Height, Stride2, Scan02, BitmapData2)
+ if (E1 || E2)
+ return -3
+
+ E := DllCall(&PixelateBitmap, Ptr, Scan01, Ptr, Scan02, "int", Width, "int", Height, "int", Stride1, "int", BlockSize)
+
+ Gdip_UnlockBits(pBitmap, BitmapData1), Gdip_UnlockBits(pBitmapOut, BitmapData2)
+ return 0
+}
+
+;#####################################################################################
+
+Gdip_ToARGB(A, R, G, B)
+{
+ return (A << 24) | (R << 16) | (G << 8) | B
+}
+
+;#####################################################################################
+
+Gdip_FromARGB(ARGB, ByRef A, ByRef R, ByRef G, ByRef B)
+{
+ A := (0xff000000 & ARGB) >> 24
+ R := (0x00ff0000 & ARGB) >> 16
+ G := (0x0000ff00 & ARGB) >> 8
+ B := 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+Gdip_AFromARGB(ARGB)
+{
+ return (0xff000000 & ARGB) >> 24
+}
+
+;#####################################################################################
+
+Gdip_RFromARGB(ARGB)
+{
+ return (0x00ff0000 & ARGB) >> 16
+}
+
+;#####################################################################################
+
+Gdip_GFromARGB(ARGB)
+{
+ return (0x0000ff00 & ARGB) >> 8
+}
+
+;#####################################################################################
+
+Gdip_BFromARGB(ARGB)
+{
+ return 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+StrGetB(Address, Length=-1, Encoding=0)
+{
+ ; Flexible parameter handling:
+ if Length is not integer
+ Encoding := Length, Length := -1
+
+ ; Check for obvious errors.
+ if (Address+0 < 1024)
+ return
+
+ ; Ensure 'Encoding' contains a numeric identifier.
+ if Encoding = UTF-16
+ Encoding = 1200
+ else if Encoding = UTF-8
+ Encoding = 65001
+ else if SubStr(Encoding,1,2)="CP"
+ Encoding := SubStr(Encoding,3)
+
+ if !Encoding ; "" or 0
+ {
+ ; No conversion necessary, but we might not want the whole string.
+ if (Length == -1)
+ Length := DllCall("lstrlen", "uint", Address)
+ VarSetCapacity(String, Length)
+ DllCall("lstrcpyn", "str", String, "uint", Address, "int", Length + 1)
+ }
+ else if Encoding = 1200 ; UTF-16
+ {
+ char_count := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "uint", 0, "uint", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(String, char_count)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "str", String, "int", char_count, "uint", 0, "uint", 0)
+ }
+ else if Encoding is integer
+ {
+ ; Convert from target encoding to UTF-16 then to the active code page.
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", 0, "int", 0)
+ VarSetCapacity(String, char_count * 2)
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", &String, "int", char_count * 2)
+ String := StrGetB(&String, char_count, 1200)
+ }
+
+ return String
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.3/clubman.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.3/clubman.ahk
new file mode 100644
index 0000000..f7542d8
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.3/clubman.ahk
@@ -0,0 +1,490 @@
+
+; https://github.com/berban/Gdip
+
+#HotkeyInterval 99000000
+#KeyHistory 0
+#MaxHotkeysPerInterval 99000000
+#NoEnv
+#Persistent
+#SingleInstance Force
+#Include Lib\Gdip.ahk
+
+CoordMode, Pixel, Client
+CoordMode, ToolTip, Client
+DetectHiddenWindows, On
+ListLines Off
+Process, priority, , High
+SendMode Input
+SetBatchLines, -1
+SetDefaultMouseSpeed, 0
+SetFormat, Float, 0.2
+; SetFormat, IntegerFast, Hex
+SetKeyDelay, 50
+SetMouseDelay, -1
+SetWorkingDir %A_ScriptDir%
+
+; Variables
+races_clean := 0
+races_clean_percent := 0
+races_completed := 0
+races_completed_check := 0
+credits_total := 0
+credits_average := 0
+
+time_start := A_TickCount
+time_current := A_TickCount
+
+window_width := 640
+window_height := 360
+
+; GUI
+Gui, New, -MaximizeBox -Resize, ClubmanPlus 0.3
+Gui, Font, S10
+Gui, Add, Button, w150 h40 Default gStart, Start
+Gui, Add, Button, w150 h40 x+10 gReset, Reset
+Gui, Show
+return
+
+; GUI events
+GuiClose:
+ Gosub, Release_All
+ SetTimer, Health, Off
+ SetTimer, Summary, Off
+ OutputDebug % "Clubman> Terminated"
+ExitApp
+
+; GUI buttons
+Start:
+ hwnd := 0
+
+ Gosub, Release_All
+ Gosub, GrabWindow
+
+ if (hwnd = 0) {
+ MsgBox, % "PS Remote Play not found"
+ return
+ }
+
+ SetTimer, Health, 600000
+ SetTimer, Summary, 3600000
+ time_start := A_TickCount
+
+ ; ** AFK Loop
+ Gosub, Press_X
+
+ Loop {
+
+ ; ** RACE
+ OutputDebug % "Clubman> Race: Waiting for position GUI to show"
+ while (!IsColor(hwnd, 0xFFFFFF, 218, 490, 6, 20)) { ; top-right tire wear indicator
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race: Starting race"
+ Gosub, Hold_X
+ Gosub, Hold_Down
+ OutputDebug % "Clubman> Race: Racing until position GUI disappears"
+ while (IsColor(hwnd, 0xFFFFFF, 218, 490, 6, 20)) { ; top-right tire wear indicator
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race: Race ended, releasing all buttons"
+ Gosub, Release_All
+ Sleep, 5000
+
+ ; ** GO TO LEADERBOARDS
+ OutputDebug % "Clubman> End race: Waiting for continue X icon to show"
+ while (!IsColor(hwnd, 0xC9C9C9, 465, 519, 6, 20)) { ; X icon
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> End race: Press X to continue"
+ while (IsColor(hwnd, 0xC9C9C9, 465, 519, 6, 20)) { ; X icon
+ Gosub, Press_X
+ Sleep, 100
+ }
+ OutputDebug % "Clubman> End race: Transitioning to leaderboard"
+
+ ; ** LEADERBOARD
+ Loop {
+ OutputDebug % "Clubman> Leaderboard: Checking positions"
+
+ if (IsColor(hwnd, 0xBADD3E, 671, 124, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 1st position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 153, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 2nd position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 182, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 3rd position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 211, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 4th position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 240, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 5th position"
+ Gosub, Press_X
+ break
+ }
+ else {
+ Sleep, 500
+ }
+ }
+
+ ; ** REWARDS
+ OutputDebug % "Clubman> Rewards: Waiting for Rewards screen to load (checking money earnt)"
+ while (!IsColor(hwnd, 0xBE140F, 848, 192, 6, 100)) { ; money earn, the red text
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Rewards: Found Rewards screen"
+ races_completed++
+
+ Loop 100 {
+ if (IsColor(hwnd, 0x5C90FB, 451, 260, 10, 20)) { ; the 'R' in Clean Race Bonus
+ OutputDebug % "Clubman> Rewards: Clean bonus"
+ races_clean++
+ PixelSearch(486, 311, 1, hwnd, "clean", "")
+ break
+ }
+
+ if (A_Index == 100) {
+ OutputDebug % "Clubman> Rewards: No clean bonus"
+ PixelSearch(486, 311, 1, hwnd, "no-clean", "")
+ }
+ }
+
+ ; ** REPLAY
+ OutputDebug % "Clubman> Replay: Waiting for Replay screen to load"
+ while (!IsColor(hwnd, 0xFFFFFF, 911, 510, 4, 20)) { ; the cursor on top the exit button
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Replay: Pressing the Exit button"
+ while (IsColor(hwnd, 0xFFFFFF, 911, 510, 4, 20)) { ; the cursor on top the exit button
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Replay: Leaving the Replay screen"
+
+ ; ** RACE RESULTS
+ OutputDebug % "Clubman> Race Result: Waiting for Race Result screen to load (checking cursor)"
+ while (!IsColor(hwnd, 0xBE1E1C, 651, 497, 4, 20)) { ; the exit button
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Result: Moving cursor to the Retry button"
+ while (!IsColor(hwnd, 0xFFFFFF, 514, 504, 4, 20)) { ; cursor on top the retry button
+ Gosub, Press_Right
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Result: Pressing the Retry button"
+ while (IsColor(hwnd, 0xFFFFFF, 514, 504, 4, 20)) { ; cursor on top the retry button
+ Gosub, Press_X
+ Sleep, 500
+ }
+
+ ; ** RACE START
+ OutputDebug % "Clubman> Race Start: Waiting for Race Start screen to load (checking cursor)"
+ while (!IsColor(hwnd, 0xFFFFFF, 287, 504, 4, 20)) { ; cursor on top the start button
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Start: Pressing the Start button"
+ while (IsColor(hwnd, 0xFFFFFF, 287, 504, 4, 20)) { ; cursor on top the start button
+ Gosub, Press_X
+ Sleep, 500
+ }
+
+ OutputDebug % "--- Summary ---"
+ credits_total := (races_completed * 0.07 + races_clean * 0.035)
+ races_clean_percent := (races_clean / races_completed) * 100
+ time_current := A_TickCount
+ credits_average := credits_total / (time_current - time_start) * 3600000
+
+ OutputDebug % "Clubman> Summary: Races " races_completed
+ OutputDebug % "Clubman> Summary: Races Clean " races_clean
+ OutputDebug % "Clubman> Summary: Races Clean Rate " races_clean_percent "%"
+ OutputDebug % "Clubman> Summary: Earnings " credits_total "M"
+ OutputDebug % "Clubman> Summary: Earnings Rate " credits_average "M/Hr"
+ OutputDebug % "---------------"
+ }
+return
+
+Reset:
+ Gosub, GrabWindow
+ ; PixelSearch(465, 519, 6, hwnd, "", "2")
+ ; OutputDebug % "Clubman> has grey " IsColor(hwnd, 0xC9C9C9, 465, 519, 6, 20)
+return
+
+; -------------------
+; Health Check
+; -------------------
+Health:
+ FormatTime, current_date,, % "yyMMdd-HHmm-ss"
+ OutputDebug % "Clubman> Health: Checking health at " current_date
+ OutputDebug % "Clubman> Health: Races completed " races_completed
+ OutputDebug % "Clubman> Health: Races completed last time " races_completed_check
+
+ if (races_completed_check >= races_completed) {
+ OutputDebug % "Clubman> Health: Error dectected, sending notification"
+ SendNotification("ClubmanPlus", "Something went wrong", 2, "persistent")
+ } else {
+ OutputDebug % "Clubman> Health: Running healthy"
+ races_completed_check := races_completed
+ }
+Return
+
+; -------------------
+; Summary Check
+; -------------------
+Summary:
+ OutputDebug % "Clubman> Summary: Sending summary notification"
+ message := ""
+ message := message "Races " races_clean " / " races_completed " (" races_clean_percent ")`n"
+ message := message "Earnings " credits_total "M (" credits_average "M/Hr)"
+ SendNotification("ClubmanPlus", message, 0, "cashregister")
+Return
+
+; -------------------
+; Send Notification
+; -------------------
+SendNotification(title, message, level, sound) {
+
+ IniRead, token, %A_ScriptDir%\clubman.ini, pushover, token
+ IniRead, user, %A_ScriptDir%\clubman.ini, pushover, user_key
+
+ retries := 60
+ expires := 3600
+
+ url := "https://api.pushover.net/1/messages.json"
+ param := "token=" token "&user=" user "&title=" title "&message=" message "&sound=" sound "&priority=" level
+
+ if (level == 2) {
+ param := param "&retry=" retries "&expire=" expires
+ }
+
+ WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
+ WebRequest.Open("POST", url)
+ WebRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
+ WebRequest.Send(param)
+Return
+}
+
+; -------------------
+; Grab Window
+; -------------------
+GrabWindow:
+ OutputDebug % "Clubman> Looking for window"
+ hwnd := WinExist("PS Remote Play")
+
+ if (hwnd > 0) {
+ OutputDebug % "Clubman> Window found: " hwnd
+ WinMove, ahk_id %hwnd%,, 0, 0, %window_width%, %window_height%
+ WinActivate, ahk_id %hwnd%
+ ControlFocus,, ahk_id %hwnd%
+ }
+return
+
+; -------------------
+; Is Color
+; -------------------
+IsColor(hwnd, target_color, x, y, b, tolerance) {
+ for i, c in PixelSearch(x, y, b, hwnd) {
+ if (ColorDistance(c, target_color) <= tolerance) {
+ Return True
+ }
+ }
+Return False
+}
+
+; -------------------
+; Color Distance
+; -------------------
+ColorDistance( c1, c2 ) {
+ r1 := c1 >> 16
+ g1 := c1 >> 8 & 255
+ b1 := c1 & 255
+ r2 := c2 >> 16
+ g2 := c2 >> 8 & 255
+ b2 := c2 & 255
+return Sqrt( (r1-r2)**2 + (g1-g2)**2 + (b1-b2)**2 )
+}
+
+; -------------------
+; Pixel Search
+; -------------------
+PixelSearch(x, y, b, hwnd, debugsave := "", debugsavecropped := "") {
+ ; Find out client area
+ VarSetCapacity(rect, 16)
+ DllCall("GetClientRect", "ptr", hwnd, "ptr", &rect)
+ client_width := NumGet(rect, 8, "int")
+ client_height := NumGet(rect, 12, "int")
+
+ ; Recalculate the area desired to the current system scaling; values were taken using 150% scale
+ b := Floor((b * client_width) / 960)
+
+ ; Convert x and y to currrent system; values were taken using 4K resolution
+ x := Floor((A_ScreenWidth * x) / 3840)
+ y := Floor((A_ScreenHeight * y) / 2160)
+
+ ; Convert client to screen coordinates
+ VarSetCapacity(POINT, 8)
+ NumPut(x, &POINT, 0, "Int")
+ NumPut(y, &POINT, 4, "Int")
+ DllCall("user32\ClientToScreen", Ptr,hWnd, Ptr,&POINT)
+ x := NumGet(&POINT, 0, "Int")
+ y := NumGet(&POINT, 4, "Int")
+
+ WinGetPos,,, width, height, ahk_id %hwnd%
+
+ pToken := Gdip_Startup()
+ hbm := CreateDIBSection(width, height),
+ hdc := CreateCompatibleDC(),
+ obm := SelectObject(hdc, hbm)
+
+ RegExMatch(A_OsVersion, "\d+", version)
+ PrintWindow(hwnd, hdc, version >= 8 ? 2 : 0)
+
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(hdc, obm),
+ DeleteObject(hbm),
+ DeleteDC(hdc)
+
+ pixs := []
+ Loop % b*2 + 1 {
+ i := (-1 * b) + (A_Index - 1)
+ Loop % b*2 + 1 {
+ j := (-1 * b) + (A_Index - 1)
+ pixs.Push(Gdip_GetPixel(pBitmap, x+i, y+j) & 0x00FFFFFF)
+ }
+ }
+
+ FormatTime, current_date,, % "yyMMdd-HHmm-ss"
+
+ if (debugsave != "") {
+ Gdip_SaveBitmapToFile(pBitmap, A_ScriptDir . "\" . current_date . "-" . debugsave . ".bmp")
+ ; Run % filename
+ }
+ if (debugsavecropped != "") {
+ debugbitmap:=Gdip_CloneBitmapArea(pBitmap, x-b, y-b, b*2, b*2)
+ Gdip_SaveBitmapToFile(debugbitmap, A_ScriptDir . "\" . current_date . "-" . debugsavecropped . ".bmp")
+ Gdip_DisposeImage(debugbitmap)
+ ; Run % filename
+ }
+
+ Gdip_DisposeImage(pBitmap)
+ Gdip_Shutdown(pToken)
+return pixs
+}
+
+; -------------------
+; Release All
+; -------------------
+Release_All:
+ Gosub, Release_X
+ Gosub, Release_O
+return
+
+; -------------------
+; Press x
+; -------------------
+Press_X:
+ Gosub, Hold_X
+ Gosub, Release_x
+return
+
+Hold_X:
+ ControlSend,, {Enter down}, ahk_id %hwnd%
+return
+
+Release_X:
+ ControlSend,, {Enter up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press O
+; -------------------
+Press_O:
+ Gosub, Hold_O
+ Gosub, Release_O
+return
+
+Hold_O:
+ ControlSend,, {Esc down}, ahk_id %hwnd%
+return
+
+Release_O:
+ ControlSend,, {Esc up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press Right
+; -------------------
+Press_Right:
+ Gosub, Hold_Right
+ Gosub, Release_Right
+return
+
+Hold_Right:
+ ControlSend,, {Right down}, ahk_id %hwnd%
+return
+
+Release_Right:
+ ControlSend,, {Right up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press Left
+; -------------------
+Press_Left:
+ Gosub, Hold_Left
+ Gosub, Release_Left
+return
+
+Hold_Left:
+ ControlSend,, {Left down}, ahk_id %hwnd%
+return
+
+Release_Left:
+ ControlSend,, {Left up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press Up
+; -------------------
+Press_Up:
+ Gosub, Hold_Up
+ Gosub, Release_Up
+return
+
+Hold_Up:
+ ControlSend,, {Up down}, ahk_id %hwnd%
+return
+
+Release_Up:
+ ControlSend,, {Up up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press Down
+; -------------------
+Press_Down:
+ Gosub, Hold_Down
+ Gosub, Release_Down
+return
+
+Hold_Down:
+ ControlSend,, {Down down}, ahk_id %hwnd%
+return
+
+Release_Down:
+ ControlSend,, {Down up}, ahk_id %hwnd%
+return
+
+; Hotkeys
+^Esc::ExitApp
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.3/clubman.ini b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.3/clubman.ini
new file mode 100644
index 0000000..e70a764
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.3/clubman.ini
@@ -0,0 +1,3 @@
+[pushover]
+user_key=your_key
+token=your_token
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.4/Lib/Gdip.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.4/Lib/Gdip.ahk
new file mode 100644
index 0000000..0b629d5
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.4/Lib/Gdip.ahk
@@ -0,0 +1,2698 @@
+; Gdip standard library v1.45 by tic (Tariq Porter) 07/09/11
+; Modifed by Rseding91 using fincs 64 bit compatible Gdip library 5/1/2013
+; Supports: Basic, _L ANSi, _L Unicode x86 and _L Unicode x64
+;
+;#####################################################################################
+;#####################################################################################
+; STATUS ENUMERATION
+; Return values for functions specified to have status enumerated return type
+;#####################################################################################
+;
+; Ok = = 0
+; GenericError = 1
+; InvalidParameter = 2
+; OutOfMemory = 3
+; ObjectBusy = 4
+; InsufficientBuffer = 5
+; NotImplemented = 6
+; Win32Error = 7
+; WrongState = 8
+; Aborted = 9
+; FileNotFound = 10
+; ValueOverflow = 11
+; AccessDenied = 12
+; UnknownImageFormat = 13
+; FontFamilyNotFound = 14
+; FontStyleNotFound = 15
+; NotTrueTypeFont = 16
+; UnsupportedGdiplusVersion = 17
+; GdiplusNotInitialized = 18
+; PropertyNotFound = 19
+; PropertyNotSupported = 20
+; ProfileNotFound = 21
+;
+;#####################################################################################
+;#####################################################################################
+; FUNCTIONS
+;#####################################################################################
+;
+; UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255)
+; BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+; StretchBlt(dDC, dx, dy, dw, dh, sDC, sx, sy, sw, sh, Raster="")
+; SetImage(hwnd, hBitmap)
+; Gdip_BitmapFromScreen(Screen=0, Raster="")
+; CreateRectF(ByRef RectF, x, y, w, h)
+; CreateSizeF(ByRef SizeF, w, h)
+; CreateDIBSection
+;
+;#####################################################################################
+
+; Function: UpdateLayeredWindow
+; Description: Updates a layered window with the handle to the DC of a gdi bitmap
+;
+; hwnd Handle of the layered window to update
+; hdc Handle to the DC of the GDI bitmap to update the window with
+; Layeredx x position to place the window
+; Layeredy y position to place the window
+; Layeredw Width of the window
+; Layeredh Height of the window
+; Alpha Default = 255 : The transparency (0-255) to set the window transparency
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If x or y omitted, then layered window will use its current coordinates
+; If w or h omitted then current width and height will be used
+
+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)
+}
+
+;#####################################################################################
+
+; Function BitBlt
+; Description The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle
+; of pixels from the specified source device context into a destination device context.
+;
+; dDC handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of the area to copy
+; dh height of the area to copy
+; sDC handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used, which copies the source directly to the destination rectangle
+;
+; BLACKNESS = 0x00000042
+; NOTSRCERASE = 0x001100A6
+; NOTSRCCOPY = 0x00330008
+; SRCERASE = 0x00440328
+; DSTINVERT = 0x00550009
+; PATINVERT = 0x005A0049
+; SRCINVERT = 0x00660046
+; SRCAND = 0x008800C6
+; MERGEPAINT = 0x00BB0226
+; MERGECOPY = 0x00C000CA
+; SRCCOPY = 0x00CC0020
+; SRCPAINT = 0x00EE0086
+; PATCOPY = 0x00F00021
+; PATPAINT = 0x00FB0A09
+; WHITENESS = 0x00FF0062
+; CAPTUREBLT = 0x40000000
+; NOMIRRORBITMAP = 0x80000000
+
+BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\BitBlt"
+ , Ptr, dDC
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sDC
+ , "int", sx
+ , "int", sy
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function StretchBlt
+; Description The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle,
+; stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary.
+; The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.
+;
+; ddc handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination rectangle
+; dh height of destination rectangle
+; sdc handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used. It uses the same raster operations as BitBlt
+
+StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\StretchBlt"
+ , Ptr, ddc
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sdc
+ , "int", sx
+ , "int", sy
+ , "int", sw
+ , "int", sh
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function SetStretchBltMode
+; Description The SetStretchBltMode function sets the bitmap stretching mode in the specified device context
+;
+; hdc handle to the DC
+; iStretchMode The stretching mode, describing how the target will be stretched
+;
+; return If the function succeeds, the return value is the previous stretching mode. If it fails it will return 0
+;
+; STRETCH_ANDSCANS = 0x01
+; STRETCH_ORSCANS = 0x02
+; STRETCH_DELETESCANS = 0x03
+; STRETCH_HALFTONE = 0x04
+
+SetStretchBltMode(hdc, iStretchMode=4)
+{
+ return DllCall("gdi32\SetStretchBltMode"
+ , A_PtrSize ? "UPtr" : "UInt", hdc
+ , "int", iStretchMode)
+}
+
+;#####################################################################################
+
+; Function SetImage
+; Description Associates a new image with a static control
+;
+; hwnd handle of the control to update
+; hBitmap a gdi bitmap to associate the static control with
+;
+; return If the function succeeds, the return value is nonzero
+
+SetImage(hwnd, hBitmap)
+{
+ SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
+ E := ErrorLevel
+ DeleteObject(E)
+ return E
+}
+
+;#####################################################################################
+
+; Function SetSysColorToControl
+; Description Sets a solid colour to a control
+;
+; hwnd handle of the control to update
+; SysColor A system colour to set to the control
+;
+; return If the function succeeds, the return value is zero
+;
+; notes A control must have the 0xE style set to it so it is recognised as a bitmap
+; By default SysColor=15 is used which is COLOR_3DFACE. This is the standard background for a control
+;
+; COLOR_3DDKSHADOW = 21
+; COLOR_3DFACE = 15
+; COLOR_3DHIGHLIGHT = 20
+; COLOR_3DHILIGHT = 20
+; COLOR_3DLIGHT = 22
+; COLOR_3DSHADOW = 16
+; COLOR_ACTIVEBORDER = 10
+; COLOR_ACTIVECAPTION = 2
+; COLOR_APPWORKSPACE = 12
+; COLOR_BACKGROUND = 1
+; COLOR_BTNFACE = 15
+; COLOR_BTNHIGHLIGHT = 20
+; COLOR_BTNHILIGHT = 20
+; COLOR_BTNSHADOW = 16
+; COLOR_BTNTEXT = 18
+; COLOR_CAPTIONTEXT = 9
+; COLOR_DESKTOP = 1
+; COLOR_GRADIENTACTIVECAPTION = 27
+; COLOR_GRADIENTINACTIVECAPTION = 28
+; COLOR_GRAYTEXT = 17
+; COLOR_HIGHLIGHT = 13
+; COLOR_HIGHLIGHTTEXT = 14
+; COLOR_HOTLIGHT = 26
+; COLOR_INACTIVEBORDER = 11
+; COLOR_INACTIVECAPTION = 3
+; COLOR_INACTIVECAPTIONTEXT = 19
+; COLOR_INFOBK = 24
+; COLOR_INFOTEXT = 23
+; COLOR_MENU = 4
+; COLOR_MENUHILIGHT = 29
+; COLOR_MENUBAR = 30
+; COLOR_MENUTEXT = 7
+; COLOR_SCROLLBAR = 0
+; COLOR_WINDOW = 5
+; COLOR_WINDOWFRAME = 6
+; COLOR_WINDOWTEXT = 8
+
+SetSysColorToControl(hwnd, SysColor=15)
+{
+ WinGetPos,,, w, h, ahk_id %hwnd%
+ bc := DllCall("GetSysColor", "Int", SysColor, "UInt")
+ pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc >> 16 | bc & 0xff00 | (bc & 0xff) << 16))
+ pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap)
+ Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h)
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ SetImage(hwnd, hBitmap)
+ Gdip_DeleteBrush(pBrushClear)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap)
+ return 0
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromScreen
+; Description Gets a gdi+ bitmap from the screen
+;
+; Screen 0 = All screens
+; Any numerical value = Just that screen
+; x|y|w|h = Take specific coordinates with a width and height
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1: one or more of x,y,w,h not passed properly
+;
+; notes If no raster operation is specified, then SRCCOPY is used to the returned bitmap
+
+Gdip_BitmapFromScreen(Screen=0, Raster="")
+{
+ if (Screen = 0)
+ {
+ Sysget, x, 76
+ Sysget, y, 77
+ Sysget, w, 78
+ Sysget, h, 79
+ }
+ else if (SubStr(Screen, 1, 5) = "hwnd:")
+ {
+ Screen := SubStr(Screen, 6)
+ if !WinExist( "ahk_id " Screen)
+ return -2
+ WinGetPos,,, w, h, ahk_id %Screen%
+ x := y := 0
+ hhdc := GetDCEx(Screen, 3)
+ }
+ else if (Screen&1 != "")
+ {
+ Sysget, M, Monitor, %Screen%
+ x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
+ }
+ else
+ {
+ StringSplit, S, Screen, |
+ x := S1, y := S2, w := S3, h := S4
+ }
+
+ if (x = "") || (y = "") || (w = "") || (h = "")
+ return -1
+
+ chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
+ BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
+ ReleaseDC(hhdc)
+
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromHWND
+; Description Uses PrintWindow to get a handle to the specified window and return a bitmap from it
+;
+; hwnd handle to the window to get a bitmap from
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+;
+; notes Window must not be not minimised in order to get a handle to it's client area
+
+Gdip_BitmapFromHWND(hwnd)
+{
+ WinGetPos,,, Width, Height, ahk_id %hwnd%
+ hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ PrintWindow(hwnd, hdc)
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function CreateRectF
+; Description Creates a RectF object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+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")
+}
+
+;#####################################################################################
+
+; Function CreateRect
+; Description Creates a Rect object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+CreateRect(ByRef Rect, x, y, w, h)
+{
+ VarSetCapacity(Rect, 16)
+ NumPut(x, Rect, 0, "uint"), NumPut(y, Rect, 4, "uint"), NumPut(w, Rect, 8, "uint"), NumPut(h, Rect, 12, "uint")
+}
+;#####################################################################################
+
+; Function CreateSizeF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreateSizeF(ByRef SizeF, w, h)
+{
+ VarSetCapacity(SizeF, 8)
+ NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreatePointF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreatePointF(ByRef PointF, x, y)
+{
+ VarSetCapacity(PointF, 8)
+ NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreateDIBSection
+; Description The CreateDIBSection function creates a DIB (Device Independent Bitmap) that applications can write to directly
+;
+; w width of the bitmap to create
+; h height of the bitmap to create
+; hdc a handle to the device context to use the palette from
+; bpp bits per pixel (32 = ARGB)
+; ppvBits A pointer to a variable that receives a pointer to the location of the DIB bit values
+;
+; return returns a DIB. A gdi bitmap
+;
+; notes ppvBits will receive the location of the pixels in the DIB
+
+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
+}
+
+;#####################################################################################
+
+; Function PrintWindow
+; Description The PrintWindow function copies a visual window into the specified device context (DC), typically a printer DC
+;
+; hwnd A handle to the window that will be copied
+; hdc A handle to the device context
+; Flags Drawing options
+;
+; return If the function succeeds, it returns a nonzero value
+;
+; PW_CLIENTONLY = 1
+
+PrintWindow(hwnd, hdc, Flags=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("PrintWindow", Ptr, hwnd, Ptr, hdc, "uint", Flags)
+}
+
+;#####################################################################################
+
+; Function DestroyIcon
+; Description Destroys an icon and frees any memory the icon occupied
+;
+; hIcon Handle to the icon to be destroyed. The icon must not be in use
+;
+; return If the function succeeds, the return value is nonzero
+
+DestroyIcon(hIcon)
+{
+ return DllCall("DestroyIcon", A_PtrSize ? "UPtr" : "UInt", hIcon)
+}
+
+;#####################################################################################
+
+PaintDesktop(hdc)
+{
+ return DllCall("PaintDesktop", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+CreateCompatibleBitmap(hdc, w, h)
+{
+ return DllCall("gdi32\CreateCompatibleBitmap", A_PtrSize ? "UPtr" : "UInt", hdc, "int", w, "int", h)
+}
+
+;#####################################################################################
+
+; Function CreateCompatibleDC
+; Description This function creates a memory device context (DC) compatible with the specified device
+;
+; hdc Handle to an existing device context
+;
+; return returns the handle to a device context or 0 on failure
+;
+; notes If this handle is 0 (by default), the function creates a memory device context compatible with the application's current screen
+
+CreateCompatibleDC(hdc=0)
+{
+ return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+; Function SelectObject
+; Description The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type
+;
+; hdc Handle to a DC
+; hgdiobj A handle to the object to be selected into the DC
+;
+; return If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced
+;
+; notes The specified object must have been created by using one of the following functions
+; Bitmap - CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection (A single bitmap cannot be selected into more than one DC at the same time)
+; Brush - CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush
+; Font - CreateFont, CreateFontIndirect
+; Pen - CreatePen, CreatePenIndirect
+; Region - CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirect
+;
+; notes If the selected object is a region and the function succeeds, the return value is one of the following value
+;
+; SIMPLEREGION = 2 Region consists of a single rectangle
+; COMPLEXREGION = 3 Region consists of more than one rectangle
+; NULLREGION = 1 Region is empty
+
+SelectObject(hdc, hgdiobj)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
+}
+
+;#####################################################################################
+
+; Function DeleteObject
+; Description This function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object
+; After the object is deleted, the specified handle is no longer valid
+;
+; hObject Handle to a logical pen, brush, font, bitmap, region, or palette to delete
+;
+; return Nonzero indicates success. Zero indicates that the specified handle is not valid or that the handle is currently selected into a device context
+
+DeleteObject(hObject)
+{
+ return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject)
+}
+
+;#####################################################################################
+
+; Function GetDC
+; Description This function retrieves a handle to a display device context (DC) for the client area of the specified window.
+; The display device context can be used in subsequent graphics display interface (GDI) functions to draw in the client area of the window.
+;
+; hwnd Handle to the window whose device context is to be retrieved. If this value is NULL, GetDC retrieves the device context for the entire screen
+;
+; return The handle the device context for the specified window's client area indicates success. NULL indicates failure
+
+GetDC(hwnd=0)
+{
+ return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
+}
+
+;#####################################################################################
+
+; DCX_CACHE = 0x2
+; DCX_CLIPCHILDREN = 0x8
+; DCX_CLIPSIBLINGS = 0x10
+; DCX_EXCLUDERGN = 0x40
+; DCX_EXCLUDEUPDATE = 0x100
+; DCX_INTERSECTRGN = 0x80
+; DCX_INTERSECTUPDATE = 0x200
+; DCX_LOCKWINDOWUPDATE = 0x400
+; DCX_NORECOMPUTE = 0x100000
+; DCX_NORESETATTRS = 0x4
+; DCX_PARENTCLIP = 0x20
+; DCX_VALIDATE = 0x200000
+; DCX_WINDOW = 0x1
+
+GetDCEx(hwnd, flags=0, hrgnClip=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("GetDCEx", Ptr, hwnd, Ptr, hrgnClip, "int", flags)
+}
+
+;#####################################################################################
+
+; Function ReleaseDC
+; Description This function releases a device context (DC), freeing it for use by other applications. The effect of ReleaseDC depends on the type of device context
+;
+; hdc Handle to the device context to be released
+; hwnd Handle to the window whose device context is to be released
+;
+; return 1 = released
+; 0 = not released
+;
+; notes The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common device context
+; An application cannot use the ReleaseDC function to release a device context that was created by calling the CreateDC function; instead, it must use the DeleteDC function.
+
+ReleaseDC(hdc, hwnd=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function DeleteDC
+; Description The DeleteDC function deletes the specified device context (DC)
+;
+; hdc A handle to the device context
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC
+
+DeleteDC(hdc)
+{
+ return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+;#####################################################################################
+
+; Function Gdip_LibraryVersion
+; Description Get the current library version
+;
+; return the library version
+;
+; notes This is useful for non compiled programs to ensure that a person doesn't run an old version when testing your scripts
+
+Gdip_LibraryVersion()
+{
+ return 1.45
+}
+
+;#####################################################################################
+
+; Function: Gdip_BitmapFromBRA
+; Description: Gets a pointer to a gdi+ bitmap from a BRA file
+;
+; BRAFromMemIn The variable for a BRA file read to memory
+; File The name of the file, or its number that you would like (This depends on alternate parameter)
+; Alternate Changes whether the File parameter is the file name or its number
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1 = The BRA variable is empty
+; -2 = The BRA has an incorrect header
+; -3 = The BRA has information missing
+; -4 = Could not find file inside the BRA
+
+Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate=0)
+{
+ Static FName = "ObjRelease"
+
+ if !BRAFromMemIn
+ return -1
+ Loop, Parse, BRAFromMemIn, `n
+ {
+ if (A_Index = 1)
+ {
+ StringSplit, Header, A_LoopField, |
+ if (Header0 != 4 || Header2 != "BRA!")
+ return -2
+ }
+ else if (A_Index = 2)
+ {
+ StringSplit, Info, A_LoopField, |
+ if (Info0 != 3)
+ return -3
+ }
+ else
+ break
+ }
+ if !Alternate
+ StringReplace, File, File, \, \\, All
+ RegExMatch(BRAFromMemIn, "mi`n)^" (Alternate ? File "\|.+?\|(\d+)\|(\d+)" : "\d+\|" File "\|(\d+)\|(\d+)") "$", FileInfo)
+ if !FileInfo
+ return -4
+
+ hData := DllCall("GlobalAlloc", "uint", 2, Ptr, FileInfo2, Ptr)
+ pData := DllCall("GlobalLock", Ptr, hData, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pData, Ptr, &BRAFromMemIn+Info2+FileInfo1, Ptr, FileInfo2)
+ DllCall("GlobalUnlock", Ptr, hData)
+ DllCall("ole32\CreateStreamOnHGlobal", Ptr, hData, "int", 1, A_PtrSize ? "UPtr*" : "UInt*", pStream)
+ DllCall("gdiplus\GdipCreateBitmapFromStream", Ptr, pStream, A_PtrSize ? "UPtr*" : "UInt*", pBitmap)
+ If (A_PtrSize)
+ %FName%(pStream)
+ Else
+ DllCall(NumGet(NumGet(1*pStream)+8), "uint", pStream)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRectangle
+; Description This function uses a pen to draw the outline of a rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRoundedRectangle
+; Description This function uses a pen to draw the outline of a rounded rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawEllipse
+; Description This function uses a pen to draw the outline of an ellipse into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle the ellipse will be drawn into
+; y y-coordinate of the top left of the rectangle the ellipse will be drawn into
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawBezier
+; Description This function uses a pen to draw the outline of a bezier (a weighted curve) into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the bezier
+; y1 y-coordinate of the start of the bezier
+; x2 x-coordinate of the first arc of the bezier
+; y2 y-coordinate of the first arc of the bezier
+; x3 x-coordinate of the second arc of the bezier
+; y3 y-coordinate of the second arc of the bezier
+; x4 x-coordinate of the end of the bezier
+; y4 y-coordinate of the end of the bezier
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawBezier"
+ , Ptr, pgraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2
+ , "float", x3
+ , "float", y3
+ , "float", x4
+ , "float", y4)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawArc
+; Description This function uses a pen to draw the outline of an arc into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the arc
+; y y-coordinate of the start of the arc
+; w width of the arc
+; h height of the arc
+; StartAngle specifies the angle between the x-axis and the starting point of the arc
+; SweepAngle specifies the angle between the starting and ending points of the arc
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawArc"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawPie
+; Description This function uses a pen to draw the outline of a pie into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the pie
+; y y-coordinate of the start of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawPie", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLine
+; Description This function uses a pen to draw a line into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the line
+; y1 y-coordinate of the start of the line
+; x2 x-coordinate of the end of the line
+; y2 y-coordinate of the end of the line
+;
+; return status enumeration. 0 = success
+
+Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawLine"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLines
+; Description This function uses a pen to draw a series of joined lines into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRectangle
+; Description This function uses a brush to fill a rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRoundedRectangle
+; Description This function uses a brush to fill a rounded rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPolygon
+; Description This function uses a brush to fill a polygon in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+;
+; notes Alternate will fill the polygon as a whole, wheras winding will fill each new "segment"
+; Alternate = 0
+; Winding = 1
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPie
+; Description This function uses a brush to fill a pie in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the pie
+; y y-coordinate of the top left of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPie"
+ , Ptr, pGraphics
+ , Ptr, pBrush
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillEllipse
+; Description This function uses a brush to fill an ellipse in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the ellipse
+; y y-coordinate of the top left of the ellipse
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRegion
+; Description This function uses a brush to fill a region in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Region
+;
+; return status enumeration. 0 = success
+;
+; notes You can create a region Gdip_CreateRegion() and then add to this
+
+Gdip_FillRegion(pGraphics, pBrush, Region)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillRegion", Ptr, pGraphics, Ptr, pBrush, Ptr, Region)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPath
+; Description This function uses a brush to fill a path in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Path
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPath(pGraphics, pBrush, Path)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPath", Ptr, pGraphics, Ptr, pBrush, Ptr, Path)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImagePointsRect
+; Description This function draws a bitmap into the Graphics of another bitmap and skews it
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; Points Points passed as x1,y1|x2,y2|x3,y3 (3 points: top left, top right, bottom left) describing the drawing of the bitmap
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter
+
+Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1)
+{
+ 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")
+ }
+
+ 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 = "")
+ {
+ sx := 0, sy := 0
+ sw := Gdip_GetImageWidth(pBitmap)
+ sh := Gdip_GetImageHeight(pBitmap)
+ }
+
+ E := DllCall("gdiplus\GdipDrawImagePointsRect"
+ , Ptr, pGraphics
+ , Ptr, pBitmap
+ , Ptr, &PointF
+ , "int", Points0
+ , "float", sx
+ , "float", sy
+ , "float", sw
+ , "float", sh
+ , "int", 2
+ , Ptr, ImageAttr
+ , Ptr, 0
+ , Ptr, 0)
+ if ImageAttr
+ Gdip_DisposeImageAttributes(ImageAttr)
+ return E
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImage
+; Description This function draws a bitmap into the Graphics of another bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination image
+; dh height of destination image
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source image
+; sh height of source image
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Gdip_DrawImage performs faster
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter. For example:
+; MatrixBright=
+; (
+; 1.5 |0 |0 |0 |0
+; 0 |1.5 |0 |0 |0
+; 0 |0 |1.5 |0 |0
+; 0 |0 |0 |1 |0
+; 0.05 |0.05 |0.05 |0 |1
+; )
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_SetImageAttributesColorMatrix
+; Description This function creates an image matrix ready for drawing
+;
+; Matrix a matrix used to alter image attributes when drawing
+; passed with any delimeter
+;
+; return returns an image matrix on sucess or 0 if it fails
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromImage
+; Description This function gets the graphics for a bitmap used for drawing functions
+;
+; pBitmap Pointer to a bitmap to get the pointer to its graphics
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes a bitmap can be drawn into the graphics of another bitmap
+
+Gdip_GraphicsFromImage(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromHDC
+; Description This function gets the graphics from the handle to a device context
+;
+; hdc This is the handle to the device context
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes You can draw a bitmap into the graphics of another bitmap
+
+Gdip_GraphicsFromHDC(hdc)
+{
+ DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDC
+; Description This function gets the device context of the passed Graphics
+;
+; hdc This is the handle to the device context
+;
+; return returns the device context for the graphics of a bitmap
+
+Gdip_GetDC(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDC", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", hdc)
+ return hdc
+}
+
+;#####################################################################################
+
+; Function Gdip_ReleaseDC
+; Description This function releases a device context from use for further use
+;
+; pGraphics Pointer to the graphics of a bitmap
+; hdc This is the handle to the device context
+;
+; return status enumeration. 0 = success
+
+Gdip_ReleaseDC(pGraphics, hdc)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipReleaseDC", Ptr, pGraphics, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsClear
+; Description Clears the graphics of a bitmap ready for further drawing
+;
+; pGraphics Pointer to the graphics of a bitmap
+; ARGB The colour to clear the graphics to
+;
+; return status enumeration. 0 = success
+;
+; notes By default this will make the background invisible
+; Using clipping regions you can clear a particular area on the graphics rather than clearing the entire graphics
+
+Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff)
+{
+ return DllCall("gdiplus\GdipGraphicsClear", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_BlurBitmap
+; Description Gives a pointer to a blurred bitmap from a pointer to a bitmap
+;
+; pBitmap Pointer to a bitmap to be blurred
+; Blur The Amount to blur a bitmap by from 1 (least blur) to 100 (most blur)
+;
+; return If the function succeeds, the return value is a pointer to the new blurred bitmap
+; -1 = The blur parameter is outside the range 1-100
+;
+; notes This function will not dispose of the original bitmap
+
+Gdip_BlurBitmap(pBitmap, Blur)
+{
+ if (Blur > 100) || (Blur < 1)
+ return -1
+
+ sWidth := Gdip_GetImageWidth(pBitmap), sHeight := Gdip_GetImageHeight(pBitmap)
+ dWidth := sWidth//Blur, dHeight := sHeight//Blur
+
+ pBitmap1 := Gdip_CreateBitmap(dWidth, dHeight)
+ G1 := Gdip_GraphicsFromImage(pBitmap1)
+ Gdip_SetInterpolationMode(G1, 7)
+ Gdip_DrawImage(G1, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight)
+
+ Gdip_DeleteGraphics(G1)
+
+ pBitmap2 := Gdip_CreateBitmap(sWidth, sHeight)
+ G2 := Gdip_GraphicsFromImage(pBitmap2)
+ Gdip_SetInterpolationMode(G2, 7)
+ Gdip_DrawImage(G2, pBitmap1, 0, 0, sWidth, sHeight, 0, 0, dWidth, dHeight)
+
+ Gdip_DeleteGraphics(G2)
+ Gdip_DisposeImage(pBitmap1)
+ return pBitmap2
+}
+
+;#####################################################################################
+
+; Function: Gdip_SaveBitmapToFile
+; Description: Saves a bitmap to a file in any supported format onto disk
+;
+; pBitmap Pointer to a bitmap
+; sOutput The name of the file that the bitmap will be saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG
+; Quality If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality
+;
+; return If the function succeeds, the return value is zero, otherwise:
+; -1 = Extension supplied is not a supported file format
+; -2 = Could not get a list of encoders on system
+; -3 = Could not find matching encoder for specified file format
+; -4 = Could not get WideChar name of output file
+; -5 = Could not save file to disk
+;
+; notes This function will use the extension supplied from the sOutput parameter to determine the output format
+
+Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=75)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ SplitPath, sOutput,,, Extension
+ if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
+ return -1
+ Extension := "." Extension
+
+ DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
+ VarSetCapacity(ci, nSize)
+ DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
+ if !(nCount && nSize)
+ return -2
+
+ If (A_IsUnicode){
+ StrGet_Name := "StrGet"
+ Loop, %nCount%
+ {
+ sString := %StrGet_Name%(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
+ }
+ } else {
+ Loop, %nCount%
+ {
+ Location := NumGet(ci, 76*(A_Index-1)+44)
+ nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(sString, nSize)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0)
+ if !InStr(sString, "*" Extension)
+ continue
+
+ pCodec := &ci+76*(A_Index-1)
+ 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
+ }
+ }
+ }
+ }
+
+ if (!A_IsUnicode)
+ {
+ nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, 0, "int", 0)
+ VarSetCapacity(wOutput, nSize*2)
+ DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, &wOutput, "int", nSize)
+ VarSetCapacity(wOutput, -1)
+ if !VarSetCapacity(wOutput)
+ return -4
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &wOutput, Ptr, pCodec, "uint", p ? p : 0)
+ }
+ else
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &sOutput, Ptr, pCodec, "uint", p ? p : 0)
+ return E ? -5 : 0
+}
+
+;#####################################################################################
+
+; Function Gdip_GetPixel
+; Description Gets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return Returns the ARGB value of the pixel
+
+Gdip_GetPixel(pBitmap, x, y)
+{
+ DllCall("gdiplus\GdipBitmapGetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "uint*", ARGB)
+ return ARGB
+}
+
+;#####################################################################################
+
+; Function Gdip_SetPixel
+; Description Sets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return status enumeration. 0 = success
+
+Gdip_SetPixel(pBitmap, x, y, ARGB)
+{
+ return DllCall("gdiplus\GdipBitmapSetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageWidth
+; Description Gives the width of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the width in pixels of the supplied bitmap
+
+Gdip_GetImageWidth(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width)
+ return Width
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageHeight
+; Description Gives the height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the height in pixels of the supplied bitmap
+
+Gdip_GetImageHeight(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height)
+ return Height
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDimensions
+; Description Gives the width and height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetImageDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ DllCall("gdiplus\GdipGetImageWidth", Ptr, pBitmap, "uint*", Width)
+ DllCall("gdiplus\GdipGetImageHeight", Ptr, pBitmap, "uint*", Height)
+}
+
+;#####################################################################################
+
+Gdip_GetDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+}
+
+;#####################################################################################
+
+Gdip_GetImagePixelFormat(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImagePixelFormat", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", Format)
+ return Format
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDpiX
+; Description Gives the horizontal dots per inch of the graphics of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetDpiX(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiX", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetDpiY(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiY", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_GetImageHorizontalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHorizontalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetImageVerticalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageVerticalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_BitmapSetResolution(pBitmap, dpix, dpiy)
+{
+ return DllCall("gdiplus\GdipBitmapSetResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float", dpix, "float", dpiy)
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromFile(sFile, IconNumber=1, IconSize="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ SplitPath, sFile,,, ext
+ if ext in exe,dll
+ {
+ Sizes := IconSize ? IconSize : 256 "|" 128 "|" 64 "|" 48 "|" 32 "|" 16
+ BufSize := 16 + (2*(A_PtrSize ? A_PtrSize : 4))
+
+ VarSetCapacity(buf, BufSize, 0)
+ Loop, Parse, Sizes, |
+ {
+ DllCall("PrivateExtractIcons", "str", sFile, "int", IconNumber-1, "int", A_LoopField, "int", A_LoopField, PtrA, hIcon, PtrA, 0, "uint", 1, "uint", 0)
+
+ if !hIcon
+ continue
+
+ if !DllCall("GetIconInfo", Ptr, hIcon, Ptr, &buf)
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+
+ hbmMask := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4))
+ hbmColor := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4) + (A_PtrSize ? A_PtrSize : 4))
+ if !(hbmColor && DllCall("GetObject", Ptr, hbmColor, "int", BufSize, Ptr, &buf))
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+ break
+ }
+ if !hIcon
+ return -1
+
+ Width := NumGet(buf, 4, "int"), Height := NumGet(buf, 8, "int")
+ hbm := CreateDIBSection(Width, -Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ if !DllCall("DrawIconEx", Ptr, hdc, "int", 0, "int", 0, Ptr, hIcon, "uint", Width, "uint", Height, "uint", 0, Ptr, 0, "uint", 3)
+ {
+ DestroyIcon(hIcon)
+ return -2
+ }
+
+ VarSetCapacity(dib, 104)
+ DllCall("GetObject", Ptr, hbm, "int", A_PtrSize = 8 ? 104 : 84, Ptr, &dib) ; sizeof(DIBSECTION) = 76+2*(A_PtrSize=8?4:0)+2*A_PtrSize
+ Stride := NumGet(dib, 12, "Int"), Bits := NumGet(dib, 20 + (A_PtrSize = 8 ? 4 : 0)) ; padding
+ DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", Stride, "int", 0x26200A, Ptr, Bits, PtrA, pBitmapOld)
+ pBitmap := Gdip_CreateBitmap(Width, Height)
+ G := Gdip_GraphicsFromImage(pBitmap)
+ , Gdip_DrawImage(G, pBitmapOld, 0, 0, Width, Height, 0, 0, Width, Height)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapOld)
+ DestroyIcon(hIcon)
+ }
+ else
+ {
+ if (!A_IsUnicode)
+ {
+ VarSetCapacity(wFile, 1024)
+ DllCall("kernel32\MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sFile, "int", -1, Ptr, &wFile, "int", 512)
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &wFile, PtrA, pBitmap)
+ }
+ else
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &sFile, PtrA, pBitmap)
+ }
+
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", Ptr, hBitmap, Ptr, Palette, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff)
+{
+ DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hbm, "int", Background)
+ return hbm
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHICON(hIcon)
+{
+ DllCall("gdiplus\GdipCreateBitmapFromHICON", A_PtrSize ? "UPtr" : "UInt", hIcon, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHICONFromBitmap(pBitmap)
+{
+ DllCall("gdiplus\GdipCreateHICONFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hIcon)
+ return hIcon
+}
+
+;#####################################################################################
+
+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_CreateBitmapFromClipboard()
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if !DllCall("OpenClipboard", Ptr, 0)
+ return -1
+ if !DllCall("IsClipboardFormatAvailable", "uint", 8)
+ return -2
+ if !hBitmap := DllCall("GetClipboardData", "uint", 2, Ptr)
+ return -3
+ if !pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap)
+ return -4
+ if !DllCall("CloseClipboard")
+ return -5
+ DeleteObject(hBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_SetBitmapToClipboard(pBitmap)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ off1 := A_PtrSize = 8 ? 52 : 44, off2 := A_PtrSize = 8 ? 32 : 24
+
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ DllCall("GetObject", Ptr, hBitmap, "int", VarSetCapacity(oi, A_PtrSize = 8 ? 96 : 84, 0), Ptr, &oi)
+ hdib := DllCall("GlobalAlloc", "uint", 2, Ptr, off1+NumGet(oi, off1, "UInt")-4, Ptr)
+ pdib := DllCall("GlobalLock", Ptr, hdib, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pdib, "uint", &oi+off2, Ptr, 40)
+ DllCall("RtlMoveMemory", Ptr, pdib+40, Ptr, NumGet(oi, off2 - (A_PtrSize ? A_PtrSize : 4)), Ptr, NumGet(oi, off1, "UInt"))
+ DllCall("GlobalUnlock", Ptr, hdib)
+ DllCall("DeleteObject", Ptr, hBitmap)
+ DllCall("OpenClipboard", Ptr, 0)
+ DllCall("EmptyClipboard")
+ DllCall("SetClipboardData", "uint", 8, Ptr, hdib)
+ DllCall("CloseClipboard")
+}
+
+;#####################################################################################
+
+Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format=0x26200A)
+{
+ DllCall("gdiplus\GdipCloneBitmapArea"
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "int", Format
+ , A_PtrSize ? "UPtr" : "UInt", pBitmap
+ , A_PtrSize ? "UPtr*" : "UInt*", pBitmapDest)
+ return pBitmapDest
+}
+
+;#####################################################################################
+; Create resources
+;#####################################################################################
+
+Gdip_CreatePen(ARGB, w)
+{
+ DllCall("gdiplus\GdipCreatePen1", "UInt", ARGB, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_CreatePenFromBrush(pBrush, w)
+{
+ DllCall("gdiplus\GdipCreatePen2", A_PtrSize ? "UPtr" : "UInt", pBrush, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_BrushCreateSolid(ARGB=0xff000000)
+{
+ DllCall("gdiplus\GdipCreateSolidFill", "UInt", ARGB, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; HatchStyleHorizontal = 0
+; HatchStyleVertical = 1
+; HatchStyleForwardDiagonal = 2
+; HatchStyleBackwardDiagonal = 3
+; HatchStyleCross = 4
+; HatchStyleDiagonalCross = 5
+; HatchStyle05Percent = 6
+; HatchStyle10Percent = 7
+; HatchStyle20Percent = 8
+; HatchStyle25Percent = 9
+; HatchStyle30Percent = 10
+; HatchStyle40Percent = 11
+; HatchStyle50Percent = 12
+; HatchStyle60Percent = 13
+; HatchStyle70Percent = 14
+; HatchStyle75Percent = 15
+; HatchStyle80Percent = 16
+; HatchStyle90Percent = 17
+; HatchStyleLightDownwardDiagonal = 18
+; HatchStyleLightUpwardDiagonal = 19
+; HatchStyleDarkDownwardDiagonal = 20
+; HatchStyleDarkUpwardDiagonal = 21
+; HatchStyleWideDownwardDiagonal = 22
+; HatchStyleWideUpwardDiagonal = 23
+; HatchStyleLightVertical = 24
+; HatchStyleLightHorizontal = 25
+; HatchStyleNarrowVertical = 26
+; HatchStyleNarrowHorizontal = 27
+; HatchStyleDarkVertical = 28
+; HatchStyleDarkHorizontal = 29
+; HatchStyleDashedDownwardDiagonal = 30
+; HatchStyleDashedUpwardDiagonal = 31
+; HatchStyleDashedHorizontal = 32
+; HatchStyleDashedVertical = 33
+; HatchStyleSmallConfetti = 34
+; HatchStyleLargeConfetti = 35
+; HatchStyleZigZag = 36
+; HatchStyleWave = 37
+; HatchStyleDiagonalBrick = 38
+; HatchStyleHorizontalBrick = 39
+; HatchStyleWeave = 40
+; HatchStylePlaid = 41
+; HatchStyleDivot = 42
+; HatchStyleDottedGrid = 43
+; HatchStyleDottedDiamond = 44
+; HatchStyleShingle = 45
+; HatchStyleTrellis = 46
+; HatchStyleSphere = 47
+; HatchStyleSmallGrid = 48
+; HatchStyleSmallCheckerBoard = 49
+; HatchStyleLargeCheckerBoard = 50
+; HatchStyleOutlinedDiamond = 51
+; HatchStyleSolidDiamond = 52
+; HatchStyleTotal = 53
+Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0)
+{
+ DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "UInt", ARGBfront, "UInt", ARGBback, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+Gdip_CreateTextureBrush(pBitmap, WrapMode=1, x=0, y=0, w="", h="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ if !(w && h)
+ DllCall("gdiplus\GdipCreateTexture", Ptr, pBitmap, "int", WrapMode, PtrA, pBrush)
+ else
+ DllCall("gdiplus\GdipCreateTexture2", Ptr, pBitmap, "int", WrapMode, "float", x, "float", y, "float", w, "float", h, PtrA, pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; WrapModeTile = 0
+; WrapModeTileFlipX = 1
+; WrapModeTileFlipY = 2
+; WrapModeTileFlipXY = 3
+; WrapModeClamp = 4
+Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2)
+ DllCall("gdiplus\GdipCreateLineBrush", Ptr, &PointF1, Ptr, &PointF2, "Uint", ARGB1, "Uint", ARGB2, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
+ return LGpBrush
+}
+
+;#####################################################################################
+
+; LinearGradientModeHorizontal = 0
+; LinearGradientModeVertical = 1
+; LinearGradientModeForwardDiagonal = 2
+; LinearGradientModeBackwardDiagonal = 3
+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_CloneBrush(pBrush)
+{
+ DllCall("gdiplus\GdipCloneBrush", A_PtrSize ? "UPtr" : "UInt", pBrush, A_PtrSize ? "UPtr*" : "UInt*", pBrushClone)
+ return pBrushClone
+}
+
+;#####################################################################################
+; Delete resources
+;#####################################################################################
+
+Gdip_DeletePen(pPen)
+{
+ return DllCall("gdiplus\GdipDeletePen", A_PtrSize ? "UPtr" : "UInt", pPen)
+}
+
+;#####################################################################################
+
+Gdip_DeleteBrush(pBrush)
+{
+ return DllCall("gdiplus\GdipDeleteBrush", A_PtrSize ? "UPtr" : "UInt", pBrush)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImage(pBitmap)
+{
+ return DllCall("gdiplus\GdipDisposeImage", A_PtrSize ? "UPtr" : "UInt", pBitmap)
+}
+
+;#####################################################################################
+
+Gdip_DeleteGraphics(pGraphics)
+{
+ return DllCall("gdiplus\GdipDeleteGraphics", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImageAttributes(ImageAttr)
+{
+ return DllCall("gdiplus\GdipDisposeImageAttributes", A_PtrSize ? "UPtr" : "UInt", ImageAttr)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFont(hFont)
+{
+ return DllCall("gdiplus\GdipDeleteFont", A_PtrSize ? "UPtr" : "UInt", hFont)
+}
+
+;#####################################################################################
+
+Gdip_DeleteStringFormat(hFormat)
+{
+ return DllCall("gdiplus\GdipDeleteStringFormat", A_PtrSize ? "UPtr" : "UInt", hFormat)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFontFamily(hFamily)
+{
+ return DllCall("gdiplus\GdipDeleteFontFamily", A_PtrSize ? "UPtr" : "UInt", hFamily)
+}
+
+;#####################################################################################
+
+Gdip_DeleteMatrix(Matrix)
+{
+ return DllCall("gdiplus\GdipDeleteMatrix", A_PtrSize ? "UPtr" : "UInt", Matrix)
+}
+
+;#####################################################################################
+; Text functions
+;#####################################################################################
+
+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_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_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
+}
+
+; Near = 0
+; Center = 1
+; Far = 2
+Gdip_SetStringFormatAlign(hFormat, Align)
+{
+ return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align)
+}
+
+; StringFormatFlagsDirectionRightToLeft = 0x00000001
+; StringFormatFlagsDirectionVertical = 0x00000002
+; StringFormatFlagsNoFitBlackBox = 0x00000004
+; StringFormatFlagsDisplayFormatControl = 0x00000020
+; StringFormatFlagsNoFontFallback = 0x00000400
+; StringFormatFlagsMeasureTrailingSpaces = 0x00000800
+; StringFormatFlagsNoWrap = 0x00001000
+; StringFormatFlagsLineLimit = 0x00002000
+; StringFormatFlagsNoClip = 0x00004000
+Gdip_StringFormatCreate(Format=0, Lang=0)
+{
+ DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat)
+ return hFormat
+}
+
+; Regular = 0
+; Bold = 1
+; Italic = 2
+; BoldItalic = 3
+; Underline = 4
+; Strikeout = 8
+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
+}
+
+;#####################################################################################
+; Matrix functions
+;#####################################################################################
+
+Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y)
+{
+ DllCall("gdiplus\GdipCreateMatrix2", "float", m11, "float", m12, "float", m21, "float", m22, "float", x, "float", y, A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+Gdip_CreateMatrix()
+{
+ DllCall("gdiplus\GdipCreateMatrix", A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+;#####################################################################################
+; GraphicsPath functions
+;#####################################################################################
+
+; Alternate = 0
+; Winding = 1
+Gdip_CreatePath(BrushMode=0)
+{
+ DllCall("gdiplus\GdipCreatePath", "int", BrushMode, A_PtrSize ? "UPtr*" : "UInt*", Path)
+ return Path
+}
+
+Gdip_AddPathEllipse(Path, x, y, w, h)
+{
+ return DllCall("gdiplus\GdipAddPathEllipse", A_PtrSize ? "UPtr" : "UInt", Path, "float", x, "float", y, "float", w, "float", h)
+}
+
+Gdip_AddPathPolygon(Path, 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\GdipAddPathPolygon", Ptr, Path, Ptr, &PointF, "int", Points0)
+}
+
+Gdip_DeletePath(Path)
+{
+ return DllCall("gdiplus\GdipDeletePath", A_PtrSize ? "UPtr" : "UInt", Path)
+}
+
+;#####################################################################################
+; Quality functions
+;#####################################################################################
+
+; SystemDefault = 0
+; SingleBitPerPixelGridFit = 1
+; SingleBitPerPixel = 2
+; AntiAliasGridFit = 3
+; AntiAlias = 4
+Gdip_SetTextRenderingHint(pGraphics, RenderingHint)
+{
+ return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint)
+}
+
+; Default = 0
+; LowQuality = 1
+; HighQuality = 2
+; Bilinear = 3
+; Bicubic = 4
+; NearestNeighbor = 5
+; HighQualityBilinear = 6
+; HighQualityBicubic = 7
+Gdip_SetInterpolationMode(pGraphics, InterpolationMode)
+{
+ return DllCall("gdiplus\GdipSetInterpolationMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", InterpolationMode)
+}
+
+; Default = 0
+; HighSpeed = 1
+; HighQuality = 2
+; None = 3
+; AntiAlias = 4
+Gdip_SetSmoothingMode(pGraphics, SmoothingMode)
+{
+ return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
+}
+
+; CompositingModeSourceOver = 0 (blended)
+; CompositingModeSourceCopy = 1 (overwrite)
+Gdip_SetCompositingMode(pGraphics, CompositingMode=0)
+{
+ return DllCall("gdiplus\GdipSetCompositingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", CompositingMode)
+}
+
+;#####################################################################################
+; Extra functions
+;#####################################################################################
+
+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
+}
+
+; Prepend = 0; The new operation is applied before the old operation.
+; Append = 1; The new operation is applied after the old operation.
+Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipRotateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", Angle, "int", MatrixOrder)
+}
+
+Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipScaleWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipTranslateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_ResetWorldTransform(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetRotatedTranslation(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+
+ Bound := (Angle >= 0) ? Mod(Angle, 360) : 360-Mod(-Angle, -360)
+ if ((Bound >= 0) && (Bound <= 90))
+ xTranslation := Height*Sin(TAngle), yTranslation := 0
+ else if ((Bound > 90) && (Bound <= 180))
+ xTranslation := (Height*Sin(TAngle))-(Width*Cos(TAngle)), yTranslation := -Height*Cos(TAngle)
+ else if ((Bound > 180) && (Bound <= 270))
+ xTranslation := -(Width*Cos(TAngle)), yTranslation := -(Height*Cos(TAngle))-(Width*Sin(TAngle))
+ else if ((Bound > 270) && (Bound <= 360))
+ xTranslation := 0, yTranslation := -Width*Sin(TAngle)
+}
+
+Gdip_GetRotatedDimensions(Width, Height, Angle, ByRef RWidth, ByRef RHeight)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+ if !(Width && Height)
+ return -1
+ RWidth := Ceil(Abs(Width*Cos(TAngle))+Abs(Height*Sin(TAngle)))
+ RHeight := Ceil(Abs(Width*Sin(TAngle))+Abs(Height*Cos(Tangle)))
+}
+
+; RotateNoneFlipNone = 0
+; Rotate90FlipNone = 1
+; Rotate180FlipNone = 2
+; Rotate270FlipNone = 3
+; RotateNoneFlipX = 4
+; Rotate90FlipX = 5
+; Rotate180FlipX = 6
+; Rotate270FlipX = 7
+; RotateNoneFlipY = Rotate180FlipX
+; Rotate90FlipY = Rotate270FlipX
+; Rotate180FlipY = RotateNoneFlipX
+; Rotate270FlipY = Rotate90FlipX
+; RotateNoneFlipXY = Rotate180FlipNone
+; Rotate90FlipXY = Rotate270FlipNone
+; Rotate180FlipXY = RotateNoneFlipNone
+; Rotate270FlipXY = Rotate90FlipNone
+
+Gdip_ImageRotateFlip(pBitmap, RotateFlipType=1)
+{
+ return DllCall("gdiplus\GdipImageRotateFlip", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", RotateFlipType)
+}
+
+; Replace = 0
+; Intersect = 1
+; Union = 2
+; Xor = 3
+; Exclude = 4
+; Complement = 5
+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_SetClipPath(pGraphics, Path, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ return DllCall("gdiplus\GdipSetClipPath", Ptr, pGraphics, Ptr, Path, "int", CombineMode)
+}
+
+Gdip_ResetClip(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetClipRegion(pGraphics)
+{
+ Region := Gdip_CreateRegion()
+ DllCall("gdiplus\GdipGetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", Region)
+ return Region
+}
+
+Gdip_SetClipRegion(pGraphics, Region, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipSetClipRegion", Ptr, pGraphics, Ptr, Region, "int", CombineMode)
+}
+
+Gdip_CreateRegion()
+{
+ DllCall("gdiplus\GdipCreateRegion", A_PtrSize ? "UPtr*" : "UInt*", Region)
+ return Region
+}
+
+Gdip_DeleteRegion(Region)
+{
+ return DllCall("gdiplus\GdipDeleteRegion", A_PtrSize ? "UPtr" : "UInt", Region)
+}
+
+;#####################################################################################
+; BitmapLockBits
+;#####################################################################################
+
+Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode = 3, PixelFormat = 0x26200a)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreateRect(Rect, x, y, w, h)
+ VarSetCapacity(BitmapData, 16+2*(A_PtrSize ? A_PtrSize : 4), 0)
+ E := DllCall("Gdiplus\GdipBitmapLockBits", Ptr, pBitmap, Ptr, &Rect, "uint", LockMode, "int", PixelFormat, Ptr, &BitmapData)
+ Stride := NumGet(BitmapData, 8, "Int")
+ Scan0 := NumGet(BitmapData, 16, Ptr)
+ return E
+}
+
+;#####################################################################################
+
+Gdip_UnlockBits(pBitmap, ByRef BitmapData)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("Gdiplus\GdipBitmapUnlockBits", Ptr, pBitmap, Ptr, &BitmapData)
+}
+
+;#####################################################################################
+
+Gdip_SetLockBitPixel(ARGB, Scan0, x, y, Stride)
+{
+ Numput(ARGB, Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_GetLockBitPixel(Scan0, x, y, Stride)
+{
+ return NumGet(Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_PixelateBitmap(pBitmap, ByRef pBitmapOut, BlockSize)
+{
+ static PixelateBitmap
+
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if (!PixelateBitmap)
+ {
+ if A_PtrSize != 8 ; x86 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 558BEC83EC3C8B4514538B5D1C99F7FB56578BC88955EC894DD885C90F8E830200008B451099F7FB8365DC008365E000894DC88955F08945E833FF897DD4
+ 397DE80F8E160100008BCB0FAFCB894DCC33C08945F88945FC89451C8945143BD87E608B45088D50028BC82BCA8BF02BF2418945F48B45E02955F4894DC4
+ 8D0CB80FAFCB03CA895DD08BD1895DE40FB64416030145140FB60201451C8B45C40FB604100145FC8B45F40FB604020145F883C204FF4DE475D6034D18FF
+ 4DD075C98B4DCC8B451499F7F98945148B451C99F7F989451C8B45FC99F7F98945FC8B45F899F7F98945F885DB7E648B450C8D50028BC82BCA83C103894D
+ C48BC82BCA41894DF48B4DD48945E48B45E02955E48D0C880FAFCB03CA895DD08BD18BF38A45148B7DC48804178A451C8B7DF488028A45FC8804178A45F8
+ 8B7DE488043A83C2044E75DA034D18FF4DD075CE8B4DCC8B7DD447897DD43B7DE80F8CF2FEFFFF837DF0000F842C01000033C08945F88945FC89451C8945
+ 148945E43BD87E65837DF0007E578B4DDC034DE48B75E80FAF4D180FAFF38B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945CC0F
+ B6440E030145140FB60101451C0FB6440F010145FC8B45F40FB604010145F883C104FF4DCC75D8FF45E4395DE47C9B8B4DF00FAFCB85C9740B8B451499F7
+ F9894514EB048365140033F63BCE740B8B451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB
+ 038975F88975E43BDE7E5A837DF0007E4C8B4DDC034DE48B75E80FAF4D180FAFF38B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955CC8A55
+ 1488540E038A551C88118A55FC88540F018A55F888140183C104FF4DCC75DFFF45E4395DE47CA68B45180145E0015DDCFF4DC80F8594FDFFFF8B451099F7
+ FB8955F08945E885C00F8E450100008B45EC0FAFC38365DC008945D48B45E88945CC33C08945F88945FC89451C8945148945103945EC7E6085DB7E518B4D
+ D88B45080FAFCB034D108D50020FAF4D18034DDC8BF08BF88945F403CA2BF22BFA2955F4895DC80FB6440E030145140FB60101451C0FB6440F010145FC8B
+ 45F40FB604080145F883C104FF4DC875D8FF45108B45103B45EC7CA08B4DD485C9740B8B451499F7F9894514EB048365140033F63BCE740B8B451C99F7F9
+ 89451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975103975EC7E5585DB7E468B4DD88B450C
+ 0FAFCB034D108D50020FAF4D18034DDC8BF08BF803CA2BF22BFA2BC2895DC88A551488540E038A551C88118A55FC88540F018A55F888140183C104FF4DC8
+ 75DFFF45108B45103B45EC7CAB8BC3C1E0020145DCFF4DCC0F85CEFEFFFF8B4DEC33C08945F88945FC89451C8945148945103BC87E6C3945F07E5C8B4DD8
+ 8B75E80FAFCB034D100FAFF30FAF4D188B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945C80FB6440E030145140FB60101451C0F
+ B6440F010145FC8B45F40FB604010145F883C104FF4DC875D833C0FF45108B4DEC394D107C940FAF4DF03BC874068B451499F7F933F68945143BCE740B8B
+ 451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975083975EC7E63EB0233F639
+ 75F07E4F8B4DD88B75E80FAFCB034D080FAFF30FAF4D188B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955108A551488540E038A551C8811
+ 8A55FC88540F018A55F888140883C104FF4D1075DFFF45088B45083B45EC7C9F5F5E33C05BC9C21800
+ )
+ else ; x64 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 4489442418488954241048894C24085355565741544155415641574883EC28418BC1448B8C24980000004C8BDA99488BD941F7F9448BD0448BFA8954240C
+ 448994248800000085C00F8E9D020000418BC04533E4458BF299448924244C8954241041F7F933C9898C24980000008BEA89542404448BE889442408EB05
+ 4C8B5C24784585ED0F8E1A010000458BF1418BFD48897C2418450FAFF14533D233F633ED4533E44533ED4585C97E5B4C63BC2490000000418D040A410FAF
+ C148984C8D441802498BD9498BD04D8BD90FB642010FB64AFF4403E80FB60203E90FB64AFE4883C2044403E003F149FFCB75DE4D03C748FFCB75D0488B7C
+ 24188B8C24980000004C8B5C2478418BC59941F7FE448BE8418BC49941F7FE448BE08BC59941F7FE8BE88BC69941F7FE8BF04585C97E4048639C24900000
+ 004103CA4D8BC1410FAFC94863C94A8D541902488BCA498BC144886901448821408869FF408871FE4883C10448FFC875E84803D349FFC875DA8B8C249800
+ 0000488B5C24704C8B5C24784183C20448FFCF48897C24180F850AFFFFFF8B6C2404448B2424448B6C24084C8B74241085ED0F840A01000033FF33DB4533
+ DB4533D24533C04585C97E53488B74247085ED7E42438D0C04418BC50FAF8C2490000000410FAFC18D04814863C8488D5431028BCD0FB642014403D00FB6
+ 024883C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC17CB28BCD410FAFC985C9740A418BC299F7F98BF0EB0233F685C9740B418BC3
+ 99F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585C97E4D4C8B74247885ED7E3841
+ 8D0C14418BC50FAF8C2490000000410FAFC18D04814863C84A8D4431028BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2413BD17CBD
+ 4C8B7424108B8C2498000000038C2490000000488B5C24704503E149FFCE44892424898C24980000004C897424100F859EFDFFFF448B7C240C448B842480
+ 000000418BC09941F7F98BE8448BEA89942498000000896C240C85C00F8E3B010000448BAC2488000000418BCF448BF5410FAFC9898C248000000033FF33
+ ED33F64533DB4533D24533C04585FF7E524585C97E40418BC5410FAFC14103C00FAF84249000000003C74898488D541802498BD90FB642014403D00FB602
+ 4883C2044403D80FB642FB03F00FB642FA03E848FFCB75DE488B5C247041FFC0453BC77CAE85C9740B418BC299F7F9448BE0EB034533E485C9740A418BC3
+ 99F7F98BD8EB0233DB85C9740A8BC699F7F9448BD8EB034533DB85C9740A8BC599F7F9448BD0EB034533D24533C04585FF7E4E488B4C24784585C97E3541
+ 8BC5410FAFC14103C00FAF84249000000003C74898488D540802498BC144886201881A44885AFF448852FE4883C20448FFC875E941FFC0453BC77CBE8B8C
+ 2480000000488B5C2470418BC1C1E00203F849FFCE0F85ECFEFFFF448BAC24980000008B6C240C448BA4248800000033FF33DB4533DB4533D24533C04585
+ FF7E5A488B7424704585ED7E48418BCC8BC5410FAFC94103C80FAF8C2490000000410FAFC18D04814863C8488D543102418BCD0FB642014403D00FB60248
+ 83C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC77CAB418BCF410FAFCD85C9740A418BC299F7F98BF0EB0233F685C9740B418BC399
+ F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585FF7E4E4585ED7E42418BCC8BC541
+ 0FAFC903CA0FAF8C2490000000410FAFC18D04814863C8488B442478488D440102418BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2
+ 413BD77CB233C04883C428415F415E415D415C5F5E5D5BC3
+ )
+
+ VarSetCapacity(PixelateBitmap, StrLen(MCode_PixelateBitmap)//2)
+ Loop % StrLen(MCode_PixelateBitmap)//2 ;%
+ NumPut("0x" SubStr(MCode_PixelateBitmap, (2*A_Index)-1, 2), PixelateBitmap, A_Index-1, "UChar")
+ DllCall("VirtualProtect", Ptr, &PixelateBitmap, Ptr, VarSetCapacity(PixelateBitmap), "uint", 0x40, A_PtrSize ? "UPtr*" : "UInt*", 0)
+ }
+
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+
+ if (Width != Gdip_GetImageWidth(pBitmapOut) || Height != Gdip_GetImageHeight(pBitmapOut))
+ return -1
+ if (BlockSize > Width || BlockSize > Height)
+ return -2
+
+ E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1)
+ E2 := Gdip_LockBits(pBitmapOut, 0, 0, Width, Height, Stride2, Scan02, BitmapData2)
+ if (E1 || E2)
+ return -3
+
+ E := DllCall(&PixelateBitmap, Ptr, Scan01, Ptr, Scan02, "int", Width, "int", Height, "int", Stride1, "int", BlockSize)
+
+ Gdip_UnlockBits(pBitmap, BitmapData1), Gdip_UnlockBits(pBitmapOut, BitmapData2)
+ return 0
+}
+
+;#####################################################################################
+
+Gdip_ToARGB(A, R, G, B)
+{
+ return (A << 24) | (R << 16) | (G << 8) | B
+}
+
+;#####################################################################################
+
+Gdip_FromARGB(ARGB, ByRef A, ByRef R, ByRef G, ByRef B)
+{
+ A := (0xff000000 & ARGB) >> 24
+ R := (0x00ff0000 & ARGB) >> 16
+ G := (0x0000ff00 & ARGB) >> 8
+ B := 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+Gdip_AFromARGB(ARGB)
+{
+ return (0xff000000 & ARGB) >> 24
+}
+
+;#####################################################################################
+
+Gdip_RFromARGB(ARGB)
+{
+ return (0x00ff0000 & ARGB) >> 16
+}
+
+;#####################################################################################
+
+Gdip_GFromARGB(ARGB)
+{
+ return (0x0000ff00 & ARGB) >> 8
+}
+
+;#####################################################################################
+
+Gdip_BFromARGB(ARGB)
+{
+ return 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+StrGetB(Address, Length=-1, Encoding=0)
+{
+ ; Flexible parameter handling:
+ if Length is not integer
+ Encoding := Length, Length := -1
+
+ ; Check for obvious errors.
+ if (Address+0 < 1024)
+ return
+
+ ; Ensure 'Encoding' contains a numeric identifier.
+ if Encoding = UTF-16
+ Encoding = 1200
+ else if Encoding = UTF-8
+ Encoding = 65001
+ else if SubStr(Encoding,1,2)="CP"
+ Encoding := SubStr(Encoding,3)
+
+ if !Encoding ; "" or 0
+ {
+ ; No conversion necessary, but we might not want the whole string.
+ if (Length == -1)
+ Length := DllCall("lstrlen", "uint", Address)
+ VarSetCapacity(String, Length)
+ DllCall("lstrcpyn", "str", String, "uint", Address, "int", Length + 1)
+ }
+ else if Encoding = 1200 ; UTF-16
+ {
+ char_count := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "uint", 0, "uint", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(String, char_count)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "str", String, "int", char_count, "uint", 0, "uint", 0)
+ }
+ else if Encoding is integer
+ {
+ ; Convert from target encoding to UTF-16 then to the active code page.
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", 0, "int", 0)
+ VarSetCapacity(String, char_count * 2)
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", &String, "int", char_count * 2)
+ String := StrGetB(&String, char_count, 1200)
+ }
+
+ return String
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.4/clubman.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.4/clubman.ahk
new file mode 100644
index 0000000..b661a0f
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.4/clubman.ahk
@@ -0,0 +1,521 @@
+
+; https://github.com/berban/Gdip
+
+#HotkeyInterval 99000000
+#KeyHistory 0
+#MaxHotkeysPerInterval 99000000
+#NoEnv
+#Persistent
+#SingleInstance Force
+#Include Lib\Gdip.ahk
+
+CoordMode, Pixel, Client
+CoordMode, ToolTip, Client
+DetectHiddenWindows, On
+ListLines Off
+Process, priority, , High
+SendMode Input
+SetBatchLines, -1
+SetDefaultMouseSpeed, 0
+SetFormat, Float, 0.2
+; SetFormat, IntegerFast, Hex
+SetKeyDelay, 50
+SetMouseDelay, -1
+SetWorkingDir %A_ScriptDir%
+
+; Variables
+races_clean := 0
+races_clean_percent := 0
+races_completed := 0
+races_completed_check := 0
+credits_total := 0
+credits_average := 0
+
+time_start := A_TickCount
+time_current := A_TickCount
+
+window_width := 640
+window_height := 360
+
+; GUI
+Gui, New, -MaximizeBox -Resize, ClubmanPlus 0.4
+Gui, Font, S10
+Gui, Add, Button, w150 h40 Default gStart, Start
+Gui, Add, Button, w150 h40 x+10 gReset, Reset
+Gui, Show
+return
+
+; GUI events
+GuiClose:
+ Gosub, Release_All
+ SetTimer, Health, Off
+ SetTimer, Summary, Off
+ OutputDebug % "Clubman> Terminated"
+ExitApp
+
+; GUI buttons
+Start:
+ hwnd := 0
+
+ Gosub, Release_All
+ Gosub, GrabWindow
+
+ if (hwnd = 0) {
+ MsgBox, % "PS Remote Play not found"
+ return
+ }
+
+ SetTimer, Health, 600000
+ SetTimer, Summary, 3600000
+ time_start := A_TickCount
+
+ ; ** AFK Loop
+ Gosub, Press_X
+
+ Loop {
+
+ ; ** RACE
+ OutputDebug % "Clubman> Race: Waiting for position GUI to show"
+ while (!IsColor(hwnd, 0xFFFFFF, 218, 490, 6, 20)) { ; top-right tire wear indicator
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race: Starting race"
+ Gosub, Hold_X
+ ; Gosub, Hold_Down
+ OutputDebug % "Clubman> Race: Racing until position GUI disappears"
+ while (IsColor(hwnd, 0xFFFFFF, 218, 490, 6, 20)) { ; top-right tire wear indicator
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race: Race ended, releasing all buttons"
+ Gosub, Release_All
+ ; Sleep, 5000
+
+ ; ** GO TO LEADERBOARDS
+ OutputDebug % "Clubman> End race: Waiting for continue X icon to show"
+ while (!IsColor(hwnd, 0xC9C9C9, 465, 519, 6, 20)) { ; X icon
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> End race: Press X to continue"
+ while (IsColor(hwnd, 0xC9C9C9, 465, 519, 6, 20)) { ; X icon
+ Gosub, Press_X
+ Sleep, 100
+ }
+ OutputDebug % "Clubman> End race: Transitioning to leaderboard"
+
+ ; ** LEADERBOARD
+ Loop {
+ OutputDebug % "Clubman> Leaderboard: Checking positions"
+
+ if (IsColor(hwnd, 0xBADD3E, 671, 124, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 1st position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 153, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 2nd position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 182, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 3rd position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 211, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 4th position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 240, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 5th position"
+ Gosub, Press_X
+ break
+ }
+ else {
+ Sleep, 500
+ }
+ }
+
+ ; ** REWARDS
+ OutputDebug % "Clubman> Rewards: Waiting for Rewards screen to load (checking money earnt)"
+ while (!IsColor(hwnd, 0xBE140F, 848, 192, 6, 100)) { ; money earn, the red text
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Rewards: Found Rewards screen"
+ races_completed++
+
+ Loop 100 {
+ if (IsColor(hwnd, 0x5C90FB, 451, 260, 10, 20)) { ; the 'R' in Clean Race Bonus
+ OutputDebug % "Clubman> Rewards: Clean bonus"
+ races_clean++
+ PixelSearch(486, 311, 1, hwnd, "clean", "")
+ break
+ }
+
+ if (A_Index == 100) {
+ OutputDebug % "Clubman> Rewards: No clean bonus"
+ PixelSearch(486, 311, 1, hwnd, "no-clean", "")
+ }
+ }
+
+ ; ** REPLAY
+ OutputDebug % "Clubman> Replay: Waiting for Replay screen to load"
+ while (!IsColor(hwnd, 0xFFFFFF, 911, 510, 4, 20)) { ; the cursor on top the exit button
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Replay: Pressing the Exit button"
+ while (IsColor(hwnd, 0xFFFFFF, 911, 510, 4, 20)) { ; the cursor on top the exit button
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Replay: Leaving the Replay screen"
+
+ ; ** RACE RESULTS
+ OutputDebug % "Clubman> Race Result: Waiting for Race Result screen to load (checking cursor)"
+ while (!IsColor(hwnd, 0xBE1E1C, 651, 497, 4, 20)) { ; the exit button
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Result: Moving cursor to the Retry button"
+ while (!IsColor(hwnd, 0xFFFFFF, 514, 504, 4, 20)) { ; cursor on top the retry button
+ Gosub, Press_Right
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Result: Pressing the Retry button"
+ while (IsColor(hwnd, 0xFFFFFF, 514, 504, 4, 20)) { ; cursor on top the retry button
+ Gosub, Press_X
+ Sleep, 500
+ }
+
+ ; ** RACE START
+ OutputDebug % "Clubman> Race Start: Waiting for Race Start screen to load (checking cursor)"
+ while (!IsColor(hwnd, 0xFFFFFF, 287, 504, 4, 20)) { ; cursor on top the start button
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Start: Pressing the Start button"
+ while (IsColor(hwnd, 0xFFFFFF, 287, 504, 4, 20)) { ; cursor on top the start button
+ Gosub, Press_X
+ Sleep, 500
+ }
+
+ OutputDebug % "--- Summary ---"
+ credits_total := (races_completed * 0.07 + races_clean * 0.035)
+ races_clean_percent := (races_clean / races_completed) * 100
+ time_current := A_TickCount
+ credits_average := credits_total / (time_current - time_start) * 3600000
+
+ OutputDebug % "Clubman> Summary: Races " races_completed
+ OutputDebug % "Clubman> Summary: Races Clean " races_clean
+ OutputDebug % "Clubman> Summary: Races Clean Rate " races_clean_percent "%"
+ OutputDebug % "Clubman> Summary: Earnings " credits_total "M"
+ OutputDebug % "Clubman> Summary: Earnings Rate " credits_average "M/Hr"
+ OutputDebug % "---------------"
+ }
+return
+
+Reset:
+ Gosub, GrabWindow
+ ; PixelSearch(465, 519, 6, hwnd, "", "2")
+ ; OutputDebug % "Clubman> has grey " IsColor(hwnd, 0xC9C9C9, 465, 519, 6, 20)
+
+ ; 960 / 296
+ ; 540 / 134
+ ; PixelSearch(3.243243, 4.029851, 20, hwnd, "", "test")
+
+ ; pToken := Gdip_Startup()
+ ; pBitmap := Gdip_BitmapFromScreen("hwnd:" hwnd)
+ ; Gdip_SaveBitmapToFile(pBitmap, A_ScriptDir . "\bolas.bmp")
+ ; Gdip_DisposeImage(pBitmap)
+ ; Gdip_Shutdown(pToken)
+return
+
+; -------------------
+; Health Check
+; -------------------
+Health:
+ FormatTime, current_date,, % "yyMMdd-HHmm-ss"
+ OutputDebug % "Clubman> Health: Checking health at " current_date
+ OutputDebug % "Clubman> Health: Races completed " races_completed
+ OutputDebug % "Clubman> Health: Races completed last time " races_completed_check
+
+ if (races_completed_check >= races_completed) {
+ OutputDebug % "Clubman> Health: Error dectected, sending notification"
+ SendNotification("ClubmanPlus", "Something went wrong", 2, "persistent")
+ } else {
+ OutputDebug % "Clubman> Health: Running healthy"
+ races_completed_check := races_completed
+ }
+Return
+
+; -------------------
+; Summary Check
+; -------------------
+Summary:
+ OutputDebug % "Clubman> Summary: Sending summary notification"
+ message := ""
+ message := message "Races " races_clean " / " races_completed " (" races_clean_percent ")`n"
+ message := message "Earnings " credits_total "M (" credits_average "M/Hr)"
+ SendNotification("ClubmanPlus", message, 0, "cashregister")
+Return
+
+; -------------------
+; Send Notification
+; -------------------
+SendNotification(title, message, level, sound) {
+
+ IniRead, token, %A_ScriptDir%\clubman.ini, pushover, token
+ IniRead, user, %A_ScriptDir%\clubman.ini, pushover, user_key
+
+ retries := 60
+ expires := 3600
+
+ url := "https://api.pushover.net/1/messages.json"
+ param := "token=" token "&user=" user "&title=" title "&message=" message "&sound=" sound "&priority=" level
+
+ if (level == 2) {
+ param := param "&retry=" retries "&expire=" expires
+ }
+
+ WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
+ WebRequest.Open("POST", url)
+ WebRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
+ WebRequest.Send(param)
+Return
+}
+
+; -------------------
+; Grab Window
+; -------------------
+GrabWindow:
+ OutputDebug % "Clubman> Looking for window"
+ hwnd := WinExist("PS Remote Play")
+
+ if (hwnd > 0) {
+ OutputDebug % "Clubman> Window found: " hwnd
+ WinMove, ahk_id %hwnd%,, 0, 0, %window_width%, %window_height%
+ WinActivate, ahk_id %hwnd%
+ ControlFocus,, ahk_id %hwnd%
+ }
+return
+
+; -------------------
+; Is Color
+; -------------------
+IsColor(hwnd, target_color, x, y, b, tolerance) {
+ for i, c in PixelSearch(x, y, b, hwnd) {
+ if (ColorDistance(c, target_color) <= tolerance) {
+ Return True
+ }
+ }
+Return False
+}
+
+; -------------------
+; Color Distance
+; -------------------
+ColorDistance( c1, c2 ) {
+ r1 := c1 >> 16
+ g1 := c1 >> 8 & 255
+ b1 := c1 & 255
+ r2 := c2 >> 16
+ g2 := c2 >> 8 & 255
+ b2 := c2 & 255
+return Sqrt( (r1-r2)**2 + (g1-g2)**2 + (b1-b2)**2 )
+}
+
+; -------------------
+; Pixel Search
+; -------------------
+PixelSearch(x, y, b, hwnd, debugsave := "", debugsavecropped := "") {
+ ; ; Find out client area
+ ; VarSetCapacity(rect, 16)
+ ; DllCall("GetClientRect", "ptr", hwnd, "ptr", &rect)
+ ; client_width := NumGet(rect, 8, "int")
+ ; client_height := NumGet(rect, 12, "int")
+
+ ; ; Recalculate the area desired to the current system scaling; values were taken using 150% scale
+ ; b := Floor((b * client_width) / 960)
+
+ ; ; Convert x and y to currrent system; values were taken using 4K resolution
+ ; x := Floor((A_ScreenWidth * x) / 3840)
+ ; y := Floor((A_ScreenHeight * y) / 2160)
+
+ ; ; Convert client to screen coordinates
+ ; VarSetCapacity(POINT, 8)
+ ; NumPut(x, &POINT, 0, "Int")
+ ; NumPut(y, &POINT, 4, "Int")
+ ; DllCall("user32\ClientToScreen", Ptr,hWnd, Ptr,&POINT)
+ ; x := NumGet(&POINT, 0, "Int")
+ ; y := NumGet(&POINT, 4, "Int")
+
+ x := (960 / x)
+ y := (540 / y)
+
+ VarSetCapacity(rect, 16)
+ DllCall("GetClientRect", "ptr", hwnd, "ptr", &rect)
+ x := floor(NumGet(rect, 8, "int") // x)
+ y := floor(NumGet(rect, 12, "int") // y)
+ b := floor((b * NumGet(rect, 8, "int")) / 960)
+
+ VarSetCapacity(POINT, 8)
+ NumPut(x, &POINT, 0, "Int")
+ NumPut(y, &POINT, 4, "Int")
+ DllCall("user32\ClientToScreen", Ptr, hwnd, Ptr,&POINT)
+ x := NumGet(&POINT, 0, "Int")
+ y := NumGet(&POINT, 4, "Int")
+
+ ; OutputDebug % "Clubman> Reading screen at " x "x" y
+
+ ; WinGetPos,,, width, height, ahk_id %hwnd%
+
+ ; pToken := Gdip_Startup()
+ ; hbm := CreateDIBSection(width, height),
+ ; hdc := CreateCompatibleDC(),
+ ; obm := SelectObject(hdc, hbm)
+
+ ; RegExMatch(A_OsVersion, "\d+", version)
+ ; PrintWindow(hwnd, hdc, version >= 8 ? 2 : 0)
+
+ ; pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ ; SelectObject(hdc, obm),
+ ; DeleteObject(hbm),
+ ; DeleteDC(hdc)
+
+ pToken := Gdip_Startup()
+ pBitmap := Gdip_BitmapFromScreen("hwnd:" hwnd)
+
+ pixs := []
+ Loop % b*2 + 1 {
+ i := (-1 * b) + (A_Index - 1)
+ Loop % b*2 + 1 {
+ j := (-1 * b) + (A_Index - 1)
+ pixs.Push(Gdip_GetPixel(pBitmap, x+i, y+j) & 0x00FFFFFF)
+ }
+ }
+
+ FormatTime, current_date,, % "yyMMdd-HHmm-ss"
+
+ if (debugsave != "") {
+ Gdip_SaveBitmapToFile(pBitmap, A_ScriptDir . "\" . current_date . "-" . debugsave . ".bmp")
+ ; Run % filename
+ }
+ if (debugsavecropped != "") {
+ debugbitmap:=Gdip_CloneBitmapArea(pBitmap, x-b, y-b, b*2, b*2)
+ Gdip_SaveBitmapToFile(debugbitmap, A_ScriptDir . "\" . current_date . "-" . debugsavecropped . ".bmp")
+ Gdip_DisposeImage(debugbitmap)
+ ; Run % filename
+ }
+
+ Gdip_DisposeImage(pBitmap)
+ Gdip_Shutdown(pToken)
+return pixs
+}
+
+; -------------------
+; Release All
+; -------------------
+Release_All:
+ Gosub, Release_X
+ Gosub, Release_O
+return
+
+; -------------------
+; Press x
+; -------------------
+Press_X:
+ Gosub, Hold_X
+ Gosub, Release_x
+return
+
+Hold_X:
+ ControlSend,, {Enter down}, ahk_id %hwnd%
+return
+
+Release_X:
+ ControlSend,, {Enter up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press O
+; -------------------
+Press_O:
+ Gosub, Hold_O
+ Gosub, Release_O
+return
+
+Hold_O:
+ ControlSend,, {Esc down}, ahk_id %hwnd%
+return
+
+Release_O:
+ ControlSend,, {Esc up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press Right
+; -------------------
+Press_Right:
+ Gosub, Hold_Right
+ Gosub, Release_Right
+return
+
+Hold_Right:
+ ControlSend,, {Right down}, ahk_id %hwnd%
+return
+
+Release_Right:
+ ControlSend,, {Right up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press Left
+; -------------------
+Press_Left:
+ Gosub, Hold_Left
+ Gosub, Release_Left
+return
+
+Hold_Left:
+ ControlSend,, {Left down}, ahk_id %hwnd%
+return
+
+Release_Left:
+ ControlSend,, {Left up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press Up
+; -------------------
+Press_Up:
+ Gosub, Hold_Up
+ Gosub, Release_Up
+return
+
+Hold_Up:
+ ControlSend,, {Up down}, ahk_id %hwnd%
+return
+
+Release_Up:
+ ControlSend,, {Up up}, ahk_id %hwnd%
+return
+
+; -------------------
+; Press Down
+; -------------------
+Press_Down:
+ Gosub, Hold_Down
+ Gosub, Release_Down
+return
+
+Hold_Down:
+ ControlSend,, {Down down}, ahk_id %hwnd%
+return
+
+Release_Down:
+ ControlSend,, {Down up}, ahk_id %hwnd%
+return
+
+; Hotkeys
+^Esc::ExitApp
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.4/clubman.ini b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.4/clubman.ini
new file mode 100644
index 0000000..e70a764
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.4/clubman.ini
@@ -0,0 +1,3 @@
+[pushover]
+user_key=your_key
+token=your_token
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/Lib/AHK-ViGEm-Bus.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/Lib/AHK-ViGEm-Bus.ahk
new file mode 100644
index 0000000..858cb3d
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/Lib/AHK-ViGEm-Bus.ahk
@@ -0,0 +1,211 @@
+#include %A_LineFile%\..\CLR.ahk
+
+; Static class, holds ViGEm Client instance
+class ViGEmWrapper {
+ static asm := 0
+ static client := 0
+
+ Init(){
+ if (this.client == 0){
+ this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
+ }
+ }
+
+ CreateInstance(cls){
+ return this.asm.CreateInstance(cls)
+ }
+
+}
+
+; Base class for ViGEm "Targets" (Controller types - eg xb360 / ds4) to inherit from
+class ViGEmTarget {
+ target := 0
+ helperClass := ""
+ controllerClass := ""
+
+ __New(){
+ ;~ this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
+ ViGEmWrapper.Init()
+ this.Instance := ViGEmWrapper.CreateInstance(this.helperClass)
+
+ if (this.Instance.OkCheck() != "OK"){
+ msgbox ViGEmWrapper.dll failed to load!
+ ExitApp
+ }
+ }
+
+ SendReport(){
+ this.Instance.SendReport()
+ }
+
+ SubscribeFeedback(callback){
+ this.Instance.SubscribeFeedback(callback)
+ }
+}
+
+; DS4 (DualShock 4 for Playstation 4)
+class ViGEmDS4 extends ViGEmTarget {
+ helperClass := "ViGEmWrapper.Ds4"
+ __New(){
+ static buttons := {Square: 16, Cross: 32, Circle: 64, Triangle: 128, L1: 256, R1: 512, L2: 1024, R2: 2048
+ , Share: 4096, Options: 8192, LS: 16384, RS: 32768 }
+ static specialButtons := {Ps: 1, TouchPad: 2}
+ static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
+
+ this.Buttons := {}
+ for name, id in buttons {
+ this.Buttons[name] := new this._ButtonHelper(this, id)
+ }
+ for name, id in specialButtons {
+ this.Buttons[name] := new this._SpecialButtonHelper(this, id)
+ }
+
+ this.Axes := {}
+ for name, id in axes {
+ this.Axes[name] := new this._AxisHelper(this, id)
+ }
+
+ this.Dpad := new this._DpadHelper(this)
+ base.__New()
+ }
+
+ class _ButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _SpecialButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetSpecialButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _AxisHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+
+ ConvertAxis(state){
+ return round(state * 2.55)
+ }
+ }
+
+ class _DpadHelper {
+ __New(parent){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ static dPadDirections := {Up: 0, UpRight: 1, Right: 2, DownRight: 3, Down: 4, DownLeft: 5, Left: 6, UpLeft: 7, None: 8}
+ this._Parent.Instance.SetDpadState(dPadDirections[state])
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+}
+
+; Xb360
+class ViGEmXb360 extends ViGEmTarget {
+ helperClass := "ViGEmWrapper.Xb360"
+ __New(){
+ static buttons := {A: 4096, B: 8192, X: 16384, Y: 32768, LB: 256, RB: 512, LS: 64, RS: 128, Back: 32, Start: 16, Xbox: 1024}
+ static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
+
+ this.Buttons := {}
+ for name, id in buttons {
+ this.Buttons[name] := new this._ButtonHelper(this, id)
+ }
+
+ this.Axes := {}
+ for name, id in axes {
+ this.Axes[name] := new this._AxisHelper(this, id)
+ }
+
+ this.Dpad := new this._DpadHelper(this)
+
+ base.__New()
+ }
+
+ class _ButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _AxisHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
+ this._Parent.Instance.SendReport()
+ }
+
+ ConvertAxis(state){
+ value := round((state * 655.36) - 32768)
+ if (value == 32768)
+ return 32767
+ return value
+ }
+ }
+
+ class _DpadHelper {
+ _DpadStates := {1:0, 8:0, 2:0, 4:0} ; Up, Right, Down, Left
+ __New(parent){
+ this._Parent := parent
+ }
+
+ SetState(state){
+ static dpadDirections := { None: {1:0, 8:0, 2:0, 4:0}
+ , Up: {1:1, 8:0, 2:0, 4:0}
+ , UpRight: {1:1, 8:1, 2:0, 4:0}
+ , Right: {1:0, 8:1, 2:0, 4:0}
+ , DownRight: {1:0, 8:1, 2:1, 4:0}
+ , Down: {1:0, 8:0, 2:1, 4:0}
+ , DownLeft: {1:0, 8:0, 2:1, 4:1}
+ , Left: {1:0, 8:0, 2:0, 4:1}
+ , UpLeft: {1:1, 8:0, 2:0, 4:1}}
+ newStates := dpadDirections[state]
+ for id, newState in newStates {
+ oldState := this._DpadStates[id]
+ if (oldState != newState){
+ this._DpadStates[id] := newState
+ this._Parent.Instance.SetButtonState(id, newState)
+ }
+ this._Parent.SendReport()
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/Lib/CLR.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/Lib/CLR.ahk
new file mode 100644
index 0000000..d16ab68
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/Lib/CLR.ahk
@@ -0,0 +1,151 @@
+; ==========================================================
+; .NET Framework Interop
+; https://autohotkey.com/boards/viewtopic.php?t=4633
+; ==========================================================
+;
+; Author: Lexikos
+; Version: 1.2
+; Requires: AutoHotkey_L v1.0.96+
+;
+
+CLR_LoadLibrary(AssemblyName, AppDomain=0)
+{
+ if !AppDomain
+ AppDomain := CLR_GetDefaultDomain()
+ e := ComObjError(0)
+ Loop 1 {
+ if assembly := AppDomain.Load_2(AssemblyName)
+ break
+ static null := ComObject(13,0)
+ args := ComObjArray(0xC, 1), args[0] := AssemblyName
+ typeofAssembly := AppDomain.GetType().Assembly.GetType()
+ if assembly := typeofAssembly.InvokeMember_3("LoadWithPartialName", 0x158, null, null, args)
+ break
+ if assembly := typeofAssembly.InvokeMember_3("LoadFrom", 0x158, null, null, args)
+ break
+ }
+ ComObjError(e)
+ return assembly
+}
+
+CLR_CreateObject(Assembly, TypeName, Args*)
+{
+ if !(argCount := Args.MaxIndex())
+ return Assembly.CreateInstance_2(TypeName, true)
+
+ vargs := ComObjArray(0xC, argCount)
+ Loop % argCount
+ vargs[A_Index-1] := Args[A_Index]
+
+ static Array_Empty := ComObjArray(0xC,0), null := ComObject(13,0)
+
+ return Assembly.CreateInstance_3(TypeName, true, 0, null, vargs, null, Array_Empty)
+}
+
+CLR_CompileC#(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
+{
+ return CLR_CompileAssembly(Code, References, "System", "Microsoft.CSharp.CSharpCodeProvider", AppDomain, FileName, CompilerOptions)
+}
+
+CLR_CompileVB(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
+{
+ return CLR_CompileAssembly(Code, References, "System", "Microsoft.VisualBasic.VBCodeProvider", AppDomain, FileName, CompilerOptions)
+}
+
+CLR_StartDomain(ByRef AppDomain, BaseDirectory="")
+{
+ static null := ComObject(13,0)
+ args := ComObjArray(0xC, 5), args[0] := "", args[2] := BaseDirectory, args[4] := ComObject(0xB,false)
+ AppDomain := CLR_GetDefaultDomain().GetType().InvokeMember_3("CreateDomain", 0x158, null, null, args)
+ return A_LastError >= 0
+}
+
+CLR_StopDomain(ByRef AppDomain)
+{ ; ICorRuntimeHost::UnloadDomain
+ DllCall("SetLastError", "uint", hr := DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+20*A_PtrSize), "ptr", RtHst, "ptr", ComObjValue(AppDomain))), AppDomain := ""
+ return hr >= 0
+}
+
+; NOTE: IT IS NOT NECESSARY TO CALL THIS FUNCTION unless you need to load a specific version.
+CLR_Start(Version="") ; returns ICorRuntimeHost*
+{
+ static RtHst := 0
+ ; The simple method gives no control over versioning, and seems to load .NET v2 even when v4 is present:
+ ; return RtHst ? RtHst : (RtHst:=COM_CreateObject("CLRMetaData.CorRuntimeHost","{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}"), DllCall(NumGet(NumGet(RtHst+0)+40),"uint",RtHst))
+ if RtHst
+ return RtHst
+ EnvGet SystemRoot, SystemRoot
+ if Version =
+ Loop % SystemRoot "\Microsoft.NET\Framework" (A_PtrSize=8?"64":"") "\*", 2
+ if (FileExist(A_LoopFileFullPath "\mscorlib.dll") && A_LoopFileName > Version)
+ Version := A_LoopFileName
+ if DllCall("mscoree\CorBindToRuntimeEx", "wstr", Version, "ptr", 0, "uint", 0
+ , "ptr", CLR_GUID(CLSID_CorRuntimeHost, "{CB2F6723-AB3A-11D2-9C40-00C04FA30A3E}")
+ , "ptr", CLR_GUID(IID_ICorRuntimeHost, "{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}")
+ , "ptr*", RtHst) >= 0
+ DllCall(NumGet(NumGet(RtHst+0)+10*A_PtrSize), "ptr", RtHst) ; Start
+ return RtHst
+}
+
+;
+; INTERNAL FUNCTIONS
+;
+
+CLR_GetDefaultDomain()
+{
+ static defaultDomain := 0
+ if !defaultDomain
+ { ; ICorRuntimeHost::GetDefaultDomain
+ if DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+13*A_PtrSize), "ptr", RtHst, "ptr*", p:=0) >= 0
+ defaultDomain := ComObject(p), ObjRelease(p)
+ }
+ return defaultDomain
+}
+
+CLR_CompileAssembly(Code, References, ProviderAssembly, ProviderType, AppDomain=0, FileName="", CompilerOptions="")
+{
+ if !AppDomain
+ AppDomain := CLR_GetDefaultDomain()
+
+ if !(asmProvider := CLR_LoadLibrary(ProviderAssembly, AppDomain))
+ || !(codeProvider := asmProvider.CreateInstance(ProviderType))
+ || !(codeCompiler := codeProvider.CreateCompiler())
+ return 0
+
+ if !(asmSystem := (ProviderAssembly="System") ? asmProvider : CLR_LoadLibrary("System", AppDomain))
+ return 0
+
+ ; Convert | delimited list of references into an array.
+ StringSplit, Refs, References, |, %A_Space%%A_Tab%
+ aRefs := ComObjArray(8, Refs0)
+ Loop % Refs0
+ aRefs[A_Index-1] := Refs%A_Index%
+
+ ; Set parameters for compiler.
+ prms := CLR_CreateObject(asmSystem, "System.CodeDom.Compiler.CompilerParameters", aRefs)
+ , prms.OutputAssembly := FileName
+ , prms.GenerateInMemory := FileName=""
+ , prms.GenerateExecutable := SubStr(FileName,-3)=".exe"
+ , prms.CompilerOptions := CompilerOptions
+ , prms.IncludeDebugInformation := true
+
+ ; Compile!
+ compilerRes := codeCompiler.CompileAssemblyFromSource(prms, Code)
+
+ if error_count := (errors := compilerRes.Errors).Count
+ {
+ error_text := ""
+ Loop % error_count
+ error_text .= ((e := errors.Item[A_Index-1]).IsWarning ? "Warning " : "Error ") . e.ErrorNumber " on line " e.Line ": " e.ErrorText "`n`n"
+ MsgBox, 16, Compilation Failed, %error_text%
+ return 0
+ }
+ ; Success. Return Assembly object or path.
+ return compilerRes[FileName="" ? "CompiledAssembly" : "PathToAssembly"]
+}
+
+CLR_GUID(ByRef GUID, sGUID)
+{
+ VarSetCapacity(GUID, 16, 0)
+ return DllCall("ole32\CLSIDFromString", "wstr", sGUID, "ptr", &GUID) >= 0 ? &GUID : ""
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/Lib/Gdip.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/Lib/Gdip.ahk
new file mode 100644
index 0000000..0b629d5
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/Lib/Gdip.ahk
@@ -0,0 +1,2698 @@
+; Gdip standard library v1.45 by tic (Tariq Porter) 07/09/11
+; Modifed by Rseding91 using fincs 64 bit compatible Gdip library 5/1/2013
+; Supports: Basic, _L ANSi, _L Unicode x86 and _L Unicode x64
+;
+;#####################################################################################
+;#####################################################################################
+; STATUS ENUMERATION
+; Return values for functions specified to have status enumerated return type
+;#####################################################################################
+;
+; Ok = = 0
+; GenericError = 1
+; InvalidParameter = 2
+; OutOfMemory = 3
+; ObjectBusy = 4
+; InsufficientBuffer = 5
+; NotImplemented = 6
+; Win32Error = 7
+; WrongState = 8
+; Aborted = 9
+; FileNotFound = 10
+; ValueOverflow = 11
+; AccessDenied = 12
+; UnknownImageFormat = 13
+; FontFamilyNotFound = 14
+; FontStyleNotFound = 15
+; NotTrueTypeFont = 16
+; UnsupportedGdiplusVersion = 17
+; GdiplusNotInitialized = 18
+; PropertyNotFound = 19
+; PropertyNotSupported = 20
+; ProfileNotFound = 21
+;
+;#####################################################################################
+;#####################################################################################
+; FUNCTIONS
+;#####################################################################################
+;
+; UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255)
+; BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+; StretchBlt(dDC, dx, dy, dw, dh, sDC, sx, sy, sw, sh, Raster="")
+; SetImage(hwnd, hBitmap)
+; Gdip_BitmapFromScreen(Screen=0, Raster="")
+; CreateRectF(ByRef RectF, x, y, w, h)
+; CreateSizeF(ByRef SizeF, w, h)
+; CreateDIBSection
+;
+;#####################################################################################
+
+; Function: UpdateLayeredWindow
+; Description: Updates a layered window with the handle to the DC of a gdi bitmap
+;
+; hwnd Handle of the layered window to update
+; hdc Handle to the DC of the GDI bitmap to update the window with
+; Layeredx x position to place the window
+; Layeredy y position to place the window
+; Layeredw Width of the window
+; Layeredh Height of the window
+; Alpha Default = 255 : The transparency (0-255) to set the window transparency
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If x or y omitted, then layered window will use its current coordinates
+; If w or h omitted then current width and height will be used
+
+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)
+}
+
+;#####################################################################################
+
+; Function BitBlt
+; Description The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle
+; of pixels from the specified source device context into a destination device context.
+;
+; dDC handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of the area to copy
+; dh height of the area to copy
+; sDC handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used, which copies the source directly to the destination rectangle
+;
+; BLACKNESS = 0x00000042
+; NOTSRCERASE = 0x001100A6
+; NOTSRCCOPY = 0x00330008
+; SRCERASE = 0x00440328
+; DSTINVERT = 0x00550009
+; PATINVERT = 0x005A0049
+; SRCINVERT = 0x00660046
+; SRCAND = 0x008800C6
+; MERGEPAINT = 0x00BB0226
+; MERGECOPY = 0x00C000CA
+; SRCCOPY = 0x00CC0020
+; SRCPAINT = 0x00EE0086
+; PATCOPY = 0x00F00021
+; PATPAINT = 0x00FB0A09
+; WHITENESS = 0x00FF0062
+; CAPTUREBLT = 0x40000000
+; NOMIRRORBITMAP = 0x80000000
+
+BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\BitBlt"
+ , Ptr, dDC
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sDC
+ , "int", sx
+ , "int", sy
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function StretchBlt
+; Description The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle,
+; stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary.
+; The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.
+;
+; ddc handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination rectangle
+; dh height of destination rectangle
+; sdc handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used. It uses the same raster operations as BitBlt
+
+StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\StretchBlt"
+ , Ptr, ddc
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sdc
+ , "int", sx
+ , "int", sy
+ , "int", sw
+ , "int", sh
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function SetStretchBltMode
+; Description The SetStretchBltMode function sets the bitmap stretching mode in the specified device context
+;
+; hdc handle to the DC
+; iStretchMode The stretching mode, describing how the target will be stretched
+;
+; return If the function succeeds, the return value is the previous stretching mode. If it fails it will return 0
+;
+; STRETCH_ANDSCANS = 0x01
+; STRETCH_ORSCANS = 0x02
+; STRETCH_DELETESCANS = 0x03
+; STRETCH_HALFTONE = 0x04
+
+SetStretchBltMode(hdc, iStretchMode=4)
+{
+ return DllCall("gdi32\SetStretchBltMode"
+ , A_PtrSize ? "UPtr" : "UInt", hdc
+ , "int", iStretchMode)
+}
+
+;#####################################################################################
+
+; Function SetImage
+; Description Associates a new image with a static control
+;
+; hwnd handle of the control to update
+; hBitmap a gdi bitmap to associate the static control with
+;
+; return If the function succeeds, the return value is nonzero
+
+SetImage(hwnd, hBitmap)
+{
+ SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
+ E := ErrorLevel
+ DeleteObject(E)
+ return E
+}
+
+;#####################################################################################
+
+; Function SetSysColorToControl
+; Description Sets a solid colour to a control
+;
+; hwnd handle of the control to update
+; SysColor A system colour to set to the control
+;
+; return If the function succeeds, the return value is zero
+;
+; notes A control must have the 0xE style set to it so it is recognised as a bitmap
+; By default SysColor=15 is used which is COLOR_3DFACE. This is the standard background for a control
+;
+; COLOR_3DDKSHADOW = 21
+; COLOR_3DFACE = 15
+; COLOR_3DHIGHLIGHT = 20
+; COLOR_3DHILIGHT = 20
+; COLOR_3DLIGHT = 22
+; COLOR_3DSHADOW = 16
+; COLOR_ACTIVEBORDER = 10
+; COLOR_ACTIVECAPTION = 2
+; COLOR_APPWORKSPACE = 12
+; COLOR_BACKGROUND = 1
+; COLOR_BTNFACE = 15
+; COLOR_BTNHIGHLIGHT = 20
+; COLOR_BTNHILIGHT = 20
+; COLOR_BTNSHADOW = 16
+; COLOR_BTNTEXT = 18
+; COLOR_CAPTIONTEXT = 9
+; COLOR_DESKTOP = 1
+; COLOR_GRADIENTACTIVECAPTION = 27
+; COLOR_GRADIENTINACTIVECAPTION = 28
+; COLOR_GRAYTEXT = 17
+; COLOR_HIGHLIGHT = 13
+; COLOR_HIGHLIGHTTEXT = 14
+; COLOR_HOTLIGHT = 26
+; COLOR_INACTIVEBORDER = 11
+; COLOR_INACTIVECAPTION = 3
+; COLOR_INACTIVECAPTIONTEXT = 19
+; COLOR_INFOBK = 24
+; COLOR_INFOTEXT = 23
+; COLOR_MENU = 4
+; COLOR_MENUHILIGHT = 29
+; COLOR_MENUBAR = 30
+; COLOR_MENUTEXT = 7
+; COLOR_SCROLLBAR = 0
+; COLOR_WINDOW = 5
+; COLOR_WINDOWFRAME = 6
+; COLOR_WINDOWTEXT = 8
+
+SetSysColorToControl(hwnd, SysColor=15)
+{
+ WinGetPos,,, w, h, ahk_id %hwnd%
+ bc := DllCall("GetSysColor", "Int", SysColor, "UInt")
+ pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc >> 16 | bc & 0xff00 | (bc & 0xff) << 16))
+ pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap)
+ Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h)
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ SetImage(hwnd, hBitmap)
+ Gdip_DeleteBrush(pBrushClear)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap)
+ return 0
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromScreen
+; Description Gets a gdi+ bitmap from the screen
+;
+; Screen 0 = All screens
+; Any numerical value = Just that screen
+; x|y|w|h = Take specific coordinates with a width and height
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1: one or more of x,y,w,h not passed properly
+;
+; notes If no raster operation is specified, then SRCCOPY is used to the returned bitmap
+
+Gdip_BitmapFromScreen(Screen=0, Raster="")
+{
+ if (Screen = 0)
+ {
+ Sysget, x, 76
+ Sysget, y, 77
+ Sysget, w, 78
+ Sysget, h, 79
+ }
+ else if (SubStr(Screen, 1, 5) = "hwnd:")
+ {
+ Screen := SubStr(Screen, 6)
+ if !WinExist( "ahk_id " Screen)
+ return -2
+ WinGetPos,,, w, h, ahk_id %Screen%
+ x := y := 0
+ hhdc := GetDCEx(Screen, 3)
+ }
+ else if (Screen&1 != "")
+ {
+ Sysget, M, Monitor, %Screen%
+ x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
+ }
+ else
+ {
+ StringSplit, S, Screen, |
+ x := S1, y := S2, w := S3, h := S4
+ }
+
+ if (x = "") || (y = "") || (w = "") || (h = "")
+ return -1
+
+ chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
+ BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
+ ReleaseDC(hhdc)
+
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromHWND
+; Description Uses PrintWindow to get a handle to the specified window and return a bitmap from it
+;
+; hwnd handle to the window to get a bitmap from
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+;
+; notes Window must not be not minimised in order to get a handle to it's client area
+
+Gdip_BitmapFromHWND(hwnd)
+{
+ WinGetPos,,, Width, Height, ahk_id %hwnd%
+ hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ PrintWindow(hwnd, hdc)
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function CreateRectF
+; Description Creates a RectF object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+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")
+}
+
+;#####################################################################################
+
+; Function CreateRect
+; Description Creates a Rect object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+CreateRect(ByRef Rect, x, y, w, h)
+{
+ VarSetCapacity(Rect, 16)
+ NumPut(x, Rect, 0, "uint"), NumPut(y, Rect, 4, "uint"), NumPut(w, Rect, 8, "uint"), NumPut(h, Rect, 12, "uint")
+}
+;#####################################################################################
+
+; Function CreateSizeF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreateSizeF(ByRef SizeF, w, h)
+{
+ VarSetCapacity(SizeF, 8)
+ NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreatePointF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreatePointF(ByRef PointF, x, y)
+{
+ VarSetCapacity(PointF, 8)
+ NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreateDIBSection
+; Description The CreateDIBSection function creates a DIB (Device Independent Bitmap) that applications can write to directly
+;
+; w width of the bitmap to create
+; h height of the bitmap to create
+; hdc a handle to the device context to use the palette from
+; bpp bits per pixel (32 = ARGB)
+; ppvBits A pointer to a variable that receives a pointer to the location of the DIB bit values
+;
+; return returns a DIB. A gdi bitmap
+;
+; notes ppvBits will receive the location of the pixels in the DIB
+
+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
+}
+
+;#####################################################################################
+
+; Function PrintWindow
+; Description The PrintWindow function copies a visual window into the specified device context (DC), typically a printer DC
+;
+; hwnd A handle to the window that will be copied
+; hdc A handle to the device context
+; Flags Drawing options
+;
+; return If the function succeeds, it returns a nonzero value
+;
+; PW_CLIENTONLY = 1
+
+PrintWindow(hwnd, hdc, Flags=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("PrintWindow", Ptr, hwnd, Ptr, hdc, "uint", Flags)
+}
+
+;#####################################################################################
+
+; Function DestroyIcon
+; Description Destroys an icon and frees any memory the icon occupied
+;
+; hIcon Handle to the icon to be destroyed. The icon must not be in use
+;
+; return If the function succeeds, the return value is nonzero
+
+DestroyIcon(hIcon)
+{
+ return DllCall("DestroyIcon", A_PtrSize ? "UPtr" : "UInt", hIcon)
+}
+
+;#####################################################################################
+
+PaintDesktop(hdc)
+{
+ return DllCall("PaintDesktop", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+CreateCompatibleBitmap(hdc, w, h)
+{
+ return DllCall("gdi32\CreateCompatibleBitmap", A_PtrSize ? "UPtr" : "UInt", hdc, "int", w, "int", h)
+}
+
+;#####################################################################################
+
+; Function CreateCompatibleDC
+; Description This function creates a memory device context (DC) compatible with the specified device
+;
+; hdc Handle to an existing device context
+;
+; return returns the handle to a device context or 0 on failure
+;
+; notes If this handle is 0 (by default), the function creates a memory device context compatible with the application's current screen
+
+CreateCompatibleDC(hdc=0)
+{
+ return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+; Function SelectObject
+; Description The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type
+;
+; hdc Handle to a DC
+; hgdiobj A handle to the object to be selected into the DC
+;
+; return If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced
+;
+; notes The specified object must have been created by using one of the following functions
+; Bitmap - CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection (A single bitmap cannot be selected into more than one DC at the same time)
+; Brush - CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush
+; Font - CreateFont, CreateFontIndirect
+; Pen - CreatePen, CreatePenIndirect
+; Region - CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirect
+;
+; notes If the selected object is a region and the function succeeds, the return value is one of the following value
+;
+; SIMPLEREGION = 2 Region consists of a single rectangle
+; COMPLEXREGION = 3 Region consists of more than one rectangle
+; NULLREGION = 1 Region is empty
+
+SelectObject(hdc, hgdiobj)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
+}
+
+;#####################################################################################
+
+; Function DeleteObject
+; Description This function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object
+; After the object is deleted, the specified handle is no longer valid
+;
+; hObject Handle to a logical pen, brush, font, bitmap, region, or palette to delete
+;
+; return Nonzero indicates success. Zero indicates that the specified handle is not valid or that the handle is currently selected into a device context
+
+DeleteObject(hObject)
+{
+ return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject)
+}
+
+;#####################################################################################
+
+; Function GetDC
+; Description This function retrieves a handle to a display device context (DC) for the client area of the specified window.
+; The display device context can be used in subsequent graphics display interface (GDI) functions to draw in the client area of the window.
+;
+; hwnd Handle to the window whose device context is to be retrieved. If this value is NULL, GetDC retrieves the device context for the entire screen
+;
+; return The handle the device context for the specified window's client area indicates success. NULL indicates failure
+
+GetDC(hwnd=0)
+{
+ return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
+}
+
+;#####################################################################################
+
+; DCX_CACHE = 0x2
+; DCX_CLIPCHILDREN = 0x8
+; DCX_CLIPSIBLINGS = 0x10
+; DCX_EXCLUDERGN = 0x40
+; DCX_EXCLUDEUPDATE = 0x100
+; DCX_INTERSECTRGN = 0x80
+; DCX_INTERSECTUPDATE = 0x200
+; DCX_LOCKWINDOWUPDATE = 0x400
+; DCX_NORECOMPUTE = 0x100000
+; DCX_NORESETATTRS = 0x4
+; DCX_PARENTCLIP = 0x20
+; DCX_VALIDATE = 0x200000
+; DCX_WINDOW = 0x1
+
+GetDCEx(hwnd, flags=0, hrgnClip=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("GetDCEx", Ptr, hwnd, Ptr, hrgnClip, "int", flags)
+}
+
+;#####################################################################################
+
+; Function ReleaseDC
+; Description This function releases a device context (DC), freeing it for use by other applications. The effect of ReleaseDC depends on the type of device context
+;
+; hdc Handle to the device context to be released
+; hwnd Handle to the window whose device context is to be released
+;
+; return 1 = released
+; 0 = not released
+;
+; notes The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common device context
+; An application cannot use the ReleaseDC function to release a device context that was created by calling the CreateDC function; instead, it must use the DeleteDC function.
+
+ReleaseDC(hdc, hwnd=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function DeleteDC
+; Description The DeleteDC function deletes the specified device context (DC)
+;
+; hdc A handle to the device context
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC
+
+DeleteDC(hdc)
+{
+ return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+;#####################################################################################
+
+; Function Gdip_LibraryVersion
+; Description Get the current library version
+;
+; return the library version
+;
+; notes This is useful for non compiled programs to ensure that a person doesn't run an old version when testing your scripts
+
+Gdip_LibraryVersion()
+{
+ return 1.45
+}
+
+;#####################################################################################
+
+; Function: Gdip_BitmapFromBRA
+; Description: Gets a pointer to a gdi+ bitmap from a BRA file
+;
+; BRAFromMemIn The variable for a BRA file read to memory
+; File The name of the file, or its number that you would like (This depends on alternate parameter)
+; Alternate Changes whether the File parameter is the file name or its number
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1 = The BRA variable is empty
+; -2 = The BRA has an incorrect header
+; -3 = The BRA has information missing
+; -4 = Could not find file inside the BRA
+
+Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate=0)
+{
+ Static FName = "ObjRelease"
+
+ if !BRAFromMemIn
+ return -1
+ Loop, Parse, BRAFromMemIn, `n
+ {
+ if (A_Index = 1)
+ {
+ StringSplit, Header, A_LoopField, |
+ if (Header0 != 4 || Header2 != "BRA!")
+ return -2
+ }
+ else if (A_Index = 2)
+ {
+ StringSplit, Info, A_LoopField, |
+ if (Info0 != 3)
+ return -3
+ }
+ else
+ break
+ }
+ if !Alternate
+ StringReplace, File, File, \, \\, All
+ RegExMatch(BRAFromMemIn, "mi`n)^" (Alternate ? File "\|.+?\|(\d+)\|(\d+)" : "\d+\|" File "\|(\d+)\|(\d+)") "$", FileInfo)
+ if !FileInfo
+ return -4
+
+ hData := DllCall("GlobalAlloc", "uint", 2, Ptr, FileInfo2, Ptr)
+ pData := DllCall("GlobalLock", Ptr, hData, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pData, Ptr, &BRAFromMemIn+Info2+FileInfo1, Ptr, FileInfo2)
+ DllCall("GlobalUnlock", Ptr, hData)
+ DllCall("ole32\CreateStreamOnHGlobal", Ptr, hData, "int", 1, A_PtrSize ? "UPtr*" : "UInt*", pStream)
+ DllCall("gdiplus\GdipCreateBitmapFromStream", Ptr, pStream, A_PtrSize ? "UPtr*" : "UInt*", pBitmap)
+ If (A_PtrSize)
+ %FName%(pStream)
+ Else
+ DllCall(NumGet(NumGet(1*pStream)+8), "uint", pStream)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRectangle
+; Description This function uses a pen to draw the outline of a rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRoundedRectangle
+; Description This function uses a pen to draw the outline of a rounded rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawEllipse
+; Description This function uses a pen to draw the outline of an ellipse into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle the ellipse will be drawn into
+; y y-coordinate of the top left of the rectangle the ellipse will be drawn into
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawBezier
+; Description This function uses a pen to draw the outline of a bezier (a weighted curve) into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the bezier
+; y1 y-coordinate of the start of the bezier
+; x2 x-coordinate of the first arc of the bezier
+; y2 y-coordinate of the first arc of the bezier
+; x3 x-coordinate of the second arc of the bezier
+; y3 y-coordinate of the second arc of the bezier
+; x4 x-coordinate of the end of the bezier
+; y4 y-coordinate of the end of the bezier
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawBezier"
+ , Ptr, pgraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2
+ , "float", x3
+ , "float", y3
+ , "float", x4
+ , "float", y4)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawArc
+; Description This function uses a pen to draw the outline of an arc into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the arc
+; y y-coordinate of the start of the arc
+; w width of the arc
+; h height of the arc
+; StartAngle specifies the angle between the x-axis and the starting point of the arc
+; SweepAngle specifies the angle between the starting and ending points of the arc
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawArc"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawPie
+; Description This function uses a pen to draw the outline of a pie into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the pie
+; y y-coordinate of the start of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawPie", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLine
+; Description This function uses a pen to draw a line into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the line
+; y1 y-coordinate of the start of the line
+; x2 x-coordinate of the end of the line
+; y2 y-coordinate of the end of the line
+;
+; return status enumeration. 0 = success
+
+Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawLine"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLines
+; Description This function uses a pen to draw a series of joined lines into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRectangle
+; Description This function uses a brush to fill a rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRoundedRectangle
+; Description This function uses a brush to fill a rounded rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPolygon
+; Description This function uses a brush to fill a polygon in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+;
+; notes Alternate will fill the polygon as a whole, wheras winding will fill each new "segment"
+; Alternate = 0
+; Winding = 1
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPie
+; Description This function uses a brush to fill a pie in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the pie
+; y y-coordinate of the top left of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPie"
+ , Ptr, pGraphics
+ , Ptr, pBrush
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillEllipse
+; Description This function uses a brush to fill an ellipse in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the ellipse
+; y y-coordinate of the top left of the ellipse
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRegion
+; Description This function uses a brush to fill a region in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Region
+;
+; return status enumeration. 0 = success
+;
+; notes You can create a region Gdip_CreateRegion() and then add to this
+
+Gdip_FillRegion(pGraphics, pBrush, Region)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillRegion", Ptr, pGraphics, Ptr, pBrush, Ptr, Region)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPath
+; Description This function uses a brush to fill a path in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Path
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPath(pGraphics, pBrush, Path)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPath", Ptr, pGraphics, Ptr, pBrush, Ptr, Path)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImagePointsRect
+; Description This function draws a bitmap into the Graphics of another bitmap and skews it
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; Points Points passed as x1,y1|x2,y2|x3,y3 (3 points: top left, top right, bottom left) describing the drawing of the bitmap
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter
+
+Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1)
+{
+ 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")
+ }
+
+ 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 = "")
+ {
+ sx := 0, sy := 0
+ sw := Gdip_GetImageWidth(pBitmap)
+ sh := Gdip_GetImageHeight(pBitmap)
+ }
+
+ E := DllCall("gdiplus\GdipDrawImagePointsRect"
+ , Ptr, pGraphics
+ , Ptr, pBitmap
+ , Ptr, &PointF
+ , "int", Points0
+ , "float", sx
+ , "float", sy
+ , "float", sw
+ , "float", sh
+ , "int", 2
+ , Ptr, ImageAttr
+ , Ptr, 0
+ , Ptr, 0)
+ if ImageAttr
+ Gdip_DisposeImageAttributes(ImageAttr)
+ return E
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImage
+; Description This function draws a bitmap into the Graphics of another bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination image
+; dh height of destination image
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source image
+; sh height of source image
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Gdip_DrawImage performs faster
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter. For example:
+; MatrixBright=
+; (
+; 1.5 |0 |0 |0 |0
+; 0 |1.5 |0 |0 |0
+; 0 |0 |1.5 |0 |0
+; 0 |0 |0 |1 |0
+; 0.05 |0.05 |0.05 |0 |1
+; )
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_SetImageAttributesColorMatrix
+; Description This function creates an image matrix ready for drawing
+;
+; Matrix a matrix used to alter image attributes when drawing
+; passed with any delimeter
+;
+; return returns an image matrix on sucess or 0 if it fails
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromImage
+; Description This function gets the graphics for a bitmap used for drawing functions
+;
+; pBitmap Pointer to a bitmap to get the pointer to its graphics
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes a bitmap can be drawn into the graphics of another bitmap
+
+Gdip_GraphicsFromImage(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromHDC
+; Description This function gets the graphics from the handle to a device context
+;
+; hdc This is the handle to the device context
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes You can draw a bitmap into the graphics of another bitmap
+
+Gdip_GraphicsFromHDC(hdc)
+{
+ DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDC
+; Description This function gets the device context of the passed Graphics
+;
+; hdc This is the handle to the device context
+;
+; return returns the device context for the graphics of a bitmap
+
+Gdip_GetDC(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDC", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", hdc)
+ return hdc
+}
+
+;#####################################################################################
+
+; Function Gdip_ReleaseDC
+; Description This function releases a device context from use for further use
+;
+; pGraphics Pointer to the graphics of a bitmap
+; hdc This is the handle to the device context
+;
+; return status enumeration. 0 = success
+
+Gdip_ReleaseDC(pGraphics, hdc)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipReleaseDC", Ptr, pGraphics, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsClear
+; Description Clears the graphics of a bitmap ready for further drawing
+;
+; pGraphics Pointer to the graphics of a bitmap
+; ARGB The colour to clear the graphics to
+;
+; return status enumeration. 0 = success
+;
+; notes By default this will make the background invisible
+; Using clipping regions you can clear a particular area on the graphics rather than clearing the entire graphics
+
+Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff)
+{
+ return DllCall("gdiplus\GdipGraphicsClear", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_BlurBitmap
+; Description Gives a pointer to a blurred bitmap from a pointer to a bitmap
+;
+; pBitmap Pointer to a bitmap to be blurred
+; Blur The Amount to blur a bitmap by from 1 (least blur) to 100 (most blur)
+;
+; return If the function succeeds, the return value is a pointer to the new blurred bitmap
+; -1 = The blur parameter is outside the range 1-100
+;
+; notes This function will not dispose of the original bitmap
+
+Gdip_BlurBitmap(pBitmap, Blur)
+{
+ if (Blur > 100) || (Blur < 1)
+ return -1
+
+ sWidth := Gdip_GetImageWidth(pBitmap), sHeight := Gdip_GetImageHeight(pBitmap)
+ dWidth := sWidth//Blur, dHeight := sHeight//Blur
+
+ pBitmap1 := Gdip_CreateBitmap(dWidth, dHeight)
+ G1 := Gdip_GraphicsFromImage(pBitmap1)
+ Gdip_SetInterpolationMode(G1, 7)
+ Gdip_DrawImage(G1, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight)
+
+ Gdip_DeleteGraphics(G1)
+
+ pBitmap2 := Gdip_CreateBitmap(sWidth, sHeight)
+ G2 := Gdip_GraphicsFromImage(pBitmap2)
+ Gdip_SetInterpolationMode(G2, 7)
+ Gdip_DrawImage(G2, pBitmap1, 0, 0, sWidth, sHeight, 0, 0, dWidth, dHeight)
+
+ Gdip_DeleteGraphics(G2)
+ Gdip_DisposeImage(pBitmap1)
+ return pBitmap2
+}
+
+;#####################################################################################
+
+; Function: Gdip_SaveBitmapToFile
+; Description: Saves a bitmap to a file in any supported format onto disk
+;
+; pBitmap Pointer to a bitmap
+; sOutput The name of the file that the bitmap will be saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG
+; Quality If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality
+;
+; return If the function succeeds, the return value is zero, otherwise:
+; -1 = Extension supplied is not a supported file format
+; -2 = Could not get a list of encoders on system
+; -3 = Could not find matching encoder for specified file format
+; -4 = Could not get WideChar name of output file
+; -5 = Could not save file to disk
+;
+; notes This function will use the extension supplied from the sOutput parameter to determine the output format
+
+Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=75)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ SplitPath, sOutput,,, Extension
+ if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
+ return -1
+ Extension := "." Extension
+
+ DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
+ VarSetCapacity(ci, nSize)
+ DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
+ if !(nCount && nSize)
+ return -2
+
+ If (A_IsUnicode){
+ StrGet_Name := "StrGet"
+ Loop, %nCount%
+ {
+ sString := %StrGet_Name%(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
+ }
+ } else {
+ Loop, %nCount%
+ {
+ Location := NumGet(ci, 76*(A_Index-1)+44)
+ nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(sString, nSize)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0)
+ if !InStr(sString, "*" Extension)
+ continue
+
+ pCodec := &ci+76*(A_Index-1)
+ 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
+ }
+ }
+ }
+ }
+
+ if (!A_IsUnicode)
+ {
+ nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, 0, "int", 0)
+ VarSetCapacity(wOutput, nSize*2)
+ DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, &wOutput, "int", nSize)
+ VarSetCapacity(wOutput, -1)
+ if !VarSetCapacity(wOutput)
+ return -4
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &wOutput, Ptr, pCodec, "uint", p ? p : 0)
+ }
+ else
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &sOutput, Ptr, pCodec, "uint", p ? p : 0)
+ return E ? -5 : 0
+}
+
+;#####################################################################################
+
+; Function Gdip_GetPixel
+; Description Gets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return Returns the ARGB value of the pixel
+
+Gdip_GetPixel(pBitmap, x, y)
+{
+ DllCall("gdiplus\GdipBitmapGetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "uint*", ARGB)
+ return ARGB
+}
+
+;#####################################################################################
+
+; Function Gdip_SetPixel
+; Description Sets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return status enumeration. 0 = success
+
+Gdip_SetPixel(pBitmap, x, y, ARGB)
+{
+ return DllCall("gdiplus\GdipBitmapSetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageWidth
+; Description Gives the width of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the width in pixels of the supplied bitmap
+
+Gdip_GetImageWidth(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width)
+ return Width
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageHeight
+; Description Gives the height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the height in pixels of the supplied bitmap
+
+Gdip_GetImageHeight(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height)
+ return Height
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDimensions
+; Description Gives the width and height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetImageDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ DllCall("gdiplus\GdipGetImageWidth", Ptr, pBitmap, "uint*", Width)
+ DllCall("gdiplus\GdipGetImageHeight", Ptr, pBitmap, "uint*", Height)
+}
+
+;#####################################################################################
+
+Gdip_GetDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+}
+
+;#####################################################################################
+
+Gdip_GetImagePixelFormat(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImagePixelFormat", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", Format)
+ return Format
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDpiX
+; Description Gives the horizontal dots per inch of the graphics of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetDpiX(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiX", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetDpiY(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiY", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_GetImageHorizontalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHorizontalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetImageVerticalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageVerticalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_BitmapSetResolution(pBitmap, dpix, dpiy)
+{
+ return DllCall("gdiplus\GdipBitmapSetResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float", dpix, "float", dpiy)
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromFile(sFile, IconNumber=1, IconSize="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ SplitPath, sFile,,, ext
+ if ext in exe,dll
+ {
+ Sizes := IconSize ? IconSize : 256 "|" 128 "|" 64 "|" 48 "|" 32 "|" 16
+ BufSize := 16 + (2*(A_PtrSize ? A_PtrSize : 4))
+
+ VarSetCapacity(buf, BufSize, 0)
+ Loop, Parse, Sizes, |
+ {
+ DllCall("PrivateExtractIcons", "str", sFile, "int", IconNumber-1, "int", A_LoopField, "int", A_LoopField, PtrA, hIcon, PtrA, 0, "uint", 1, "uint", 0)
+
+ if !hIcon
+ continue
+
+ if !DllCall("GetIconInfo", Ptr, hIcon, Ptr, &buf)
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+
+ hbmMask := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4))
+ hbmColor := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4) + (A_PtrSize ? A_PtrSize : 4))
+ if !(hbmColor && DllCall("GetObject", Ptr, hbmColor, "int", BufSize, Ptr, &buf))
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+ break
+ }
+ if !hIcon
+ return -1
+
+ Width := NumGet(buf, 4, "int"), Height := NumGet(buf, 8, "int")
+ hbm := CreateDIBSection(Width, -Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ if !DllCall("DrawIconEx", Ptr, hdc, "int", 0, "int", 0, Ptr, hIcon, "uint", Width, "uint", Height, "uint", 0, Ptr, 0, "uint", 3)
+ {
+ DestroyIcon(hIcon)
+ return -2
+ }
+
+ VarSetCapacity(dib, 104)
+ DllCall("GetObject", Ptr, hbm, "int", A_PtrSize = 8 ? 104 : 84, Ptr, &dib) ; sizeof(DIBSECTION) = 76+2*(A_PtrSize=8?4:0)+2*A_PtrSize
+ Stride := NumGet(dib, 12, "Int"), Bits := NumGet(dib, 20 + (A_PtrSize = 8 ? 4 : 0)) ; padding
+ DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", Stride, "int", 0x26200A, Ptr, Bits, PtrA, pBitmapOld)
+ pBitmap := Gdip_CreateBitmap(Width, Height)
+ G := Gdip_GraphicsFromImage(pBitmap)
+ , Gdip_DrawImage(G, pBitmapOld, 0, 0, Width, Height, 0, 0, Width, Height)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapOld)
+ DestroyIcon(hIcon)
+ }
+ else
+ {
+ if (!A_IsUnicode)
+ {
+ VarSetCapacity(wFile, 1024)
+ DllCall("kernel32\MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sFile, "int", -1, Ptr, &wFile, "int", 512)
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &wFile, PtrA, pBitmap)
+ }
+ else
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &sFile, PtrA, pBitmap)
+ }
+
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", Ptr, hBitmap, Ptr, Palette, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff)
+{
+ DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hbm, "int", Background)
+ return hbm
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHICON(hIcon)
+{
+ DllCall("gdiplus\GdipCreateBitmapFromHICON", A_PtrSize ? "UPtr" : "UInt", hIcon, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHICONFromBitmap(pBitmap)
+{
+ DllCall("gdiplus\GdipCreateHICONFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hIcon)
+ return hIcon
+}
+
+;#####################################################################################
+
+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_CreateBitmapFromClipboard()
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if !DllCall("OpenClipboard", Ptr, 0)
+ return -1
+ if !DllCall("IsClipboardFormatAvailable", "uint", 8)
+ return -2
+ if !hBitmap := DllCall("GetClipboardData", "uint", 2, Ptr)
+ return -3
+ if !pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap)
+ return -4
+ if !DllCall("CloseClipboard")
+ return -5
+ DeleteObject(hBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_SetBitmapToClipboard(pBitmap)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ off1 := A_PtrSize = 8 ? 52 : 44, off2 := A_PtrSize = 8 ? 32 : 24
+
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ DllCall("GetObject", Ptr, hBitmap, "int", VarSetCapacity(oi, A_PtrSize = 8 ? 96 : 84, 0), Ptr, &oi)
+ hdib := DllCall("GlobalAlloc", "uint", 2, Ptr, off1+NumGet(oi, off1, "UInt")-4, Ptr)
+ pdib := DllCall("GlobalLock", Ptr, hdib, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pdib, "uint", &oi+off2, Ptr, 40)
+ DllCall("RtlMoveMemory", Ptr, pdib+40, Ptr, NumGet(oi, off2 - (A_PtrSize ? A_PtrSize : 4)), Ptr, NumGet(oi, off1, "UInt"))
+ DllCall("GlobalUnlock", Ptr, hdib)
+ DllCall("DeleteObject", Ptr, hBitmap)
+ DllCall("OpenClipboard", Ptr, 0)
+ DllCall("EmptyClipboard")
+ DllCall("SetClipboardData", "uint", 8, Ptr, hdib)
+ DllCall("CloseClipboard")
+}
+
+;#####################################################################################
+
+Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format=0x26200A)
+{
+ DllCall("gdiplus\GdipCloneBitmapArea"
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "int", Format
+ , A_PtrSize ? "UPtr" : "UInt", pBitmap
+ , A_PtrSize ? "UPtr*" : "UInt*", pBitmapDest)
+ return pBitmapDest
+}
+
+;#####################################################################################
+; Create resources
+;#####################################################################################
+
+Gdip_CreatePen(ARGB, w)
+{
+ DllCall("gdiplus\GdipCreatePen1", "UInt", ARGB, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_CreatePenFromBrush(pBrush, w)
+{
+ DllCall("gdiplus\GdipCreatePen2", A_PtrSize ? "UPtr" : "UInt", pBrush, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_BrushCreateSolid(ARGB=0xff000000)
+{
+ DllCall("gdiplus\GdipCreateSolidFill", "UInt", ARGB, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; HatchStyleHorizontal = 0
+; HatchStyleVertical = 1
+; HatchStyleForwardDiagonal = 2
+; HatchStyleBackwardDiagonal = 3
+; HatchStyleCross = 4
+; HatchStyleDiagonalCross = 5
+; HatchStyle05Percent = 6
+; HatchStyle10Percent = 7
+; HatchStyle20Percent = 8
+; HatchStyle25Percent = 9
+; HatchStyle30Percent = 10
+; HatchStyle40Percent = 11
+; HatchStyle50Percent = 12
+; HatchStyle60Percent = 13
+; HatchStyle70Percent = 14
+; HatchStyle75Percent = 15
+; HatchStyle80Percent = 16
+; HatchStyle90Percent = 17
+; HatchStyleLightDownwardDiagonal = 18
+; HatchStyleLightUpwardDiagonal = 19
+; HatchStyleDarkDownwardDiagonal = 20
+; HatchStyleDarkUpwardDiagonal = 21
+; HatchStyleWideDownwardDiagonal = 22
+; HatchStyleWideUpwardDiagonal = 23
+; HatchStyleLightVertical = 24
+; HatchStyleLightHorizontal = 25
+; HatchStyleNarrowVertical = 26
+; HatchStyleNarrowHorizontal = 27
+; HatchStyleDarkVertical = 28
+; HatchStyleDarkHorizontal = 29
+; HatchStyleDashedDownwardDiagonal = 30
+; HatchStyleDashedUpwardDiagonal = 31
+; HatchStyleDashedHorizontal = 32
+; HatchStyleDashedVertical = 33
+; HatchStyleSmallConfetti = 34
+; HatchStyleLargeConfetti = 35
+; HatchStyleZigZag = 36
+; HatchStyleWave = 37
+; HatchStyleDiagonalBrick = 38
+; HatchStyleHorizontalBrick = 39
+; HatchStyleWeave = 40
+; HatchStylePlaid = 41
+; HatchStyleDivot = 42
+; HatchStyleDottedGrid = 43
+; HatchStyleDottedDiamond = 44
+; HatchStyleShingle = 45
+; HatchStyleTrellis = 46
+; HatchStyleSphere = 47
+; HatchStyleSmallGrid = 48
+; HatchStyleSmallCheckerBoard = 49
+; HatchStyleLargeCheckerBoard = 50
+; HatchStyleOutlinedDiamond = 51
+; HatchStyleSolidDiamond = 52
+; HatchStyleTotal = 53
+Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0)
+{
+ DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "UInt", ARGBfront, "UInt", ARGBback, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+Gdip_CreateTextureBrush(pBitmap, WrapMode=1, x=0, y=0, w="", h="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ if !(w && h)
+ DllCall("gdiplus\GdipCreateTexture", Ptr, pBitmap, "int", WrapMode, PtrA, pBrush)
+ else
+ DllCall("gdiplus\GdipCreateTexture2", Ptr, pBitmap, "int", WrapMode, "float", x, "float", y, "float", w, "float", h, PtrA, pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; WrapModeTile = 0
+; WrapModeTileFlipX = 1
+; WrapModeTileFlipY = 2
+; WrapModeTileFlipXY = 3
+; WrapModeClamp = 4
+Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2)
+ DllCall("gdiplus\GdipCreateLineBrush", Ptr, &PointF1, Ptr, &PointF2, "Uint", ARGB1, "Uint", ARGB2, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
+ return LGpBrush
+}
+
+;#####################################################################################
+
+; LinearGradientModeHorizontal = 0
+; LinearGradientModeVertical = 1
+; LinearGradientModeForwardDiagonal = 2
+; LinearGradientModeBackwardDiagonal = 3
+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_CloneBrush(pBrush)
+{
+ DllCall("gdiplus\GdipCloneBrush", A_PtrSize ? "UPtr" : "UInt", pBrush, A_PtrSize ? "UPtr*" : "UInt*", pBrushClone)
+ return pBrushClone
+}
+
+;#####################################################################################
+; Delete resources
+;#####################################################################################
+
+Gdip_DeletePen(pPen)
+{
+ return DllCall("gdiplus\GdipDeletePen", A_PtrSize ? "UPtr" : "UInt", pPen)
+}
+
+;#####################################################################################
+
+Gdip_DeleteBrush(pBrush)
+{
+ return DllCall("gdiplus\GdipDeleteBrush", A_PtrSize ? "UPtr" : "UInt", pBrush)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImage(pBitmap)
+{
+ return DllCall("gdiplus\GdipDisposeImage", A_PtrSize ? "UPtr" : "UInt", pBitmap)
+}
+
+;#####################################################################################
+
+Gdip_DeleteGraphics(pGraphics)
+{
+ return DllCall("gdiplus\GdipDeleteGraphics", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImageAttributes(ImageAttr)
+{
+ return DllCall("gdiplus\GdipDisposeImageAttributes", A_PtrSize ? "UPtr" : "UInt", ImageAttr)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFont(hFont)
+{
+ return DllCall("gdiplus\GdipDeleteFont", A_PtrSize ? "UPtr" : "UInt", hFont)
+}
+
+;#####################################################################################
+
+Gdip_DeleteStringFormat(hFormat)
+{
+ return DllCall("gdiplus\GdipDeleteStringFormat", A_PtrSize ? "UPtr" : "UInt", hFormat)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFontFamily(hFamily)
+{
+ return DllCall("gdiplus\GdipDeleteFontFamily", A_PtrSize ? "UPtr" : "UInt", hFamily)
+}
+
+;#####################################################################################
+
+Gdip_DeleteMatrix(Matrix)
+{
+ return DllCall("gdiplus\GdipDeleteMatrix", A_PtrSize ? "UPtr" : "UInt", Matrix)
+}
+
+;#####################################################################################
+; Text functions
+;#####################################################################################
+
+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_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_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
+}
+
+; Near = 0
+; Center = 1
+; Far = 2
+Gdip_SetStringFormatAlign(hFormat, Align)
+{
+ return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align)
+}
+
+; StringFormatFlagsDirectionRightToLeft = 0x00000001
+; StringFormatFlagsDirectionVertical = 0x00000002
+; StringFormatFlagsNoFitBlackBox = 0x00000004
+; StringFormatFlagsDisplayFormatControl = 0x00000020
+; StringFormatFlagsNoFontFallback = 0x00000400
+; StringFormatFlagsMeasureTrailingSpaces = 0x00000800
+; StringFormatFlagsNoWrap = 0x00001000
+; StringFormatFlagsLineLimit = 0x00002000
+; StringFormatFlagsNoClip = 0x00004000
+Gdip_StringFormatCreate(Format=0, Lang=0)
+{
+ DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat)
+ return hFormat
+}
+
+; Regular = 0
+; Bold = 1
+; Italic = 2
+; BoldItalic = 3
+; Underline = 4
+; Strikeout = 8
+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
+}
+
+;#####################################################################################
+; Matrix functions
+;#####################################################################################
+
+Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y)
+{
+ DllCall("gdiplus\GdipCreateMatrix2", "float", m11, "float", m12, "float", m21, "float", m22, "float", x, "float", y, A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+Gdip_CreateMatrix()
+{
+ DllCall("gdiplus\GdipCreateMatrix", A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+;#####################################################################################
+; GraphicsPath functions
+;#####################################################################################
+
+; Alternate = 0
+; Winding = 1
+Gdip_CreatePath(BrushMode=0)
+{
+ DllCall("gdiplus\GdipCreatePath", "int", BrushMode, A_PtrSize ? "UPtr*" : "UInt*", Path)
+ return Path
+}
+
+Gdip_AddPathEllipse(Path, x, y, w, h)
+{
+ return DllCall("gdiplus\GdipAddPathEllipse", A_PtrSize ? "UPtr" : "UInt", Path, "float", x, "float", y, "float", w, "float", h)
+}
+
+Gdip_AddPathPolygon(Path, 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\GdipAddPathPolygon", Ptr, Path, Ptr, &PointF, "int", Points0)
+}
+
+Gdip_DeletePath(Path)
+{
+ return DllCall("gdiplus\GdipDeletePath", A_PtrSize ? "UPtr" : "UInt", Path)
+}
+
+;#####################################################################################
+; Quality functions
+;#####################################################################################
+
+; SystemDefault = 0
+; SingleBitPerPixelGridFit = 1
+; SingleBitPerPixel = 2
+; AntiAliasGridFit = 3
+; AntiAlias = 4
+Gdip_SetTextRenderingHint(pGraphics, RenderingHint)
+{
+ return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint)
+}
+
+; Default = 0
+; LowQuality = 1
+; HighQuality = 2
+; Bilinear = 3
+; Bicubic = 4
+; NearestNeighbor = 5
+; HighQualityBilinear = 6
+; HighQualityBicubic = 7
+Gdip_SetInterpolationMode(pGraphics, InterpolationMode)
+{
+ return DllCall("gdiplus\GdipSetInterpolationMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", InterpolationMode)
+}
+
+; Default = 0
+; HighSpeed = 1
+; HighQuality = 2
+; None = 3
+; AntiAlias = 4
+Gdip_SetSmoothingMode(pGraphics, SmoothingMode)
+{
+ return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
+}
+
+; CompositingModeSourceOver = 0 (blended)
+; CompositingModeSourceCopy = 1 (overwrite)
+Gdip_SetCompositingMode(pGraphics, CompositingMode=0)
+{
+ return DllCall("gdiplus\GdipSetCompositingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", CompositingMode)
+}
+
+;#####################################################################################
+; Extra functions
+;#####################################################################################
+
+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
+}
+
+; Prepend = 0; The new operation is applied before the old operation.
+; Append = 1; The new operation is applied after the old operation.
+Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipRotateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", Angle, "int", MatrixOrder)
+}
+
+Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipScaleWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipTranslateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_ResetWorldTransform(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetRotatedTranslation(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+
+ Bound := (Angle >= 0) ? Mod(Angle, 360) : 360-Mod(-Angle, -360)
+ if ((Bound >= 0) && (Bound <= 90))
+ xTranslation := Height*Sin(TAngle), yTranslation := 0
+ else if ((Bound > 90) && (Bound <= 180))
+ xTranslation := (Height*Sin(TAngle))-(Width*Cos(TAngle)), yTranslation := -Height*Cos(TAngle)
+ else if ((Bound > 180) && (Bound <= 270))
+ xTranslation := -(Width*Cos(TAngle)), yTranslation := -(Height*Cos(TAngle))-(Width*Sin(TAngle))
+ else if ((Bound > 270) && (Bound <= 360))
+ xTranslation := 0, yTranslation := -Width*Sin(TAngle)
+}
+
+Gdip_GetRotatedDimensions(Width, Height, Angle, ByRef RWidth, ByRef RHeight)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+ if !(Width && Height)
+ return -1
+ RWidth := Ceil(Abs(Width*Cos(TAngle))+Abs(Height*Sin(TAngle)))
+ RHeight := Ceil(Abs(Width*Sin(TAngle))+Abs(Height*Cos(Tangle)))
+}
+
+; RotateNoneFlipNone = 0
+; Rotate90FlipNone = 1
+; Rotate180FlipNone = 2
+; Rotate270FlipNone = 3
+; RotateNoneFlipX = 4
+; Rotate90FlipX = 5
+; Rotate180FlipX = 6
+; Rotate270FlipX = 7
+; RotateNoneFlipY = Rotate180FlipX
+; Rotate90FlipY = Rotate270FlipX
+; Rotate180FlipY = RotateNoneFlipX
+; Rotate270FlipY = Rotate90FlipX
+; RotateNoneFlipXY = Rotate180FlipNone
+; Rotate90FlipXY = Rotate270FlipNone
+; Rotate180FlipXY = RotateNoneFlipNone
+; Rotate270FlipXY = Rotate90FlipNone
+
+Gdip_ImageRotateFlip(pBitmap, RotateFlipType=1)
+{
+ return DllCall("gdiplus\GdipImageRotateFlip", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", RotateFlipType)
+}
+
+; Replace = 0
+; Intersect = 1
+; Union = 2
+; Xor = 3
+; Exclude = 4
+; Complement = 5
+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_SetClipPath(pGraphics, Path, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ return DllCall("gdiplus\GdipSetClipPath", Ptr, pGraphics, Ptr, Path, "int", CombineMode)
+}
+
+Gdip_ResetClip(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetClipRegion(pGraphics)
+{
+ Region := Gdip_CreateRegion()
+ DllCall("gdiplus\GdipGetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", Region)
+ return Region
+}
+
+Gdip_SetClipRegion(pGraphics, Region, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipSetClipRegion", Ptr, pGraphics, Ptr, Region, "int", CombineMode)
+}
+
+Gdip_CreateRegion()
+{
+ DllCall("gdiplus\GdipCreateRegion", A_PtrSize ? "UPtr*" : "UInt*", Region)
+ return Region
+}
+
+Gdip_DeleteRegion(Region)
+{
+ return DllCall("gdiplus\GdipDeleteRegion", A_PtrSize ? "UPtr" : "UInt", Region)
+}
+
+;#####################################################################################
+; BitmapLockBits
+;#####################################################################################
+
+Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode = 3, PixelFormat = 0x26200a)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreateRect(Rect, x, y, w, h)
+ VarSetCapacity(BitmapData, 16+2*(A_PtrSize ? A_PtrSize : 4), 0)
+ E := DllCall("Gdiplus\GdipBitmapLockBits", Ptr, pBitmap, Ptr, &Rect, "uint", LockMode, "int", PixelFormat, Ptr, &BitmapData)
+ Stride := NumGet(BitmapData, 8, "Int")
+ Scan0 := NumGet(BitmapData, 16, Ptr)
+ return E
+}
+
+;#####################################################################################
+
+Gdip_UnlockBits(pBitmap, ByRef BitmapData)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("Gdiplus\GdipBitmapUnlockBits", Ptr, pBitmap, Ptr, &BitmapData)
+}
+
+;#####################################################################################
+
+Gdip_SetLockBitPixel(ARGB, Scan0, x, y, Stride)
+{
+ Numput(ARGB, Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_GetLockBitPixel(Scan0, x, y, Stride)
+{
+ return NumGet(Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_PixelateBitmap(pBitmap, ByRef pBitmapOut, BlockSize)
+{
+ static PixelateBitmap
+
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if (!PixelateBitmap)
+ {
+ if A_PtrSize != 8 ; x86 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 558BEC83EC3C8B4514538B5D1C99F7FB56578BC88955EC894DD885C90F8E830200008B451099F7FB8365DC008365E000894DC88955F08945E833FF897DD4
+ 397DE80F8E160100008BCB0FAFCB894DCC33C08945F88945FC89451C8945143BD87E608B45088D50028BC82BCA8BF02BF2418945F48B45E02955F4894DC4
+ 8D0CB80FAFCB03CA895DD08BD1895DE40FB64416030145140FB60201451C8B45C40FB604100145FC8B45F40FB604020145F883C204FF4DE475D6034D18FF
+ 4DD075C98B4DCC8B451499F7F98945148B451C99F7F989451C8B45FC99F7F98945FC8B45F899F7F98945F885DB7E648B450C8D50028BC82BCA83C103894D
+ C48BC82BCA41894DF48B4DD48945E48B45E02955E48D0C880FAFCB03CA895DD08BD18BF38A45148B7DC48804178A451C8B7DF488028A45FC8804178A45F8
+ 8B7DE488043A83C2044E75DA034D18FF4DD075CE8B4DCC8B7DD447897DD43B7DE80F8CF2FEFFFF837DF0000F842C01000033C08945F88945FC89451C8945
+ 148945E43BD87E65837DF0007E578B4DDC034DE48B75E80FAF4D180FAFF38B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945CC0F
+ B6440E030145140FB60101451C0FB6440F010145FC8B45F40FB604010145F883C104FF4DCC75D8FF45E4395DE47C9B8B4DF00FAFCB85C9740B8B451499F7
+ F9894514EB048365140033F63BCE740B8B451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB
+ 038975F88975E43BDE7E5A837DF0007E4C8B4DDC034DE48B75E80FAF4D180FAFF38B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955CC8A55
+ 1488540E038A551C88118A55FC88540F018A55F888140183C104FF4DCC75DFFF45E4395DE47CA68B45180145E0015DDCFF4DC80F8594FDFFFF8B451099F7
+ FB8955F08945E885C00F8E450100008B45EC0FAFC38365DC008945D48B45E88945CC33C08945F88945FC89451C8945148945103945EC7E6085DB7E518B4D
+ D88B45080FAFCB034D108D50020FAF4D18034DDC8BF08BF88945F403CA2BF22BFA2955F4895DC80FB6440E030145140FB60101451C0FB6440F010145FC8B
+ 45F40FB604080145F883C104FF4DC875D8FF45108B45103B45EC7CA08B4DD485C9740B8B451499F7F9894514EB048365140033F63BCE740B8B451C99F7F9
+ 89451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975103975EC7E5585DB7E468B4DD88B450C
+ 0FAFCB034D108D50020FAF4D18034DDC8BF08BF803CA2BF22BFA2BC2895DC88A551488540E038A551C88118A55FC88540F018A55F888140183C104FF4DC8
+ 75DFFF45108B45103B45EC7CAB8BC3C1E0020145DCFF4DCC0F85CEFEFFFF8B4DEC33C08945F88945FC89451C8945148945103BC87E6C3945F07E5C8B4DD8
+ 8B75E80FAFCB034D100FAFF30FAF4D188B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945C80FB6440E030145140FB60101451C0F
+ B6440F010145FC8B45F40FB604010145F883C104FF4DC875D833C0FF45108B4DEC394D107C940FAF4DF03BC874068B451499F7F933F68945143BCE740B8B
+ 451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975083975EC7E63EB0233F639
+ 75F07E4F8B4DD88B75E80FAFCB034D080FAFF30FAF4D188B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955108A551488540E038A551C8811
+ 8A55FC88540F018A55F888140883C104FF4D1075DFFF45088B45083B45EC7C9F5F5E33C05BC9C21800
+ )
+ else ; x64 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 4489442418488954241048894C24085355565741544155415641574883EC28418BC1448B8C24980000004C8BDA99488BD941F7F9448BD0448BFA8954240C
+ 448994248800000085C00F8E9D020000418BC04533E4458BF299448924244C8954241041F7F933C9898C24980000008BEA89542404448BE889442408EB05
+ 4C8B5C24784585ED0F8E1A010000458BF1418BFD48897C2418450FAFF14533D233F633ED4533E44533ED4585C97E5B4C63BC2490000000418D040A410FAF
+ C148984C8D441802498BD9498BD04D8BD90FB642010FB64AFF4403E80FB60203E90FB64AFE4883C2044403E003F149FFCB75DE4D03C748FFCB75D0488B7C
+ 24188B8C24980000004C8B5C2478418BC59941F7FE448BE8418BC49941F7FE448BE08BC59941F7FE8BE88BC69941F7FE8BF04585C97E4048639C24900000
+ 004103CA4D8BC1410FAFC94863C94A8D541902488BCA498BC144886901448821408869FF408871FE4883C10448FFC875E84803D349FFC875DA8B8C249800
+ 0000488B5C24704C8B5C24784183C20448FFCF48897C24180F850AFFFFFF8B6C2404448B2424448B6C24084C8B74241085ED0F840A01000033FF33DB4533
+ DB4533D24533C04585C97E53488B74247085ED7E42438D0C04418BC50FAF8C2490000000410FAFC18D04814863C8488D5431028BCD0FB642014403D00FB6
+ 024883C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC17CB28BCD410FAFC985C9740A418BC299F7F98BF0EB0233F685C9740B418BC3
+ 99F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585C97E4D4C8B74247885ED7E3841
+ 8D0C14418BC50FAF8C2490000000410FAFC18D04814863C84A8D4431028BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2413BD17CBD
+ 4C8B7424108B8C2498000000038C2490000000488B5C24704503E149FFCE44892424898C24980000004C897424100F859EFDFFFF448B7C240C448B842480
+ 000000418BC09941F7F98BE8448BEA89942498000000896C240C85C00F8E3B010000448BAC2488000000418BCF448BF5410FAFC9898C248000000033FF33
+ ED33F64533DB4533D24533C04585FF7E524585C97E40418BC5410FAFC14103C00FAF84249000000003C74898488D541802498BD90FB642014403D00FB602
+ 4883C2044403D80FB642FB03F00FB642FA03E848FFCB75DE488B5C247041FFC0453BC77CAE85C9740B418BC299F7F9448BE0EB034533E485C9740A418BC3
+ 99F7F98BD8EB0233DB85C9740A8BC699F7F9448BD8EB034533DB85C9740A8BC599F7F9448BD0EB034533D24533C04585FF7E4E488B4C24784585C97E3541
+ 8BC5410FAFC14103C00FAF84249000000003C74898488D540802498BC144886201881A44885AFF448852FE4883C20448FFC875E941FFC0453BC77CBE8B8C
+ 2480000000488B5C2470418BC1C1E00203F849FFCE0F85ECFEFFFF448BAC24980000008B6C240C448BA4248800000033FF33DB4533DB4533D24533C04585
+ FF7E5A488B7424704585ED7E48418BCC8BC5410FAFC94103C80FAF8C2490000000410FAFC18D04814863C8488D543102418BCD0FB642014403D00FB60248
+ 83C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC77CAB418BCF410FAFCD85C9740A418BC299F7F98BF0EB0233F685C9740B418BC399
+ F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585FF7E4E4585ED7E42418BCC8BC541
+ 0FAFC903CA0FAF8C2490000000410FAFC18D04814863C8488B442478488D440102418BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2
+ 413BD77CB233C04883C428415F415E415D415C5F5E5D5BC3
+ )
+
+ VarSetCapacity(PixelateBitmap, StrLen(MCode_PixelateBitmap)//2)
+ Loop % StrLen(MCode_PixelateBitmap)//2 ;%
+ NumPut("0x" SubStr(MCode_PixelateBitmap, (2*A_Index)-1, 2), PixelateBitmap, A_Index-1, "UChar")
+ DllCall("VirtualProtect", Ptr, &PixelateBitmap, Ptr, VarSetCapacity(PixelateBitmap), "uint", 0x40, A_PtrSize ? "UPtr*" : "UInt*", 0)
+ }
+
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+
+ if (Width != Gdip_GetImageWidth(pBitmapOut) || Height != Gdip_GetImageHeight(pBitmapOut))
+ return -1
+ if (BlockSize > Width || BlockSize > Height)
+ return -2
+
+ E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1)
+ E2 := Gdip_LockBits(pBitmapOut, 0, 0, Width, Height, Stride2, Scan02, BitmapData2)
+ if (E1 || E2)
+ return -3
+
+ E := DllCall(&PixelateBitmap, Ptr, Scan01, Ptr, Scan02, "int", Width, "int", Height, "int", Stride1, "int", BlockSize)
+
+ Gdip_UnlockBits(pBitmap, BitmapData1), Gdip_UnlockBits(pBitmapOut, BitmapData2)
+ return 0
+}
+
+;#####################################################################################
+
+Gdip_ToARGB(A, R, G, B)
+{
+ return (A << 24) | (R << 16) | (G << 8) | B
+}
+
+;#####################################################################################
+
+Gdip_FromARGB(ARGB, ByRef A, ByRef R, ByRef G, ByRef B)
+{
+ A := (0xff000000 & ARGB) >> 24
+ R := (0x00ff0000 & ARGB) >> 16
+ G := (0x0000ff00 & ARGB) >> 8
+ B := 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+Gdip_AFromARGB(ARGB)
+{
+ return (0xff000000 & ARGB) >> 24
+}
+
+;#####################################################################################
+
+Gdip_RFromARGB(ARGB)
+{
+ return (0x00ff0000 & ARGB) >> 16
+}
+
+;#####################################################################################
+
+Gdip_GFromARGB(ARGB)
+{
+ return (0x0000ff00 & ARGB) >> 8
+}
+
+;#####################################################################################
+
+Gdip_BFromARGB(ARGB)
+{
+ return 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+StrGetB(Address, Length=-1, Encoding=0)
+{
+ ; Flexible parameter handling:
+ if Length is not integer
+ Encoding := Length, Length := -1
+
+ ; Check for obvious errors.
+ if (Address+0 < 1024)
+ return
+
+ ; Ensure 'Encoding' contains a numeric identifier.
+ if Encoding = UTF-16
+ Encoding = 1200
+ else if Encoding = UTF-8
+ Encoding = 65001
+ else if SubStr(Encoding,1,2)="CP"
+ Encoding := SubStr(Encoding,3)
+
+ if !Encoding ; "" or 0
+ {
+ ; No conversion necessary, but we might not want the whole string.
+ if (Length == -1)
+ Length := DllCall("lstrlen", "uint", Address)
+ VarSetCapacity(String, Length)
+ DllCall("lstrcpyn", "str", String, "uint", Address, "int", Length + 1)
+ }
+ else if Encoding = 1200 ; UTF-16
+ {
+ char_count := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "uint", 0, "uint", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(String, char_count)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "str", String, "int", char_count, "uint", 0, "uint", 0)
+ }
+ else if Encoding is integer
+ {
+ ; Convert from target encoding to UTF-16 then to the active code page.
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", 0, "int", 0)
+ VarSetCapacity(String, char_count * 2)
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", &String, "int", char_count * 2)
+ String := StrGetB(&String, char_count, 1200)
+ }
+
+ return String
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/Lib/ViGEmWrapper.dll b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/Lib/ViGEmWrapper.dll
new file mode 100644
index 0000000..2a08e3a
Binary files /dev/null and b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/Lib/ViGEmWrapper.dll differ
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/clubman.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/clubman.ahk
new file mode 100644
index 0000000..8e68e1d
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/clubman.ahk
@@ -0,0 +1,506 @@
+
+; https://github.com/berban/Gdip
+
+#HotkeyInterval 99000000
+#KeyHistory 0
+#MaxHotkeysPerInterval 99000000
+#NoEnv
+#Persistent
+#SingleInstance Force
+#Include Lib\Gdip.ahk
+#Include Lib\AHK-ViGEm-Bus.ahk
+
+CoordMode, Pixel, Client
+CoordMode, ToolTip, Client
+DetectHiddenWindows, On
+ListLines Off
+Process, priority, , High
+SendMode Input
+SetBatchLines, -1
+SetDefaultMouseSpeed, 0
+SetFormat, Float, 0.2
+; SetFormat, IntegerFast, Hex
+SetKeyDelay, 50
+SetMouseDelay, -1
+SetWorkingDir %A_ScriptDir%
+
+; Variables
+races_clean := 0
+races_clean_percent := 0
+races_completed := 0
+races_completed_check := 0
+credits_total := 0
+credits_average := 0
+
+time_start := A_TickCount
+time_current := A_TickCount
+
+window_width := 640
+window_height := 360
+
+; Create a new controller controller
+controller := new ViGEmDS4()
+
+; GUI
+Gui, New, -MaximizeBox -Resize, ClubmanPlus 0.5.1
+Gui, Font, S10
+Gui, Add, Text, w300 vStatRace, Race Counts: %races_completed%
+Gui, Add, Text, y+0 w300 vCleanRace, Clean Races: %races_clean%
+Gui, Add, Text, y+0 w300 vCleanRate, Average Clean Runs: %races_clean_percent%`%
+Gui, Add, Text, y+0 w300 vEarnings, Earnings: %credits_total%M
+Gui, Add, Text, y+0 w300 vEarningsRate, Earnings Rate: %credits_average%M/hr
+Gui, Add, Button, w150 h40 Default gStart, Start
+Gui, Add, Button, w150 h40 x+10 gReset, Reset
+Gui, Show
+return
+
+; GUI events
+GuiClose:
+ Gosub, Release_All
+ SetTimer, Health, Off
+ SetTimer, Summary, Off
+ OutputDebug % "Clubman> Terminated"
+ExitApp
+
+; GUI controls
+Stats:
+ format_avg_clean_race := Format("{1:0.2f}", races_clean_percent)
+ format_earnings := Format("{1:0.2f}", credits_total)
+ format_earnings_rate := Format("{1:0.2f}", credits_average)
+
+ GuiControl,,StatRace, Race Counts: %races_completed%
+ GuiControl,,CleanRace, Clean Races: %races_clean%
+ GuiControl,,CleanRate, Average Clean Runs: %format_avg_clean_race%`%
+ GuiControl,,Earnings, Earnings: %format_earnings%M
+ GuiControl,,EarningsRate, Earnings Rate: %format_earnings_rate%M/hr
+Return
+
+Start:
+ hwnd := 0
+
+ Gosub, Release_All
+ Gosub, GrabWindow
+
+ if (hwnd = 0) {
+ MsgBox, % "PS Remote Play not found"
+ return
+ }
+
+ SetTimer, Health, 600000
+ SetTimer, Summary, 3600000
+ time_start := A_TickCount
+
+ ; ** AFK Loop
+ Gosub, Press_X
+
+ Loop {
+
+ ; ** RACE
+ OutputDebug % "Clubman> Race: Waiting for position GUI to show"
+ while (!IsColor(hwnd, 0xFFFFFF, 218, 490, 6, 20)) { ; top-right tire wear indicator
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race: Starting race"
+ Gosub, Hold_X
+ ; Gosub, Hold_Down
+ OutputDebug % "Clubman> Race: Racing until position GUI disappears"
+ while (IsColor(hwnd, 0xFFFFFF, 218, 490, 6, 20)) { ; top-right tire wear indicator
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race: Race ended, releasing all buttons"
+ Gosub, Release_All
+ ; Sleep, 5000
+
+ ; ** GO TO LEADERBOARDS
+ OutputDebug % "Clubman> End race: Waiting for continue X icon to show"
+ while (!IsColor(hwnd, 0xC9C9C9, 465, 519, 6, 20)) { ; X icon
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> End race: Press X to continue"
+ while (IsColor(hwnd, 0xC9C9C9, 465, 519, 6, 20)) { ; X icon
+ Gosub, Press_X
+ Sleep, 100
+ }
+ OutputDebug % "Clubman> End race: Transitioning to leaderboard"
+
+ ; ** LEADERBOARD
+ Loop {
+ OutputDebug % "Clubman> Leaderboard: Checking positions"
+
+ if (IsColor(hwnd, 0xBADD3E, 671, 124, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 1st position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 153, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 2nd position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 182, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 3rd position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 211, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 4th position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 240, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 5th position"
+ Gosub, Press_X
+ break
+ }
+ else {
+ Sleep, 500
+ }
+ }
+
+ ; ** REWARDS
+ OutputDebug % "Clubman> Rewards: Waiting for Rewards screen to load (checking money earnt)"
+ while (!IsColor(hwnd, 0xBE140F, 848, 192, 6, 100)) { ; money earn, the red text
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Rewards: Found Rewards screen"
+ races_completed++
+
+ Loop 100 {
+ if (IsColor(hwnd, 0x5C90FB, 451, 260, 10, 20)) { ; the 'R' in Clean Race Bonus
+ OutputDebug % "Clubman> Rewards: Clean bonus"
+ races_clean++
+ PixelSearch(486, 311, 1, hwnd, "clean", "")
+ break
+ }
+
+ if (A_Index == 100) {
+ OutputDebug % "Clubman> Rewards: No clean bonus"
+ PixelSearch(486, 311, 1, hwnd, "no-clean", "")
+ }
+ }
+
+ ; ** REPLAY
+ OutputDebug % "Clubman> Replay: Waiting for Replay screen to load"
+ while (!IsColor(hwnd, 0xFFFFFF, 911, 510, 4, 20)) { ; the cursor on top the exit button
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Replay: Pressing the Exit button"
+ while (IsColor(hwnd, 0xFFFFFF, 911, 510, 4, 20)) { ; the cursor on top the exit button
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Replay: Leaving the Replay screen"
+
+ ; ** RACE RESULTS
+ OutputDebug % "Clubman> Race Result: Waiting for Race Result screen to load (checking cursor)"
+ while (!IsColor(hwnd, 0xBE1E1C, 651, 497, 4, 20)) { ; the exit button
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Result: Moving cursor to the Retry button"
+ while (!IsColor(hwnd, 0xFFFFFF, 514, 504, 4, 20)) { ; cursor on top the retry button
+ Gosub, Press_Right
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Result: Pressing the Retry button"
+ while (IsColor(hwnd, 0xFFFFFF, 514, 504, 4, 20)) { ; cursor on top the retry button
+ Gosub, Press_X
+ Sleep, 500
+ }
+
+ ; ** RACE START
+ OutputDebug % "Clubman> Race Start: Waiting for Race Start screen to load (checking cursor)"
+ while (!IsColor(hwnd, 0xFFFFFF, 287, 504, 4, 20)) { ; cursor on top the start button
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Start: Pressing the Start button"
+ while (IsColor(hwnd, 0xFFFFFF, 287, 504, 4, 20)) { ; cursor on top the start button
+ Gosub, Press_X
+ Sleep, 500
+ }
+
+ OutputDebug % "--- Summary ---"
+ credits_total := (races_completed * 0.07 + races_clean * 0.035)
+ races_clean_percent := (races_clean / races_completed) * 100
+ time_current := A_TickCount
+ credits_average := credits_total / (time_current - time_start) * 3600000
+
+ Gosub, Stats
+
+ OutputDebug % "Clubman> Summary: Races " races_completed
+ OutputDebug % "Clubman> Summary: Races Clean " races_clean
+ OutputDebug % "Clubman> Summary: Races Clean Rate " races_clean_percent "%"
+ OutputDebug % "Clubman> Summary: Earnings " credits_total "M"
+ OutputDebug % "Clubman> Summary: Earnings Rate " credits_average "M/Hr"
+ OutputDebug % "---------------"
+ }
+return
+
+Reset:
+ OutputDebug % "Clubman> Reloading"
+ Gosub, Release_All
+ SetTimer, Health, Off
+ SetTimer, Summary, Off
+ Reload
+return
+
+; -------------------
+; Health Check
+; -------------------
+Health:
+ FormatTime, current_date,, % "yyMMdd-HHmm-ss"
+ OutputDebug % "Clubman> Health: Checking health at " current_date
+ OutputDebug % "Clubman> Health: Races completed " races_completed
+ OutputDebug % "Clubman> Health: Races completed last time " races_completed_check
+
+ if (races_completed_check >= races_completed) {
+ OutputDebug % "Clubman> Health: Error dectected, sending notification"
+ SendNotification("ClubmanPlus", "Something went wrong", 2, "persistent")
+ } else {
+ OutputDebug % "Clubman> Health: Running healthy"
+ races_completed_check := races_completed
+ }
+Return
+
+; -------------------
+; Summary Check
+; -------------------
+Summary:
+ OutputDebug % "Clubman> Summary: Sending summary notification"
+ message := ""
+ message := message "Races " races_clean " / " races_completed " (" races_clean_percent ")`n"
+ message := message "Earnings " credits_total "M (" credits_average "M/Hr)"
+ SendNotification("ClubmanPlus", message, 0, "cashregister")
+Return
+
+; -------------------
+; Send Notification
+; -------------------
+SendNotification(title, message, level, sound) {
+
+ IniRead, token, %A_ScriptDir%\clubman.ini, pushover, token
+ IniRead, user, %A_ScriptDir%\clubman.ini, pushover, user_key
+
+ retries := 60
+ expires := 3600
+
+ url := "https://api.pushover.net/1/messages.json"
+ param := "token=" token "&user=" user "&title=" title "&message=" message "&sound=" sound "&priority=" level
+
+ if (level == 2) {
+ param := param "&retry=" retries "&expire=" expires
+ }
+
+ WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
+ WebRequest.Open("POST", url)
+ WebRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
+ WebRequest.Send(param)
+Return
+}
+
+; -------------------
+; Grab Window
+; -------------------
+GrabWindow:
+ OutputDebug % "Clubman> Looking for window"
+ hwnd := WinExist("PS Remote Play")
+
+ if (hwnd > 0) {
+ OutputDebug % "Clubman> Window found: " hwnd
+ WinMove, ahk_id %hwnd%,, 0, 0, %window_width%, %window_height%
+ WinActivate, ahk_id %hwnd%
+ ControlFocus,, ahk_id %hwnd%
+ }
+return
+
+; -------------------
+; Is Color
+; -------------------
+IsColor(hwnd, target_color, x, y, b, tolerance) {
+ for i, c in PixelSearch(x, y, b, hwnd) {
+ if (ColorDistance(c, target_color) <= tolerance) {
+ Return True
+ }
+ }
+Return False
+}
+
+; -------------------
+; Color Distance
+; -------------------
+ColorDistance( c1, c2 ) {
+ r1 := c1 >> 16
+ g1 := c1 >> 8 & 255
+ b1 := c1 & 255
+ r2 := c2 >> 16
+ g2 := c2 >> 8 & 255
+ b2 := c2 & 255
+return Sqrt( (r1-r2)**2 + (g1-g2)**2 + (b1-b2)**2 )
+}
+
+; -------------------
+; Pixel Search
+; -------------------
+PixelSearch(x, y, b, hwnd, debugsave := "", debugsavecropped := "") {
+ x := (960 / x)
+ y := (540 / y)
+
+ VarSetCapacity(rect, 16)
+ DllCall("GetClientRect", "ptr", hwnd, "ptr", &rect)
+ x := floor(NumGet(rect, 8, "int") // x)
+ y := floor(NumGet(rect, 12, "int") // y)
+ b := floor((b * NumGet(rect, 8, "int")) / 960)
+
+ VarSetCapacity(POINT, 8)
+ NumPut(x, &POINT, 0, "Int")
+ NumPut(y, &POINT, 4, "Int")
+ DllCall("user32\ClientToScreen", Ptr, hwnd, Ptr,&POINT)
+ x := NumGet(&POINT, 0, "Int")
+ y := NumGet(&POINT, 4, "Int")
+
+ pToken := Gdip_Startup()
+ pBitmap := Gdip_BitmapFromScreen("hwnd:" hwnd)
+
+ pixs := []
+ Loop % b*2 + 1 {
+ i := (-1 * b) + (A_Index - 1)
+ Loop % b*2 + 1 {
+ j := (-1 * b) + (A_Index - 1)
+ pixs.Push(Gdip_GetPixel(pBitmap, x+i, y+j) & 0x00FFFFFF)
+ }
+ }
+
+ FormatTime, current_date,, % "yyMMdd-HHmm-ss"
+
+ if (debugsave != "") {
+ Gdip_SaveBitmapToFile(pBitmap, A_ScriptDir . "\" . current_date . "-" . debugsave . ".bmp")
+ }
+ if (debugsavecropped != "") {
+ debugbitmap:=Gdip_CloneBitmapArea(pBitmap, x-b, y-b, b*2, b*2)
+ Gdip_SaveBitmapToFile(debugbitmap, A_ScriptDir . "\" . current_date . "-" . debugsavecropped . ".bmp")
+ Gdip_DisposeImage(debugbitmap)
+ }
+
+ Gdip_DisposeImage(pBitmap)
+ Gdip_Shutdown(pToken)
+return pixs
+}
+
+; -------------------
+; Release All
+; -------------------
+Release_All:
+ Gosub, Release_X
+ Gosub, Release_O
+ Gosub, Release_Right
+ Gosub, Release_Left
+ Gosub, Release_Up
+ Gosub, Release_Down
+return
+
+; -------------------
+; Press x
+; -------------------
+Press_X:
+ Gosub, Hold_X
+ Sleep, 50
+ Gosub, Release_x
+return
+
+Hold_X:
+ controller.Buttons.Cross.SetState(true)
+return
+
+Release_X:
+ controller.Buttons.Cross.SetState(false)
+return
+
+; -------------------
+; Press O
+; -------------------
+Press_O:
+ Gosub, Hold_O
+ Sleep, 50
+ Gosub, Release_O
+return
+
+Hold_O:
+ controller.Buttons.Circle.SetState(true)
+return
+
+Release_O:
+ controller.Buttons.Circle.SetState(false)
+return
+
+; -------------------
+; Press Right
+; -------------------
+Press_Right:
+ Gosub, Hold_Right
+ Sleep, 50
+ Gosub, Release_Right
+return
+
+Hold_Right:
+ controller.Dpad.SetState("Right")
+return
+
+Release_Right:
+ controller.Dpad.SetState("None")
+return
+
+; -------------------
+; Press Left
+; -------------------
+Press_Left:
+ Gosub, Hold_Left
+ Sleep, 50
+ Gosub, Release_Left
+return
+
+Hold_Left:
+ controller.Dpad.SetState("Left")
+return
+
+Release_Left:
+ controller.Dpad.SetState("None")
+return
+
+; -------------------
+; Press Up
+; -------------------
+Press_Up:
+ Gosub, Hold_Up
+ Sleep, 50
+ Gosub, Release_Up
+return
+
+Hold_Up:
+ controller.Dpad.SetState("Up")
+return
+
+Release_Up:
+ controller.Dpad.SetState("None")
+return
+
+; -------------------
+; Press Down
+; -------------------
+Press_Down:
+ Gosub, Hold_Down
+ Sleep, 50
+ Gosub, Release_Down
+return
+
+Hold_Down:
+ controller.Dpad.SetState("Down")
+return
+
+Release_Down:
+ controller.Dpad.SetState("None")
+return
+
+; Hotkeys
+^Esc::ExitApp
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/clubman.ini b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/clubman.ini
new file mode 100644
index 0000000..e70a764
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5.1/clubman.ini
@@ -0,0 +1,3 @@
+[pushover]
+user_key=your_key
+token=your_token
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/Lib/AHK-ViGEm-Bus.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/Lib/AHK-ViGEm-Bus.ahk
new file mode 100644
index 0000000..858cb3d
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/Lib/AHK-ViGEm-Bus.ahk
@@ -0,0 +1,211 @@
+#include %A_LineFile%\..\CLR.ahk
+
+; Static class, holds ViGEm Client instance
+class ViGEmWrapper {
+ static asm := 0
+ static client := 0
+
+ Init(){
+ if (this.client == 0){
+ this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
+ }
+ }
+
+ CreateInstance(cls){
+ return this.asm.CreateInstance(cls)
+ }
+
+}
+
+; Base class for ViGEm "Targets" (Controller types - eg xb360 / ds4) to inherit from
+class ViGEmTarget {
+ target := 0
+ helperClass := ""
+ controllerClass := ""
+
+ __New(){
+ ;~ this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
+ ViGEmWrapper.Init()
+ this.Instance := ViGEmWrapper.CreateInstance(this.helperClass)
+
+ if (this.Instance.OkCheck() != "OK"){
+ msgbox ViGEmWrapper.dll failed to load!
+ ExitApp
+ }
+ }
+
+ SendReport(){
+ this.Instance.SendReport()
+ }
+
+ SubscribeFeedback(callback){
+ this.Instance.SubscribeFeedback(callback)
+ }
+}
+
+; DS4 (DualShock 4 for Playstation 4)
+class ViGEmDS4 extends ViGEmTarget {
+ helperClass := "ViGEmWrapper.Ds4"
+ __New(){
+ static buttons := {Square: 16, Cross: 32, Circle: 64, Triangle: 128, L1: 256, R1: 512, L2: 1024, R2: 2048
+ , Share: 4096, Options: 8192, LS: 16384, RS: 32768 }
+ static specialButtons := {Ps: 1, TouchPad: 2}
+ static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
+
+ this.Buttons := {}
+ for name, id in buttons {
+ this.Buttons[name] := new this._ButtonHelper(this, id)
+ }
+ for name, id in specialButtons {
+ this.Buttons[name] := new this._SpecialButtonHelper(this, id)
+ }
+
+ this.Axes := {}
+ for name, id in axes {
+ this.Axes[name] := new this._AxisHelper(this, id)
+ }
+
+ this.Dpad := new this._DpadHelper(this)
+ base.__New()
+ }
+
+ class _ButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _SpecialButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetSpecialButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _AxisHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+
+ ConvertAxis(state){
+ return round(state * 2.55)
+ }
+ }
+
+ class _DpadHelper {
+ __New(parent){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ static dPadDirections := {Up: 0, UpRight: 1, Right: 2, DownRight: 3, Down: 4, DownLeft: 5, Left: 6, UpLeft: 7, None: 8}
+ this._Parent.Instance.SetDpadState(dPadDirections[state])
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+}
+
+; Xb360
+class ViGEmXb360 extends ViGEmTarget {
+ helperClass := "ViGEmWrapper.Xb360"
+ __New(){
+ static buttons := {A: 4096, B: 8192, X: 16384, Y: 32768, LB: 256, RB: 512, LS: 64, RS: 128, Back: 32, Start: 16, Xbox: 1024}
+ static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
+
+ this.Buttons := {}
+ for name, id in buttons {
+ this.Buttons[name] := new this._ButtonHelper(this, id)
+ }
+
+ this.Axes := {}
+ for name, id in axes {
+ this.Axes[name] := new this._AxisHelper(this, id)
+ }
+
+ this.Dpad := new this._DpadHelper(this)
+
+ base.__New()
+ }
+
+ class _ButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _AxisHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
+ this._Parent.Instance.SendReport()
+ }
+
+ ConvertAxis(state){
+ value := round((state * 655.36) - 32768)
+ if (value == 32768)
+ return 32767
+ return value
+ }
+ }
+
+ class _DpadHelper {
+ _DpadStates := {1:0, 8:0, 2:0, 4:0} ; Up, Right, Down, Left
+ __New(parent){
+ this._Parent := parent
+ }
+
+ SetState(state){
+ static dpadDirections := { None: {1:0, 8:0, 2:0, 4:0}
+ , Up: {1:1, 8:0, 2:0, 4:0}
+ , UpRight: {1:1, 8:1, 2:0, 4:0}
+ , Right: {1:0, 8:1, 2:0, 4:0}
+ , DownRight: {1:0, 8:1, 2:1, 4:0}
+ , Down: {1:0, 8:0, 2:1, 4:0}
+ , DownLeft: {1:0, 8:0, 2:1, 4:1}
+ , Left: {1:0, 8:0, 2:0, 4:1}
+ , UpLeft: {1:1, 8:0, 2:0, 4:1}}
+ newStates := dpadDirections[state]
+ for id, newState in newStates {
+ oldState := this._DpadStates[id]
+ if (oldState != newState){
+ this._DpadStates[id] := newState
+ this._Parent.Instance.SetButtonState(id, newState)
+ }
+ this._Parent.SendReport()
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/Lib/CLR.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/Lib/CLR.ahk
new file mode 100644
index 0000000..d16ab68
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/Lib/CLR.ahk
@@ -0,0 +1,151 @@
+; ==========================================================
+; .NET Framework Interop
+; https://autohotkey.com/boards/viewtopic.php?t=4633
+; ==========================================================
+;
+; Author: Lexikos
+; Version: 1.2
+; Requires: AutoHotkey_L v1.0.96+
+;
+
+CLR_LoadLibrary(AssemblyName, AppDomain=0)
+{
+ if !AppDomain
+ AppDomain := CLR_GetDefaultDomain()
+ e := ComObjError(0)
+ Loop 1 {
+ if assembly := AppDomain.Load_2(AssemblyName)
+ break
+ static null := ComObject(13,0)
+ args := ComObjArray(0xC, 1), args[0] := AssemblyName
+ typeofAssembly := AppDomain.GetType().Assembly.GetType()
+ if assembly := typeofAssembly.InvokeMember_3("LoadWithPartialName", 0x158, null, null, args)
+ break
+ if assembly := typeofAssembly.InvokeMember_3("LoadFrom", 0x158, null, null, args)
+ break
+ }
+ ComObjError(e)
+ return assembly
+}
+
+CLR_CreateObject(Assembly, TypeName, Args*)
+{
+ if !(argCount := Args.MaxIndex())
+ return Assembly.CreateInstance_2(TypeName, true)
+
+ vargs := ComObjArray(0xC, argCount)
+ Loop % argCount
+ vargs[A_Index-1] := Args[A_Index]
+
+ static Array_Empty := ComObjArray(0xC,0), null := ComObject(13,0)
+
+ return Assembly.CreateInstance_3(TypeName, true, 0, null, vargs, null, Array_Empty)
+}
+
+CLR_CompileC#(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
+{
+ return CLR_CompileAssembly(Code, References, "System", "Microsoft.CSharp.CSharpCodeProvider", AppDomain, FileName, CompilerOptions)
+}
+
+CLR_CompileVB(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
+{
+ return CLR_CompileAssembly(Code, References, "System", "Microsoft.VisualBasic.VBCodeProvider", AppDomain, FileName, CompilerOptions)
+}
+
+CLR_StartDomain(ByRef AppDomain, BaseDirectory="")
+{
+ static null := ComObject(13,0)
+ args := ComObjArray(0xC, 5), args[0] := "", args[2] := BaseDirectory, args[4] := ComObject(0xB,false)
+ AppDomain := CLR_GetDefaultDomain().GetType().InvokeMember_3("CreateDomain", 0x158, null, null, args)
+ return A_LastError >= 0
+}
+
+CLR_StopDomain(ByRef AppDomain)
+{ ; ICorRuntimeHost::UnloadDomain
+ DllCall("SetLastError", "uint", hr := DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+20*A_PtrSize), "ptr", RtHst, "ptr", ComObjValue(AppDomain))), AppDomain := ""
+ return hr >= 0
+}
+
+; NOTE: IT IS NOT NECESSARY TO CALL THIS FUNCTION unless you need to load a specific version.
+CLR_Start(Version="") ; returns ICorRuntimeHost*
+{
+ static RtHst := 0
+ ; The simple method gives no control over versioning, and seems to load .NET v2 even when v4 is present:
+ ; return RtHst ? RtHst : (RtHst:=COM_CreateObject("CLRMetaData.CorRuntimeHost","{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}"), DllCall(NumGet(NumGet(RtHst+0)+40),"uint",RtHst))
+ if RtHst
+ return RtHst
+ EnvGet SystemRoot, SystemRoot
+ if Version =
+ Loop % SystemRoot "\Microsoft.NET\Framework" (A_PtrSize=8?"64":"") "\*", 2
+ if (FileExist(A_LoopFileFullPath "\mscorlib.dll") && A_LoopFileName > Version)
+ Version := A_LoopFileName
+ if DllCall("mscoree\CorBindToRuntimeEx", "wstr", Version, "ptr", 0, "uint", 0
+ , "ptr", CLR_GUID(CLSID_CorRuntimeHost, "{CB2F6723-AB3A-11D2-9C40-00C04FA30A3E}")
+ , "ptr", CLR_GUID(IID_ICorRuntimeHost, "{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}")
+ , "ptr*", RtHst) >= 0
+ DllCall(NumGet(NumGet(RtHst+0)+10*A_PtrSize), "ptr", RtHst) ; Start
+ return RtHst
+}
+
+;
+; INTERNAL FUNCTIONS
+;
+
+CLR_GetDefaultDomain()
+{
+ static defaultDomain := 0
+ if !defaultDomain
+ { ; ICorRuntimeHost::GetDefaultDomain
+ if DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+13*A_PtrSize), "ptr", RtHst, "ptr*", p:=0) >= 0
+ defaultDomain := ComObject(p), ObjRelease(p)
+ }
+ return defaultDomain
+}
+
+CLR_CompileAssembly(Code, References, ProviderAssembly, ProviderType, AppDomain=0, FileName="", CompilerOptions="")
+{
+ if !AppDomain
+ AppDomain := CLR_GetDefaultDomain()
+
+ if !(asmProvider := CLR_LoadLibrary(ProviderAssembly, AppDomain))
+ || !(codeProvider := asmProvider.CreateInstance(ProviderType))
+ || !(codeCompiler := codeProvider.CreateCompiler())
+ return 0
+
+ if !(asmSystem := (ProviderAssembly="System") ? asmProvider : CLR_LoadLibrary("System", AppDomain))
+ return 0
+
+ ; Convert | delimited list of references into an array.
+ StringSplit, Refs, References, |, %A_Space%%A_Tab%
+ aRefs := ComObjArray(8, Refs0)
+ Loop % Refs0
+ aRefs[A_Index-1] := Refs%A_Index%
+
+ ; Set parameters for compiler.
+ prms := CLR_CreateObject(asmSystem, "System.CodeDom.Compiler.CompilerParameters", aRefs)
+ , prms.OutputAssembly := FileName
+ , prms.GenerateInMemory := FileName=""
+ , prms.GenerateExecutable := SubStr(FileName,-3)=".exe"
+ , prms.CompilerOptions := CompilerOptions
+ , prms.IncludeDebugInformation := true
+
+ ; Compile!
+ compilerRes := codeCompiler.CompileAssemblyFromSource(prms, Code)
+
+ if error_count := (errors := compilerRes.Errors).Count
+ {
+ error_text := ""
+ Loop % error_count
+ error_text .= ((e := errors.Item[A_Index-1]).IsWarning ? "Warning " : "Error ") . e.ErrorNumber " on line " e.Line ": " e.ErrorText "`n`n"
+ MsgBox, 16, Compilation Failed, %error_text%
+ return 0
+ }
+ ; Success. Return Assembly object or path.
+ return compilerRes[FileName="" ? "CompiledAssembly" : "PathToAssembly"]
+}
+
+CLR_GUID(ByRef GUID, sGUID)
+{
+ VarSetCapacity(GUID, 16, 0)
+ return DllCall("ole32\CLSIDFromString", "wstr", sGUID, "ptr", &GUID) >= 0 ? &GUID : ""
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/Lib/Gdip.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/Lib/Gdip.ahk
new file mode 100644
index 0000000..0b629d5
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/Lib/Gdip.ahk
@@ -0,0 +1,2698 @@
+; Gdip standard library v1.45 by tic (Tariq Porter) 07/09/11
+; Modifed by Rseding91 using fincs 64 bit compatible Gdip library 5/1/2013
+; Supports: Basic, _L ANSi, _L Unicode x86 and _L Unicode x64
+;
+;#####################################################################################
+;#####################################################################################
+; STATUS ENUMERATION
+; Return values for functions specified to have status enumerated return type
+;#####################################################################################
+;
+; Ok = = 0
+; GenericError = 1
+; InvalidParameter = 2
+; OutOfMemory = 3
+; ObjectBusy = 4
+; InsufficientBuffer = 5
+; NotImplemented = 6
+; Win32Error = 7
+; WrongState = 8
+; Aborted = 9
+; FileNotFound = 10
+; ValueOverflow = 11
+; AccessDenied = 12
+; UnknownImageFormat = 13
+; FontFamilyNotFound = 14
+; FontStyleNotFound = 15
+; NotTrueTypeFont = 16
+; UnsupportedGdiplusVersion = 17
+; GdiplusNotInitialized = 18
+; PropertyNotFound = 19
+; PropertyNotSupported = 20
+; ProfileNotFound = 21
+;
+;#####################################################################################
+;#####################################################################################
+; FUNCTIONS
+;#####################################################################################
+;
+; UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255)
+; BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+; StretchBlt(dDC, dx, dy, dw, dh, sDC, sx, sy, sw, sh, Raster="")
+; SetImage(hwnd, hBitmap)
+; Gdip_BitmapFromScreen(Screen=0, Raster="")
+; CreateRectF(ByRef RectF, x, y, w, h)
+; CreateSizeF(ByRef SizeF, w, h)
+; CreateDIBSection
+;
+;#####################################################################################
+
+; Function: UpdateLayeredWindow
+; Description: Updates a layered window with the handle to the DC of a gdi bitmap
+;
+; hwnd Handle of the layered window to update
+; hdc Handle to the DC of the GDI bitmap to update the window with
+; Layeredx x position to place the window
+; Layeredy y position to place the window
+; Layeredw Width of the window
+; Layeredh Height of the window
+; Alpha Default = 255 : The transparency (0-255) to set the window transparency
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If x or y omitted, then layered window will use its current coordinates
+; If w or h omitted then current width and height will be used
+
+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)
+}
+
+;#####################################################################################
+
+; Function BitBlt
+; Description The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle
+; of pixels from the specified source device context into a destination device context.
+;
+; dDC handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of the area to copy
+; dh height of the area to copy
+; sDC handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used, which copies the source directly to the destination rectangle
+;
+; BLACKNESS = 0x00000042
+; NOTSRCERASE = 0x001100A6
+; NOTSRCCOPY = 0x00330008
+; SRCERASE = 0x00440328
+; DSTINVERT = 0x00550009
+; PATINVERT = 0x005A0049
+; SRCINVERT = 0x00660046
+; SRCAND = 0x008800C6
+; MERGEPAINT = 0x00BB0226
+; MERGECOPY = 0x00C000CA
+; SRCCOPY = 0x00CC0020
+; SRCPAINT = 0x00EE0086
+; PATCOPY = 0x00F00021
+; PATPAINT = 0x00FB0A09
+; WHITENESS = 0x00FF0062
+; CAPTUREBLT = 0x40000000
+; NOMIRRORBITMAP = 0x80000000
+
+BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\BitBlt"
+ , Ptr, dDC
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sDC
+ , "int", sx
+ , "int", sy
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function StretchBlt
+; Description The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle,
+; stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary.
+; The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.
+;
+; ddc handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination rectangle
+; dh height of destination rectangle
+; sdc handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used. It uses the same raster operations as BitBlt
+
+StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\StretchBlt"
+ , Ptr, ddc
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sdc
+ , "int", sx
+ , "int", sy
+ , "int", sw
+ , "int", sh
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function SetStretchBltMode
+; Description The SetStretchBltMode function sets the bitmap stretching mode in the specified device context
+;
+; hdc handle to the DC
+; iStretchMode The stretching mode, describing how the target will be stretched
+;
+; return If the function succeeds, the return value is the previous stretching mode. If it fails it will return 0
+;
+; STRETCH_ANDSCANS = 0x01
+; STRETCH_ORSCANS = 0x02
+; STRETCH_DELETESCANS = 0x03
+; STRETCH_HALFTONE = 0x04
+
+SetStretchBltMode(hdc, iStretchMode=4)
+{
+ return DllCall("gdi32\SetStretchBltMode"
+ , A_PtrSize ? "UPtr" : "UInt", hdc
+ , "int", iStretchMode)
+}
+
+;#####################################################################################
+
+; Function SetImage
+; Description Associates a new image with a static control
+;
+; hwnd handle of the control to update
+; hBitmap a gdi bitmap to associate the static control with
+;
+; return If the function succeeds, the return value is nonzero
+
+SetImage(hwnd, hBitmap)
+{
+ SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
+ E := ErrorLevel
+ DeleteObject(E)
+ return E
+}
+
+;#####################################################################################
+
+; Function SetSysColorToControl
+; Description Sets a solid colour to a control
+;
+; hwnd handle of the control to update
+; SysColor A system colour to set to the control
+;
+; return If the function succeeds, the return value is zero
+;
+; notes A control must have the 0xE style set to it so it is recognised as a bitmap
+; By default SysColor=15 is used which is COLOR_3DFACE. This is the standard background for a control
+;
+; COLOR_3DDKSHADOW = 21
+; COLOR_3DFACE = 15
+; COLOR_3DHIGHLIGHT = 20
+; COLOR_3DHILIGHT = 20
+; COLOR_3DLIGHT = 22
+; COLOR_3DSHADOW = 16
+; COLOR_ACTIVEBORDER = 10
+; COLOR_ACTIVECAPTION = 2
+; COLOR_APPWORKSPACE = 12
+; COLOR_BACKGROUND = 1
+; COLOR_BTNFACE = 15
+; COLOR_BTNHIGHLIGHT = 20
+; COLOR_BTNHILIGHT = 20
+; COLOR_BTNSHADOW = 16
+; COLOR_BTNTEXT = 18
+; COLOR_CAPTIONTEXT = 9
+; COLOR_DESKTOP = 1
+; COLOR_GRADIENTACTIVECAPTION = 27
+; COLOR_GRADIENTINACTIVECAPTION = 28
+; COLOR_GRAYTEXT = 17
+; COLOR_HIGHLIGHT = 13
+; COLOR_HIGHLIGHTTEXT = 14
+; COLOR_HOTLIGHT = 26
+; COLOR_INACTIVEBORDER = 11
+; COLOR_INACTIVECAPTION = 3
+; COLOR_INACTIVECAPTIONTEXT = 19
+; COLOR_INFOBK = 24
+; COLOR_INFOTEXT = 23
+; COLOR_MENU = 4
+; COLOR_MENUHILIGHT = 29
+; COLOR_MENUBAR = 30
+; COLOR_MENUTEXT = 7
+; COLOR_SCROLLBAR = 0
+; COLOR_WINDOW = 5
+; COLOR_WINDOWFRAME = 6
+; COLOR_WINDOWTEXT = 8
+
+SetSysColorToControl(hwnd, SysColor=15)
+{
+ WinGetPos,,, w, h, ahk_id %hwnd%
+ bc := DllCall("GetSysColor", "Int", SysColor, "UInt")
+ pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc >> 16 | bc & 0xff00 | (bc & 0xff) << 16))
+ pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap)
+ Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h)
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ SetImage(hwnd, hBitmap)
+ Gdip_DeleteBrush(pBrushClear)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap)
+ return 0
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromScreen
+; Description Gets a gdi+ bitmap from the screen
+;
+; Screen 0 = All screens
+; Any numerical value = Just that screen
+; x|y|w|h = Take specific coordinates with a width and height
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1: one or more of x,y,w,h not passed properly
+;
+; notes If no raster operation is specified, then SRCCOPY is used to the returned bitmap
+
+Gdip_BitmapFromScreen(Screen=0, Raster="")
+{
+ if (Screen = 0)
+ {
+ Sysget, x, 76
+ Sysget, y, 77
+ Sysget, w, 78
+ Sysget, h, 79
+ }
+ else if (SubStr(Screen, 1, 5) = "hwnd:")
+ {
+ Screen := SubStr(Screen, 6)
+ if !WinExist( "ahk_id " Screen)
+ return -2
+ WinGetPos,,, w, h, ahk_id %Screen%
+ x := y := 0
+ hhdc := GetDCEx(Screen, 3)
+ }
+ else if (Screen&1 != "")
+ {
+ Sysget, M, Monitor, %Screen%
+ x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
+ }
+ else
+ {
+ StringSplit, S, Screen, |
+ x := S1, y := S2, w := S3, h := S4
+ }
+
+ if (x = "") || (y = "") || (w = "") || (h = "")
+ return -1
+
+ chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
+ BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
+ ReleaseDC(hhdc)
+
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromHWND
+; Description Uses PrintWindow to get a handle to the specified window and return a bitmap from it
+;
+; hwnd handle to the window to get a bitmap from
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+;
+; notes Window must not be not minimised in order to get a handle to it's client area
+
+Gdip_BitmapFromHWND(hwnd)
+{
+ WinGetPos,,, Width, Height, ahk_id %hwnd%
+ hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ PrintWindow(hwnd, hdc)
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function CreateRectF
+; Description Creates a RectF object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+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")
+}
+
+;#####################################################################################
+
+; Function CreateRect
+; Description Creates a Rect object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+CreateRect(ByRef Rect, x, y, w, h)
+{
+ VarSetCapacity(Rect, 16)
+ NumPut(x, Rect, 0, "uint"), NumPut(y, Rect, 4, "uint"), NumPut(w, Rect, 8, "uint"), NumPut(h, Rect, 12, "uint")
+}
+;#####################################################################################
+
+; Function CreateSizeF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreateSizeF(ByRef SizeF, w, h)
+{
+ VarSetCapacity(SizeF, 8)
+ NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreatePointF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreatePointF(ByRef PointF, x, y)
+{
+ VarSetCapacity(PointF, 8)
+ NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreateDIBSection
+; Description The CreateDIBSection function creates a DIB (Device Independent Bitmap) that applications can write to directly
+;
+; w width of the bitmap to create
+; h height of the bitmap to create
+; hdc a handle to the device context to use the palette from
+; bpp bits per pixel (32 = ARGB)
+; ppvBits A pointer to a variable that receives a pointer to the location of the DIB bit values
+;
+; return returns a DIB. A gdi bitmap
+;
+; notes ppvBits will receive the location of the pixels in the DIB
+
+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
+}
+
+;#####################################################################################
+
+; Function PrintWindow
+; Description The PrintWindow function copies a visual window into the specified device context (DC), typically a printer DC
+;
+; hwnd A handle to the window that will be copied
+; hdc A handle to the device context
+; Flags Drawing options
+;
+; return If the function succeeds, it returns a nonzero value
+;
+; PW_CLIENTONLY = 1
+
+PrintWindow(hwnd, hdc, Flags=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("PrintWindow", Ptr, hwnd, Ptr, hdc, "uint", Flags)
+}
+
+;#####################################################################################
+
+; Function DestroyIcon
+; Description Destroys an icon and frees any memory the icon occupied
+;
+; hIcon Handle to the icon to be destroyed. The icon must not be in use
+;
+; return If the function succeeds, the return value is nonzero
+
+DestroyIcon(hIcon)
+{
+ return DllCall("DestroyIcon", A_PtrSize ? "UPtr" : "UInt", hIcon)
+}
+
+;#####################################################################################
+
+PaintDesktop(hdc)
+{
+ return DllCall("PaintDesktop", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+CreateCompatibleBitmap(hdc, w, h)
+{
+ return DllCall("gdi32\CreateCompatibleBitmap", A_PtrSize ? "UPtr" : "UInt", hdc, "int", w, "int", h)
+}
+
+;#####################################################################################
+
+; Function CreateCompatibleDC
+; Description This function creates a memory device context (DC) compatible with the specified device
+;
+; hdc Handle to an existing device context
+;
+; return returns the handle to a device context or 0 on failure
+;
+; notes If this handle is 0 (by default), the function creates a memory device context compatible with the application's current screen
+
+CreateCompatibleDC(hdc=0)
+{
+ return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+; Function SelectObject
+; Description The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type
+;
+; hdc Handle to a DC
+; hgdiobj A handle to the object to be selected into the DC
+;
+; return If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced
+;
+; notes The specified object must have been created by using one of the following functions
+; Bitmap - CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection (A single bitmap cannot be selected into more than one DC at the same time)
+; Brush - CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush
+; Font - CreateFont, CreateFontIndirect
+; Pen - CreatePen, CreatePenIndirect
+; Region - CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirect
+;
+; notes If the selected object is a region and the function succeeds, the return value is one of the following value
+;
+; SIMPLEREGION = 2 Region consists of a single rectangle
+; COMPLEXREGION = 3 Region consists of more than one rectangle
+; NULLREGION = 1 Region is empty
+
+SelectObject(hdc, hgdiobj)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
+}
+
+;#####################################################################################
+
+; Function DeleteObject
+; Description This function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object
+; After the object is deleted, the specified handle is no longer valid
+;
+; hObject Handle to a logical pen, brush, font, bitmap, region, or palette to delete
+;
+; return Nonzero indicates success. Zero indicates that the specified handle is not valid or that the handle is currently selected into a device context
+
+DeleteObject(hObject)
+{
+ return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject)
+}
+
+;#####################################################################################
+
+; Function GetDC
+; Description This function retrieves a handle to a display device context (DC) for the client area of the specified window.
+; The display device context can be used in subsequent graphics display interface (GDI) functions to draw in the client area of the window.
+;
+; hwnd Handle to the window whose device context is to be retrieved. If this value is NULL, GetDC retrieves the device context for the entire screen
+;
+; return The handle the device context for the specified window's client area indicates success. NULL indicates failure
+
+GetDC(hwnd=0)
+{
+ return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
+}
+
+;#####################################################################################
+
+; DCX_CACHE = 0x2
+; DCX_CLIPCHILDREN = 0x8
+; DCX_CLIPSIBLINGS = 0x10
+; DCX_EXCLUDERGN = 0x40
+; DCX_EXCLUDEUPDATE = 0x100
+; DCX_INTERSECTRGN = 0x80
+; DCX_INTERSECTUPDATE = 0x200
+; DCX_LOCKWINDOWUPDATE = 0x400
+; DCX_NORECOMPUTE = 0x100000
+; DCX_NORESETATTRS = 0x4
+; DCX_PARENTCLIP = 0x20
+; DCX_VALIDATE = 0x200000
+; DCX_WINDOW = 0x1
+
+GetDCEx(hwnd, flags=0, hrgnClip=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("GetDCEx", Ptr, hwnd, Ptr, hrgnClip, "int", flags)
+}
+
+;#####################################################################################
+
+; Function ReleaseDC
+; Description This function releases a device context (DC), freeing it for use by other applications. The effect of ReleaseDC depends on the type of device context
+;
+; hdc Handle to the device context to be released
+; hwnd Handle to the window whose device context is to be released
+;
+; return 1 = released
+; 0 = not released
+;
+; notes The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common device context
+; An application cannot use the ReleaseDC function to release a device context that was created by calling the CreateDC function; instead, it must use the DeleteDC function.
+
+ReleaseDC(hdc, hwnd=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function DeleteDC
+; Description The DeleteDC function deletes the specified device context (DC)
+;
+; hdc A handle to the device context
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC
+
+DeleteDC(hdc)
+{
+ return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+;#####################################################################################
+
+; Function Gdip_LibraryVersion
+; Description Get the current library version
+;
+; return the library version
+;
+; notes This is useful for non compiled programs to ensure that a person doesn't run an old version when testing your scripts
+
+Gdip_LibraryVersion()
+{
+ return 1.45
+}
+
+;#####################################################################################
+
+; Function: Gdip_BitmapFromBRA
+; Description: Gets a pointer to a gdi+ bitmap from a BRA file
+;
+; BRAFromMemIn The variable for a BRA file read to memory
+; File The name of the file, or its number that you would like (This depends on alternate parameter)
+; Alternate Changes whether the File parameter is the file name or its number
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1 = The BRA variable is empty
+; -2 = The BRA has an incorrect header
+; -3 = The BRA has information missing
+; -4 = Could not find file inside the BRA
+
+Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate=0)
+{
+ Static FName = "ObjRelease"
+
+ if !BRAFromMemIn
+ return -1
+ Loop, Parse, BRAFromMemIn, `n
+ {
+ if (A_Index = 1)
+ {
+ StringSplit, Header, A_LoopField, |
+ if (Header0 != 4 || Header2 != "BRA!")
+ return -2
+ }
+ else if (A_Index = 2)
+ {
+ StringSplit, Info, A_LoopField, |
+ if (Info0 != 3)
+ return -3
+ }
+ else
+ break
+ }
+ if !Alternate
+ StringReplace, File, File, \, \\, All
+ RegExMatch(BRAFromMemIn, "mi`n)^" (Alternate ? File "\|.+?\|(\d+)\|(\d+)" : "\d+\|" File "\|(\d+)\|(\d+)") "$", FileInfo)
+ if !FileInfo
+ return -4
+
+ hData := DllCall("GlobalAlloc", "uint", 2, Ptr, FileInfo2, Ptr)
+ pData := DllCall("GlobalLock", Ptr, hData, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pData, Ptr, &BRAFromMemIn+Info2+FileInfo1, Ptr, FileInfo2)
+ DllCall("GlobalUnlock", Ptr, hData)
+ DllCall("ole32\CreateStreamOnHGlobal", Ptr, hData, "int", 1, A_PtrSize ? "UPtr*" : "UInt*", pStream)
+ DllCall("gdiplus\GdipCreateBitmapFromStream", Ptr, pStream, A_PtrSize ? "UPtr*" : "UInt*", pBitmap)
+ If (A_PtrSize)
+ %FName%(pStream)
+ Else
+ DllCall(NumGet(NumGet(1*pStream)+8), "uint", pStream)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRectangle
+; Description This function uses a pen to draw the outline of a rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRoundedRectangle
+; Description This function uses a pen to draw the outline of a rounded rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawEllipse
+; Description This function uses a pen to draw the outline of an ellipse into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle the ellipse will be drawn into
+; y y-coordinate of the top left of the rectangle the ellipse will be drawn into
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawBezier
+; Description This function uses a pen to draw the outline of a bezier (a weighted curve) into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the bezier
+; y1 y-coordinate of the start of the bezier
+; x2 x-coordinate of the first arc of the bezier
+; y2 y-coordinate of the first arc of the bezier
+; x3 x-coordinate of the second arc of the bezier
+; y3 y-coordinate of the second arc of the bezier
+; x4 x-coordinate of the end of the bezier
+; y4 y-coordinate of the end of the bezier
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawBezier"
+ , Ptr, pgraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2
+ , "float", x3
+ , "float", y3
+ , "float", x4
+ , "float", y4)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawArc
+; Description This function uses a pen to draw the outline of an arc into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the arc
+; y y-coordinate of the start of the arc
+; w width of the arc
+; h height of the arc
+; StartAngle specifies the angle between the x-axis and the starting point of the arc
+; SweepAngle specifies the angle between the starting and ending points of the arc
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawArc"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawPie
+; Description This function uses a pen to draw the outline of a pie into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the pie
+; y y-coordinate of the start of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawPie", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLine
+; Description This function uses a pen to draw a line into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the line
+; y1 y-coordinate of the start of the line
+; x2 x-coordinate of the end of the line
+; y2 y-coordinate of the end of the line
+;
+; return status enumeration. 0 = success
+
+Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawLine"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLines
+; Description This function uses a pen to draw a series of joined lines into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRectangle
+; Description This function uses a brush to fill a rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRoundedRectangle
+; Description This function uses a brush to fill a rounded rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPolygon
+; Description This function uses a brush to fill a polygon in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+;
+; notes Alternate will fill the polygon as a whole, wheras winding will fill each new "segment"
+; Alternate = 0
+; Winding = 1
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPie
+; Description This function uses a brush to fill a pie in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the pie
+; y y-coordinate of the top left of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPie"
+ , Ptr, pGraphics
+ , Ptr, pBrush
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillEllipse
+; Description This function uses a brush to fill an ellipse in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the ellipse
+; y y-coordinate of the top left of the ellipse
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRegion
+; Description This function uses a brush to fill a region in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Region
+;
+; return status enumeration. 0 = success
+;
+; notes You can create a region Gdip_CreateRegion() and then add to this
+
+Gdip_FillRegion(pGraphics, pBrush, Region)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillRegion", Ptr, pGraphics, Ptr, pBrush, Ptr, Region)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPath
+; Description This function uses a brush to fill a path in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Path
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPath(pGraphics, pBrush, Path)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPath", Ptr, pGraphics, Ptr, pBrush, Ptr, Path)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImagePointsRect
+; Description This function draws a bitmap into the Graphics of another bitmap and skews it
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; Points Points passed as x1,y1|x2,y2|x3,y3 (3 points: top left, top right, bottom left) describing the drawing of the bitmap
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter
+
+Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1)
+{
+ 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")
+ }
+
+ 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 = "")
+ {
+ sx := 0, sy := 0
+ sw := Gdip_GetImageWidth(pBitmap)
+ sh := Gdip_GetImageHeight(pBitmap)
+ }
+
+ E := DllCall("gdiplus\GdipDrawImagePointsRect"
+ , Ptr, pGraphics
+ , Ptr, pBitmap
+ , Ptr, &PointF
+ , "int", Points0
+ , "float", sx
+ , "float", sy
+ , "float", sw
+ , "float", sh
+ , "int", 2
+ , Ptr, ImageAttr
+ , Ptr, 0
+ , Ptr, 0)
+ if ImageAttr
+ Gdip_DisposeImageAttributes(ImageAttr)
+ return E
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImage
+; Description This function draws a bitmap into the Graphics of another bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination image
+; dh height of destination image
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source image
+; sh height of source image
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Gdip_DrawImage performs faster
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter. For example:
+; MatrixBright=
+; (
+; 1.5 |0 |0 |0 |0
+; 0 |1.5 |0 |0 |0
+; 0 |0 |1.5 |0 |0
+; 0 |0 |0 |1 |0
+; 0.05 |0.05 |0.05 |0 |1
+; )
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_SetImageAttributesColorMatrix
+; Description This function creates an image matrix ready for drawing
+;
+; Matrix a matrix used to alter image attributes when drawing
+; passed with any delimeter
+;
+; return returns an image matrix on sucess or 0 if it fails
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromImage
+; Description This function gets the graphics for a bitmap used for drawing functions
+;
+; pBitmap Pointer to a bitmap to get the pointer to its graphics
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes a bitmap can be drawn into the graphics of another bitmap
+
+Gdip_GraphicsFromImage(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromHDC
+; Description This function gets the graphics from the handle to a device context
+;
+; hdc This is the handle to the device context
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes You can draw a bitmap into the graphics of another bitmap
+
+Gdip_GraphicsFromHDC(hdc)
+{
+ DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDC
+; Description This function gets the device context of the passed Graphics
+;
+; hdc This is the handle to the device context
+;
+; return returns the device context for the graphics of a bitmap
+
+Gdip_GetDC(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDC", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", hdc)
+ return hdc
+}
+
+;#####################################################################################
+
+; Function Gdip_ReleaseDC
+; Description This function releases a device context from use for further use
+;
+; pGraphics Pointer to the graphics of a bitmap
+; hdc This is the handle to the device context
+;
+; return status enumeration. 0 = success
+
+Gdip_ReleaseDC(pGraphics, hdc)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipReleaseDC", Ptr, pGraphics, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsClear
+; Description Clears the graphics of a bitmap ready for further drawing
+;
+; pGraphics Pointer to the graphics of a bitmap
+; ARGB The colour to clear the graphics to
+;
+; return status enumeration. 0 = success
+;
+; notes By default this will make the background invisible
+; Using clipping regions you can clear a particular area on the graphics rather than clearing the entire graphics
+
+Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff)
+{
+ return DllCall("gdiplus\GdipGraphicsClear", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_BlurBitmap
+; Description Gives a pointer to a blurred bitmap from a pointer to a bitmap
+;
+; pBitmap Pointer to a bitmap to be blurred
+; Blur The Amount to blur a bitmap by from 1 (least blur) to 100 (most blur)
+;
+; return If the function succeeds, the return value is a pointer to the new blurred bitmap
+; -1 = The blur parameter is outside the range 1-100
+;
+; notes This function will not dispose of the original bitmap
+
+Gdip_BlurBitmap(pBitmap, Blur)
+{
+ if (Blur > 100) || (Blur < 1)
+ return -1
+
+ sWidth := Gdip_GetImageWidth(pBitmap), sHeight := Gdip_GetImageHeight(pBitmap)
+ dWidth := sWidth//Blur, dHeight := sHeight//Blur
+
+ pBitmap1 := Gdip_CreateBitmap(dWidth, dHeight)
+ G1 := Gdip_GraphicsFromImage(pBitmap1)
+ Gdip_SetInterpolationMode(G1, 7)
+ Gdip_DrawImage(G1, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight)
+
+ Gdip_DeleteGraphics(G1)
+
+ pBitmap2 := Gdip_CreateBitmap(sWidth, sHeight)
+ G2 := Gdip_GraphicsFromImage(pBitmap2)
+ Gdip_SetInterpolationMode(G2, 7)
+ Gdip_DrawImage(G2, pBitmap1, 0, 0, sWidth, sHeight, 0, 0, dWidth, dHeight)
+
+ Gdip_DeleteGraphics(G2)
+ Gdip_DisposeImage(pBitmap1)
+ return pBitmap2
+}
+
+;#####################################################################################
+
+; Function: Gdip_SaveBitmapToFile
+; Description: Saves a bitmap to a file in any supported format onto disk
+;
+; pBitmap Pointer to a bitmap
+; sOutput The name of the file that the bitmap will be saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG
+; Quality If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality
+;
+; return If the function succeeds, the return value is zero, otherwise:
+; -1 = Extension supplied is not a supported file format
+; -2 = Could not get a list of encoders on system
+; -3 = Could not find matching encoder for specified file format
+; -4 = Could not get WideChar name of output file
+; -5 = Could not save file to disk
+;
+; notes This function will use the extension supplied from the sOutput parameter to determine the output format
+
+Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=75)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ SplitPath, sOutput,,, Extension
+ if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
+ return -1
+ Extension := "." Extension
+
+ DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
+ VarSetCapacity(ci, nSize)
+ DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
+ if !(nCount && nSize)
+ return -2
+
+ If (A_IsUnicode){
+ StrGet_Name := "StrGet"
+ Loop, %nCount%
+ {
+ sString := %StrGet_Name%(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
+ }
+ } else {
+ Loop, %nCount%
+ {
+ Location := NumGet(ci, 76*(A_Index-1)+44)
+ nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(sString, nSize)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0)
+ if !InStr(sString, "*" Extension)
+ continue
+
+ pCodec := &ci+76*(A_Index-1)
+ 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
+ }
+ }
+ }
+ }
+
+ if (!A_IsUnicode)
+ {
+ nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, 0, "int", 0)
+ VarSetCapacity(wOutput, nSize*2)
+ DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, &wOutput, "int", nSize)
+ VarSetCapacity(wOutput, -1)
+ if !VarSetCapacity(wOutput)
+ return -4
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &wOutput, Ptr, pCodec, "uint", p ? p : 0)
+ }
+ else
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &sOutput, Ptr, pCodec, "uint", p ? p : 0)
+ return E ? -5 : 0
+}
+
+;#####################################################################################
+
+; Function Gdip_GetPixel
+; Description Gets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return Returns the ARGB value of the pixel
+
+Gdip_GetPixel(pBitmap, x, y)
+{
+ DllCall("gdiplus\GdipBitmapGetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "uint*", ARGB)
+ return ARGB
+}
+
+;#####################################################################################
+
+; Function Gdip_SetPixel
+; Description Sets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return status enumeration. 0 = success
+
+Gdip_SetPixel(pBitmap, x, y, ARGB)
+{
+ return DllCall("gdiplus\GdipBitmapSetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageWidth
+; Description Gives the width of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the width in pixels of the supplied bitmap
+
+Gdip_GetImageWidth(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width)
+ return Width
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageHeight
+; Description Gives the height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the height in pixels of the supplied bitmap
+
+Gdip_GetImageHeight(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height)
+ return Height
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDimensions
+; Description Gives the width and height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetImageDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ DllCall("gdiplus\GdipGetImageWidth", Ptr, pBitmap, "uint*", Width)
+ DllCall("gdiplus\GdipGetImageHeight", Ptr, pBitmap, "uint*", Height)
+}
+
+;#####################################################################################
+
+Gdip_GetDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+}
+
+;#####################################################################################
+
+Gdip_GetImagePixelFormat(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImagePixelFormat", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", Format)
+ return Format
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDpiX
+; Description Gives the horizontal dots per inch of the graphics of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetDpiX(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiX", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetDpiY(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiY", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_GetImageHorizontalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHorizontalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetImageVerticalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageVerticalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_BitmapSetResolution(pBitmap, dpix, dpiy)
+{
+ return DllCall("gdiplus\GdipBitmapSetResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float", dpix, "float", dpiy)
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromFile(sFile, IconNumber=1, IconSize="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ SplitPath, sFile,,, ext
+ if ext in exe,dll
+ {
+ Sizes := IconSize ? IconSize : 256 "|" 128 "|" 64 "|" 48 "|" 32 "|" 16
+ BufSize := 16 + (2*(A_PtrSize ? A_PtrSize : 4))
+
+ VarSetCapacity(buf, BufSize, 0)
+ Loop, Parse, Sizes, |
+ {
+ DllCall("PrivateExtractIcons", "str", sFile, "int", IconNumber-1, "int", A_LoopField, "int", A_LoopField, PtrA, hIcon, PtrA, 0, "uint", 1, "uint", 0)
+
+ if !hIcon
+ continue
+
+ if !DllCall("GetIconInfo", Ptr, hIcon, Ptr, &buf)
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+
+ hbmMask := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4))
+ hbmColor := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4) + (A_PtrSize ? A_PtrSize : 4))
+ if !(hbmColor && DllCall("GetObject", Ptr, hbmColor, "int", BufSize, Ptr, &buf))
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+ break
+ }
+ if !hIcon
+ return -1
+
+ Width := NumGet(buf, 4, "int"), Height := NumGet(buf, 8, "int")
+ hbm := CreateDIBSection(Width, -Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ if !DllCall("DrawIconEx", Ptr, hdc, "int", 0, "int", 0, Ptr, hIcon, "uint", Width, "uint", Height, "uint", 0, Ptr, 0, "uint", 3)
+ {
+ DestroyIcon(hIcon)
+ return -2
+ }
+
+ VarSetCapacity(dib, 104)
+ DllCall("GetObject", Ptr, hbm, "int", A_PtrSize = 8 ? 104 : 84, Ptr, &dib) ; sizeof(DIBSECTION) = 76+2*(A_PtrSize=8?4:0)+2*A_PtrSize
+ Stride := NumGet(dib, 12, "Int"), Bits := NumGet(dib, 20 + (A_PtrSize = 8 ? 4 : 0)) ; padding
+ DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", Stride, "int", 0x26200A, Ptr, Bits, PtrA, pBitmapOld)
+ pBitmap := Gdip_CreateBitmap(Width, Height)
+ G := Gdip_GraphicsFromImage(pBitmap)
+ , Gdip_DrawImage(G, pBitmapOld, 0, 0, Width, Height, 0, 0, Width, Height)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapOld)
+ DestroyIcon(hIcon)
+ }
+ else
+ {
+ if (!A_IsUnicode)
+ {
+ VarSetCapacity(wFile, 1024)
+ DllCall("kernel32\MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sFile, "int", -1, Ptr, &wFile, "int", 512)
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &wFile, PtrA, pBitmap)
+ }
+ else
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &sFile, PtrA, pBitmap)
+ }
+
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", Ptr, hBitmap, Ptr, Palette, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff)
+{
+ DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hbm, "int", Background)
+ return hbm
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHICON(hIcon)
+{
+ DllCall("gdiplus\GdipCreateBitmapFromHICON", A_PtrSize ? "UPtr" : "UInt", hIcon, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHICONFromBitmap(pBitmap)
+{
+ DllCall("gdiplus\GdipCreateHICONFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hIcon)
+ return hIcon
+}
+
+;#####################################################################################
+
+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_CreateBitmapFromClipboard()
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if !DllCall("OpenClipboard", Ptr, 0)
+ return -1
+ if !DllCall("IsClipboardFormatAvailable", "uint", 8)
+ return -2
+ if !hBitmap := DllCall("GetClipboardData", "uint", 2, Ptr)
+ return -3
+ if !pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap)
+ return -4
+ if !DllCall("CloseClipboard")
+ return -5
+ DeleteObject(hBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_SetBitmapToClipboard(pBitmap)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ off1 := A_PtrSize = 8 ? 52 : 44, off2 := A_PtrSize = 8 ? 32 : 24
+
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ DllCall("GetObject", Ptr, hBitmap, "int", VarSetCapacity(oi, A_PtrSize = 8 ? 96 : 84, 0), Ptr, &oi)
+ hdib := DllCall("GlobalAlloc", "uint", 2, Ptr, off1+NumGet(oi, off1, "UInt")-4, Ptr)
+ pdib := DllCall("GlobalLock", Ptr, hdib, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pdib, "uint", &oi+off2, Ptr, 40)
+ DllCall("RtlMoveMemory", Ptr, pdib+40, Ptr, NumGet(oi, off2 - (A_PtrSize ? A_PtrSize : 4)), Ptr, NumGet(oi, off1, "UInt"))
+ DllCall("GlobalUnlock", Ptr, hdib)
+ DllCall("DeleteObject", Ptr, hBitmap)
+ DllCall("OpenClipboard", Ptr, 0)
+ DllCall("EmptyClipboard")
+ DllCall("SetClipboardData", "uint", 8, Ptr, hdib)
+ DllCall("CloseClipboard")
+}
+
+;#####################################################################################
+
+Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format=0x26200A)
+{
+ DllCall("gdiplus\GdipCloneBitmapArea"
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "int", Format
+ , A_PtrSize ? "UPtr" : "UInt", pBitmap
+ , A_PtrSize ? "UPtr*" : "UInt*", pBitmapDest)
+ return pBitmapDest
+}
+
+;#####################################################################################
+; Create resources
+;#####################################################################################
+
+Gdip_CreatePen(ARGB, w)
+{
+ DllCall("gdiplus\GdipCreatePen1", "UInt", ARGB, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_CreatePenFromBrush(pBrush, w)
+{
+ DllCall("gdiplus\GdipCreatePen2", A_PtrSize ? "UPtr" : "UInt", pBrush, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_BrushCreateSolid(ARGB=0xff000000)
+{
+ DllCall("gdiplus\GdipCreateSolidFill", "UInt", ARGB, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; HatchStyleHorizontal = 0
+; HatchStyleVertical = 1
+; HatchStyleForwardDiagonal = 2
+; HatchStyleBackwardDiagonal = 3
+; HatchStyleCross = 4
+; HatchStyleDiagonalCross = 5
+; HatchStyle05Percent = 6
+; HatchStyle10Percent = 7
+; HatchStyle20Percent = 8
+; HatchStyle25Percent = 9
+; HatchStyle30Percent = 10
+; HatchStyle40Percent = 11
+; HatchStyle50Percent = 12
+; HatchStyle60Percent = 13
+; HatchStyle70Percent = 14
+; HatchStyle75Percent = 15
+; HatchStyle80Percent = 16
+; HatchStyle90Percent = 17
+; HatchStyleLightDownwardDiagonal = 18
+; HatchStyleLightUpwardDiagonal = 19
+; HatchStyleDarkDownwardDiagonal = 20
+; HatchStyleDarkUpwardDiagonal = 21
+; HatchStyleWideDownwardDiagonal = 22
+; HatchStyleWideUpwardDiagonal = 23
+; HatchStyleLightVertical = 24
+; HatchStyleLightHorizontal = 25
+; HatchStyleNarrowVertical = 26
+; HatchStyleNarrowHorizontal = 27
+; HatchStyleDarkVertical = 28
+; HatchStyleDarkHorizontal = 29
+; HatchStyleDashedDownwardDiagonal = 30
+; HatchStyleDashedUpwardDiagonal = 31
+; HatchStyleDashedHorizontal = 32
+; HatchStyleDashedVertical = 33
+; HatchStyleSmallConfetti = 34
+; HatchStyleLargeConfetti = 35
+; HatchStyleZigZag = 36
+; HatchStyleWave = 37
+; HatchStyleDiagonalBrick = 38
+; HatchStyleHorizontalBrick = 39
+; HatchStyleWeave = 40
+; HatchStylePlaid = 41
+; HatchStyleDivot = 42
+; HatchStyleDottedGrid = 43
+; HatchStyleDottedDiamond = 44
+; HatchStyleShingle = 45
+; HatchStyleTrellis = 46
+; HatchStyleSphere = 47
+; HatchStyleSmallGrid = 48
+; HatchStyleSmallCheckerBoard = 49
+; HatchStyleLargeCheckerBoard = 50
+; HatchStyleOutlinedDiamond = 51
+; HatchStyleSolidDiamond = 52
+; HatchStyleTotal = 53
+Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0)
+{
+ DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "UInt", ARGBfront, "UInt", ARGBback, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+Gdip_CreateTextureBrush(pBitmap, WrapMode=1, x=0, y=0, w="", h="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ if !(w && h)
+ DllCall("gdiplus\GdipCreateTexture", Ptr, pBitmap, "int", WrapMode, PtrA, pBrush)
+ else
+ DllCall("gdiplus\GdipCreateTexture2", Ptr, pBitmap, "int", WrapMode, "float", x, "float", y, "float", w, "float", h, PtrA, pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; WrapModeTile = 0
+; WrapModeTileFlipX = 1
+; WrapModeTileFlipY = 2
+; WrapModeTileFlipXY = 3
+; WrapModeClamp = 4
+Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2)
+ DllCall("gdiplus\GdipCreateLineBrush", Ptr, &PointF1, Ptr, &PointF2, "Uint", ARGB1, "Uint", ARGB2, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
+ return LGpBrush
+}
+
+;#####################################################################################
+
+; LinearGradientModeHorizontal = 0
+; LinearGradientModeVertical = 1
+; LinearGradientModeForwardDiagonal = 2
+; LinearGradientModeBackwardDiagonal = 3
+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_CloneBrush(pBrush)
+{
+ DllCall("gdiplus\GdipCloneBrush", A_PtrSize ? "UPtr" : "UInt", pBrush, A_PtrSize ? "UPtr*" : "UInt*", pBrushClone)
+ return pBrushClone
+}
+
+;#####################################################################################
+; Delete resources
+;#####################################################################################
+
+Gdip_DeletePen(pPen)
+{
+ return DllCall("gdiplus\GdipDeletePen", A_PtrSize ? "UPtr" : "UInt", pPen)
+}
+
+;#####################################################################################
+
+Gdip_DeleteBrush(pBrush)
+{
+ return DllCall("gdiplus\GdipDeleteBrush", A_PtrSize ? "UPtr" : "UInt", pBrush)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImage(pBitmap)
+{
+ return DllCall("gdiplus\GdipDisposeImage", A_PtrSize ? "UPtr" : "UInt", pBitmap)
+}
+
+;#####################################################################################
+
+Gdip_DeleteGraphics(pGraphics)
+{
+ return DllCall("gdiplus\GdipDeleteGraphics", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImageAttributes(ImageAttr)
+{
+ return DllCall("gdiplus\GdipDisposeImageAttributes", A_PtrSize ? "UPtr" : "UInt", ImageAttr)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFont(hFont)
+{
+ return DllCall("gdiplus\GdipDeleteFont", A_PtrSize ? "UPtr" : "UInt", hFont)
+}
+
+;#####################################################################################
+
+Gdip_DeleteStringFormat(hFormat)
+{
+ return DllCall("gdiplus\GdipDeleteStringFormat", A_PtrSize ? "UPtr" : "UInt", hFormat)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFontFamily(hFamily)
+{
+ return DllCall("gdiplus\GdipDeleteFontFamily", A_PtrSize ? "UPtr" : "UInt", hFamily)
+}
+
+;#####################################################################################
+
+Gdip_DeleteMatrix(Matrix)
+{
+ return DllCall("gdiplus\GdipDeleteMatrix", A_PtrSize ? "UPtr" : "UInt", Matrix)
+}
+
+;#####################################################################################
+; Text functions
+;#####################################################################################
+
+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_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_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
+}
+
+; Near = 0
+; Center = 1
+; Far = 2
+Gdip_SetStringFormatAlign(hFormat, Align)
+{
+ return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align)
+}
+
+; StringFormatFlagsDirectionRightToLeft = 0x00000001
+; StringFormatFlagsDirectionVertical = 0x00000002
+; StringFormatFlagsNoFitBlackBox = 0x00000004
+; StringFormatFlagsDisplayFormatControl = 0x00000020
+; StringFormatFlagsNoFontFallback = 0x00000400
+; StringFormatFlagsMeasureTrailingSpaces = 0x00000800
+; StringFormatFlagsNoWrap = 0x00001000
+; StringFormatFlagsLineLimit = 0x00002000
+; StringFormatFlagsNoClip = 0x00004000
+Gdip_StringFormatCreate(Format=0, Lang=0)
+{
+ DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat)
+ return hFormat
+}
+
+; Regular = 0
+; Bold = 1
+; Italic = 2
+; BoldItalic = 3
+; Underline = 4
+; Strikeout = 8
+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
+}
+
+;#####################################################################################
+; Matrix functions
+;#####################################################################################
+
+Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y)
+{
+ DllCall("gdiplus\GdipCreateMatrix2", "float", m11, "float", m12, "float", m21, "float", m22, "float", x, "float", y, A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+Gdip_CreateMatrix()
+{
+ DllCall("gdiplus\GdipCreateMatrix", A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+;#####################################################################################
+; GraphicsPath functions
+;#####################################################################################
+
+; Alternate = 0
+; Winding = 1
+Gdip_CreatePath(BrushMode=0)
+{
+ DllCall("gdiplus\GdipCreatePath", "int", BrushMode, A_PtrSize ? "UPtr*" : "UInt*", Path)
+ return Path
+}
+
+Gdip_AddPathEllipse(Path, x, y, w, h)
+{
+ return DllCall("gdiplus\GdipAddPathEllipse", A_PtrSize ? "UPtr" : "UInt", Path, "float", x, "float", y, "float", w, "float", h)
+}
+
+Gdip_AddPathPolygon(Path, 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\GdipAddPathPolygon", Ptr, Path, Ptr, &PointF, "int", Points0)
+}
+
+Gdip_DeletePath(Path)
+{
+ return DllCall("gdiplus\GdipDeletePath", A_PtrSize ? "UPtr" : "UInt", Path)
+}
+
+;#####################################################################################
+; Quality functions
+;#####################################################################################
+
+; SystemDefault = 0
+; SingleBitPerPixelGridFit = 1
+; SingleBitPerPixel = 2
+; AntiAliasGridFit = 3
+; AntiAlias = 4
+Gdip_SetTextRenderingHint(pGraphics, RenderingHint)
+{
+ return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint)
+}
+
+; Default = 0
+; LowQuality = 1
+; HighQuality = 2
+; Bilinear = 3
+; Bicubic = 4
+; NearestNeighbor = 5
+; HighQualityBilinear = 6
+; HighQualityBicubic = 7
+Gdip_SetInterpolationMode(pGraphics, InterpolationMode)
+{
+ return DllCall("gdiplus\GdipSetInterpolationMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", InterpolationMode)
+}
+
+; Default = 0
+; HighSpeed = 1
+; HighQuality = 2
+; None = 3
+; AntiAlias = 4
+Gdip_SetSmoothingMode(pGraphics, SmoothingMode)
+{
+ return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
+}
+
+; CompositingModeSourceOver = 0 (blended)
+; CompositingModeSourceCopy = 1 (overwrite)
+Gdip_SetCompositingMode(pGraphics, CompositingMode=0)
+{
+ return DllCall("gdiplus\GdipSetCompositingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", CompositingMode)
+}
+
+;#####################################################################################
+; Extra functions
+;#####################################################################################
+
+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
+}
+
+; Prepend = 0; The new operation is applied before the old operation.
+; Append = 1; The new operation is applied after the old operation.
+Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipRotateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", Angle, "int", MatrixOrder)
+}
+
+Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipScaleWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipTranslateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_ResetWorldTransform(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetRotatedTranslation(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+
+ Bound := (Angle >= 0) ? Mod(Angle, 360) : 360-Mod(-Angle, -360)
+ if ((Bound >= 0) && (Bound <= 90))
+ xTranslation := Height*Sin(TAngle), yTranslation := 0
+ else if ((Bound > 90) && (Bound <= 180))
+ xTranslation := (Height*Sin(TAngle))-(Width*Cos(TAngle)), yTranslation := -Height*Cos(TAngle)
+ else if ((Bound > 180) && (Bound <= 270))
+ xTranslation := -(Width*Cos(TAngle)), yTranslation := -(Height*Cos(TAngle))-(Width*Sin(TAngle))
+ else if ((Bound > 270) && (Bound <= 360))
+ xTranslation := 0, yTranslation := -Width*Sin(TAngle)
+}
+
+Gdip_GetRotatedDimensions(Width, Height, Angle, ByRef RWidth, ByRef RHeight)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+ if !(Width && Height)
+ return -1
+ RWidth := Ceil(Abs(Width*Cos(TAngle))+Abs(Height*Sin(TAngle)))
+ RHeight := Ceil(Abs(Width*Sin(TAngle))+Abs(Height*Cos(Tangle)))
+}
+
+; RotateNoneFlipNone = 0
+; Rotate90FlipNone = 1
+; Rotate180FlipNone = 2
+; Rotate270FlipNone = 3
+; RotateNoneFlipX = 4
+; Rotate90FlipX = 5
+; Rotate180FlipX = 6
+; Rotate270FlipX = 7
+; RotateNoneFlipY = Rotate180FlipX
+; Rotate90FlipY = Rotate270FlipX
+; Rotate180FlipY = RotateNoneFlipX
+; Rotate270FlipY = Rotate90FlipX
+; RotateNoneFlipXY = Rotate180FlipNone
+; Rotate90FlipXY = Rotate270FlipNone
+; Rotate180FlipXY = RotateNoneFlipNone
+; Rotate270FlipXY = Rotate90FlipNone
+
+Gdip_ImageRotateFlip(pBitmap, RotateFlipType=1)
+{
+ return DllCall("gdiplus\GdipImageRotateFlip", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", RotateFlipType)
+}
+
+; Replace = 0
+; Intersect = 1
+; Union = 2
+; Xor = 3
+; Exclude = 4
+; Complement = 5
+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_SetClipPath(pGraphics, Path, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ return DllCall("gdiplus\GdipSetClipPath", Ptr, pGraphics, Ptr, Path, "int", CombineMode)
+}
+
+Gdip_ResetClip(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetClipRegion(pGraphics)
+{
+ Region := Gdip_CreateRegion()
+ DllCall("gdiplus\GdipGetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", Region)
+ return Region
+}
+
+Gdip_SetClipRegion(pGraphics, Region, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipSetClipRegion", Ptr, pGraphics, Ptr, Region, "int", CombineMode)
+}
+
+Gdip_CreateRegion()
+{
+ DllCall("gdiplus\GdipCreateRegion", A_PtrSize ? "UPtr*" : "UInt*", Region)
+ return Region
+}
+
+Gdip_DeleteRegion(Region)
+{
+ return DllCall("gdiplus\GdipDeleteRegion", A_PtrSize ? "UPtr" : "UInt", Region)
+}
+
+;#####################################################################################
+; BitmapLockBits
+;#####################################################################################
+
+Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode = 3, PixelFormat = 0x26200a)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreateRect(Rect, x, y, w, h)
+ VarSetCapacity(BitmapData, 16+2*(A_PtrSize ? A_PtrSize : 4), 0)
+ E := DllCall("Gdiplus\GdipBitmapLockBits", Ptr, pBitmap, Ptr, &Rect, "uint", LockMode, "int", PixelFormat, Ptr, &BitmapData)
+ Stride := NumGet(BitmapData, 8, "Int")
+ Scan0 := NumGet(BitmapData, 16, Ptr)
+ return E
+}
+
+;#####################################################################################
+
+Gdip_UnlockBits(pBitmap, ByRef BitmapData)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("Gdiplus\GdipBitmapUnlockBits", Ptr, pBitmap, Ptr, &BitmapData)
+}
+
+;#####################################################################################
+
+Gdip_SetLockBitPixel(ARGB, Scan0, x, y, Stride)
+{
+ Numput(ARGB, Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_GetLockBitPixel(Scan0, x, y, Stride)
+{
+ return NumGet(Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_PixelateBitmap(pBitmap, ByRef pBitmapOut, BlockSize)
+{
+ static PixelateBitmap
+
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if (!PixelateBitmap)
+ {
+ if A_PtrSize != 8 ; x86 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 558BEC83EC3C8B4514538B5D1C99F7FB56578BC88955EC894DD885C90F8E830200008B451099F7FB8365DC008365E000894DC88955F08945E833FF897DD4
+ 397DE80F8E160100008BCB0FAFCB894DCC33C08945F88945FC89451C8945143BD87E608B45088D50028BC82BCA8BF02BF2418945F48B45E02955F4894DC4
+ 8D0CB80FAFCB03CA895DD08BD1895DE40FB64416030145140FB60201451C8B45C40FB604100145FC8B45F40FB604020145F883C204FF4DE475D6034D18FF
+ 4DD075C98B4DCC8B451499F7F98945148B451C99F7F989451C8B45FC99F7F98945FC8B45F899F7F98945F885DB7E648B450C8D50028BC82BCA83C103894D
+ C48BC82BCA41894DF48B4DD48945E48B45E02955E48D0C880FAFCB03CA895DD08BD18BF38A45148B7DC48804178A451C8B7DF488028A45FC8804178A45F8
+ 8B7DE488043A83C2044E75DA034D18FF4DD075CE8B4DCC8B7DD447897DD43B7DE80F8CF2FEFFFF837DF0000F842C01000033C08945F88945FC89451C8945
+ 148945E43BD87E65837DF0007E578B4DDC034DE48B75E80FAF4D180FAFF38B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945CC0F
+ B6440E030145140FB60101451C0FB6440F010145FC8B45F40FB604010145F883C104FF4DCC75D8FF45E4395DE47C9B8B4DF00FAFCB85C9740B8B451499F7
+ F9894514EB048365140033F63BCE740B8B451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB
+ 038975F88975E43BDE7E5A837DF0007E4C8B4DDC034DE48B75E80FAF4D180FAFF38B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955CC8A55
+ 1488540E038A551C88118A55FC88540F018A55F888140183C104FF4DCC75DFFF45E4395DE47CA68B45180145E0015DDCFF4DC80F8594FDFFFF8B451099F7
+ FB8955F08945E885C00F8E450100008B45EC0FAFC38365DC008945D48B45E88945CC33C08945F88945FC89451C8945148945103945EC7E6085DB7E518B4D
+ D88B45080FAFCB034D108D50020FAF4D18034DDC8BF08BF88945F403CA2BF22BFA2955F4895DC80FB6440E030145140FB60101451C0FB6440F010145FC8B
+ 45F40FB604080145F883C104FF4DC875D8FF45108B45103B45EC7CA08B4DD485C9740B8B451499F7F9894514EB048365140033F63BCE740B8B451C99F7F9
+ 89451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975103975EC7E5585DB7E468B4DD88B450C
+ 0FAFCB034D108D50020FAF4D18034DDC8BF08BF803CA2BF22BFA2BC2895DC88A551488540E038A551C88118A55FC88540F018A55F888140183C104FF4DC8
+ 75DFFF45108B45103B45EC7CAB8BC3C1E0020145DCFF4DCC0F85CEFEFFFF8B4DEC33C08945F88945FC89451C8945148945103BC87E6C3945F07E5C8B4DD8
+ 8B75E80FAFCB034D100FAFF30FAF4D188B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945C80FB6440E030145140FB60101451C0F
+ B6440F010145FC8B45F40FB604010145F883C104FF4DC875D833C0FF45108B4DEC394D107C940FAF4DF03BC874068B451499F7F933F68945143BCE740B8B
+ 451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975083975EC7E63EB0233F639
+ 75F07E4F8B4DD88B75E80FAFCB034D080FAFF30FAF4D188B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955108A551488540E038A551C8811
+ 8A55FC88540F018A55F888140883C104FF4D1075DFFF45088B45083B45EC7C9F5F5E33C05BC9C21800
+ )
+ else ; x64 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 4489442418488954241048894C24085355565741544155415641574883EC28418BC1448B8C24980000004C8BDA99488BD941F7F9448BD0448BFA8954240C
+ 448994248800000085C00F8E9D020000418BC04533E4458BF299448924244C8954241041F7F933C9898C24980000008BEA89542404448BE889442408EB05
+ 4C8B5C24784585ED0F8E1A010000458BF1418BFD48897C2418450FAFF14533D233F633ED4533E44533ED4585C97E5B4C63BC2490000000418D040A410FAF
+ C148984C8D441802498BD9498BD04D8BD90FB642010FB64AFF4403E80FB60203E90FB64AFE4883C2044403E003F149FFCB75DE4D03C748FFCB75D0488B7C
+ 24188B8C24980000004C8B5C2478418BC59941F7FE448BE8418BC49941F7FE448BE08BC59941F7FE8BE88BC69941F7FE8BF04585C97E4048639C24900000
+ 004103CA4D8BC1410FAFC94863C94A8D541902488BCA498BC144886901448821408869FF408871FE4883C10448FFC875E84803D349FFC875DA8B8C249800
+ 0000488B5C24704C8B5C24784183C20448FFCF48897C24180F850AFFFFFF8B6C2404448B2424448B6C24084C8B74241085ED0F840A01000033FF33DB4533
+ DB4533D24533C04585C97E53488B74247085ED7E42438D0C04418BC50FAF8C2490000000410FAFC18D04814863C8488D5431028BCD0FB642014403D00FB6
+ 024883C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC17CB28BCD410FAFC985C9740A418BC299F7F98BF0EB0233F685C9740B418BC3
+ 99F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585C97E4D4C8B74247885ED7E3841
+ 8D0C14418BC50FAF8C2490000000410FAFC18D04814863C84A8D4431028BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2413BD17CBD
+ 4C8B7424108B8C2498000000038C2490000000488B5C24704503E149FFCE44892424898C24980000004C897424100F859EFDFFFF448B7C240C448B842480
+ 000000418BC09941F7F98BE8448BEA89942498000000896C240C85C00F8E3B010000448BAC2488000000418BCF448BF5410FAFC9898C248000000033FF33
+ ED33F64533DB4533D24533C04585FF7E524585C97E40418BC5410FAFC14103C00FAF84249000000003C74898488D541802498BD90FB642014403D00FB602
+ 4883C2044403D80FB642FB03F00FB642FA03E848FFCB75DE488B5C247041FFC0453BC77CAE85C9740B418BC299F7F9448BE0EB034533E485C9740A418BC3
+ 99F7F98BD8EB0233DB85C9740A8BC699F7F9448BD8EB034533DB85C9740A8BC599F7F9448BD0EB034533D24533C04585FF7E4E488B4C24784585C97E3541
+ 8BC5410FAFC14103C00FAF84249000000003C74898488D540802498BC144886201881A44885AFF448852FE4883C20448FFC875E941FFC0453BC77CBE8B8C
+ 2480000000488B5C2470418BC1C1E00203F849FFCE0F85ECFEFFFF448BAC24980000008B6C240C448BA4248800000033FF33DB4533DB4533D24533C04585
+ FF7E5A488B7424704585ED7E48418BCC8BC5410FAFC94103C80FAF8C2490000000410FAFC18D04814863C8488D543102418BCD0FB642014403D00FB60248
+ 83C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC77CAB418BCF410FAFCD85C9740A418BC299F7F98BF0EB0233F685C9740B418BC399
+ F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585FF7E4E4585ED7E42418BCC8BC541
+ 0FAFC903CA0FAF8C2490000000410FAFC18D04814863C8488B442478488D440102418BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2
+ 413BD77CB233C04883C428415F415E415D415C5F5E5D5BC3
+ )
+
+ VarSetCapacity(PixelateBitmap, StrLen(MCode_PixelateBitmap)//2)
+ Loop % StrLen(MCode_PixelateBitmap)//2 ;%
+ NumPut("0x" SubStr(MCode_PixelateBitmap, (2*A_Index)-1, 2), PixelateBitmap, A_Index-1, "UChar")
+ DllCall("VirtualProtect", Ptr, &PixelateBitmap, Ptr, VarSetCapacity(PixelateBitmap), "uint", 0x40, A_PtrSize ? "UPtr*" : "UInt*", 0)
+ }
+
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+
+ if (Width != Gdip_GetImageWidth(pBitmapOut) || Height != Gdip_GetImageHeight(pBitmapOut))
+ return -1
+ if (BlockSize > Width || BlockSize > Height)
+ return -2
+
+ E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1)
+ E2 := Gdip_LockBits(pBitmapOut, 0, 0, Width, Height, Stride2, Scan02, BitmapData2)
+ if (E1 || E2)
+ return -3
+
+ E := DllCall(&PixelateBitmap, Ptr, Scan01, Ptr, Scan02, "int", Width, "int", Height, "int", Stride1, "int", BlockSize)
+
+ Gdip_UnlockBits(pBitmap, BitmapData1), Gdip_UnlockBits(pBitmapOut, BitmapData2)
+ return 0
+}
+
+;#####################################################################################
+
+Gdip_ToARGB(A, R, G, B)
+{
+ return (A << 24) | (R << 16) | (G << 8) | B
+}
+
+;#####################################################################################
+
+Gdip_FromARGB(ARGB, ByRef A, ByRef R, ByRef G, ByRef B)
+{
+ A := (0xff000000 & ARGB) >> 24
+ R := (0x00ff0000 & ARGB) >> 16
+ G := (0x0000ff00 & ARGB) >> 8
+ B := 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+Gdip_AFromARGB(ARGB)
+{
+ return (0xff000000 & ARGB) >> 24
+}
+
+;#####################################################################################
+
+Gdip_RFromARGB(ARGB)
+{
+ return (0x00ff0000 & ARGB) >> 16
+}
+
+;#####################################################################################
+
+Gdip_GFromARGB(ARGB)
+{
+ return (0x0000ff00 & ARGB) >> 8
+}
+
+;#####################################################################################
+
+Gdip_BFromARGB(ARGB)
+{
+ return 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+StrGetB(Address, Length=-1, Encoding=0)
+{
+ ; Flexible parameter handling:
+ if Length is not integer
+ Encoding := Length, Length := -1
+
+ ; Check for obvious errors.
+ if (Address+0 < 1024)
+ return
+
+ ; Ensure 'Encoding' contains a numeric identifier.
+ if Encoding = UTF-16
+ Encoding = 1200
+ else if Encoding = UTF-8
+ Encoding = 65001
+ else if SubStr(Encoding,1,2)="CP"
+ Encoding := SubStr(Encoding,3)
+
+ if !Encoding ; "" or 0
+ {
+ ; No conversion necessary, but we might not want the whole string.
+ if (Length == -1)
+ Length := DllCall("lstrlen", "uint", Address)
+ VarSetCapacity(String, Length)
+ DllCall("lstrcpyn", "str", String, "uint", Address, "int", Length + 1)
+ }
+ else if Encoding = 1200 ; UTF-16
+ {
+ char_count := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "uint", 0, "uint", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(String, char_count)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "str", String, "int", char_count, "uint", 0, "uint", 0)
+ }
+ else if Encoding is integer
+ {
+ ; Convert from target encoding to UTF-16 then to the active code page.
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", 0, "int", 0)
+ VarSetCapacity(String, char_count * 2)
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", &String, "int", char_count * 2)
+ String := StrGetB(&String, char_count, 1200)
+ }
+
+ return String
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/Lib/ViGEmWrapper.dll b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/Lib/ViGEmWrapper.dll
new file mode 100644
index 0000000..2a08e3a
Binary files /dev/null and b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/Lib/ViGEmWrapper.dll differ
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/clubman.ahk b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/clubman.ahk
new file mode 100644
index 0000000..4aa7ee4
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/clubman.ahk
@@ -0,0 +1,502 @@
+
+; https://github.com/berban/Gdip
+
+#HotkeyInterval 99000000
+#KeyHistory 0
+#MaxHotkeysPerInterval 99000000
+#NoEnv
+#Persistent
+#SingleInstance Force
+#Include Lib\Gdip.ahk
+#Include Lib\AHK-ViGEm-Bus.ahk
+
+CoordMode, Pixel, Client
+CoordMode, ToolTip, Client
+DetectHiddenWindows, On
+ListLines Off
+Process, priority, , High
+SendMode Input
+SetBatchLines, -1
+SetDefaultMouseSpeed, 0
+SetFormat, Float, 0.2
+; SetFormat, IntegerFast, Hex
+SetKeyDelay, 50
+SetMouseDelay, -1
+SetWorkingDir %A_ScriptDir%
+
+; Variables
+races_clean := 0
+races_clean_percent := 0
+races_completed := 0
+races_completed_check := 0
+credits_total := 0
+credits_average := 0
+
+time_start := A_TickCount
+time_current := A_TickCount
+
+window_width := 640
+window_height := 360
+
+; Create a new controller controller
+controller := new ViGEmDS4()
+
+; GUI
+Gui, New, -MaximizeBox -Resize, ClubmanPlus 0.5
+Gui, Font, S10
+Gui, Add, Text, vStatRace, Race Counts: %races_completed%
+Gui, Add, Text, vCleanRace, Clean Races: %races_clean%
+Gui, Add, Text, vCleanRate, Average Clean Runs: %races_clean_percent%`%
+Gui, Add, Text, vEarnings, Earnings: %credits_total%M
+Gui, Add, Text, vEarningsRate, Earnings Rate: %credits_average%M/hr
+Gui, Add, Button, w150 h40 Default gStart, Start
+Gui, Add, Button, w150 h40 x+10 gReset, Reset
+Gui, Show
+return
+
+; GUI events
+GuiClose:
+ Gosub, Release_All
+ SetTimer, Health, Off
+ SetTimer, Summary, Off
+ OutputDebug % "Clubman> Terminated"
+ExitApp
+
+; GUI buttons
+Stats:
+ GuiControl,,StatRace, Race Counts: %races_completed%
+ GuiControl,,CleanRace, Clean Races: %races_clean%
+ GuiControl,,CleanRate, Average Clean Runs: %races_clean_percent%`%
+ GuiControl,,Earnings, Earnings: %credits_total%M
+ GuiControl,,EarningsRate, Earnings Rate: %credits_average%M/hr
+Return
+
+Start:
+ hwnd := 0
+
+ Gosub, Release_All
+ Gosub, GrabWindow
+
+ if (hwnd = 0) {
+ MsgBox, % "PS Remote Play not found"
+ return
+ }
+
+ SetTimer, Health, 600000
+ SetTimer, Summary, 3600000
+ time_start := A_TickCount
+
+ ; ** AFK Loop
+ Gosub, Press_X
+
+ Loop {
+
+ ; ** RACE
+ OutputDebug % "Clubman> Race: Waiting for position GUI to show"
+ while (!IsColor(hwnd, 0xFFFFFF, 218, 490, 6, 20)) { ; top-right tire wear indicator
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race: Starting race"
+ Gosub, Hold_X
+ ; Gosub, Hold_Down
+ OutputDebug % "Clubman> Race: Racing until position GUI disappears"
+ while (IsColor(hwnd, 0xFFFFFF, 218, 490, 6, 20)) { ; top-right tire wear indicator
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race: Race ended, releasing all buttons"
+ Gosub, Release_All
+ ; Sleep, 5000
+
+ ; ** GO TO LEADERBOARDS
+ OutputDebug % "Clubman> End race: Waiting for continue X icon to show"
+ while (!IsColor(hwnd, 0xC9C9C9, 465, 519, 6, 20)) { ; X icon
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> End race: Press X to continue"
+ while (IsColor(hwnd, 0xC9C9C9, 465, 519, 6, 20)) { ; X icon
+ Gosub, Press_X
+ Sleep, 100
+ }
+ OutputDebug % "Clubman> End race: Transitioning to leaderboard"
+
+ ; ** LEADERBOARD
+ Loop {
+ OutputDebug % "Clubman> Leaderboard: Checking positions"
+
+ if (IsColor(hwnd, 0xBADD3E, 671, 124, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 1st position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 153, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 2nd position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 182, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 3rd position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 211, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 4th position"
+ Gosub, Press_X
+ break
+ }
+ else if (IsColor(hwnd, 0xBADD3E, 671, 240, 10, 20)) { ; venom green on the leaderboard
+ OutputDebug % "Clubman> Leaderboard: 5th position"
+ Gosub, Press_X
+ break
+ }
+ else {
+ Sleep, 500
+ }
+ }
+
+ ; ** REWARDS
+ OutputDebug % "Clubman> Rewards: Waiting for Rewards screen to load (checking money earnt)"
+ while (!IsColor(hwnd, 0xBE140F, 848, 192, 6, 100)) { ; money earn, the red text
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Rewards: Found Rewards screen"
+ races_completed++
+
+ Loop 100 {
+ if (IsColor(hwnd, 0x5C90FB, 451, 260, 10, 20)) { ; the 'R' in Clean Race Bonus
+ OutputDebug % "Clubman> Rewards: Clean bonus"
+ races_clean++
+ PixelSearch(486, 311, 1, hwnd, "clean", "")
+ break
+ }
+
+ if (A_Index == 100) {
+ OutputDebug % "Clubman> Rewards: No clean bonus"
+ PixelSearch(486, 311, 1, hwnd, "no-clean", "")
+ }
+ }
+
+ ; ** REPLAY
+ OutputDebug % "Clubman> Replay: Waiting for Replay screen to load"
+ while (!IsColor(hwnd, 0xFFFFFF, 911, 510, 4, 20)) { ; the cursor on top the exit button
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Replay: Pressing the Exit button"
+ while (IsColor(hwnd, 0xFFFFFF, 911, 510, 4, 20)) { ; the cursor on top the exit button
+ Gosub, Press_X
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Replay: Leaving the Replay screen"
+
+ ; ** RACE RESULTS
+ OutputDebug % "Clubman> Race Result: Waiting for Race Result screen to load (checking cursor)"
+ while (!IsColor(hwnd, 0xBE1E1C, 651, 497, 4, 20)) { ; the exit button
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Result: Moving cursor to the Retry button"
+ while (!IsColor(hwnd, 0xFFFFFF, 514, 504, 4, 20)) { ; cursor on top the retry button
+ Gosub, Press_Right
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Result: Pressing the Retry button"
+ while (IsColor(hwnd, 0xFFFFFF, 514, 504, 4, 20)) { ; cursor on top the retry button
+ Gosub, Press_X
+ Sleep, 500
+ }
+
+ ; ** RACE START
+ OutputDebug % "Clubman> Race Start: Waiting for Race Start screen to load (checking cursor)"
+ while (!IsColor(hwnd, 0xFFFFFF, 287, 504, 4, 20)) { ; cursor on top the start button
+ Sleep, 500
+ }
+ OutputDebug % "Clubman> Race Start: Pressing the Start button"
+ while (IsColor(hwnd, 0xFFFFFF, 287, 504, 4, 20)) { ; cursor on top the start button
+ Gosub, Press_X
+ Sleep, 500
+ }
+
+ OutputDebug % "--- Summary ---"
+ credits_total := (races_completed * 0.07 + races_clean * 0.035)
+ races_clean_percent := (races_clean / races_completed) * 100
+ time_current := A_TickCount
+ credits_average := credits_total / (time_current - time_start) * 3600000
+
+ Gosub, Stats
+
+ OutputDebug % "Clubman> Summary: Races " races_completed
+ OutputDebug % "Clubman> Summary: Races Clean " races_clean
+ OutputDebug % "Clubman> Summary: Races Clean Rate " races_clean_percent "%"
+ OutputDebug % "Clubman> Summary: Earnings " credits_total "M"
+ OutputDebug % "Clubman> Summary: Earnings Rate " credits_average "M/Hr"
+ OutputDebug % "---------------"
+ }
+return
+
+Reset:
+ OutputDebug % "Clubman> Reloading"
+ Gosub, Release_All
+ SetTimer, Health, Off
+ SetTimer, Summary, Off
+ Reload
+return
+
+; -------------------
+; Health Check
+; -------------------
+Health:
+ FormatTime, current_date,, % "yyMMdd-HHmm-ss"
+ OutputDebug % "Clubman> Health: Checking health at " current_date
+ OutputDebug % "Clubman> Health: Races completed " races_completed
+ OutputDebug % "Clubman> Health: Races completed last time " races_completed_check
+
+ if (races_completed_check >= races_completed) {
+ OutputDebug % "Clubman> Health: Error dectected, sending notification"
+ SendNotification("ClubmanPlus", "Something went wrong", 2, "persistent")
+ } else {
+ OutputDebug % "Clubman> Health: Running healthy"
+ races_completed_check := races_completed
+ }
+Return
+
+; -------------------
+; Summary Check
+; -------------------
+Summary:
+ OutputDebug % "Clubman> Summary: Sending summary notification"
+ message := ""
+ message := message "Races " races_clean " / " races_completed " (" races_clean_percent ")`n"
+ message := message "Earnings " credits_total "M (" credits_average "M/Hr)"
+ SendNotification("ClubmanPlus", message, 0, "cashregister")
+Return
+
+; -------------------
+; Send Notification
+; -------------------
+SendNotification(title, message, level, sound) {
+
+ IniRead, token, %A_ScriptDir%\clubman.ini, pushover, token
+ IniRead, user, %A_ScriptDir%\clubman.ini, pushover, user_key
+
+ retries := 60
+ expires := 3600
+
+ url := "https://api.pushover.net/1/messages.json"
+ param := "token=" token "&user=" user "&title=" title "&message=" message "&sound=" sound "&priority=" level
+
+ if (level == 2) {
+ param := param "&retry=" retries "&expire=" expires
+ }
+
+ WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
+ WebRequest.Open("POST", url)
+ WebRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
+ WebRequest.Send(param)
+Return
+}
+
+; -------------------
+; Grab Window
+; -------------------
+GrabWindow:
+ OutputDebug % "Clubman> Looking for window"
+ hwnd := WinExist("PS Remote Play")
+
+ if (hwnd > 0) {
+ OutputDebug % "Clubman> Window found: " hwnd
+ WinMove, ahk_id %hwnd%,, 0, 0, %window_width%, %window_height%
+ WinActivate, ahk_id %hwnd%
+ ControlFocus,, ahk_id %hwnd%
+ }
+return
+
+; -------------------
+; Is Color
+; -------------------
+IsColor(hwnd, target_color, x, y, b, tolerance) {
+ for i, c in PixelSearch(x, y, b, hwnd) {
+ if (ColorDistance(c, target_color) <= tolerance) {
+ Return True
+ }
+ }
+Return False
+}
+
+; -------------------
+; Color Distance
+; -------------------
+ColorDistance( c1, c2 ) {
+ r1 := c1 >> 16
+ g1 := c1 >> 8 & 255
+ b1 := c1 & 255
+ r2 := c2 >> 16
+ g2 := c2 >> 8 & 255
+ b2 := c2 & 255
+return Sqrt( (r1-r2)**2 + (g1-g2)**2 + (b1-b2)**2 )
+}
+
+; -------------------
+; Pixel Search
+; -------------------
+PixelSearch(x, y, b, hwnd, debugsave := "", debugsavecropped := "") {
+ x := (960 / x)
+ y := (540 / y)
+
+ VarSetCapacity(rect, 16)
+ DllCall("GetClientRect", "ptr", hwnd, "ptr", &rect)
+ x := floor(NumGet(rect, 8, "int") // x)
+ y := floor(NumGet(rect, 12, "int") // y)
+ b := floor((b * NumGet(rect, 8, "int")) / 960)
+
+ VarSetCapacity(POINT, 8)
+ NumPut(x, &POINT, 0, "Int")
+ NumPut(y, &POINT, 4, "Int")
+ DllCall("user32\ClientToScreen", Ptr, hwnd, Ptr,&POINT)
+ x := NumGet(&POINT, 0, "Int")
+ y := NumGet(&POINT, 4, "Int")
+
+ pToken := Gdip_Startup()
+ pBitmap := Gdip_BitmapFromScreen("hwnd:" hwnd)
+
+ pixs := []
+ Loop % b*2 + 1 {
+ i := (-1 * b) + (A_Index - 1)
+ Loop % b*2 + 1 {
+ j := (-1 * b) + (A_Index - 1)
+ pixs.Push(Gdip_GetPixel(pBitmap, x+i, y+j) & 0x00FFFFFF)
+ }
+ }
+
+ FormatTime, current_date,, % "yyMMdd-HHmm-ss"
+
+ if (debugsave != "") {
+ Gdip_SaveBitmapToFile(pBitmap, A_ScriptDir . "\" . current_date . "-" . debugsave . ".bmp")
+ }
+ if (debugsavecropped != "") {
+ debugbitmap:=Gdip_CloneBitmapArea(pBitmap, x-b, y-b, b*2, b*2)
+ Gdip_SaveBitmapToFile(debugbitmap, A_ScriptDir . "\" . current_date . "-" . debugsavecropped . ".bmp")
+ Gdip_DisposeImage(debugbitmap)
+ }
+
+ Gdip_DisposeImage(pBitmap)
+ Gdip_Shutdown(pToken)
+return pixs
+}
+
+; -------------------
+; Release All
+; -------------------
+Release_All:
+ Gosub, Release_X
+ Gosub, Release_O
+ Gosub, Release_Right
+ Gosub, Release_Left
+ Gosub, Release_Up
+ Gosub, Release_Down
+return
+
+; -------------------
+; Press x
+; -------------------
+Press_X:
+ Gosub, Hold_X
+ Sleep, 50
+ Gosub, Release_x
+return
+
+Hold_X:
+ controller.Buttons.Cross.SetState(true)
+return
+
+Release_X:
+ controller.Buttons.Cross.SetState(false)
+return
+
+; -------------------
+; Press O
+; -------------------
+Press_O:
+ Gosub, Hold_O
+ Sleep, 50
+ Gosub, Release_O
+return
+
+Hold_O:
+ controller.Buttons.Circle.SetState(true)
+return
+
+Release_O:
+ controller.Buttons.Circle.SetState(false)
+return
+
+; -------------------
+; Press Right
+; -------------------
+Press_Right:
+ Gosub, Hold_Right
+ Sleep, 50
+ Gosub, Release_Right
+return
+
+Hold_Right:
+ controller.Dpad.SetState("Right")
+return
+
+Release_Right:
+ controller.Dpad.SetState("None")
+return
+
+; -------------------
+; Press Left
+; -------------------
+Press_Left:
+ Gosub, Hold_Left
+ Sleep, 50
+ Gosub, Release_Left
+return
+
+Hold_Left:
+ controller.Dpad.SetState("Left")
+return
+
+Release_Left:
+ controller.Dpad.SetState("None")
+return
+
+; -------------------
+; Press Up
+; -------------------
+Press_Up:
+ Gosub, Hold_Up
+ Sleep, 50
+ Gosub, Release_Up
+return
+
+Hold_Up:
+ controller.Dpad.SetState("Up")
+return
+
+Release_Up:
+ controller.Dpad.SetState("None")
+return
+
+; -------------------
+; Press Down
+; -------------------
+Press_Down:
+ Gosub, Hold_Down
+ Sleep, 50
+ Gosub, Release_Down
+return
+
+Hold_Down:
+ controller.Dpad.SetState("Down")
+return
+
+Release_Down:
+ controller.Dpad.SetState("None")
+return
+
+; Hotkeys
+^Esc::ExitApp
diff --git a/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/clubman.ini b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/clubman.ini
new file mode 100644
index 0000000..e70a764
--- /dev/null
+++ b/bnowakow/old versions/4 Clubmanplus/clubman-test-0.5/clubman.ini
@@ -0,0 +1,3 @@
+[pushover]
+user_key=your_key
+token=your_token
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Assets/GT7_Tokyo.ico b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Assets/GT7_Tokyo.ico
new file mode 100644
index 0000000..6e4e770
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Assets/GT7_Tokyo.ico differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Assets/tokyo_gui.png b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Assets/tokyo_gui.png
new file mode 100644
index 0000000..97f8acf
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Assets/tokyo_gui.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/GT7_Tokyo.AHK b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/GT7_Tokyo.AHK
new file mode 100644
index 0000000..9a7e7e6
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/GT7_Tokyo.AHK
@@ -0,0 +1,313 @@
+#Persistent
+#NoEnv
+#MaxHotkeysPerInterval 99000000
+#HotkeyInterval 99000000
+#KeyHistory 0
+#Include Lib\Gdip.ahk
+#Include Lib\AHK-ViGEm-Bus.ahk
+#Include Lib\__utility__.ahk
+#Include Lib\__controller_functions__.ahk
+#Include Mod\TokyoDetections.ahk
+#Include Races\Tokyo.ahk
+
+hModule := DllCall("LoadLibrary", "Str", A_LineFile "\..\Lib\SuperSleep.dll", "Ptr")
+SuperSleep := DllCall("GetProcAddress", "Ptr", DllCall("GetModuleHandle", "Str", A_LineFile "\..\Lib\SuperSleep.dll", "Ptr"), "AStr", "super_sleep", "Ptr")
+
+ListLines Off
+Process, Priority, , A
+SetBatchLines, -1
+SetKeyDelay, -1, -1
+SetMouseDelay, -1
+SetDefaultMouseSpeed, 0
+SendMode Input
+
+SetWorkingDir %A_ScriptDir%
+DetectHiddenWindows, On
+#Persistent
+
+Global script_start := A_TickCount
+Global remote_play_offsetY := 71
+Global racecounter := 0
+Global resetcounter := 0
+Global color_pitstop1 := 0xFFFFFF
+Global color_restart := 0x6D5223
+Global hairpin_delay := 0
+
+Global TelegramBotToken := ""
+Global TelegramChatID := ""
+Global location := ""
+Global TokyoLapCount := 1
+
+
+
+SetFormat, integerfast, d
+ps_win_width := 640
+ps_win_height := 360
+IniRead, hairpin_delay, config.ini, Vars, hairpin_delay, 0
+IniRead, color_pitstop1, config.ini, Vars, color_pitstop1, 0
+IniRead, RaceCounterTotal, config.ini, Stats, racecountertotal, 0
+IniRead, ResetCounterTotal, config.ini, Stats, resetcountertotal, 0
+IniRead, TelegramBotToken, config.ini, API, TelegramBotToken, 0
+IniRead, TelegramChatID, config.ini, API, TelegramChatID, 0
+SetFormat, FloatFast, 0.2
+creditcountertotal := 835000*racecountertotal/1000000
+
+Global controller := new ViGEmDS4()
+controller.SubscribeFeedback(Func("OnFeedback"))
+OnFeedback(largeMotor, smallMotor, lightbarColor){
+}
+
+;- GUI 1 (MAIN) -------------------------------------------------------------------------------------------------
+Icon = Assets\GT7_Tokyo.ico
+Menu, Tray, Icon, %Icon%
+Gui, -Caption
+Gui, Add, Picture, x0 y0 w650 h207 , Assets\tokyo_gui.png
+Gui, Add, Button, x222 y82 w410 h80 default gButtonStart, START
+Gui, Add, Progress, x0 y54 w641 h12 RaceProgress vRaceProgress -Smooth, 0
+Gui, Font, S8 CDefault Bold, Verdana
+Gui, Add, Text, x440 y3 w160 h20 RaceCounterTotal +BackgroundTrans, // ALL TIME
+Gui, Font, ,
+Gui, Add, Text, x440 y23 w160 h20 RaceCounterTotal vracecountertotal +BackgroundTrans, Races completed: %racecountertotal%
+Gui, Add, Text, x440 y38 w160 h20 ResetCounterTotal vresetcountertotal +BackgroundTrans, Races failed: %resetcountertotal%
+Gui, Add, Text, x550 y38 w160 h20 CreditCounterTotal vcreditcountertotal +BackgroundTrans, Credits: %creditcountertotal% M
+Gui, Font, S8 CDefault Bold, Verdana
+Gui, Add, Text, x220 y3 w300 h20 RaceSession vracesession +BackgroundTrans, // SESSION
+Gui, Font, ,
+Gui, Add, Text, x220 y23 w160 h20 RaceCounterSession vracecountersession +BackgroundTrans, Races completed: 0
+Gui, Add, Text, x220 y38 w160 h20 ResetCounterSession vresetcountersession +BackgroundTrans, Races failed: 0
+Gui, Add, Text, x330 y23 w160 h20 CreditCounterSession vcreditcountersession +BackgroundTrans, Credits: 0
+Gui, Add, Text, x330 y38 w160 h20 CreditAVG vcreditavg +BackgroundTrans, Avg./h: 0
+Gui, Add, Text, x10 y38 w150 h20 CounterLap vcurrentlap +BackgroundTrans, Current Lap: 0/12
+Gui, Add, Text, x10 y23 w150 h20 CurrentLoop vcurrentloop +BackgroundTrans, Current Location: -
+Gui, Add, Button, x222 y172 w300 h20 default gGUIReset, Reset
+Gui, Add, Button, x531 y172 w101 h20 default gGUIClose, Exit
+Gui, Add, Button, x12 y82 w200 h20 default gMachineSettingsWindow, Settings: Machine/Setup
+Gui, Add, Button, x12 y112 w200 h20 default gIngameSettingsWindow, Settings: Ingame (wip)
+Gui, Add, Button, x12 y142 w200 h20 default gRiskRewardWindow, Settings: Risk/Reward (wip)
+Gui, Add, Button, x12 y172 w200 h20 default gNotificationsWindow, Settings: Notifications/API
+Gui, Font, S8 CDefault Bold, Verdana
+Gui, Add, Text, x10 y3 w620 h20 +BackgroundTrans, // TOKYO CONTROL CENTER
+Gui, Add, Statusbar, -Theme Backgroundeeeeee ;#eeeeee, no typo
+SB_SetParts(80,270,190)
+SB_SetText(" beta 9.2 ",1)
+SB_SetText(" by problemz.",4)
+Gui, Show, x8 y532 h225 w640, GT7 Tokyo // by problemz
+guicontrol,, CurrentLoop, Press START, go go!
+;- GUI 2 (MACHINE/SETUP) ----------------------------------------------------------------------------------------
+Gui, 2: Add, Picture, x0 y0 w650 h210 , Assets\tokyo_gui.png
+Gui, 2: Add, Text, x10 y14 w200 h20 +BackgroundTrans , Hairpin Turn Delay:
+Gui, 2: Font, ,
+Gui, 2: Add, Text, x170 y14 w200 h20 +BackgroundTrans , (ms)
+Gui, 2: Add, Slider, x220 y10 w300 h51 vsliderhairpindelay Range0-800 Thick40 +ToolTip TickInterval50 gSliderMove,%hairpin_delay%
+Gui, 2: Add, Edit, x106 y11 w60 vtxthairpindelay gtextchanged, %hairpin_delay%
+Gui, 2: Add, Text, x10 y40 w200 h20 +BackgroundTrans , Lower = slower PC // Higher = faster PC
+Gui, 2: Add, Button, x530 y11 w100 h51 +BackgroundTrans gSaveToIni, Save
+
+Gui, 2: Add, Button, x10 y80 w200 h40 gPit1Color, Stuck in pit `n(Only click when at tire selection menu)
+;- GUI 3 (INGAME) -----------------------------------------------------------------------------------------------
+Gui, 3: Add, Picture, x0 y0 w650 h177 , Assets\tokyo_gui.png
+;- GUI 4 (RISK/REWARD) ------------------------------------------------------------------------------------------
+Gui, 4: Add, Picture, x0 y0 w650 h177 , Assets\tokyo_gui.png
+;- GUI 5 (NOTIFICATIONS/API) ------------------------------------------------------------------------------------
+Gui, 5: Add, Picture, x0 y0 w650 h400 , Assets\tokyo_gui.png
+Gui, 5: Add, Text, x10 y14 w205 h20 +BackgroundTrans , Telegram Bot Token:
+Gui, 5: Add, Edit, x116 y11 w400 vTelegramBotToken Password, %TelegramBotToken%
+Gui, 5: Add, Text, x10 y44 w205 h20 +BackgroundTrans , Telegram Chat ID:
+Gui, 5: Add, Edit, x116 y41 w400 vTelegramChatID Password, %TelegramChatID%
+Gui, 5: Add, Button, x530 y11 w100 h51 +BackgroundTrans gSaveToIni, Save
+Return
+
+MachineSettingsWindow:
+
+if (GetKeyState("LShift", "P") AND GetKeyState("LAlt", "P")){
+ goto, MouseColor
+ }
+ else{
+ Gui, 2: Show, x6 y757 w639 h133, Settings: Machine/Setup
+ }
+
+return
+
+IngameSettingsWindow:
+ Gui, 3: Show, x6 y757 w639 h35, Settings: Ingame
+return
+
+RiskRewardWindow:
+ Gui, 4: Show, x6 y757 w639 h35, Settings: Risk/Reward
+return
+
+NotificationsWindow:
+ Gui, 5: Show, x6 y757 w639 h70, Settings: Notifications/API
+return
+
+SliderMove:
+Gui, Submit, nohide
+GuiControl,, txthairpindelay, %sliderhairpindelay%
+Return
+
+SaveToIni:
+ Gui, Submit, Hide
+ IniWrite, %txthairpindelay%, config.ini,Vars, hairpin_delay
+ IniWrite, %TelegramBotToken%, config.ini,API, TelegramBotToken
+ IniWrite, %TelegramChatID%, config.ini,API, TelegramChatID
+return
+
+TextChanged:
+ guiControlGet, txtvar,, txthairpindelay
+ if (txtvar > 800)
+ {
+ GuiControl,, txthairpindelay, 800
+ }
+
+ GuiControl,, sliderhairpindelay, %txtvar%
+ return
+
+Pit1Color:
+ MsgBox, 4,, Do you really wanna set a new Pitstop color?
+ IfMsgBox Yes
+ {
+ gosub, GrabRemotePlay
+ color_pitstop1 := PixelColorSimple(199, 315+remote_play_offsetY)
+ IniWrite, %color_pitstop1%, config.ini,Vars, color_pitstop1
+ }
+ return
+
+ButtonStart:
+ SetTimer, UpdateTimer, 1000
+ Gui, Submit, NoHide
+ id := ""
+ SetKeyDelay, 10
+ Process, priority, , High
+ gosub, GrabRemotePlay
+ if (id = "")
+ return
+ gosub, PauseLoop
+ CoordMode, Pixel, Screen
+ CoordMode, ToolTip, Screen
+ loop {
+ Press_X()
+ Race_Tokyo()
+ }
+
+PixelTuning:
+ x_ratio := ps_win_width/640
+ y_ratio := ps_win_height/360
+return
+
+GrabRemotePlay:
+ WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
+ if (remotePlay_id = 0)
+ {
+ MsgBox, PS4 Remote Play not found
+ return
+ }
+ Loop, %remotePlay_id%
+ {
+ id := remotePlay_id%A_Index%
+ WinGetTitle, title, % "ahk_id " id
+ If InStr(title, "PS Remote Play")
+ break
+ }
+ WinMove, ahk_id %id%,, 0, 0, 640, 540
+
+ ControlFocus,, ahk_class %remotePlay_class%
+ WinActivate, ahk_id %id%
+ GetClientSize(remotePlay_id5, ps_win_width, ps_win_height)
+ gosub, PixelTuning
+return
+
+PauseLoop:
+ controller.Buttons.Cross.SetState(false)
+ controller.Buttons.Square.SetState(false)
+ controller.Buttons.Triangle.SetState(false)
+ controller.Buttons.Circle.SetState(false)
+ controller.Buttons.L1.SetState(false)
+ controller.Buttons.L2.SetState(false)
+ controller.Axes.L2.SetState(0)
+ controller.Buttons.R1.SetState(false)
+ controller.Buttons.R2.SetState(false)
+ controller.Axes.R2.SetState(0)
+ controller.Buttons.RS.SetState(false)
+ controller.Axes.RX.SetState(50)
+ controller.Axes.RY.SetState(50)
+ controller.Buttons.LS.SetState(false)
+ controller.Axes.LX.SetState(50)
+ controller.Axes.LY.SetState(50)
+ controller.Dpad.SetState("None")
+return
+
+ResetRace:
+
+ FormatTime, TGTime,, MM/dd hh:mm:ss
+ FileAppend, %TGTime%: Race failed - Lap %TokyoLapCount% - %location%.`n, log.txt
+ url := "https://api.telegram.org/bot" TelegramBotToken "/sendMessage?text=" TGTime ": Race failed - Lap " TokyoLapCount " - " location ".&chat_id=" TelegramChatID
+ hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
+ hObject.Open("GET",url)
+ hObject.Send()
+
+ SB_SetText(" - RESET INITIATED -",2)
+ guicontrol,, CurrentLoop, Something went wrong, reseting.
+ controller.Axes.LX.SetState(50)
+ Press_Options()
+ Sleep(1000)
+ Press_Right()
+ Sleep(500)
+ Press_X()
+ controller.Axes.LX.SetState(65)
+ IniRead, ResetCounterTotal, config.ini, Stats, resetcountertotal, 0
+ SetFormat, integerfast, d
+ resetcounter++
+ resetcountertotal++
+ IniWrite, %resetcountertotal%, config.ini,Stats, ResetCounterTotal
+ guicontrol,, ResetCounterTotal, Races failed: %resetcountertotal%
+ guicontrol,, ResetCounterSession, Races failed: %resetcounter%
+ guicontrol,, RaceProgress, 0
+ Race_Tokyo()
+ return
+
+
+MouseHelp:
+
+ coord=relative
+ sleep, 1000
+ CoordMode, ToolTip, %coord%
+ CoordMode, Pixel, %coord%
+ CoordMode, Mouse, %coord%
+ CoordMode, Caret, %coord%
+ CoordMode, Menu, %coord%
+return
+
+Refresh:
+ MouseGetPos, x, y
+ PixelGetColor, cBGR, %x%, %y%,, Alt RGB
+ WinGetPos,,, w, h, A
+ ToolTip,Location: %x% x %y%`nRGB: %cBGR%`nWindow Size: %w% x %h%
+return
+
+MouseColor:
+ gosub, MouseHelp
+ SetTimer, Refresh, 75
+return
+
+GuiClose:
+ gosub, PauseLoop
+ExitApp
+^Esc::ExitApp
+
+GUIReset:
+if (GetKeyState("LShift", "P") AND GetKeyState("LAlt", "P")){
+ MsgBox, 4,, Reset all data?
+ IfMsgBox Yes
+ {
+ IniWrite, 0, config.ini,Stats, RaceCounterTotal
+ IniWrite, 0, config.ini,Stats, ResetCounterTotal
+ }
+}
+Sleep(500)
+gosub, PauseLoop
+Reload
+
+
+
+
+
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/AHK-ViGEm-Bus.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/AHK-ViGEm-Bus.ahk
new file mode 100644
index 0000000..858cb3d
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/AHK-ViGEm-Bus.ahk
@@ -0,0 +1,211 @@
+#include %A_LineFile%\..\CLR.ahk
+
+; Static class, holds ViGEm Client instance
+class ViGEmWrapper {
+ static asm := 0
+ static client := 0
+
+ Init(){
+ if (this.client == 0){
+ this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
+ }
+ }
+
+ CreateInstance(cls){
+ return this.asm.CreateInstance(cls)
+ }
+
+}
+
+; Base class for ViGEm "Targets" (Controller types - eg xb360 / ds4) to inherit from
+class ViGEmTarget {
+ target := 0
+ helperClass := ""
+ controllerClass := ""
+
+ __New(){
+ ;~ this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
+ ViGEmWrapper.Init()
+ this.Instance := ViGEmWrapper.CreateInstance(this.helperClass)
+
+ if (this.Instance.OkCheck() != "OK"){
+ msgbox ViGEmWrapper.dll failed to load!
+ ExitApp
+ }
+ }
+
+ SendReport(){
+ this.Instance.SendReport()
+ }
+
+ SubscribeFeedback(callback){
+ this.Instance.SubscribeFeedback(callback)
+ }
+}
+
+; DS4 (DualShock 4 for Playstation 4)
+class ViGEmDS4 extends ViGEmTarget {
+ helperClass := "ViGEmWrapper.Ds4"
+ __New(){
+ static buttons := {Square: 16, Cross: 32, Circle: 64, Triangle: 128, L1: 256, R1: 512, L2: 1024, R2: 2048
+ , Share: 4096, Options: 8192, LS: 16384, RS: 32768 }
+ static specialButtons := {Ps: 1, TouchPad: 2}
+ static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
+
+ this.Buttons := {}
+ for name, id in buttons {
+ this.Buttons[name] := new this._ButtonHelper(this, id)
+ }
+ for name, id in specialButtons {
+ this.Buttons[name] := new this._SpecialButtonHelper(this, id)
+ }
+
+ this.Axes := {}
+ for name, id in axes {
+ this.Axes[name] := new this._AxisHelper(this, id)
+ }
+
+ this.Dpad := new this._DpadHelper(this)
+ base.__New()
+ }
+
+ class _ButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _SpecialButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetSpecialButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _AxisHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+
+ ConvertAxis(state){
+ return round(state * 2.55)
+ }
+ }
+
+ class _DpadHelper {
+ __New(parent){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ static dPadDirections := {Up: 0, UpRight: 1, Right: 2, DownRight: 3, Down: 4, DownLeft: 5, Left: 6, UpLeft: 7, None: 8}
+ this._Parent.Instance.SetDpadState(dPadDirections[state])
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+}
+
+; Xb360
+class ViGEmXb360 extends ViGEmTarget {
+ helperClass := "ViGEmWrapper.Xb360"
+ __New(){
+ static buttons := {A: 4096, B: 8192, X: 16384, Y: 32768, LB: 256, RB: 512, LS: 64, RS: 128, Back: 32, Start: 16, Xbox: 1024}
+ static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
+
+ this.Buttons := {}
+ for name, id in buttons {
+ this.Buttons[name] := new this._ButtonHelper(this, id)
+ }
+
+ this.Axes := {}
+ for name, id in axes {
+ this.Axes[name] := new this._AxisHelper(this, id)
+ }
+
+ this.Dpad := new this._DpadHelper(this)
+
+ base.__New()
+ }
+
+ class _ButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _AxisHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
+ this._Parent.Instance.SendReport()
+ }
+
+ ConvertAxis(state){
+ value := round((state * 655.36) - 32768)
+ if (value == 32768)
+ return 32767
+ return value
+ }
+ }
+
+ class _DpadHelper {
+ _DpadStates := {1:0, 8:0, 2:0, 4:0} ; Up, Right, Down, Left
+ __New(parent){
+ this._Parent := parent
+ }
+
+ SetState(state){
+ static dpadDirections := { None: {1:0, 8:0, 2:0, 4:0}
+ , Up: {1:1, 8:0, 2:0, 4:0}
+ , UpRight: {1:1, 8:1, 2:0, 4:0}
+ , Right: {1:0, 8:1, 2:0, 4:0}
+ , DownRight: {1:0, 8:1, 2:1, 4:0}
+ , Down: {1:0, 8:0, 2:1, 4:0}
+ , DownLeft: {1:0, 8:0, 2:1, 4:1}
+ , Left: {1:0, 8:0, 2:0, 4:1}
+ , UpLeft: {1:1, 8:0, 2:0, 4:1}}
+ newStates := dpadDirections[state]
+ for id, newState in newStates {
+ oldState := this._DpadStates[id]
+ if (oldState != newState){
+ this._DpadStates[id] := newState
+ this._Parent.Instance.SetButtonState(id, newState)
+ }
+ this._Parent.SendReport()
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/CLR.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/CLR.ahk
new file mode 100644
index 0000000..d16ab68
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/CLR.ahk
@@ -0,0 +1,151 @@
+; ==========================================================
+; .NET Framework Interop
+; https://autohotkey.com/boards/viewtopic.php?t=4633
+; ==========================================================
+;
+; Author: Lexikos
+; Version: 1.2
+; Requires: AutoHotkey_L v1.0.96+
+;
+
+CLR_LoadLibrary(AssemblyName, AppDomain=0)
+{
+ if !AppDomain
+ AppDomain := CLR_GetDefaultDomain()
+ e := ComObjError(0)
+ Loop 1 {
+ if assembly := AppDomain.Load_2(AssemblyName)
+ break
+ static null := ComObject(13,0)
+ args := ComObjArray(0xC, 1), args[0] := AssemblyName
+ typeofAssembly := AppDomain.GetType().Assembly.GetType()
+ if assembly := typeofAssembly.InvokeMember_3("LoadWithPartialName", 0x158, null, null, args)
+ break
+ if assembly := typeofAssembly.InvokeMember_3("LoadFrom", 0x158, null, null, args)
+ break
+ }
+ ComObjError(e)
+ return assembly
+}
+
+CLR_CreateObject(Assembly, TypeName, Args*)
+{
+ if !(argCount := Args.MaxIndex())
+ return Assembly.CreateInstance_2(TypeName, true)
+
+ vargs := ComObjArray(0xC, argCount)
+ Loop % argCount
+ vargs[A_Index-1] := Args[A_Index]
+
+ static Array_Empty := ComObjArray(0xC,0), null := ComObject(13,0)
+
+ return Assembly.CreateInstance_3(TypeName, true, 0, null, vargs, null, Array_Empty)
+}
+
+CLR_CompileC#(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
+{
+ return CLR_CompileAssembly(Code, References, "System", "Microsoft.CSharp.CSharpCodeProvider", AppDomain, FileName, CompilerOptions)
+}
+
+CLR_CompileVB(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
+{
+ return CLR_CompileAssembly(Code, References, "System", "Microsoft.VisualBasic.VBCodeProvider", AppDomain, FileName, CompilerOptions)
+}
+
+CLR_StartDomain(ByRef AppDomain, BaseDirectory="")
+{
+ static null := ComObject(13,0)
+ args := ComObjArray(0xC, 5), args[0] := "", args[2] := BaseDirectory, args[4] := ComObject(0xB,false)
+ AppDomain := CLR_GetDefaultDomain().GetType().InvokeMember_3("CreateDomain", 0x158, null, null, args)
+ return A_LastError >= 0
+}
+
+CLR_StopDomain(ByRef AppDomain)
+{ ; ICorRuntimeHost::UnloadDomain
+ DllCall("SetLastError", "uint", hr := DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+20*A_PtrSize), "ptr", RtHst, "ptr", ComObjValue(AppDomain))), AppDomain := ""
+ return hr >= 0
+}
+
+; NOTE: IT IS NOT NECESSARY TO CALL THIS FUNCTION unless you need to load a specific version.
+CLR_Start(Version="") ; returns ICorRuntimeHost*
+{
+ static RtHst := 0
+ ; The simple method gives no control over versioning, and seems to load .NET v2 even when v4 is present:
+ ; return RtHst ? RtHst : (RtHst:=COM_CreateObject("CLRMetaData.CorRuntimeHost","{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}"), DllCall(NumGet(NumGet(RtHst+0)+40),"uint",RtHst))
+ if RtHst
+ return RtHst
+ EnvGet SystemRoot, SystemRoot
+ if Version =
+ Loop % SystemRoot "\Microsoft.NET\Framework" (A_PtrSize=8?"64":"") "\*", 2
+ if (FileExist(A_LoopFileFullPath "\mscorlib.dll") && A_LoopFileName > Version)
+ Version := A_LoopFileName
+ if DllCall("mscoree\CorBindToRuntimeEx", "wstr", Version, "ptr", 0, "uint", 0
+ , "ptr", CLR_GUID(CLSID_CorRuntimeHost, "{CB2F6723-AB3A-11D2-9C40-00C04FA30A3E}")
+ , "ptr", CLR_GUID(IID_ICorRuntimeHost, "{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}")
+ , "ptr*", RtHst) >= 0
+ DllCall(NumGet(NumGet(RtHst+0)+10*A_PtrSize), "ptr", RtHst) ; Start
+ return RtHst
+}
+
+;
+; INTERNAL FUNCTIONS
+;
+
+CLR_GetDefaultDomain()
+{
+ static defaultDomain := 0
+ if !defaultDomain
+ { ; ICorRuntimeHost::GetDefaultDomain
+ if DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+13*A_PtrSize), "ptr", RtHst, "ptr*", p:=0) >= 0
+ defaultDomain := ComObject(p), ObjRelease(p)
+ }
+ return defaultDomain
+}
+
+CLR_CompileAssembly(Code, References, ProviderAssembly, ProviderType, AppDomain=0, FileName="", CompilerOptions="")
+{
+ if !AppDomain
+ AppDomain := CLR_GetDefaultDomain()
+
+ if !(asmProvider := CLR_LoadLibrary(ProviderAssembly, AppDomain))
+ || !(codeProvider := asmProvider.CreateInstance(ProviderType))
+ || !(codeCompiler := codeProvider.CreateCompiler())
+ return 0
+
+ if !(asmSystem := (ProviderAssembly="System") ? asmProvider : CLR_LoadLibrary("System", AppDomain))
+ return 0
+
+ ; Convert | delimited list of references into an array.
+ StringSplit, Refs, References, |, %A_Space%%A_Tab%
+ aRefs := ComObjArray(8, Refs0)
+ Loop % Refs0
+ aRefs[A_Index-1] := Refs%A_Index%
+
+ ; Set parameters for compiler.
+ prms := CLR_CreateObject(asmSystem, "System.CodeDom.Compiler.CompilerParameters", aRefs)
+ , prms.OutputAssembly := FileName
+ , prms.GenerateInMemory := FileName=""
+ , prms.GenerateExecutable := SubStr(FileName,-3)=".exe"
+ , prms.CompilerOptions := CompilerOptions
+ , prms.IncludeDebugInformation := true
+
+ ; Compile!
+ compilerRes := codeCompiler.CompileAssemblyFromSource(prms, Code)
+
+ if error_count := (errors := compilerRes.Errors).Count
+ {
+ error_text := ""
+ Loop % error_count
+ error_text .= ((e := errors.Item[A_Index-1]).IsWarning ? "Warning " : "Error ") . e.ErrorNumber " on line " e.Line ": " e.ErrorText "`n`n"
+ MsgBox, 16, Compilation Failed, %error_text%
+ return 0
+ }
+ ; Success. Return Assembly object or path.
+ return compilerRes[FileName="" ? "CompiledAssembly" : "PathToAssembly"]
+}
+
+CLR_GUID(ByRef GUID, sGUID)
+{
+ VarSetCapacity(GUID, 16, 0)
+ return DllCall("ole32\CLSIDFromString", "wstr", sGUID, "ptr", &GUID) >= 0 ? &GUID : ""
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/Gdip.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/Gdip.ahk
new file mode 100644
index 0000000..3efb7ae
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/Gdip.ahk
@@ -0,0 +1,2714 @@
+; Gdip standard library v1.45 by tic (Tariq Porter) 07/09/11
+; Modifed by Rseding91 using fincs 64 bit compatible Gdip library 5/1/2013
+; Supports: Basic, _L ANSi, _L Unicode x86 and _L Unicode x64
+;
+; Updated 2/20/2014 - fixed Gdip_CreateRegion() and Gdip_GetClipRegion() on AHK Unicode x86
+; Updated 5/13/2013 - fixed Gdip_SetBitmapToClipboard() on AHK Unicode x64
+;
+;#####################################################################################
+;#####################################################################################
+; STATUS ENUMERATION
+; Return values for functions specified to have status enumerated return type
+;#####################################################################################
+;
+; Ok = = 0
+; GenericError = 1
+; InvalidParameter = 2
+; OutOfMemory = 3
+; ObjectBusy = 4
+; InsufficientBuffer = 5
+; NotImplemented = 6
+; Win32Error = 7
+; WrongState = 8
+; Aborted = 9
+; FileNotFound = 10
+; ValueOverflow = 11
+; AccessDenied = 12
+; UnknownImageFormat = 13
+; FontFamilyNotFound = 14
+; FontStyleNotFound = 15
+; NotTrueTypeFont = 16
+; UnsupportedGdiplusVersion = 17
+; GdiplusNotInitialized = 18
+; PropertyNotFound = 19
+; PropertyNotSupported = 20
+; ProfileNotFound = 21
+;
+;#####################################################################################
+;#####################################################################################
+; FUNCTIONS
+;#####################################################################################
+;
+; UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255)
+; BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+; StretchBlt(dDC, dx, dy, dw, dh, sDC, sx, sy, sw, sh, Raster="")
+; SetImage(hwnd, hBitmap)
+; Gdip_BitmapFromScreen(Screen=0, Raster="")
+; CreateRectF(ByRef RectF, x, y, w, h)
+; CreateSizeF(ByRef SizeF, w, h)
+; CreateDIBSection
+;
+;#####################################################################################
+
+; Function: UpdateLayeredWindow
+; Description: Updates a layered window with the handle to the DC of a gdi bitmap
+;
+; hwnd Handle of the layered window to update
+; hdc Handle to the DC of the GDI bitmap to update the window with
+; Layeredx x position to place the window
+; Layeredy y position to place the window
+; Layeredw Width of the window
+; Layeredh Height of the window
+; Alpha Default = 255 : The transparency (0-255) to set the window transparency
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If x or y omitted, then layered window will use its current coordinates
+; If w or h omitted then current width and height will be used
+
+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)
+}
+
+;#####################################################################################
+
+; Function BitBlt
+; Description The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle
+; of pixels from the specified source device context into a destination device context.
+;
+; dDC handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of the area to copy
+; dh height of the area to copy
+; sDC handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used, which copies the source directly to the destination rectangle
+;
+; BLACKNESS = 0x00000042
+; NOTSRCERASE = 0x001100A6
+; NOTSRCCOPY = 0x00330008
+; SRCERASE = 0x00440328
+; DSTINVERT = 0x00550009
+; PATINVERT = 0x005A0049
+; SRCINVERT = 0x00660046
+; SRCAND = 0x008800C6
+; MERGEPAINT = 0x00BB0226
+; MERGECOPY = 0x00C000CA
+; SRCCOPY = 0x00CC0020
+; SRCPAINT = 0x00EE0086
+; PATCOPY = 0x00F00021
+; PATPAINT = 0x00FB0A09
+; WHITENESS = 0x00FF0062
+; CAPTUREBLT = 0x40000000
+; NOMIRRORBITMAP = 0x80000000
+
+BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\BitBlt"
+ , Ptr, dDC
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sDC
+ , "int", sx
+ , "int", sy
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function StretchBlt
+; Description The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle,
+; stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary.
+; The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.
+;
+; ddc handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination rectangle
+; dh height of destination rectangle
+; sdc handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used. It uses the same raster operations as BitBlt
+
+StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\StretchBlt"
+ , Ptr, ddc
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sdc
+ , "int", sx
+ , "int", sy
+ , "int", sw
+ , "int", sh
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function SetStretchBltMode
+; Description The SetStretchBltMode function sets the bitmap stretching mode in the specified device context
+;
+; hdc handle to the DC
+; iStretchMode The stretching mode, describing how the target will be stretched
+;
+; return If the function succeeds, the return value is the previous stretching mode. If it fails it will return 0
+;
+; STRETCH_ANDSCANS = 0x01
+; STRETCH_ORSCANS = 0x02
+; STRETCH_DELETESCANS = 0x03
+; STRETCH_HALFTONE = 0x04
+
+SetStretchBltMode(hdc, iStretchMode=4)
+{
+ return DllCall("gdi32\SetStretchBltMode"
+ , A_PtrSize ? "UPtr" : "UInt", hdc
+ , "int", iStretchMode)
+}
+
+;#####################################################################################
+
+; Function SetImage
+; Description Associates a new image with a static control
+;
+; hwnd handle of the control to update
+; hBitmap a gdi bitmap to associate the static control with
+;
+; return If the function succeeds, the return value is nonzero
+
+SetImage(hwnd, hBitmap)
+{
+ SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
+ E := ErrorLevel
+ DeleteObject(E)
+ return E
+}
+
+;#####################################################################################
+
+; Function SetSysColorToControl
+; Description Sets a solid colour to a control
+;
+; hwnd handle of the control to update
+; SysColor A system colour to set to the control
+;
+; return If the function succeeds, the return value is zero
+;
+; notes A control must have the 0xE style set to it so it is recognised as a bitmap
+; By default SysColor=15 is used which is COLOR_3DFACE. This is the standard background for a control
+;
+; COLOR_3DDKSHADOW = 21
+; COLOR_3DFACE = 15
+; COLOR_3DHIGHLIGHT = 20
+; COLOR_3DHILIGHT = 20
+; COLOR_3DLIGHT = 22
+; COLOR_3DSHADOW = 16
+; COLOR_ACTIVEBORDER = 10
+; COLOR_ACTIVECAPTION = 2
+; COLOR_APPWORKSPACE = 12
+; COLOR_BACKGROUND = 1
+; COLOR_BTNFACE = 15
+; COLOR_BTNHIGHLIGHT = 20
+; COLOR_BTNHILIGHT = 20
+; COLOR_BTNSHADOW = 16
+; COLOR_BTNTEXT = 18
+; COLOR_CAPTIONTEXT = 9
+; COLOR_DESKTOP = 1
+; COLOR_GRADIENTACTIVECAPTION = 27
+; COLOR_GRADIENTINACTIVECAPTION = 28
+; COLOR_GRAYTEXT = 17
+; COLOR_HIGHLIGHT = 13
+; COLOR_HIGHLIGHTTEXT = 14
+; COLOR_HOTLIGHT = 26
+; COLOR_INACTIVEBORDER = 11
+; COLOR_INACTIVECAPTION = 3
+; COLOR_INACTIVECAPTIONTEXT = 19
+; COLOR_INFOBK = 24
+; COLOR_INFOTEXT = 23
+; COLOR_MENU = 4
+; COLOR_MENUHILIGHT = 29
+; COLOR_MENUBAR = 30
+; COLOR_MENUTEXT = 7
+; COLOR_SCROLLBAR = 0
+; COLOR_WINDOW = 5
+; COLOR_WINDOWFRAME = 6
+; COLOR_WINDOWTEXT = 8
+
+SetSysColorToControl(hwnd, SysColor=15)
+{
+ WinGetPos,,, w, h, ahk_id %hwnd%
+ bc := DllCall("GetSysColor", "Int", SysColor, "UInt")
+ pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc >> 16 | bc & 0xff00 | (bc & 0xff) << 16))
+ pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap)
+ Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h)
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ SetImage(hwnd, hBitmap)
+ Gdip_DeleteBrush(pBrushClear)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap)
+ return 0
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromScreen
+; Description Gets a gdi+ bitmap from the screen
+;
+; Screen 0 = All screens
+; Any numerical value = Just that screen
+; x|y|w|h = Take specific coordinates with a width and height
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1: one or more of x,y,w,h not passed properly
+;
+; notes If no raster operation is specified, then SRCCOPY is used to the returned bitmap
+
+Gdip_BitmapFromScreen(Screen=0, Raster="")
+{
+ if (Screen = 0)
+ {
+ Sysget, x, 76
+ Sysget, y, 77
+ Sysget, w, 78
+ Sysget, h, 79
+ }
+ else if (SubStr(Screen, 1, 5) = "hwnd:")
+ {
+ Screen := SubStr(Screen, 6)
+ if !WinExist( "ahk_id " Screen)
+ return -2
+ WinGetPos,,, w, h, ahk_id %Screen%
+ x := y := 0
+ hhdc := GetDCEx(Screen, 3)
+ }
+ else if (Screen&1 != "")
+ {
+ Sysget, M, Monitor, %Screen%
+ x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
+ }
+ else
+ {
+ StringSplit, S, Screen, |
+ x := S1, y := S2, w := S3, h := S4
+ }
+
+ if (x = "") || (y = "") || (w = "") || (h = "")
+ return -1
+
+ chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
+ BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
+ ReleaseDC(hhdc)
+
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromHWND
+; Description Uses PrintWindow to get a handle to the specified window and return a bitmap from it
+;
+; hwnd handle to the window to get a bitmap from
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+;
+; notes Window must not be not minimised in order to get a handle to it's client area
+
+Gdip_BitmapFromHWND(hwnd)
+{
+ WinGetPos,,, Width, Height, ahk_id %hwnd%
+ hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ RegExMatch(A_OsVersion, "\d+", Version)
+ PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function CreateRectF
+; Description Creates a RectF object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+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")
+}
+
+;#####################################################################################
+
+; Function CreateRect
+; Description Creates a Rect object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+CreateRect(ByRef Rect, x, y, w, h)
+{
+ VarSetCapacity(Rect, 16)
+ NumPut(x, Rect, 0, "uint"), NumPut(y, Rect, 4, "uint"), NumPut(w, Rect, 8, "uint"), NumPut(h, Rect, 12, "uint")
+}
+;#####################################################################################
+
+; Function CreateSizeF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreateSizeF(ByRef SizeF, w, h)
+{
+ VarSetCapacity(SizeF, 8)
+ NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreatePointF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreatePointF(ByRef PointF, x, y)
+{
+ VarSetCapacity(PointF, 8)
+ NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreateDIBSection
+; Description The CreateDIBSection function creates a DIB (Device Independent Bitmap) that applications can write to directly
+;
+; w width of the bitmap to create
+; h height of the bitmap to create
+; hdc a handle to the device context to use the palette from
+; bpp bits per pixel (32 = ARGB)
+; ppvBits A pointer to a variable that receives a pointer to the location of the DIB bit values
+;
+; return returns a DIB. A gdi bitmap
+;
+; notes ppvBits will receive the location of the pixels in the DIB
+
+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
+}
+
+;#####################################################################################
+
+; Function PrintWindow
+; Description The PrintWindow function copies a visual window into the specified device context (DC), typically a printer DC
+;
+; hwnd A handle to the window that will be copied
+; hdc A handle to the device context
+; Flags Drawing options
+;
+; return If the function succeeds, it returns a nonzero value
+;
+; PW_CLIENTONLY = 1
+
+PrintWindow(hwnd, hdc, Flags=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("PrintWindow", Ptr, hwnd, Ptr, hdc, "uint", Flags)
+}
+
+;#####################################################################################
+
+; Function DestroyIcon
+; Description Destroys an icon and frees any memory the icon occupied
+;
+; hIcon Handle to the icon to be destroyed. The icon must not be in use
+;
+; return If the function succeeds, the return value is nonzero
+
+DestroyIcon(hIcon)
+{
+ return DllCall("DestroyIcon", A_PtrSize ? "UPtr" : "UInt", hIcon)
+}
+
+;#####################################################################################
+
+PaintDesktop(hdc)
+{
+ return DllCall("PaintDesktop", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+CreateCompatibleBitmap(hdc, w, h)
+{
+ return DllCall("gdi32\CreateCompatibleBitmap", A_PtrSize ? "UPtr" : "UInt", hdc, "int", w, "int", h)
+}
+
+;#####################################################################################
+
+; Function CreateCompatibleDC
+; Description This function creates a memory device context (DC) compatible with the specified device
+;
+; hdc Handle to an existing device context
+;
+; return returns the handle to a device context or 0 on failure
+;
+; notes If this handle is 0 (by default), the function creates a memory device context compatible with the application's current screen
+
+CreateCompatibleDC(hdc=0)
+{
+ return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+; Function SelectObject
+; Description The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type
+;
+; hdc Handle to a DC
+; hgdiobj A handle to the object to be selected into the DC
+;
+; return If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced
+;
+; notes The specified object must have been created by using one of the following functions
+; Bitmap - CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection (A single bitmap cannot be selected into more than one DC at the same time)
+; Brush - CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush
+; Font - CreateFont, CreateFontIndirect
+; Pen - CreatePen, CreatePenIndirect
+; Region - CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirect
+;
+; notes If the selected object is a region and the function succeeds, the return value is one of the following value
+;
+; SIMPLEREGION = 2 Region consists of a single rectangle
+; COMPLEXREGION = 3 Region consists of more than one rectangle
+; NULLREGION = 1 Region is empty
+
+SelectObject(hdc, hgdiobj)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
+}
+
+;#####################################################################################
+
+; Function DeleteObject
+; Description This function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object
+; After the object is deleted, the specified handle is no longer valid
+;
+; hObject Handle to a logical pen, brush, font, bitmap, region, or palette to delete
+;
+; return Nonzero indicates success. Zero indicates that the specified handle is not valid or that the handle is currently selected into a device context
+
+DeleteObject(hObject)
+{
+ return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject)
+}
+
+;#####################################################################################
+
+; Function GetDC
+; Description This function retrieves a handle to a display device context (DC) for the client area of the specified window.
+; The display device context can be used in subsequent graphics display interface (GDI) functions to draw in the client area of the window.
+;
+; hwnd Handle to the window whose device context is to be retrieved. If this value is NULL, GetDC retrieves the device context for the entire screen
+;
+; return The handle the device context for the specified window's client area indicates success. NULL indicates failure
+
+GetDC(hwnd=0)
+{
+ return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
+}
+
+;#####################################################################################
+
+; DCX_CACHE = 0x2
+; DCX_CLIPCHILDREN = 0x8
+; DCX_CLIPSIBLINGS = 0x10
+; DCX_EXCLUDERGN = 0x40
+; DCX_EXCLUDEUPDATE = 0x100
+; DCX_INTERSECTRGN = 0x80
+; DCX_INTERSECTUPDATE = 0x200
+; DCX_LOCKWINDOWUPDATE = 0x400
+; DCX_NORECOMPUTE = 0x100000
+; DCX_NORESETATTRS = 0x4
+; DCX_PARENTCLIP = 0x20
+; DCX_VALIDATE = 0x200000
+; DCX_WINDOW = 0x1
+
+GetDCEx(hwnd, flags=0, hrgnClip=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("GetDCEx", Ptr, hwnd, Ptr, hrgnClip, "int", flags)
+}
+
+;#####################################################################################
+
+; Function ReleaseDC
+; Description This function releases a device context (DC), freeing it for use by other applications. The effect of ReleaseDC depends on the type of device context
+;
+; hdc Handle to the device context to be released
+; hwnd Handle to the window whose device context is to be released
+;
+; return 1 = released
+; 0 = not released
+;
+; notes The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common device context
+; An application cannot use the ReleaseDC function to release a device context that was created by calling the CreateDC function; instead, it must use the DeleteDC function.
+
+ReleaseDC(hdc, hwnd=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function DeleteDC
+; Description The DeleteDC function deletes the specified device context (DC)
+;
+; hdc A handle to the device context
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC
+
+DeleteDC(hdc)
+{
+ return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+;#####################################################################################
+
+; Function Gdip_LibraryVersion
+; Description Get the current library version
+;
+; return the library version
+;
+; notes This is useful for non compiled programs to ensure that a person doesn't run an old version when testing your scripts
+
+Gdip_LibraryVersion()
+{
+ return 1.45
+}
+
+;#####################################################################################
+
+; Function Gdip_LibrarySubVersion
+; Description Get the current library sub version
+;
+; return the library sub version
+;
+; notes This is the sub-version currently maintained by Rseding91
+Gdip_LibrarySubVersion()
+{
+ return 1.47
+}
+
+;#####################################################################################
+
+; Function: Gdip_BitmapFromBRA
+; Description: Gets a pointer to a gdi+ bitmap from a BRA file
+;
+; BRAFromMemIn The variable for a BRA file read to memory
+; File The name of the file, or its number that you would like (This depends on alternate parameter)
+; Alternate Changes whether the File parameter is the file name or its number
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1 = The BRA variable is empty
+; -2 = The BRA has an incorrect header
+; -3 = The BRA has information missing
+; -4 = Could not find file inside the BRA
+
+Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate=0)
+{
+ Static FName = "ObjRelease"
+
+ if !BRAFromMemIn
+ return -1
+ Loop, Parse, BRAFromMemIn, `n
+ {
+ if (A_Index = 1)
+ {
+ StringSplit, Header, A_LoopField, |
+ if (Header0 != 4 || Header2 != "BRA!")
+ return -2
+ }
+ else if (A_Index = 2)
+ {
+ StringSplit, Info, A_LoopField, |
+ if (Info0 != 3)
+ return -3
+ }
+ else
+ break
+ }
+ if !Alternate
+ StringReplace, File, File, \, \\, All
+ RegExMatch(BRAFromMemIn, "mi`n)^" (Alternate ? File "\|.+?\|(\d+)\|(\d+)" : "\d+\|" File "\|(\d+)\|(\d+)") "$", FileInfo)
+ if !FileInfo
+ return -4
+
+ hData := DllCall("GlobalAlloc", "uint", 2, Ptr, FileInfo2, Ptr)
+ pData := DllCall("GlobalLock", Ptr, hData, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pData, Ptr, &BRAFromMemIn+Info2+FileInfo1, Ptr, FileInfo2)
+ DllCall("GlobalUnlock", Ptr, hData)
+ DllCall("ole32\CreateStreamOnHGlobal", Ptr, hData, "int", 1, A_PtrSize ? "UPtr*" : "UInt*", pStream)
+ DllCall("gdiplus\GdipCreateBitmapFromStream", Ptr, pStream, A_PtrSize ? "UPtr*" : "UInt*", pBitmap)
+ If (A_PtrSize)
+ %FName%(pStream)
+ Else
+ DllCall(NumGet(NumGet(1*pStream)+8), "uint", pStream)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRectangle
+; Description This function uses a pen to draw the outline of a rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRoundedRectangle
+; Description This function uses a pen to draw the outline of a rounded rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawEllipse
+; Description This function uses a pen to draw the outline of an ellipse into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle the ellipse will be drawn into
+; y y-coordinate of the top left of the rectangle the ellipse will be drawn into
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawBezier
+; Description This function uses a pen to draw the outline of a bezier (a weighted curve) into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the bezier
+; y1 y-coordinate of the start of the bezier
+; x2 x-coordinate of the first arc of the bezier
+; y2 y-coordinate of the first arc of the bezier
+; x3 x-coordinate of the second arc of the bezier
+; y3 y-coordinate of the second arc of the bezier
+; x4 x-coordinate of the end of the bezier
+; y4 y-coordinate of the end of the bezier
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawBezier"
+ , Ptr, pgraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2
+ , "float", x3
+ , "float", y3
+ , "float", x4
+ , "float", y4)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawArc
+; Description This function uses a pen to draw the outline of an arc into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the arc
+; y y-coordinate of the start of the arc
+; w width of the arc
+; h height of the arc
+; StartAngle specifies the angle between the x-axis and the starting point of the arc
+; SweepAngle specifies the angle between the starting and ending points of the arc
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawArc"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawPie
+; Description This function uses a pen to draw the outline of a pie into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the pie
+; y y-coordinate of the start of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawPie", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLine
+; Description This function uses a pen to draw a line into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the line
+; y1 y-coordinate of the start of the line
+; x2 x-coordinate of the end of the line
+; y2 y-coordinate of the end of the line
+;
+; return status enumeration. 0 = success
+
+Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawLine"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLines
+; Description This function uses a pen to draw a series of joined lines into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRectangle
+; Description This function uses a brush to fill a rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRoundedRectangle
+; Description This function uses a brush to fill a rounded rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPolygon
+; Description This function uses a brush to fill a polygon in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+;
+; notes Alternate will fill the polygon as a whole, wheras winding will fill each new "segment"
+; Alternate = 0
+; Winding = 1
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPie
+; Description This function uses a brush to fill a pie in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the pie
+; y y-coordinate of the top left of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPie"
+ , Ptr, pGraphics
+ , Ptr, pBrush
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillEllipse
+; Description This function uses a brush to fill an ellipse in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the ellipse
+; y y-coordinate of the top left of the ellipse
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRegion
+; Description This function uses a brush to fill a region in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Region
+;
+; return status enumeration. 0 = success
+;
+; notes You can create a region Gdip_CreateRegion() and then add to this
+
+Gdip_FillRegion(pGraphics, pBrush, Region)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillRegion", Ptr, pGraphics, Ptr, pBrush, Ptr, Region)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPath
+; Description This function uses a brush to fill a path in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Path
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPath(pGraphics, pBrush, Path)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPath", Ptr, pGraphics, Ptr, pBrush, Ptr, Path)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImagePointsRect
+; Description This function draws a bitmap into the Graphics of another bitmap and skews it
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; Points Points passed as x1,y1|x2,y2|x3,y3 (3 points: top left, top right, bottom left) describing the drawing of the bitmap
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter
+
+Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1)
+{
+ 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")
+ }
+
+ 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 = "")
+ {
+ sx := 0, sy := 0
+ sw := Gdip_GetImageWidth(pBitmap)
+ sh := Gdip_GetImageHeight(pBitmap)
+ }
+
+ E := DllCall("gdiplus\GdipDrawImagePointsRect"
+ , Ptr, pGraphics
+ , Ptr, pBitmap
+ , Ptr, &PointF
+ , "int", Points0
+ , "float", sx
+ , "float", sy
+ , "float", sw
+ , "float", sh
+ , "int", 2
+ , Ptr, ImageAttr
+ , Ptr, 0
+ , Ptr, 0)
+ if ImageAttr
+ Gdip_DisposeImageAttributes(ImageAttr)
+ return E
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImage
+; Description This function draws a bitmap into the Graphics of another bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination image
+; dh height of destination image
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source image
+; sh height of source image
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Gdip_DrawImage performs faster
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter. For example:
+; MatrixBright=
+; (
+; 1.5 |0 |0 |0 |0
+; 0 |1.5 |0 |0 |0
+; 0 |0 |1.5 |0 |0
+; 0 |0 |0 |1 |0
+; 0.05 |0.05 |0.05 |0 |1
+; )
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_SetImageAttributesColorMatrix
+; Description This function creates an image matrix ready for drawing
+;
+; Matrix a matrix used to alter image attributes when drawing
+; passed with any delimeter
+;
+; return returns an image matrix on sucess or 0 if it fails
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromImage
+; Description This function gets the graphics for a bitmap used for drawing functions
+;
+; pBitmap Pointer to a bitmap to get the pointer to its graphics
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes a bitmap can be drawn into the graphics of another bitmap
+
+Gdip_GraphicsFromImage(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromHDC
+; Description This function gets the graphics from the handle to a device context
+;
+; hdc This is the handle to the device context
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes You can draw a bitmap into the graphics of another bitmap
+
+Gdip_GraphicsFromHDC(hdc)
+{
+ DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDC
+; Description This function gets the device context of the passed Graphics
+;
+; hdc This is the handle to the device context
+;
+; return returns the device context for the graphics of a bitmap
+
+Gdip_GetDC(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDC", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", hdc)
+ return hdc
+}
+
+;#####################################################################################
+
+; Function Gdip_ReleaseDC
+; Description This function releases a device context from use for further use
+;
+; pGraphics Pointer to the graphics of a bitmap
+; hdc This is the handle to the device context
+;
+; return status enumeration. 0 = success
+
+Gdip_ReleaseDC(pGraphics, hdc)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipReleaseDC", Ptr, pGraphics, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsClear
+; Description Clears the graphics of a bitmap ready for further drawing
+;
+; pGraphics Pointer to the graphics of a bitmap
+; ARGB The colour to clear the graphics to
+;
+; return status enumeration. 0 = success
+;
+; notes By default this will make the background invisible
+; Using clipping regions you can clear a particular area on the graphics rather than clearing the entire graphics
+
+Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff)
+{
+ return DllCall("gdiplus\GdipGraphicsClear", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_BlurBitmap
+; Description Gives a pointer to a blurred bitmap from a pointer to a bitmap
+;
+; pBitmap Pointer to a bitmap to be blurred
+; Blur The Amount to blur a bitmap by from 1 (least blur) to 100 (most blur)
+;
+; return If the function succeeds, the return value is a pointer to the new blurred bitmap
+; -1 = The blur parameter is outside the range 1-100
+;
+; notes This function will not dispose of the original bitmap
+
+Gdip_BlurBitmap(pBitmap, Blur)
+{
+ if (Blur > 100) || (Blur < 1)
+ return -1
+
+ sWidth := Gdip_GetImageWidth(pBitmap), sHeight := Gdip_GetImageHeight(pBitmap)
+ dWidth := sWidth//Blur, dHeight := sHeight//Blur
+
+ pBitmap1 := Gdip_CreateBitmap(dWidth, dHeight)
+ G1 := Gdip_GraphicsFromImage(pBitmap1)
+ Gdip_SetInterpolationMode(G1, 7)
+ Gdip_DrawImage(G1, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight)
+
+ Gdip_DeleteGraphics(G1)
+
+ pBitmap2 := Gdip_CreateBitmap(sWidth, sHeight)
+ G2 := Gdip_GraphicsFromImage(pBitmap2)
+ Gdip_SetInterpolationMode(G2, 7)
+ Gdip_DrawImage(G2, pBitmap1, 0, 0, sWidth, sHeight, 0, 0, dWidth, dHeight)
+
+ Gdip_DeleteGraphics(G2)
+ Gdip_DisposeImage(pBitmap1)
+ return pBitmap2
+}
+
+;#####################################################################################
+
+; Function: Gdip_SaveBitmapToFile
+; Description: Saves a bitmap to a file in any supported format onto disk
+;
+; pBitmap Pointer to a bitmap
+; sOutput The name of the file that the bitmap will be saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG
+; Quality If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality
+;
+; return If the function succeeds, the return value is zero, otherwise:
+; -1 = Extension supplied is not a supported file format
+; -2 = Could not get a list of encoders on system
+; -3 = Could not find matching encoder for specified file format
+; -4 = Could not get WideChar name of output file
+; -5 = Could not save file to disk
+;
+; notes This function will use the extension supplied from the sOutput parameter to determine the output format
+
+Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=75)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ SplitPath, sOutput,,, Extension
+ if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
+ return -1
+ Extension := "." Extension
+
+ DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
+ VarSetCapacity(ci, nSize)
+ DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
+ if !(nCount && nSize)
+ return -2
+
+ If (A_IsUnicode){
+ StrGet_Name := "StrGet"
+ Loop, %nCount%
+ {
+ sString := %StrGet_Name%(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
+ }
+ } else {
+ Loop, %nCount%
+ {
+ Location := NumGet(ci, 76*(A_Index-1)+44)
+ nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(sString, nSize)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0)
+ if !InStr(sString, "*" Extension)
+ continue
+
+ pCodec := &ci+76*(A_Index-1)
+ 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
+ }
+ }
+ }
+ }
+
+ if (!A_IsUnicode)
+ {
+ nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, 0, "int", 0)
+ VarSetCapacity(wOutput, nSize*2)
+ DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, &wOutput, "int", nSize)
+ VarSetCapacity(wOutput, -1)
+ if !VarSetCapacity(wOutput)
+ return -4
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &wOutput, Ptr, pCodec, "uint", p ? p : 0)
+ }
+ else
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &sOutput, Ptr, pCodec, "uint", p ? p : 0)
+ return E ? -5 : 0
+}
+
+;#####################################################################################
+
+; Function Gdip_GetPixel
+; Description Gets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return Returns the ARGB value of the pixel
+
+Gdip_GetPixel(pBitmap, x, y)
+{
+ DllCall("gdiplus\GdipBitmapGetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "uint*", ARGB)
+ return ARGB
+}
+
+;#####################################################################################
+
+; Function Gdip_SetPixel
+; Description Sets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return status enumeration. 0 = success
+
+Gdip_SetPixel(pBitmap, x, y, ARGB)
+{
+ return DllCall("gdiplus\GdipBitmapSetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageWidth
+; Description Gives the width of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the width in pixels of the supplied bitmap
+
+Gdip_GetImageWidth(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width)
+ return Width
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageHeight
+; Description Gives the height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the height in pixels of the supplied bitmap
+
+Gdip_GetImageHeight(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height)
+ return Height
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDimensions
+; Description Gives the width and height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetImageDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ DllCall("gdiplus\GdipGetImageWidth", Ptr, pBitmap, "uint*", Width)
+ DllCall("gdiplus\GdipGetImageHeight", Ptr, pBitmap, "uint*", Height)
+}
+
+;#####################################################################################
+
+Gdip_GetDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+}
+
+;#####################################################################################
+
+Gdip_GetImagePixelFormat(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImagePixelFormat", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", Format)
+ return Format
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDpiX
+; Description Gives the horizontal dots per inch of the graphics of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetDpiX(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiX", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetDpiY(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiY", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_GetImageHorizontalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHorizontalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetImageVerticalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageVerticalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_BitmapSetResolution(pBitmap, dpix, dpiy)
+{
+ return DllCall("gdiplus\GdipBitmapSetResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float", dpix, "float", dpiy)
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromFile(sFile, IconNumber=1, IconSize="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ SplitPath, sFile,,, ext
+ if ext in exe,dll
+ {
+ Sizes := IconSize ? IconSize : 256 "|" 128 "|" 64 "|" 48 "|" 32 "|" 16
+ BufSize := 16 + (2*(A_PtrSize ? A_PtrSize : 4))
+
+ VarSetCapacity(buf, BufSize, 0)
+ Loop, Parse, Sizes, |
+ {
+ DllCall("PrivateExtractIcons", "str", sFile, "int", IconNumber-1, "int", A_LoopField, "int", A_LoopField, PtrA, hIcon, PtrA, 0, "uint", 1, "uint", 0)
+
+ if !hIcon
+ continue
+
+ if !DllCall("GetIconInfo", Ptr, hIcon, Ptr, &buf)
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+
+ hbmMask := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4))
+ hbmColor := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4) + (A_PtrSize ? A_PtrSize : 4))
+ if !(hbmColor && DllCall("GetObject", Ptr, hbmColor, "int", BufSize, Ptr, &buf))
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+ break
+ }
+ if !hIcon
+ return -1
+
+ Width := NumGet(buf, 4, "int"), Height := NumGet(buf, 8, "int")
+ hbm := CreateDIBSection(Width, -Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ if !DllCall("DrawIconEx", Ptr, hdc, "int", 0, "int", 0, Ptr, hIcon, "uint", Width, "uint", Height, "uint", 0, Ptr, 0, "uint", 3)
+ {
+ DestroyIcon(hIcon)
+ return -2
+ }
+
+ VarSetCapacity(dib, 104)
+ DllCall("GetObject", Ptr, hbm, "int", A_PtrSize = 8 ? 104 : 84, Ptr, &dib) ; sizeof(DIBSECTION) = 76+2*(A_PtrSize=8?4:0)+2*A_PtrSize
+ Stride := NumGet(dib, 12, "Int"), Bits := NumGet(dib, 20 + (A_PtrSize = 8 ? 4 : 0)) ; padding
+ DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", Stride, "int", 0x26200A, Ptr, Bits, PtrA, pBitmapOld)
+ pBitmap := Gdip_CreateBitmap(Width, Height)
+ G := Gdip_GraphicsFromImage(pBitmap)
+ , Gdip_DrawImage(G, pBitmapOld, 0, 0, Width, Height, 0, 0, Width, Height)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapOld)
+ DestroyIcon(hIcon)
+ }
+ else
+ {
+ if (!A_IsUnicode)
+ {
+ VarSetCapacity(wFile, 1024)
+ DllCall("kernel32\MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sFile, "int", -1, Ptr, &wFile, "int", 512)
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &wFile, PtrA, pBitmap)
+ }
+ else
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &sFile, PtrA, pBitmap)
+ }
+
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", Ptr, hBitmap, Ptr, Palette, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff)
+{
+ DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hbm, "int", Background)
+ return hbm
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHICON(hIcon)
+{
+ DllCall("gdiplus\GdipCreateBitmapFromHICON", A_PtrSize ? "UPtr" : "UInt", hIcon, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHICONFromBitmap(pBitmap)
+{
+ DllCall("gdiplus\GdipCreateHICONFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hIcon)
+ return hIcon
+}
+
+;#####################################################################################
+
+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_CreateBitmapFromClipboard()
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if !DllCall("OpenClipboard", Ptr, 0)
+ return -1
+ if !DllCall("IsClipboardFormatAvailable", "uint", 8)
+ return -2
+ if !hBitmap := DllCall("GetClipboardData", "uint", 2, Ptr)
+ return -3
+ if !pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap)
+ return -4
+ if !DllCall("CloseClipboard")
+ return -5
+ DeleteObject(hBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_SetBitmapToClipboard(pBitmap)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ off1 := A_PtrSize = 8 ? 52 : 44, off2 := A_PtrSize = 8 ? 32 : 24
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ DllCall("GetObject", Ptr, hBitmap, "int", VarSetCapacity(oi, A_PtrSize = 8 ? 104 : 84, 0), Ptr, &oi)
+ hdib := DllCall("GlobalAlloc", "uint", 2, Ptr, 40+NumGet(oi, off1, "UInt"), Ptr)
+ pdib := DllCall("GlobalLock", Ptr, hdib, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pdib, Ptr, &oi+off2, Ptr, 40)
+ DllCall("RtlMoveMemory", Ptr, pdib+40, Ptr, NumGet(oi, off2 - (A_PtrSize ? A_PtrSize : 4), Ptr), Ptr, NumGet(oi, off1, "UInt"))
+ DllCall("GlobalUnlock", Ptr, hdib)
+ DllCall("DeleteObject", Ptr, hBitmap)
+ DllCall("OpenClipboard", Ptr, 0)
+ DllCall("EmptyClipboard")
+ DllCall("SetClipboardData", "uint", 8, Ptr, hdib)
+ DllCall("CloseClipboard")
+}
+
+;#####################################################################################
+
+Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format=0x26200A)
+{
+ DllCall("gdiplus\GdipCloneBitmapArea"
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "int", Format
+ , A_PtrSize ? "UPtr" : "UInt", pBitmap
+ , A_PtrSize ? "UPtr*" : "UInt*", pBitmapDest)
+ return pBitmapDest
+}
+
+;#####################################################################################
+; Create resources
+;#####################################################################################
+
+Gdip_CreatePen(ARGB, w)
+{
+ DllCall("gdiplus\GdipCreatePen1", "UInt", ARGB, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_CreatePenFromBrush(pBrush, w)
+{
+ DllCall("gdiplus\GdipCreatePen2", A_PtrSize ? "UPtr" : "UInt", pBrush, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_BrushCreateSolid(ARGB=0xff000000)
+{
+ DllCall("gdiplus\GdipCreateSolidFill", "UInt", ARGB, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; HatchStyleHorizontal = 0
+; HatchStyleVertical = 1
+; HatchStyleForwardDiagonal = 2
+; HatchStyleBackwardDiagonal = 3
+; HatchStyleCross = 4
+; HatchStyleDiagonalCross = 5
+; HatchStyle05Percent = 6
+; HatchStyle10Percent = 7
+; HatchStyle20Percent = 8
+; HatchStyle25Percent = 9
+; HatchStyle30Percent = 10
+; HatchStyle40Percent = 11
+; HatchStyle50Percent = 12
+; HatchStyle60Percent = 13
+; HatchStyle70Percent = 14
+; HatchStyle75Percent = 15
+; HatchStyle80Percent = 16
+; HatchStyle90Percent = 17
+; HatchStyleLightDownwardDiagonal = 18
+; HatchStyleLightUpwardDiagonal = 19
+; HatchStyleDarkDownwardDiagonal = 20
+; HatchStyleDarkUpwardDiagonal = 21
+; HatchStyleWideDownwardDiagonal = 22
+; HatchStyleWideUpwardDiagonal = 23
+; HatchStyleLightVertical = 24
+; HatchStyleLightHorizontal = 25
+; HatchStyleNarrowVertical = 26
+; HatchStyleNarrowHorizontal = 27
+; HatchStyleDarkVertical = 28
+; HatchStyleDarkHorizontal = 29
+; HatchStyleDashedDownwardDiagonal = 30
+; HatchStyleDashedUpwardDiagonal = 31
+; HatchStyleDashedHorizontal = 32
+; HatchStyleDashedVertical = 33
+; HatchStyleSmallConfetti = 34
+; HatchStyleLargeConfetti = 35
+; HatchStyleZigZag = 36
+; HatchStyleWave = 37
+; HatchStyleDiagonalBrick = 38
+; HatchStyleHorizontalBrick = 39
+; HatchStyleWeave = 40
+; HatchStylePlaid = 41
+; HatchStyleDivot = 42
+; HatchStyleDottedGrid = 43
+; HatchStyleDottedDiamond = 44
+; HatchStyleShingle = 45
+; HatchStyleTrellis = 46
+; HatchStyleSphere = 47
+; HatchStyleSmallGrid = 48
+; HatchStyleSmallCheckerBoard = 49
+; HatchStyleLargeCheckerBoard = 50
+; HatchStyleOutlinedDiamond = 51
+; HatchStyleSolidDiamond = 52
+; HatchStyleTotal = 53
+Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0)
+{
+ DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "UInt", ARGBfront, "UInt", ARGBback, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+Gdip_CreateTextureBrush(pBitmap, WrapMode=1, x=0, y=0, w="", h="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ if !(w && h)
+ DllCall("gdiplus\GdipCreateTexture", Ptr, pBitmap, "int", WrapMode, PtrA, pBrush)
+ else
+ DllCall("gdiplus\GdipCreateTexture2", Ptr, pBitmap, "int", WrapMode, "float", x, "float", y, "float", w, "float", h, PtrA, pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; WrapModeTile = 0
+; WrapModeTileFlipX = 1
+; WrapModeTileFlipY = 2
+; WrapModeTileFlipXY = 3
+; WrapModeClamp = 4
+Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2)
+ DllCall("gdiplus\GdipCreateLineBrush", Ptr, &PointF1, Ptr, &PointF2, "Uint", ARGB1, "Uint", ARGB2, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
+ return LGpBrush
+}
+
+;#####################################################################################
+
+; LinearGradientModeHorizontal = 0
+; LinearGradientModeVertical = 1
+; LinearGradientModeForwardDiagonal = 2
+; LinearGradientModeBackwardDiagonal = 3
+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_CloneBrush(pBrush)
+{
+ DllCall("gdiplus\GdipCloneBrush", A_PtrSize ? "UPtr" : "UInt", pBrush, A_PtrSize ? "UPtr*" : "UInt*", pBrushClone)
+ return pBrushClone
+}
+
+;#####################################################################################
+; Delete resources
+;#####################################################################################
+
+Gdip_DeletePen(pPen)
+{
+ return DllCall("gdiplus\GdipDeletePen", A_PtrSize ? "UPtr" : "UInt", pPen)
+}
+
+;#####################################################################################
+
+Gdip_DeleteBrush(pBrush)
+{
+ return DllCall("gdiplus\GdipDeleteBrush", A_PtrSize ? "UPtr" : "UInt", pBrush)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImage(pBitmap)
+{
+ return DllCall("gdiplus\GdipDisposeImage", A_PtrSize ? "UPtr" : "UInt", pBitmap)
+}
+
+;#####################################################################################
+
+Gdip_DeleteGraphics(pGraphics)
+{
+ return DllCall("gdiplus\GdipDeleteGraphics", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImageAttributes(ImageAttr)
+{
+ return DllCall("gdiplus\GdipDisposeImageAttributes", A_PtrSize ? "UPtr" : "UInt", ImageAttr)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFont(hFont)
+{
+ return DllCall("gdiplus\GdipDeleteFont", A_PtrSize ? "UPtr" : "UInt", hFont)
+}
+
+;#####################################################################################
+
+Gdip_DeleteStringFormat(hFormat)
+{
+ return DllCall("gdiplus\GdipDeleteStringFormat", A_PtrSize ? "UPtr" : "UInt", hFormat)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFontFamily(hFamily)
+{
+ return DllCall("gdiplus\GdipDeleteFontFamily", A_PtrSize ? "UPtr" : "UInt", hFamily)
+}
+
+;#####################################################################################
+
+Gdip_DeleteMatrix(Matrix)
+{
+ return DllCall("gdiplus\GdipDeleteMatrix", A_PtrSize ? "UPtr" : "UInt", Matrix)
+}
+
+;#####################################################################################
+; Text functions
+;#####################################################################################
+
+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_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_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
+}
+
+; Near = 0
+; Center = 1
+; Far = 2
+Gdip_SetStringFormatAlign(hFormat, Align)
+{
+ return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align)
+}
+
+; StringFormatFlagsDirectionRightToLeft = 0x00000001
+; StringFormatFlagsDirectionVertical = 0x00000002
+; StringFormatFlagsNoFitBlackBox = 0x00000004
+; StringFormatFlagsDisplayFormatControl = 0x00000020
+; StringFormatFlagsNoFontFallback = 0x00000400
+; StringFormatFlagsMeasureTrailingSpaces = 0x00000800
+; StringFormatFlagsNoWrap = 0x00001000
+; StringFormatFlagsLineLimit = 0x00002000
+; StringFormatFlagsNoClip = 0x00004000
+Gdip_StringFormatCreate(Format=0, Lang=0)
+{
+ DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat)
+ return hFormat
+}
+
+; Regular = 0
+; Bold = 1
+; Italic = 2
+; BoldItalic = 3
+; Underline = 4
+; Strikeout = 8
+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
+}
+
+;#####################################################################################
+; Matrix functions
+;#####################################################################################
+
+Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y)
+{
+ DllCall("gdiplus\GdipCreateMatrix2", "float", m11, "float", m12, "float", m21, "float", m22, "float", x, "float", y, A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+Gdip_CreateMatrix()
+{
+ DllCall("gdiplus\GdipCreateMatrix", A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+;#####################################################################################
+; GraphicsPath functions
+;#####################################################################################
+
+; Alternate = 0
+; Winding = 1
+Gdip_CreatePath(BrushMode=0)
+{
+ DllCall("gdiplus\GdipCreatePath", "int", BrushMode, A_PtrSize ? "UPtr*" : "UInt*", Path)
+ return Path
+}
+
+Gdip_AddPathEllipse(Path, x, y, w, h)
+{
+ return DllCall("gdiplus\GdipAddPathEllipse", A_PtrSize ? "UPtr" : "UInt", Path, "float", x, "float", y, "float", w, "float", h)
+}
+
+Gdip_AddPathPolygon(Path, 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\GdipAddPathPolygon", Ptr, Path, Ptr, &PointF, "int", Points0)
+}
+
+Gdip_DeletePath(Path)
+{
+ return DllCall("gdiplus\GdipDeletePath", A_PtrSize ? "UPtr" : "UInt", Path)
+}
+
+;#####################################################################################
+; Quality functions
+;#####################################################################################
+
+; SystemDefault = 0
+; SingleBitPerPixelGridFit = 1
+; SingleBitPerPixel = 2
+; AntiAliasGridFit = 3
+; AntiAlias = 4
+Gdip_SetTextRenderingHint(pGraphics, RenderingHint)
+{
+ return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint)
+}
+
+; Default = 0
+; LowQuality = 1
+; HighQuality = 2
+; Bilinear = 3
+; Bicubic = 4
+; NearestNeighbor = 5
+; HighQualityBilinear = 6
+; HighQualityBicubic = 7
+Gdip_SetInterpolationMode(pGraphics, InterpolationMode)
+{
+ return DllCall("gdiplus\GdipSetInterpolationMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", InterpolationMode)
+}
+
+; Default = 0
+; HighSpeed = 1
+; HighQuality = 2
+; None = 3
+; AntiAlias = 4
+Gdip_SetSmoothingMode(pGraphics, SmoothingMode)
+{
+ return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
+}
+
+; CompositingModeSourceOver = 0 (blended)
+; CompositingModeSourceCopy = 1 (overwrite)
+Gdip_SetCompositingMode(pGraphics, CompositingMode=0)
+{
+ return DllCall("gdiplus\GdipSetCompositingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", CompositingMode)
+}
+
+;#####################################################################################
+; Extra functions
+;#####################################################################################
+
+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
+}
+
+; Prepend = 0; The new operation is applied before the old operation.
+; Append = 1; The new operation is applied after the old operation.
+Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipRotateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", Angle, "int", MatrixOrder)
+}
+
+Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipScaleWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipTranslateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_ResetWorldTransform(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetRotatedTranslation(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+
+ Bound := (Angle >= 0) ? Mod(Angle, 360) : 360-Mod(-Angle, -360)
+ if ((Bound >= 0) && (Bound <= 90))
+ xTranslation := Height*Sin(TAngle), yTranslation := 0
+ else if ((Bound > 90) && (Bound <= 180))
+ xTranslation := (Height*Sin(TAngle))-(Width*Cos(TAngle)), yTranslation := -Height*Cos(TAngle)
+ else if ((Bound > 180) && (Bound <= 270))
+ xTranslation := -(Width*Cos(TAngle)), yTranslation := -(Height*Cos(TAngle))-(Width*Sin(TAngle))
+ else if ((Bound > 270) && (Bound <= 360))
+ xTranslation := 0, yTranslation := -Width*Sin(TAngle)
+}
+
+Gdip_GetRotatedDimensions(Width, Height, Angle, ByRef RWidth, ByRef RHeight)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+ if !(Width && Height)
+ return -1
+ RWidth := Ceil(Abs(Width*Cos(TAngle))+Abs(Height*Sin(TAngle)))
+ RHeight := Ceil(Abs(Width*Sin(TAngle))+Abs(Height*Cos(Tangle)))
+}
+
+; RotateNoneFlipNone = 0
+; Rotate90FlipNone = 1
+; Rotate180FlipNone = 2
+; Rotate270FlipNone = 3
+; RotateNoneFlipX = 4
+; Rotate90FlipX = 5
+; Rotate180FlipX = 6
+; Rotate270FlipX = 7
+; RotateNoneFlipY = Rotate180FlipX
+; Rotate90FlipY = Rotate270FlipX
+; Rotate180FlipY = RotateNoneFlipX
+; Rotate270FlipY = Rotate90FlipX
+; RotateNoneFlipXY = Rotate180FlipNone
+; Rotate90FlipXY = Rotate270FlipNone
+; Rotate180FlipXY = RotateNoneFlipNone
+; Rotate270FlipXY = Rotate90FlipNone
+
+Gdip_ImageRotateFlip(pBitmap, RotateFlipType=1)
+{
+ return DllCall("gdiplus\GdipImageRotateFlip", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", RotateFlipType)
+}
+
+; Replace = 0
+; Intersect = 1
+; Union = 2
+; Xor = 3
+; Exclude = 4
+; Complement = 5
+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_SetClipPath(pGraphics, Path, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ return DllCall("gdiplus\GdipSetClipPath", Ptr, pGraphics, Ptr, Path, "int", CombineMode)
+}
+
+Gdip_ResetClip(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetClipRegion(pGraphics)
+{
+ Region := Gdip_CreateRegion()
+ DllCall("gdiplus\GdipGetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics, "UInt*", Region)
+ return Region
+}
+
+Gdip_SetClipRegion(pGraphics, Region, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipSetClipRegion", Ptr, pGraphics, Ptr, Region, "int", CombineMode)
+}
+
+Gdip_CreateRegion()
+{
+ DllCall("gdiplus\GdipCreateRegion", "UInt*", Region)
+ return Region
+}
+
+Gdip_DeleteRegion(Region)
+{
+ return DllCall("gdiplus\GdipDeleteRegion", A_PtrSize ? "UPtr" : "UInt", Region)
+}
+
+;#####################################################################################
+; BitmapLockBits
+;#####################################################################################
+
+Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode = 3, PixelFormat = 0x26200a)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreateRect(Rect, x, y, w, h)
+ VarSetCapacity(BitmapData, 16+2*(A_PtrSize ? A_PtrSize : 4), 0)
+ E := DllCall("Gdiplus\GdipBitmapLockBits", Ptr, pBitmap, Ptr, &Rect, "uint", LockMode, "int", PixelFormat, Ptr, &BitmapData)
+ Stride := NumGet(BitmapData, 8, "Int")
+ Scan0 := NumGet(BitmapData, 16, Ptr)
+ return E
+}
+
+;#####################################################################################
+
+Gdip_UnlockBits(pBitmap, ByRef BitmapData)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("Gdiplus\GdipBitmapUnlockBits", Ptr, pBitmap, Ptr, &BitmapData)
+}
+
+;#####################################################################################
+
+Gdip_SetLockBitPixel(ARGB, Scan0, x, y, Stride)
+{
+ Numput(ARGB, Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_GetLockBitPixel(Scan0, x, y, Stride)
+{
+ return NumGet(Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_PixelateBitmap(pBitmap, ByRef pBitmapOut, BlockSize)
+{
+ static PixelateBitmap
+
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if (!PixelateBitmap)
+ {
+ if A_PtrSize != 8 ; x86 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 558BEC83EC3C8B4514538B5D1C99F7FB56578BC88955EC894DD885C90F8E830200008B451099F7FB8365DC008365E000894DC88955F08945E833FF897DD4
+ 397DE80F8E160100008BCB0FAFCB894DCC33C08945F88945FC89451C8945143BD87E608B45088D50028BC82BCA8BF02BF2418945F48B45E02955F4894DC4
+ 8D0CB80FAFCB03CA895DD08BD1895DE40FB64416030145140FB60201451C8B45C40FB604100145FC8B45F40FB604020145F883C204FF4DE475D6034D18FF
+ 4DD075C98B4DCC8B451499F7F98945148B451C99F7F989451C8B45FC99F7F98945FC8B45F899F7F98945F885DB7E648B450C8D50028BC82BCA83C103894D
+ C48BC82BCA41894DF48B4DD48945E48B45E02955E48D0C880FAFCB03CA895DD08BD18BF38A45148B7DC48804178A451C8B7DF488028A45FC8804178A45F8
+ 8B7DE488043A83C2044E75DA034D18FF4DD075CE8B4DCC8B7DD447897DD43B7DE80F8CF2FEFFFF837DF0000F842C01000033C08945F88945FC89451C8945
+ 148945E43BD87E65837DF0007E578B4DDC034DE48B75E80FAF4D180FAFF38B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945CC0F
+ B6440E030145140FB60101451C0FB6440F010145FC8B45F40FB604010145F883C104FF4DCC75D8FF45E4395DE47C9B8B4DF00FAFCB85C9740B8B451499F7
+ F9894514EB048365140033F63BCE740B8B451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB
+ 038975F88975E43BDE7E5A837DF0007E4C8B4DDC034DE48B75E80FAF4D180FAFF38B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955CC8A55
+ 1488540E038A551C88118A55FC88540F018A55F888140183C104FF4DCC75DFFF45E4395DE47CA68B45180145E0015DDCFF4DC80F8594FDFFFF8B451099F7
+ FB8955F08945E885C00F8E450100008B45EC0FAFC38365DC008945D48B45E88945CC33C08945F88945FC89451C8945148945103945EC7E6085DB7E518B4D
+ D88B45080FAFCB034D108D50020FAF4D18034DDC8BF08BF88945F403CA2BF22BFA2955F4895DC80FB6440E030145140FB60101451C0FB6440F010145FC8B
+ 45F40FB604080145F883C104FF4DC875D8FF45108B45103B45EC7CA08B4DD485C9740B8B451499F7F9894514EB048365140033F63BCE740B8B451C99F7F9
+ 89451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975103975EC7E5585DB7E468B4DD88B450C
+ 0FAFCB034D108D50020FAF4D18034DDC8BF08BF803CA2BF22BFA2BC2895DC88A551488540E038A551C88118A55FC88540F018A55F888140183C104FF4DC8
+ 75DFFF45108B45103B45EC7CAB8BC3C1E0020145DCFF4DCC0F85CEFEFFFF8B4DEC33C08945F88945FC89451C8945148945103BC87E6C3945F07E5C8B4DD8
+ 8B75E80FAFCB034D100FAFF30FAF4D188B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945C80FB6440E030145140FB60101451C0F
+ B6440F010145FC8B45F40FB604010145F883C104FF4DC875D833C0FF45108B4DEC394D107C940FAF4DF03BC874068B451499F7F933F68945143BCE740B8B
+ 451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975083975EC7E63EB0233F639
+ 75F07E4F8B4DD88B75E80FAFCB034D080FAFF30FAF4D188B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955108A551488540E038A551C8811
+ 8A55FC88540F018A55F888140883C104FF4D1075DFFF45088B45083B45EC7C9F5F5E33C05BC9C21800
+ )
+ else ; x64 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 4489442418488954241048894C24085355565741544155415641574883EC28418BC1448B8C24980000004C8BDA99488BD941F7F9448BD0448BFA8954240C
+ 448994248800000085C00F8E9D020000418BC04533E4458BF299448924244C8954241041F7F933C9898C24980000008BEA89542404448BE889442408EB05
+ 4C8B5C24784585ED0F8E1A010000458BF1418BFD48897C2418450FAFF14533D233F633ED4533E44533ED4585C97E5B4C63BC2490000000418D040A410FAF
+ C148984C8D441802498BD9498BD04D8BD90FB642010FB64AFF4403E80FB60203E90FB64AFE4883C2044403E003F149FFCB75DE4D03C748FFCB75D0488B7C
+ 24188B8C24980000004C8B5C2478418BC59941F7FE448BE8418BC49941F7FE448BE08BC59941F7FE8BE88BC69941F7FE8BF04585C97E4048639C24900000
+ 004103CA4D8BC1410FAFC94863C94A8D541902488BCA498BC144886901448821408869FF408871FE4883C10448FFC875E84803D349FFC875DA8B8C249800
+ 0000488B5C24704C8B5C24784183C20448FFCF48897C24180F850AFFFFFF8B6C2404448B2424448B6C24084C8B74241085ED0F840A01000033FF33DB4533
+ DB4533D24533C04585C97E53488B74247085ED7E42438D0C04418BC50FAF8C2490000000410FAFC18D04814863C8488D5431028BCD0FB642014403D00FB6
+ 024883C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC17CB28BCD410FAFC985C9740A418BC299F7F98BF0EB0233F685C9740B418BC3
+ 99F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585C97E4D4C8B74247885ED7E3841
+ 8D0C14418BC50FAF8C2490000000410FAFC18D04814863C84A8D4431028BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2413BD17CBD
+ 4C8B7424108B8C2498000000038C2490000000488B5C24704503E149FFCE44892424898C24980000004C897424100F859EFDFFFF448B7C240C448B842480
+ 000000418BC09941F7F98BE8448BEA89942498000000896C240C85C00F8E3B010000448BAC2488000000418BCF448BF5410FAFC9898C248000000033FF33
+ ED33F64533DB4533D24533C04585FF7E524585C97E40418BC5410FAFC14103C00FAF84249000000003C74898488D541802498BD90FB642014403D00FB602
+ 4883C2044403D80FB642FB03F00FB642FA03E848FFCB75DE488B5C247041FFC0453BC77CAE85C9740B418BC299F7F9448BE0EB034533E485C9740A418BC3
+ 99F7F98BD8EB0233DB85C9740A8BC699F7F9448BD8EB034533DB85C9740A8BC599F7F9448BD0EB034533D24533C04585FF7E4E488B4C24784585C97E3541
+ 8BC5410FAFC14103C00FAF84249000000003C74898488D540802498BC144886201881A44885AFF448852FE4883C20448FFC875E941FFC0453BC77CBE8B8C
+ 2480000000488B5C2470418BC1C1E00203F849FFCE0F85ECFEFFFF448BAC24980000008B6C240C448BA4248800000033FF33DB4533DB4533D24533C04585
+ FF7E5A488B7424704585ED7E48418BCC8BC5410FAFC94103C80FAF8C2490000000410FAFC18D04814863C8488D543102418BCD0FB642014403D00FB60248
+ 83C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC77CAB418BCF410FAFCD85C9740A418BC299F7F98BF0EB0233F685C9740B418BC399
+ F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585FF7E4E4585ED7E42418BCC8BC541
+ 0FAFC903CA0FAF8C2490000000410FAFC18D04814863C8488B442478488D440102418BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2
+ 413BD77CB233C04883C428415F415E415D415C5F5E5D5BC3
+ )
+
+ VarSetCapacity(PixelateBitmap, StrLen(MCode_PixelateBitmap)//2)
+ Loop % StrLen(MCode_PixelateBitmap)//2 ;%
+ NumPut("0x" SubStr(MCode_PixelateBitmap, (2*A_Index)-1, 2), PixelateBitmap, A_Index-1, "UChar")
+ DllCall("VirtualProtect", Ptr, &PixelateBitmap, Ptr, VarSetCapacity(PixelateBitmap), "uint", 0x40, A_PtrSize ? "UPtr*" : "UInt*", 0)
+ }
+
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+
+ if (Width != Gdip_GetImageWidth(pBitmapOut) || Height != Gdip_GetImageHeight(pBitmapOut))
+ return -1
+ if (BlockSize > Width || BlockSize > Height)
+ return -2
+
+ E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1)
+ E2 := Gdip_LockBits(pBitmapOut, 0, 0, Width, Height, Stride2, Scan02, BitmapData2)
+ if (E1 || E2)
+ return -3
+
+ E := DllCall(&PixelateBitmap, Ptr, Scan01, Ptr, Scan02, "int", Width, "int", Height, "int", Stride1, "int", BlockSize)
+
+ Gdip_UnlockBits(pBitmap, BitmapData1), Gdip_UnlockBits(pBitmapOut, BitmapData2)
+ return 0
+}
+
+;#####################################################################################
+
+Gdip_ToARGB(A, R, G, B)
+{
+ return (A << 24) | (R << 16) | (G << 8) | B
+}
+
+;#####################################################################################
+
+Gdip_FromARGB(ARGB, ByRef A, ByRef R, ByRef G, ByRef B)
+{
+ A := (0xff000000 & ARGB) >> 24
+ R := (0x00ff0000 & ARGB) >> 16
+ G := (0x0000ff00 & ARGB) >> 8
+ B := 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+Gdip_AFromARGB(ARGB)
+{
+ return (0xff000000 & ARGB) >> 24
+}
+
+;#####################################################################################
+
+Gdip_RFromARGB(ARGB)
+{
+ return (0x00ff0000 & ARGB) >> 16
+}
+
+;#####################################################################################
+
+Gdip_GFromARGB(ARGB)
+{
+ return (0x0000ff00 & ARGB) >> 8
+}
+
+;#####################################################################################
+
+Gdip_BFromARGB(ARGB)
+{
+ return 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+StrGetB(Address, Length=-1, Encoding=0)
+{
+ ; Flexible parameter handling:
+ if Length is not integer
+ Encoding := Length, Length := -1
+
+ ; Check for obvious errors.
+ if (Address+0 < 1024)
+ return
+
+ ; Ensure 'Encoding' contains a numeric identifier.
+ if Encoding = UTF-16
+ Encoding = 1200
+ else if Encoding = UTF-8
+ Encoding = 65001
+ else if SubStr(Encoding,1,2)="CP"
+ Encoding := SubStr(Encoding,3)
+
+ if !Encoding ; "" or 0
+ {
+ ; No conversion necessary, but we might not want the whole string.
+ if (Length == -1)
+ Length := DllCall("lstrlen", "uint", Address)
+ VarSetCapacity(String, Length)
+ DllCall("lstrcpyn", "str", String, "uint", Address, "int", Length + 1)
+ }
+ else if Encoding = 1200 ; UTF-16
+ {
+ char_count := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "uint", 0, "uint", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(String, char_count)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "str", String, "int", char_count, "uint", 0, "uint", 0)
+ }
+ else if Encoding is integer
+ {
+ ; Convert from target encoding to UTF-16 then to the active code page.
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", 0, "int", 0)
+ VarSetCapacity(String, char_count * 2)
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", &String, "int", char_count * 2)
+ String := StrGetB(&String, char_count, 1200)
+ }
+
+ return String
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/SuperSleep.dll b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/SuperSleep.dll
new file mode 100644
index 0000000..535d320
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/SuperSleep.dll differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/ViGEmWrapper.dll b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/ViGEmWrapper.dll
new file mode 100644
index 0000000..2a08e3a
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/ViGEmWrapper.dll differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/__controller_functions__.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/__controller_functions__.ahk
new file mode 100644
index 0000000..ab1338c
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/__controller_functions__.ahk
@@ -0,0 +1,188 @@
+
+/**********************************************
+* Controller methods for simplicity *
+***********************************************/
+*/
+
+GoTo EndControllerFunctionsDef
+
+;;;;;;;;;;;; Turning functions
+;;;;;;;;;;;; For holding the stick in a specific position for a period of time
+;;;;;;;;;;;; Note no other button may be pressed or released when these functions are ran
+
+; Set the time you want to turn for in miliseconds and how hard (50, 100), 100 being the most, 50 being neutral
+Turn_Right(sleept, inten){
+ t := sleept
+ controller.Axes.LX.SetState(inten)
+ gosub, Turn
+ controller.Axes.LX.SetState(50)
+}
+
+; Set the time you want to turn for in miliseconds and how hard (0, 50), 0 being the most
+Turn_Left(sleept, inten){
+ t := sleept
+ controller.Axes.LX.SetState(inten)
+ gosub, Turn
+ controller.Axes.LX.SetState(50)
+}
+
+;;;;;;;;;;;; Simple button press functions
+;;;;;;;;;;;; You can pass a delay amount or leave it blank
+;;;;;;;;;;;; Longer delays hold the button longer
+
+; Press X button
+Press_X(delay:=200){
+ controller.Buttons.Cross.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.Cross.SetState(false)
+ return
+}
+
+; Press O button
+Press_O(delay:=200){
+ controller.Buttons.Circle.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.Circle.SetState(false)
+ return
+}
+
+; Press Triangle button
+Press_Triangle(delay:=200){
+ controller.Buttons.Triangle.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.Triangle.SetState(false)
+ return
+}
+
+; Press Square button
+Press_Square(delay:=200){
+ controller.Buttons.Square.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.Square.SetState(false)
+ return
+}
+
+; Press R1 button
+Press_L1(delay:=200){
+ controller.Buttons.L1.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.L1.SetState(false)
+ return
+}
+
+; Press R1 button
+Press_R1(delay:=200){
+ controller.Buttons.R1.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.R1.SetState(false)
+ return
+}
+
+; Press Right on D-pad
+Press_Right(delay:=200){
+ controller.Dpad.SetState("Right")
+ DllCall("Sleep", "UInt", delay)
+ controller.Dpad.SetState("None")
+ return
+}
+
+; Press Left on D-pad
+Press_Left(delay:=200){
+ controller.Dpad.SetState("Left")
+ DllCall("Sleep", "UInt", delay)
+ controller.Dpad.SetState("None")
+ return
+}
+
+; Press Up on D-pad
+Press_Up(delay:=200){
+ controller.Dpad.SetState("Up")
+ DllCall("Sleep", "UInt", delay)
+ controller.Dpad.SetState("None")
+ return
+}
+
+; Press Down on D-pad
+Press_Down(delay:=200){
+ controller.Dpad.SetState("Down")
+ DllCall("Sleep", "UInt", delay)
+ controller.Dpad.SetState("None")
+ return
+}
+
+;;;;;;;;;;; Other functions specific to GT7
+
+; Turn on nitrous
+Nitrous_On(){
+ controller.Buttons.RS.SetState(true)
+}
+
+; Turn off nitrous
+Nitrous_Off(){
+ controller.Buttons.RS.SetState(false)
+}
+
+Accel_On(control:=100){
+ controller.Buttons.R2.SetState(true)
+ controller.Axes.RT.SetState(control)
+}
+
+Accel_Off(){
+ controller.Buttons.R2.SetState(false)
+ controller.Axes.RT.SetState(0)
+}
+
+Brake_On(control:=100){
+ controller.Buttons.L2.SetState(true)
+ controller.Axes.LT.SetState(control)
+}
+
+Brake_Off(){
+ controller.Buttons.L2.SetState(false)
+ controller.Axes.LT.SetState(0)
+}
+; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
+Turn:
+ t0 := A_TickCount
+ tf := t0+t
+ loop {
+ Sleep(100)
+ } until A_TickCount > tf
+ return
+
+
+Press_Options(){
+ controller.Buttons.Options.SetState(true)
+ Sleep, 50
+ controller.Buttons.Options.SetState(false)
+ }
+
+
+PressX:
+; Just for menuing, does not hold X down
+ controller.Buttons.Cross.SetState(true)
+ DllCall("Sleep", "UInt", 200)
+ controller.Buttons.Cross.SetState(false)
+ return
+
+PressO:
+; Just for menuing, does not hold O down
+ controller.Buttons.Circle.SetState(true)
+ DllCall("Sleep", "UInt", 200)
+ controller.Buttons.Circle.SetState(false)
+ return
+
+PressRight:
+; For turning
+ controller.Dpad.SetState("Right")
+ Sleep, 50
+ controller.Dpad.SetState("None")
+ return
+
+PressShare:
+ controller.Buttons.Share.SetState(true)
+ Sleep, 50
+ controller.Buttons.Share.SetState(false)
+ return
+
+EndControllerFunctionsDef:
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/__utility__.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/__utility__.ahk
new file mode 100644
index 0000000..1d0470d
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Lib/__utility__.ahk
@@ -0,0 +1,136 @@
+/**********************************************
+* Only place functions here, no sub routines *
+***********************************************/
+
+
+; Grabs the colors of the pixels (x-b, y-b) to (x+b, y+b)
+; returns the array of colors
+*/
+
+BitGrab(x, y, b)
+{
+ HWND := WinExist("PS Remote Play")
+ pToken := Gdip_Startup()
+ pBitmap := Gdip_BitmapFromHWND2(hwnd)
+
+ pixs := []
+ for i in range(-1*b, b+1){
+ for j in range(-1*b, b+1){
+ pixel := Gdip_GetPixel(pBitmap,x+i,y+j)
+ rgb := ConvertARGB( pixel )
+ pixs.Push(rgb)
+ }
+ }
+
+ Gdip_DisposeImage(pBitmap)
+ Gdip_Shutdown(pToken)
+ return pixs
+}
+
+Gdip_BitmapFromHWND2(hwnd)
+{
+ WinGetPos,,, Width, Height, ahk_id %hwnd%
+ hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ RegExMatch(A_OsVersion, "\d+", Version)
+ PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ return pBitmap
+}
+
+range(start, stop:="", step:=1) {
+ static range := { _NewEnum: Func("_RangeNewEnum") }
+ if !step
+ throw "range(): Parameter 'step' must not be 0 or blank"
+ if (stop == "")
+ stop := start, start := 0
+ ; Formula: r[i] := start + step*i ; r = range object, i = 0-based index
+ ; For a postive 'step', the constraints are i >= 0 and r[i] < stop
+ ; For a negative 'step', the constraints are i >= 0 and r[i] > stop
+ ; No result is returned if r[0] does not meet the value constraint
+ if (step > 0 ? start < stop : start > stop) ;// start == start + step*0
+ return { base: range, start: start, stop: stop, step: step }
+}
+
+_RangeNewEnum(r) {
+ static enum := { "Next": Func("_RangeEnumNext") }
+ return { base: enum, r: r, i: 0 }
+}
+
+_RangeEnumNext(enum, ByRef k, ByRef v:="") {
+ stop := enum.r.stop, step := enum.r.step
+ , k := enum.r.start + step*enum.i
+ if (ret := step > 0 ? k < stop : k > stop)
+ enum.i += 1
+ return ret
+}
+
+
+Sleep(ms=1)
+{
+ global timeBeginPeriodHasAlreadyBeenCalled
+ if (timeBeginPeriodHasAlreadyBeenCalled != 1)
+ {
+ DllCall("Winmm.dll\timeBeginPeriod", UInt, 1)
+ timeBeginPeriodHasAlreadyBeenCalled := 1
+ }
+
+ DllCall("Sleep", UInt, ms)
+}
+
+
+
+PixelColorSimple(pc_x, pc_y)
+{
+ WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
+ if (remotePlay_id = 0)
+ {
+ MsgBox, PS4 Remote Play not found
+ return
+ }
+ if remotePlay_id
+ {
+ pc_wID := remotePlay_id[0]
+ pc_hDC := DllCall("GetDC", "UInt", pc_wID)
+ pc_fmtI := A_FormatInteger
+ SetFormat, IntegerFast, Hex
+ pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
+ pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
+ pc_c .= ""
+ SetFormat, IntegerFast, %pc_fmtI%
+ DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
+ return pc_c
+
+ }
+}
+
+GetClientSize(hWnd, ByRef w := "", ByRef h := "")
+{
+ VarSetCapacity(rect, 16)
+ DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
+ w := NumGet(rect, 8, "int")
+ h := NumGet(rect, 12, "int")
+}
+
+Distance(c1, c2)
+{ ; function by [VxE], return value range = [0, 441.67295593006372]
+return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
+}
+
+ConvertARGB(ARGB, Convert := 0)
+{
+ SetFormat, IntegerFast, Hex
+ RGB += ARGB
+ RGB := RGB & 0x00FFFFFF
+ if (Convert)
+ RGB := (RGB & 0xFF000000) | ((RGB & 0xFF0000) >> 16) | (RGB & 0x00FF00) | ((RGB & 0x0000FF) << 16)
+
+ return RGB
+}
+
+ToolTipper(msg, x := 100, y := 100)
+{
+ if (debug_mode = 1)
+ ToolTip, %msg%, x, y, Screen
+ return
+}
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Mod/TokyoDetections.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Mod/TokyoDetections.ahk
new file mode 100644
index 0000000..bf43f46
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Mod/TokyoDetections.ahk
@@ -0,0 +1,367 @@
+__enableTokyoDetections_mod__ := 1
+IniRead, color_pitstop1, config.ini, Vars, color_pitstop1, 0
+IniRead, color_pitstop2, config.ini, Vars, color_pitstop2, 0
+
+class TokyoTurnContainer
+{
+ __New(startX, startY, endX := 0, endY := 0)
+ {
+ this.startX := startX
+ this.startY := startY
+ this.endX := endX
+ this.endY := endY
+ }
+}
+
+GoTo EndTokyoDetectionsDef
+
+CheckTokyoMFD(x,y, b_size := 1)
+{
+ color_dot := 0xD3D2D0
+ TokyoMFD := false
+ tries := 1000 ; we shouldn't need more than 6 tries, but I have seen it loop passed
+ loop {
+
+ tc := BitGrab(x, y, b_size)
+ SB_SetText(" Searching... " td " < 5",2)
+ for i, c in tc
+ {
+ td := Distance(c, color_dot)
+
+ if (td < 5){
+ SB_SetText(" Found: " td " < 5",2)
+ TokyoMFD := true
+ break
+ }
+ else {
+ ; Gonna try to automate the mfd checker, why not right?
+ if (tries > 0){
+ SB_SetText(" Searching Track/Course Map MFD " td " < 5",2)
+ Press_Left()
+ Sleep(200)
+ tries--
+ break
+ }
+ tries := 1000
+ TokyoMFD := true
+ break
+ }
+ }
+
+ } until TokyoMFD = true
+ return
+}
+
+
+CheckTokyoTurn(x,y, b_size := 1)
+{
+ turnStart := A_TickCount
+ color_player := 0xDE6E70
+ TokyoTurnComplete := false
+ loop {
+ SB_SetText(" Searching... " td " < 50",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_player)
+
+ if (td < 50 ){
+ SB_SetText(" Found: " td " < 50",2)
+ TokyoTurnComplete := true
+ break
+ }
+ }
+ ; add recovery so we don't kill run looking for turn. Gonna start with a high number, can adjust lower later.
+ ; added some press down, x's and waits just in case we are in the pit stop
+ if (A_TickCount - turnStart > 90000) {
+ Press_Down()
+ Sleep(300)
+ Press_X()
+ Sleep(500)
+ Press_X()
+ Sleep(7000)
+ GoSub, ResetRace
+ break
+ }
+
+ } until TokyoTurnComplete = true
+ return
+}
+
+CheckTokyoPen1(x,y, b_size := 1)
+{
+ pen1Start := A_TickCount
+
+ color_pen := 0xFFC10B
+ TokyoPen1 := false
+ loop {
+ SB_SetText(" Searching... " td " < 50",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_pen)
+
+ if (td < 50 ){
+ SB_SetText(" Found: " td " < 50",2)
+ TokyoPen1 := true
+ break
+ }
+ }
+ ; add recovery so we don't kill run looking for Pen1. Gonna start with a high number, can adjust lower later.
+ ; started with 1.5 mins, i had these set to 3:33 on other file and still won.
+ if (A_TickCount - pen1Start > 90000) {
+ GoSub, ResetRace
+ break
+ }
+
+ } until TokyoPen1 = true
+ return
+}
+
+CheckTokyoHairpinTurn(x,y, b_size := 1)
+{
+ hairpinStart := A_TickCount
+
+ color_hairpinturn := 0xB3B1B2
+ TokyoHairpinTurn := false
+ loop {
+ SB_SetText(" Searching... " td " < 5",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_hairpinturn)
+
+ if (td < 5){
+ SB_SetText(" Found: " td " < 5",2)
+ TokyoHairpinTurn := true
+ break
+ }
+ }
+ ; add recovery so we don't kill run sitting in hairpin
+ ; set to 1 minute to start, I had this at 3:33 (200000) on my other file and still won.
+ if (A_TickCount - hairpinStart > 90000) {
+
+ GoSub, ResetRace
+ break
+ }
+
+ } until TokyoHairpinTurn = true
+ return
+}
+
+CheckTokyoPen2(x,y, b_size := 1)
+{
+ start := A_TickCount
+ color_pen := 0xFFC10B
+ RecoveryTried := false
+ TokyoPen2 := false
+
+ loop {
+ SB_SetText(" Searching... " td " > 60",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_pen)
+
+ if (td > 60 ){
+ SB_SetText(" Found: " td " > 60",2)
+ TokyoPen2 := true
+ break
+ }
+
+ }
+ if (A_TickCount - start > 25000 AND RecoveryTried = false) {
+ SB_SetText(" We stuck? Starting recovery try.",2)
+ Accel_off()
+ controller.Axes.LX.SetState(50)
+ loop 7 {
+ Press_Square(delay:=50)
+ Sleep(100)
+ }
+ Accel_on(80)
+ Sleep(500)
+ loop 9 {
+ Press_Triangle(delay:=50)
+ Sleep(100)
+ }
+ controller.Axes.LX.SetState(30)
+ RecoveryTried := true
+ }
+
+ if (A_TickCount - start > 60000) {
+ gosub, ResetRace
+ break
+ }
+
+ } until TokyoPen2 = true
+ return
+}
+
+CheckTokyoPenServed(x,y, b_size := 1)
+{
+ color_penserved := 0xAE1B1E
+ TokyoPenServed := false
+ loop {
+ SB_SetText(" Searching... " td " > 60",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_penserved)
+
+ if (td > 60 ){
+ SB_SetText(" Found: " td " > 60",2)
+ TokyoPenServed := true
+ break
+ }
+ }
+
+ } until TokyoPenServed = true
+ return
+}
+
+CheckTokyoPenReceived(x,y, b_size := 1)
+{
+ start := A_TickCount
+ color_penreceived := 0xAE1B1E
+ TokyoPenReceived := false
+ loop {
+ SB_SetText(" Searching... " td " < 40",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_penreceived)
+
+ if (td < 40 ){
+ SB_SetText(" Found: " td " < 40",2)
+ guicontrol,, CurrentLoop, Pen received
+ TokyoPenReceived := true
+ break
+ }
+ if (TokyoLapCount != 6 AND A_TickCount - start > 36000)
+ {
+ SB_SetText(" Not found in time. Shifting up.",2)
+ loop 6 {
+ Press_Triangle(delay:=50)
+ Sleep(200)
+ TokyoPenReceived := true
+ break
+ }
+ break
+ }
+ if (TokyoLapCount = 6 AND A_TickCount - start > 46000)
+ {
+ SB_SetText(" Not found in time. Shifting up.",2)
+ loop 20 {
+ Press_Triangle(delay:=50)
+ Sleep(200)
+ TokyoPenReceived := true
+ break
+ }
+ break
+ }
+
+ }
+ } until TokyoPenReceived = true
+ return
+}
+
+CheckTokyoPitstopDone(x,y, b_size := 1)
+{
+ pitstopDoneStart := A_TickCount
+
+ color_pitstopdone := 0xFFFFFF
+ TokyoPitstopDone := false
+ loop {
+ SB_SetText(" Searching... " td " > 10",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_pitstopdone)
+
+ if (td > 10 ){
+ SB_SetText(" Found: " td " > 10",2)
+ TokyoPitstopDone := true
+ break
+ }
+ }
+ ; add recovery so we don't kill run sitting in pit, havent tested if press down works to get us out
+ if (A_TickCount - pitstopDoneStart > 60000) {
+ Press_Down()
+ Sleep(300)
+ Press_X()
+ Sleep(500)
+ Press_X()
+ Sleep(7000)
+ GoSub, ResetRace
+ }
+ } until TokyoPitstopDone = true
+ return
+}
+
+CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+{
+if ( A_TickCount - loopStartTime > maxTime AND TokyoLapCount <= 10) {
+ gosub, ResetRace
+ }
+else if (A_TickCount - loopStartTime > maxTime+90000 AND TokyoLapCount > 10)
+ {
+ gosub, ResetRace
+ }
+}
+
+CheckTokyoPitstop1(x,y, b_size := 1)
+{
+ pitstop1Start := A_TickCount
+
+ ;color_pitstop1 := 0xFFFFFF
+ ;color_pitstop1 := 0x818002
+ ;color_pitstop1 := 0xFBFB00 ; old color
+ TokyoPitstop := false
+ loop {
+ SB_SetText(" Searching... " td " < 10",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_pitstop1)
+
+ if (td < 10 ){
+ SB_SetText(" Found: " td " < 10",2)
+ TokyoPitstop := true
+ break
+ }
+ }
+ ; add recovery so we don't kill run sitting in pit, havent tested if press down works to get us out
+ if (A_TickCount - pitstop1Start > 60000) {
+ Press_Down()
+ Sleep(300)
+ Press_X()
+ Sleep(500)
+ Press_X()
+ Sleep(7000)
+ GoSub, ResetRace
+ }
+ guicontrol,, CurrentLoop, Stuck in pit? Press GUI Button.
+
+ } until TokyoPitstop = true
+ return
+}
+UpdateAVG(racecounter, script_start)
+{
+ SetFormat, integerfast, d
+ creditcountersession := (835000*racecounter)/1000000
+ SetFormat, integerfast, d
+ SetFormat, FloatFast, 0.2
+ creditavg := creditcountersession/(A_TickCount-script_start)*3600000
+ guicontrol,, CreditAVG, Avg./h: ~%creditavg% M
+ return
+}
+
+UpdateTimer()
+{
+ElapsedTime := A_TickCount - script_start
+ VarSetCapacity(t,256),DllCall("GetDurationFormat","uint",2048,"uint",0,"ptr",0,"int64",ElapsedTime*10000,"wstr","d' day(s) 'h':'mm':'ss","wstr",t,"int",256)
+ SB_SetText("Runtime: " t,3)
+ return
+}
+
+EndTokyoDetectionsDef:
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Race.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Race.ahk
new file mode 100644
index 0000000..f948f41
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Race.ahk
@@ -0,0 +1,86 @@
+#Include Races\PanAm.ahk
+#Include Races\Tokyo.ahk
+
+GoTo EndRaceDef
+
+Race:
+
+ Switch RaceChoice
+ {
+ case "PanAm":
+ Race_PANAM()
+ return
+ case "Tokyo":
+ Race_Tokyo()
+ return
+ }
+
+ return
+
+SettingsSheet:
+
+ Gui, 4: Show, AutoSize, Settings Sheet
+ ;/////////////////////////////////////////////////////////
+ ; Add images to your setup here and in the Src folder
+ ;
+ ;/////////////////////////////////////////////////////////
+ Switch RaceChoice
+ {
+ case "PanAm":
+
+ assist_1 = %A_ScriptDir%\Src\PanAm\Assist1.jpg
+ assist_2 = %A_ScriptDir%\Src\PanAm\Assist2.jpg
+ tune_1 = %A_ScriptDir%\Src\PanAm\CarSetup.jpg
+ tune_2 = %A_ScriptDir%\Src\PanAm\CarGearRatio.jpg
+ controls = %A_ScriptDir%\Src\PanAm\Controller.jpg
+ return
+ case "Tokyo":
+
+ assist_1 = %A_ScriptDir%\Src\Tokyo\Assist_Settings.png
+ assist_2 = %A_ScriptDir%\Src\Tokyo\Misc_Settings.png
+ controls = %A_ScriptDir%\Src\Tokyo\Controller_Settings.png
+ tune_1 = %A_ScriptDir%\Src\Tokyo\Settings_Car1.png
+ tune_2 = %A_ScriptDir%\Src\Tokyo\Settings_Car2.png
+ tune_3 = %A_ScriptDir%\Src\Tokyo\Settings_Car3.png
+ return
+ }
+
+
+ return
+
+Assists1:
+ GuiControl, 4:, CurrentPic, %assist_1%
+ gosub, Guisizer
+ return
+
+Assists2:
+ GuiControl, 4:, CurrentPic, %assist_2%
+ gosub, Guisizer
+ return
+
+Tune1:
+ GuiControl, 4:, CurrentPic, %tune_1%
+ gosub, Guisizer
+ return
+
+Tune2:
+ GuiControl, 4:, CurrentPic, %tune_2%
+ gosub, Guisizer
+ return
+
+Tune3:
+ GuiControl, 4:, CurrentPic, %tune_2%
+ gosub, Guisizer
+ return
+
+ControllerSetting:
+ GuiControl, 4:, CurrentPic, %controls%
+ gosub, Guisizer
+ return
+
+Guisizer:
+ GuiControl, 4: Move, CurrentPic, % "x" 10 "y" 40 "w" 1200 . " h" . 800
+ Gui, 4: Show, AutoSize, Settings Sheet
+ return
+
+EndRaceDef:
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Races/Tokyo.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Races/Tokyo.ahk
new file mode 100644
index 0000000..1773579
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Races/Tokyo.ahk
@@ -0,0 +1,494 @@
+GoTo EndRace_Tokyo_Def
+
+Race_Tokyo()
+{
+ SetFormat, integerfast, d
+ TokyoStart:
+ ;- VARIABLES -----------------------------------------------------------------------------
+ SetFormat, integerfast, d
+ TokyoLapCount := 1
+ maxTime := 200000
+ ;- COORDINATES: TURNS --------------------------------------------------------------------
+ TokyoTurn1 := new TokyoTurnContainer(611, 59+remote_play_offsetY, 622, 69+remote_play_offsetY)
+ TokyoTurn2 := new TokyoTurnContainer(618, 70+remote_play_offsetY, 601, 76+remote_play_offsetY)
+ TokyoTurn3 := new TokyoTurnContainer(599, 79+remote_play_offsetY, 591, 87+remote_play_offsetY)
+ TokyoTurn4 := new TokyoTurnContainer(589, 88+remote_play_offsetY, 571, 96+remote_play_offsetY)
+ TokyoTurn5 := new TokyoTurnContainer(567, 96+remote_play_offsetY, 556, 90+remote_play_offsetY)
+ TokyoTurn6 := new TokyoTurnContainer(554, 86+remote_play_offsetY, 543, 82+remote_play_offsetY)
+ TokyoTurn7 := new TokyoTurnContainer(538, 81+remote_play_offsetY, 530, 75+remote_play_offsetY)
+ TokyoTurn8 := new TokyoTurnContainer(530, 75+remote_play_offsetY, 510, 72+remote_play_offsetY)
+ ;- COORDINATES: PENALTY WARNINGS ---------------------------------------------------------
+ TokyoPenWarning := new TokyoTurnContainer(360, 154+remote_play_offsetY, 408, 154+remote_play_offsetY)
+ TokyoPenIndicator := new TokyoTurnContainer(366, 132+remote_play_offsetY)
+ ;- COORDINATES: HAIRPIN TURN -------------------------------------------------------------
+ TokyoHairpinTurn := new TokyoTurnContainer(606, 334+remote_play_offsetY)
+ ;- COORDINATES: PENALTY WARNINGS ---------------------------------------------------------
+ TokyoPen := new TokyoTurnContainer(360, 154+remote_play_offsetY, 408, 154+remote_play_offsetY)
+ TokyoPenServed := new TokyoTurnContainer(366, 132+remote_play_offsetY)
+ ;- COORDINATES: HAIRPIN TURN--------------------------------------------------------------
+ TokyoHairpinTurn := new TokyoTurnContainer(606, 334+remote_play_offsetY)
+ ;- MISC ----------------------------------------------------------------------------------
+ TokyoPitstop := new TokyoTurnContainer(191, 316+remote_play_offsetY, 580, 383+remote_play_offsetY)
+ TokyoPitstopEnter := new TokyoTurnContainer(530, 70+remote_play_offsetY)
+ TokyoPitstopDone := new TokyoTurnContainer(57, 329+remote_play_offsetY)
+ TokyoRestartRace := new TokyoTurnContainer(405,465+remote_play_offsetY)
+ ;- RACE START ----------------------------------------------------------------------------
+ controller.Axes.LX.SetState(65)
+ Sleep(7400)
+
+ FormatTime, TGTime,, MM/dd hh:mm:ss
+ FileAppend, %TGTime%: Race started.`n, logs.txt
+ url := "https://api.telegram.org/bot" TelegramBotToken "/sendMessage?text=" TGTime ": Race started.&chat_id=" TelegramChatID
+ hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
+ hObject.Open("GET",url)
+ hObject.Send()
+
+ guicontrol,, CurrentLoop, Race started. Good luck!
+ guicontrol,, CurrentLap, Current Lap: %TokyoLapCount% /12
+ Accel_On(100)
+ loop 3 {
+ Press_Triangle(delay:=50)
+ Sleep(200)
+ }
+ Sleep(800)
+ controller.Axes.LX.SetState(65)
+;- 12 LAP LOOP ---------------------------------------------------------------------------
+ loop 12
+ {
+ location := "Start/Finish"
+ guicontrol,, CurrentLoop, Current Location: %location%
+ loopStartTime := A_TickCount
+ ; Turn 1
+ location := "T1 Start"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn1.startX, TokyoTurn1.startY)
+ loop 3 {
+ Press_Triangle(delay:=50)
+ Sleep(200)
+ }
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(36)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ Sleep(1000)
+ location := "T1 End"
+ CheckTokyoTurn(TokyoTurn1.endX, TokyoTurn1.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(35)
+ Sleep(1000)
+ ; Turn 2
+ location := "T2 Start"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn2.startX, TokyoTurn2.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(52)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ Sleep(1000)
+ location := "T2 End"
+ CheckTokyoTurn(TokyoTurn2.endX, TokyoTurn2.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(40)
+ Sleep(1000)
+ ; Turn 3
+ location := "T3 Start"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn3.startX, TokyoTurn3.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ Sleep(1000)
+ controller.Axes.LX.SetState(40)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn3.endX, TokyoTurn3.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(70)
+ Sleep(1000)
+ ; Turn 4
+ location := "T4 Start"
+ Accel_On(85)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn4.startX, TokyoTurn4.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ Sleep(1000)
+ controller.Axes.LX.SetState(68)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn4.endX, TokyoTurn4.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(60)
+ Accel_On(70)
+ Sleep(1000)
+ ; Turn 5
+ location := "T5 Start"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn5.startX, TokyoTurn5.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(42)
+ Sleep(1000)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn5.endX, TokyoTurn5.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(63)
+ Sleep(1000)
+ ; Turn 6
+ location := "T6 Start"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn6.startX, TokyoTurn6.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(70)
+ Sleep(1000)
+ Accel_on(75)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn6.endX, TokyoTurn6.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(40)
+ Sleep(1000)
+ ; Turn 7
+ location := "T7 Start"
+ Accel_On(100)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn7.startX, TokyoTurn7.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(40)
+ Sleep(1000)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn7.endX, TokyoTurn7.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(70)
+ Sleep(1000)
+ ; Turn 8
+ location := "T8 Start"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn8.startX, TokyoTurn8.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(65)
+ Sleep(1000)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn8.endX, TokyoTurn8.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(30)
+ Sleep(2000)
+ Brake_on(100)
+ Sleep(2200)
+ Brake_off()
+ Accel_On(35)
+ ; Penalty Warning 1
+ location := "Hairpin Entrance"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoPen1(TokyoPenWarning.startX, TokyoPenWarning.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ Accel_On(32)
+ controller.Axes.LX.SetState(40)
+ Sleep(1000)
+ ; Hairpin Turn
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ location := "Hairpin Turn"
+ CheckTokyoHairpinTurn(TokyoHairpinTurn.startX, TokyoHairpinTurn.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ Sleep(hairpin_delay)
+ controller.Axes.LX.SetState(100)
+ Sleep(200)
+ Accel_Off()
+ Sleep(4200)
+ Accel_On(45) ;was 40
+ controller.Axes.LX.SetState(60)
+ Accel_Off()
+ Sleep(800)
+ controller.Axes.LX.SetState(40)
+ Accel_On(50)
+ Sleep(5000)
+ controller.Axes.LX.SetState(30)
+ Sleep(5500)
+ Accel_On(80)
+ loop 30 { ; failsafe, if we ever get a reset caused by a cone under the car
+ Press_Triangle(delay:=100)
+ Sleep(200)
+ }
+ ; Penalty Warning 2
+ location := "Hairpin exit"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoPen2(TokyoPen.endX, TokyoPen.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ Sleep(1000)
+ if (TokyoLapCount <= 11)
+ {
+
+ location := "Pit entrance"
+ Accel_On(53)
+ controller.Axes.LX.SetState(30)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoPitstopEnter.startX, TokyoPitstopEnter.startY)
+ controller.Axes.LX.SetState(0)
+ Accel_On(55)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoPitstop1(TokyoPitstop.startX, TokyoPitstop.startY)
+ location := "In pit"
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(50)
+
+ if (TokyoLapCount = 1)
+ {
+ SetFormat, integerfast, d
+ lap01timing := 0
+ location := "In pit: Waiting " lap01timing " Seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (lap01timing)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 2)
+ {
+ SetFormat, integerfast, d
+ lap02timing := 0
+ location := "In pit: Waiting " lap02timing " Seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (lap02timing)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 3)
+ {
+ SetFormat, integerfast, d
+ lap03timing := 0
+ location := "In pit: Waiting " lap03timing " Seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (lap03timing)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 4)
+ {
+ SetFormat, integerfast, d
+ lap04timing := 0
+ location := "In pit: Waiting " lap04timing " Seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (lap04timing)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 5)
+ {
+ SetFormat, integerfast, d
+ lap05timing := 20000
+ location := "In pit: Waiting " lap05timing " Seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (lap05timing)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 6)
+ {
+ SetFormat, integerfast, d
+ lap06timing := 0
+ location := "In pit: Waiting " lap06timing " Seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (lap06timing)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 7)
+ {
+ SetFormat, integerfast, d
+ lap07timing := 0
+ location := "In pit: Waiting " lap07timing " Seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (lap07timing)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 8)
+ {
+ SetFormat, integerfast, d
+ lap08timing := 0
+ location := "In pit: Waiting " lap08timing " Seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (lap08timing)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 9)
+ {
+ SetFormat, integerfast, d
+ lap09timing := 12000
+ location := "In pit: Waiting " lap09timing " Seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (lap09timing)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 10)
+ {
+ SetFormat, integerfast, d
+ lap10timing := 20000
+ location := "In pit: Waiting " lap10timing " Seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (lap10timing)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 11)
+ {
+ SetFormat, integerfast, d
+ lap11timing := 0
+ location := "In pit: Waiting " lap11timing " Seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (lap11timing)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 12)
+ {
+ SetFormat, integerfast, d
+ lap12timing := 0
+ location := "In pit: Waiting " lap12timing " Seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (lap12timing)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ controller.Axes.LX.SetState(20)
+ Accel_On(100)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoPenReceived(TokyoPenServed.startX, TokyoPenServed.startY)
+ location := "Start/Finish"
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(38)
+ Sleep (500)
+ loop 10 {
+ Press_Triangle(delay:=200)
+ sleep, 200
+ }
+ }
+ else {
+ location := "Start/Finish"
+ guicontrol,, CurrentLoop, Current Location: %location%
+ Accel_On(100)
+ controller.Axes.LX.SetState(60)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoPenServed(TokyoPenServed.startX, TokyoPenServed.startY)
+ }
+ SetFormat, integerfast, d
+ TokyoLapCount++
+ guicontrol,, CurrentLap, Current Lap: %TokyoLapCount% /12
+ ProgressRace := (100/13)*TokyoLapCount
+ guicontrol,, RaceProgress, %ProgressRace%
+
+ if(TokyoLapCount = "13")
+ {
+ location := "Finish line"
+
+ FormatTime, TGTime,, MM/dd hh:mm:ss
+ FileAppend, %TGTime% Race finished.`n, logs.txt
+ url := "https://api.telegram.org/bot" TelegramBotToken "/sendMessage?text=" TGTime ": Race finished.&chat_id=" TelegramChatID
+ hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
+ hObject.Open("GET",url)
+ hObject.Send()
+
+ guicontrol,, CurrentLoop, Current Location: %location%
+ guicontrol,, CurrentLap, GG!
+ controller.Axes.LX.SetState(50)
+ SetFormat, integerfast, d
+ racecounter++
+ SetFormat, integerfast, d
+ racecountertotal++
+
+ ; // THIS SESSION
+ SetFormat, integerfast, d
+ SetFormat, FloatFast, 0.2
+ creditcountersession := (835000*racecounter)/1000000
+ SetFormat, integerfast, d
+ SetFormat, FloatFast, 0.2
+ creditavg := creditcountersession/(A_TickCount-script_start)*3600000
+ guicontrol,, RaceCounterSession, Races completed: %racecounter%
+ guicontrol,, ResetCounterSession, Races failed: %resetcounter%
+ guicontrol,, CreditCounterSession, Credits: %creditcountersession% M
+ guicontrol,, CreditAVGSession, Avg./h: %creditavg% M
+
+ ; // ALL TIME
+ SetFormat, integerfast, d
+ SetFormat, FloatFast, 0.2
+ creditcountertotal := (835000*racecountertotal)/1000000
+ IniWrite, %racecountertotal%, config.ini,Stats, RaceCounterTotal
+ IniWrite, %resetcountertotal%, config.ini,Stats, ResetCounterTotal
+ guicontrol,, RaceCounterTotal, Races completed: %racecountertotal%
+ guicontrol,, ResetCounterTotal, Races failed: %resetcountertotal%
+ guicontrol,, CreditCounterTotal, Credits: %creditcountertotal% M
+ UpdateAVG(racecounter, script_start)
+ lapcounter =
+ ProgressRace =
+ guicontrol,, RaceProgress, %ProgressRace%
+ loop
+ {
+ restart_found := false
+ c2 := BitGrab(162, 43+remote_play_offsetY, 2)
+ for i, c in c2
+ {
+ d2 := Distance(c, color_restart)
+ SB_SetText(" Searching... " d2 " < 50",2)
+ if (d2 < 10 )
+ {
+ SB_SetText(" Found: Restart Color",2)
+ restart_found := true
+ break
+ }
+ }
+ if (restart_found)
+ break
+ Press_X()
+ Sleep(500)
+
+ }
+ SB_SetText("Found: Restart Color",2)
+ Sleep(260)
+ Press_O()
+ Sleep(200)
+ Press_Right()
+ Sleep(3000)
+ Press_X()
+ Sleep(4000)
+ Press_X()
+ Sleep(4000)
+ guicontrol,, CurrentLoop, Setting up next race.
+ Press_Options()
+ Sleep(1000)
+ Press_Right()
+ Sleep(500)
+ Press_X()
+ controller.Axes.LX.SetState(50)
+ UpdateAVG(racecounter, script_start)
+ Goto, TokyoStart
+ }
+ }
+}
+EndRace_Tokyo_Def:
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Src/Tokyo/tokyo_car1.png b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Src/Tokyo/tokyo_car1.png
new file mode 100644
index 0000000..57b21c5
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/Src/Tokyo/tokyo_car1.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/config.ini b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/config.ini
new file mode 100644
index 0000000..5ddab7d
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/config.ini differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/logs.txt b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.2/logs.txt
new file mode 100644
index 0000000..e69de29
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Assets/GT7_Tokyo.ico b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Assets/GT7_Tokyo.ico
new file mode 100644
index 0000000..6e4e770
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Assets/GT7_Tokyo.ico differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Assets/tokyo_gui.png b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Assets/tokyo_gui.png
new file mode 100644
index 0000000..97f8acf
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Assets/tokyo_gui.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/GT7_Tokyo.AHK b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/GT7_Tokyo.AHK
new file mode 100644
index 0000000..0d4ebfb
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/GT7_Tokyo.AHK
@@ -0,0 +1,498 @@
+#Persistent
+#NoEnv
+#MaxHotkeysPerInterval 99000000
+#HotkeyInterval 99000000
+#KeyHistory 0
+#Include Lib\Gdip.ahk
+#Include Lib\AHK-ViGEm-Bus.ahk
+#Include Lib\__utility__.ahk
+#Include Lib\__controller_functions__.ahk
+#Include Mod\TokyoDetections.ahk
+#Include Races\Tokyo.ahk
+
+hModule := DllCall("LoadLibrary", "Str", A_LineFile "\..\Lib\SuperSleep.dll", "Ptr")
+SuperSleep := DllCall("GetProcAddress", "Ptr", DllCall("GetModuleHandle", "Str", A_LineFile "\..\Lib\SuperSleep.dll", "Ptr"), "AStr", "super_sleep", "Ptr")
+
+ListLines Off
+Process, Priority, , A
+SetBatchLines, -1
+SetKeyDelay, -1, -1
+SetMouseDelay, -1
+SetDefaultMouseSpeed, 0
+SendMode Input
+
+SetWorkingDir %A_ScriptDir%
+DetectHiddenWindows, On
+#Persistent
+
+Global script_start := A_TickCount
+Global remote_play_offsetY := 71
+Global racecounter := 0
+Global resetcounter := 0
+Global color_pitstop1 := 0xFFFFFF
+Global color_restart := 0x6D5223
+Global hairpin_delay := 0
+Global PitstopTimings := 0
+Global TelegramBotToken := ""
+Global TelegramChatID := ""
+Global location := ""
+Global TokyoLapCount := 1
+Global PitstopTimingsArray :=
+Global DynTurnDelay := 0
+Global SaveResetClip := 0
+SetFormat, integerfast, d
+ps_win_width := 640
+ps_win_height := 360
+IniRead, hairpin_delay, config.ini, Vars, hairpin_delay, 0
+IniRead, color_pitstop1, config.ini, Vars, color_pitstop1, 0
+IniRead, RaceCounterTotal, config.ini, Stats, racecountertotal, 0
+IniRead, ResetCounterTotal, config.ini, Stats, resetcountertotal, 0
+IniRead, TelegramBotToken, config.ini, API, TelegramBotToken, 0
+IniRead, TelegramChatID, config.ini, API, TelegramChatID, 0
+IniRead, PitstopTimings, config.ini, Vars, PitStopTimings0, 0
+StringSplit, PitstopTimingsArray, PitstopTimings, `,
+
+IniRead, DynTurnDelay, config.ini, Vars, DynTurnDelay, 0
+IniRead, SaveResetClip, config.ini, Vars, SaveResetClip, 0
+
+
+SetFormat, FloatFast, 0.2
+creditcountertotal := 835000*racecountertotal/1000000
+StringSplit, PitstopTimingsArray, PitstopTimings, `,
+
+Global controller := new ViGEmDS4()
+controller.SubscribeFeedback(Func("OnFeedback"))
+OnFeedback(largeMotor, smallMotor, lightbarColor){
+}
+
+;- GUI 1 (MAIN) -------------------------------------------------------------------------------------------------
+Icon = Assets\GT7_Tokyo.ico
+Menu, Tray, Icon, %Icon%
+Gui, -Caption
+Gui, Add, Picture, x0 y0 w650 h207 , Assets\tokyo_gui.png
+Gui, Add, Button, x222 y82 w410 h80 default gButtonStart, START
+Gui, Add, Progress, x0 y54 w641 h12 RaceProgress vRaceProgress -Smooth, 0
+Gui, Font, S8 CDefault Bold, Verdana
+Gui, Add, Text, x440 y3 w160 h20 RaceCounterTotal +BackgroundTrans, // ALL TIME
+Gui, Font, ,
+Gui, Add, Text, x440 y23 w160 h20 RaceCounterTotal vracecountertotal +BackgroundTrans, Races completed: %racecountertotal%
+Gui, Add, Text, x440 y38 w160 h20 ResetCounterTotal vresetcountertotal +BackgroundTrans, Races failed: %resetcountertotal%
+Gui, Add, Text, x550 y38 w160 h20 CreditCounterTotal vcreditcountertotal +BackgroundTrans, Credits: %creditcountertotal% M
+Gui, Font, S8 CDefault Bold, Verdana
+Gui, Add, Text, x220 y3 w300 h20 RaceSession vracesession +BackgroundTrans, // SESSION
+Gui, Font, ,
+Gui, Add, Text, x220 y23 w160 h20 RaceCounterSession vracecountersession +BackgroundTrans, Races completed: 0
+Gui, Add, Text, x220 y38 w160 h20 ResetCounterSession vresetcountersession +BackgroundTrans, Races failed: 0
+Gui, Add, Text, x330 y23 w160 h20 CreditCounterSession vcreditcountersession +BackgroundTrans, Credits: 0
+Gui, Add, Text, x330 y38 w160 h20 CreditAVG vcreditavg +BackgroundTrans, Avg./h: 0
+Gui, Add, Text, x10 y38 w150 h20 CounterLap vcurrentlap +BackgroundTrans, Current Lap: 0/12
+Gui, Add, Text, x10 y23 w220 h20 CurrentLoop vcurrentloop +BackgroundTrans, Current Location: -
+Gui, Add, Button, x222 y172 w300 h20 default gGUIReset, Reset
+Gui, Add, Button, x531 y172 w101 h20 default gGUIClose, Exit
+Gui, Add, Button, x12 y82 w200 h20 default gRaceSettingsWindow, Settings: Race
+Gui, Add, Button, x12 y112 w200 h20 default gMachineSettingsWindow, Settings: Machine/Setup
+Gui, Add, Button, x12 y142 w200 h20 default gIngameSettingsWindow, Settings: Ingame (wip)
+Gui, Add, Button, x12 y172 w200 h20 default gNotificationsWindow, Settings: Notifications/API
+Gui, Font, S8 CDefault Bold, Verdana
+Gui, Add, Text, x10 y3 w620 h20 +BackgroundTrans, // TOKYO CONTROL CENTER
+Gui, Add, Statusbar, -Theme Backgroundeeeeee ;#eeeeee, no typo
+SB_SetParts(80,270,190)
+SB_SetText(" beta 9.4 ",1)
+SB_SetText(" by problemz.",4)
+Gui, Show, x8 y532 h225 w640, GT7 Tokyo // by problemz
+guicontrol,, CurrentLoop, Press START, go go!
+;- GUI 2 (MACHINE/SETUP) ----------------------------------------------------------------------------------------
+;Gui, 2: Add, Picture, x0 y0 w650 h500 , Assets\tokyo_gui.png
+Gui, 2: Add, Text, x10 y14 w200 h20 +BackgroundTrans , Hairpin Turn Delay:
+Gui, 2: Add, Text, x170 y14 w200 h20 +BackgroundTrans , (ms)
+Gui, 2: Add, Slider, x220 y10 w300 h51 vsliderhairpindelay Range0-800 Thick40 +ToolTip TickInterval50 gSliderMove,%hairpin_delay%
+Gui, 2: Add, Edit, x106 y11 w60 vtxthairpindelay gtextchanged, %hairpin_delay%
+Gui, 2: Add, Text, x10 y40 w200 h20 +BackgroundTrans , Lower = slower PC // Higher = faster PC
+Gui, 2: Add, Button, x530 y11 w100 h73 +BackgroundTrans gSaveToIni, Save
+Gui, 2: Add, Button, x10 y103 w200 h40 gPit1Color, Stuck in pit `n(Only click when at tire selection menu)
+Gui, 2: Add, Checkbox, x320 y110 w300 gDynTurnDelay vDynTurnDelay +BackgroundTrans Checkbox Checked%DynTurnDelay%, Experimental: Use dynamic hairpin turn delays.
+Gui, 2: Add, Checkbox, x320 y130 w300 gSaveResetClip vSaveResetClip +BackgroundTrans Checkbox Checked%SaveResetClip%, Experimental: Save clip (past 3 minutes) after a reset.
+
+;- GUI 3 (INGAME) -----------------------------------------------------------------------------------------------
+;Gui, 3: Add, Picture, x0 y0 w650 h177 , Assets\tokyo_gui.png
+;- GUI 4 (RACE SETTINGS) ----------------------------------------------------------------------------------------
+;Gui, 4: Add, Picture, x0 y0 w650 h450 , Assets\tokyo_gui.png
+Gui, 4: Font, S8 CDefault Bold, Verdana
+Gui, 4: Add, Text, x220 y20 w200 h20 vFightme +gFightMe +BackgroundTrans , ლ(`ー´ლ)
+Gui, 4: Add, Text, x30 y10 w200 h50 +BackgroundTrans vPitstopText , Pit stop wait timers in ms`n(Read-only):
+Gui, 4: Font, ,
+Gui, 4: Add, Text, xp yp+40 w100 h20 +BackgroundTrans , Lap 1:
+Gui, 4: Add, Edit, +ReadOnly xp+40 yp-3 w50 vNewPitstopTimingsArray1, %PitstopTimingsArray1%
+Gui, 4: Add, Text, xp+60 yp+3 w100 h20 +BackgroundTrans , Lap 2:
+Gui, 4: Add, Edit, +ReadOnly xp+40 yp-3 w50 vNewPitstopTimingsArray2, %PitstopTimingsArray2%
+Gui, 4: Add, Text, xp+60 yp+3 w100 h20 +BackgroundTrans , Lap 3:
+Gui, 4: Add, Edit, +ReadOnly xp+40 yp-3 w50 vNewPitstopTimingsArray3, %PitstopTimingsArray3%
+Gui, 4: Add, Text, xp+60 yp+3 w100 h20 +BackgroundTrans , Lap 4:
+Gui, 4: Add, Edit, +ReadOnly xp+40 yp-3 w50 vNewPitstopTimingsArray4, %PitstopTimingsArray4%
+Gui, 4: Add, Text, xp+60 yp+3 w100 h20 +BackgroundTrans , Lap 5:
+Gui, 4: Add, Edit, +ReadOnly xp+40 yp-3 w50 vNewPitstopTimingsArray5, %PitstopTimingsArray5%
+Gui, 4: Add, Text, xp+60 yp+3 w100 h20 +BackgroundTrans , Lap 6:
+Gui, 4: Add, Edit, +ReadOnly xp+40 yp-3 w50 vNewPitstopTimingsArray6, %PitstopTimingsArray6%
+Gui, 4: Add, Text, xp-540 yp+30 w100 h20 +BackgroundTrans , Lap 7:
+Gui, 4: Add, Edit, +ReadOnly xp+40 yp-3 w50 vNewPitstopTimingsArray7, %PitstopTimingsArray7%
+Gui, 4: Add, Text, xp+60 yp+3 w100 h20 +BackgroundTrans , Lap 8:
+Gui, 4: Add, Edit, +ReadOnly xp+40 yp-3 w50 vNewPitstopTimingsArray8, %PitstopTimingsArray8%
+Gui, 4: Add, Text, xp+60 yp+3 w100 h20 +BackgroundTrans , Lap 9:
+Gui, 4: Add, Edit, +ReadOnly xp+40 yp-3 w50 vNewPitstopTimingsArray9, %PitstopTimingsArray9%
+Gui, 4: Add, Text, xp+60 yp+3 w100 h20 +BackgroundTrans , Lap 10:
+Gui, 4: Add, Edit, +ReadOnly xp+40 yp-3 w50 vNewPitstopTimingsArray10, %PitstopTimingsArray10%
+Gui, 4: Add, Text, xp+60 yp+3 w100 h20 +BackgroundTrans , Lap 11:
+Gui, 4: Add, Edit, +ReadOnly xp+40 yp-3 w50 vNewPitstopTimingsArray11, %PitstopTimingsArray11%
+Gui, 4: Add, Text, xp+60 yp+3 w100 h20 +BackgroundTrans , Lap 12:
+Gui, 4: Add, Edit, +ReadOnly xp+40 yp-3 w50 vNewPitstopTimingsArray12, %PitstopTimingsArray12%
+Gui, 4: Add, Button, +hidden xp-540 yp+30 w590 h25 vNewPitstopTimingsButton gSaveNewTimings, Save pit stop timings
+Gui, 4: Font, S8 CDefault Bold, Verdana
+Gui, 4: Add, Text, x370 y10 w120 h20 +BackgroundTrans , Select Race pace:
+Gui, 4: Font, ,
+Gui, 4: Add, DropDownList, xp+125 yp-3 w125 vRacePaceChoice gRacePaceChoice, Select to change||Safe (slower)|Risky (faster)
+Gui, 4: Add, Button, +hidden x230 yp+10 w120 h25 vLoadDevTimings gLoadDevTimings, Load last dev timings
+
+;- GUI 5 (NOTIFICATIONS/API) ------------------------------------------------------------------------------------
+;Gui, 5: Add, Picture, x0 y0 w650 h400 , Assets\tokyo_gui.png
+Gui, 5: Add, Text, x10 y14 w205 h20 +BackgroundTrans , Telegram Bot Token:
+Gui, 5: Add, Edit, x116 y11 w400 vTelegramBotToken Password, %TelegramBotToken%
+Gui, 5: Add, Text, x10 y44 w205 h20 +BackgroundTrans , Telegram Chat ID:
+Gui, 5: Add, Edit, x116 y41 w400 vTelegramChatID Password, %TelegramChatID%
+Gui, 5: Add, Button, x530 y11 w100 h51 +BackgroundTrans gSaveToIni, Save
+Return
+
+DynTurnDelay:
+return
+
+SaveResetClip:
+return
+
+MachineSettingsWindow:
+
+if (GetKeyState("LShift", "P") AND GetKeyState("LAlt", "P")){
+ goto, MouseColor
+ }
+ else{
+ Gui, 2: Show, x6 y757 w639 h150, Settings: Machine/Setup
+ }
+return
+
+IngameSettingsWindow:
+ Gui, 3: Show, x6 y757 w639 h35, Settings: Ingame
+return
+
+RaceSettingsWindow:
+ Gui, 4: Show, x6 y757 w639 h140, Settings: Race
+return
+
+NotificationsWindow:
+ Gui, 5: Show, x6 y757 w639 h70, Settings: Notifications/API
+return
+
+SliderMove:
+Gui, Submit, nohide
+GuiControl,, txthairpindelay, %sliderhairpindelay%
+Return
+
+SaveToIni:
+ Gui, Submit, Hide
+ IniWrite, %txthairpindelay%, config.ini,Vars, hairpin_delay
+ IniWrite, %TelegramBotToken%, config.ini,API, TelegramBotToken
+ IniWrite, %TelegramChatID%, config.ini,API, TelegramChatID
+ GuiControlGet, DynTurnDelay,,DynTurnDelay
+ IniWrite, %DynTurnDelay%, config.ini,VARS, DynTurnDelay
+ GuiControlGet, SaveResetClip,,SaveResetClip
+IniWrite, %SaveResetClip%, config.ini,VARS, SaveResetClip
+return
+
+SaveNewTimings:
+ MsgBox, 4,, Do you really wanna save new pitstop timings?
+ IfMsgBox Yes
+ {
+ Gui, Submit, NoHide
+ NewPitStopTimings = %NewPitstopTimingsArray1%`,%NewPitstopTimingsArray2%`,%NewPitstopTimingsArray3%`,%NewPitstopTimingsArray4%`,%NewPitstopTimingsArray5%`,%NewPitstopTimingsArray6%`,%NewPitstopTimingsArray7%`,%NewPitstopTimingsArray8%`,%NewPitstopTimingsArray9%`,%NewPitstopTimingsArray10%`,%NewPitstopTimingsArray11%`,%NewPitstopTimingsArray12%
+ IniWrite, %NewPitStopTimings%, config.ini,VARS, PitStopTimings0
+ IniWrite, %NewPitStopTimings%, config.ini,VARS, PitStopTimings99
+ IniRead, PitstopTimings, config.ini, Vars, PitStopTimings0, 0
+ StringSplit, PitstopTimingsArray, PitstopTimings, `,
+ }
+return
+
+
+RacePaceChoice:
+Gui, Submit, NoHide
+If (RacePaceChoice = "Safe (slower)")
+ IniRead, PitstopTimings, config.ini, Vars, PitStopTimings1, 0
+ IniWrite, %PitstopTimings%, config.ini,VARS, PitStopTimings0
+ IniRead, PitstopTimings, config.ini, Vars, PitStopTimings0, 0
+ StringSplit, PitstopTimingsArray, PitstopTimings, `,
+ guicontrol,, NewPitstopTimingsArray1, %PitstopTimingsArray1%
+ guicontrol,, NewPitstopTimingsArray2, %PitstopTimingsArray2%
+ guicontrol,, NewPitstopTimingsArray3, %PitstopTimingsArray3%
+ guicontrol,, NewPitstopTimingsArray4, %PitstopTimingsArray4%
+ guicontrol,, NewPitstopTimingsArray5, %PitstopTimingsArray5%
+ guicontrol,, NewPitstopTimingsArray6, %PitstopTimingsArray6%
+ guicontrol,, NewPitstopTimingsArray7, %PitstopTimingsArray7%
+ guicontrol,, NewPitstopTimingsArray8, %PitstopTimingsArray8%
+ guicontrol,, NewPitstopTimingsArray9, %PitstopTimingsArray9%
+ guicontrol,, NewPitstopTimingsArray10, %PitstopTimingsArray10%
+ guicontrol,, NewPitstopTimingsArray11, %PitstopTimingsArray11%
+ guicontrol,, NewPitstopTimingsArray11, %PitstopTimingsArray11%
+
+If (RacePaceChoice = "Risky (faster)")
+ IniRead, PitstopTimings, config.ini, Vars, PitStopTimings2, 0
+ IniWrite, %PitstopTimings%, config.ini,VARS, PitStopTimings0
+ IniRead, PitstopTimings, config.ini, Vars, PitStopTimings0, 0
+ StringSplit, PitstopTimingsArray, PitstopTimings, `,
+ guicontrol,, NewPitstopTimingsArray1, %PitstopTimingsArray1%
+ guicontrol,, NewPitstopTimingsArray2, %PitstopTimingsArray2%
+ guicontrol,, NewPitstopTimingsArray3, %PitstopTimingsArray3%
+ guicontrol,, NewPitstopTimingsArray4, %PitstopTimingsArray4%
+ guicontrol,, NewPitstopTimingsArray5, %PitstopTimingsArray5%
+ guicontrol,, NewPitstopTimingsArray6, %PitstopTimingsArray6%
+ guicontrol,, NewPitstopTimingsArray7, %PitstopTimingsArray7%
+ guicontrol,, NewPitstopTimingsArray8, %PitstopTimingsArray8%
+ guicontrol,, NewPitstopTimingsArray9, %PitstopTimingsArray9%
+ guicontrol,, NewPitstopTimingsArray10, %PitstopTimingsArray10%
+ guicontrol,, NewPitstopTimingsArray11, %PitstopTimingsArray11%
+ guicontrol,, NewPitstopTimingsArray11, %PitstopTimingsArray11%
+return
+
+TextChanged:
+ guiControlGet, txtvar,, txthairpindelay
+ if (txtvar > 800)
+ {
+ GuiControl,, txthairpindelay, 800
+ }
+
+ GuiControl,, sliderhairpindelay, %txtvar%
+ return
+
+Pit1Color:
+ MsgBox, 4,, Do you really wanna set a new Pitstop color?
+ IfMsgBox Yes
+ {
+ gosub, GrabRemotePlay
+ color_pitstop1 := PixelColorSimple(199, 315+remote_play_offsetY)
+ IniWrite, %color_pitstop1%, config.ini,Vars, color_pitstop1
+ }
+ return
+
+ButtonStart:
+ SetTimer, UpdateTimer, 1000
+ Gui, Submit, NoHide
+ id := ""
+ SetKeyDelay, 10
+ Process, priority, , High
+ gosub, GrabRemotePlay
+ if (id = "")
+ return
+ gosub, PauseLoop
+ CoordMode, Pixel, Screen
+ CoordMode, ToolTip, Screen
+ loop {
+ Press_X()
+ Race_Tokyo()
+ }
+
+PixelTuning:
+ x_ratio := ps_win_width/640
+ y_ratio := ps_win_height/360
+return
+
+GrabRemotePlay:
+ WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
+ if (remotePlay_id = 0)
+ {
+ MsgBox, PS4 Remote Play not found
+ return
+ }
+ Loop, %remotePlay_id%
+ {
+ id := remotePlay_id%A_Index%
+ WinGetTitle, title, % "ahk_id " id
+ If InStr(title, "PS Remote Play")
+ break
+ }
+ WinMove, ahk_id %id%,, 0, 0, 640, 540
+
+ ControlFocus,, ahk_class %remotePlay_class%
+ WinActivate, ahk_id %id%
+ GetClientSize(remotePlay_id5, ps_win_width, ps_win_height)
+ gosub, PixelTuning
+return
+
+FightMe:
+if (A_GuiEvent = "DoubleClick")
+{
+ guicontrol, -readonly, NewPitstopTimingsArray1
+ guicontrol, -readonly, NewPitstopTimingsArray2
+ guicontrol, -readonly, NewPitstopTimingsArray3
+ guicontrol, -readonly, NewPitstopTimingsArray4
+ guicontrol, -readonly, NewPitstopTimingsArray5
+ guicontrol, -readonly, NewPitstopTimingsArray6
+ guicontrol, -readonly, NewPitstopTimingsArray7
+ guicontrol, -readonly, NewPitstopTimingsArray8
+ guicontrol, -readonly, NewPitstopTimingsArray9
+ guicontrol, -readonly, NewPitstopTimingsArray10
+ guicontrol, -readonly, NewPitstopTimingsArray11
+ guicontrol, -readonly, NewPitstopTimingsArray12
+ guicontrol, -hidden, NewPitstopTimingsButton
+ guicontrol, -hidden, LoadDevTimings
+ guicontrol,, PitstopText, Pit stop wait timers in ms`ndevmode unlocked ლ(`ー´ლ):
+ guicontrol, +hidden, FightMe
+}
+return
+
+LoadDevTimings:
+ IniRead, PitstopTimings, config.ini, Vars, PitStopTimings99, 0
+ StringSplit, PitstopTimingsArray, PitstopTimings, `,
+ guicontrol,, NewPitstopTimingsArray1, %PitstopTimingsArray1%
+ guicontrol,, NewPitstopTimingsArray2, %PitstopTimingsArray2%
+ guicontrol,, NewPitstopTimingsArray3, %PitstopTimingsArray3%
+ guicontrol,, NewPitstopTimingsArray4, %PitstopTimingsArray4%
+ guicontrol,, NewPitstopTimingsArray5, %PitstopTimingsArray5%
+ guicontrol,, NewPitstopTimingsArray6, %PitstopTimingsArray6%
+ guicontrol,, NewPitstopTimingsArray7, %PitstopTimingsArray7%
+ guicontrol,, NewPitstopTimingsArray8, %PitstopTimingsArray8%
+ guicontrol,, NewPitstopTimingsArray9, %PitstopTimingsArray9%
+ guicontrol,, NewPitstopTimingsArray10, %PitstopTimingsArray10%
+ guicontrol,, NewPitstopTimingsArray11, %PitstopTimingsArray11%
+ guicontrol,, NewPitstopTimingsArray11, %PitstopTimingsArray11%
+return
+
+PauseLoop:
+ controller.Buttons.Cross.SetState(false)
+ controller.Buttons.Square.SetState(false)
+ controller.Buttons.Triangle.SetState(false)
+ controller.Buttons.Circle.SetState(false)
+ controller.Buttons.L1.SetState(false)
+ controller.Buttons.L2.SetState(false)
+ controller.Axes.L2.SetState(0)
+ controller.Buttons.R1.SetState(false)
+ controller.Buttons.R2.SetState(false)
+ controller.Axes.R2.SetState(0)
+ controller.Buttons.RS.SetState(false)
+ controller.Axes.RX.SetState(50)
+ controller.Axes.RY.SetState(50)
+ controller.Buttons.LS.SetState(false)
+ controller.Axes.LX.SetState(50)
+ controller.Axes.LY.SetState(50)
+ controller.Dpad.SetState("None")
+return
+
+ResetRace:
+
+
+
+ SB_SetText(" - RESET INITIATED -",2)
+ guicontrol,, CurrentLoop, Something went wrong, reseting.
+ controller.Axes.LX.SetState(50)
+
+ if(SaveResetClip)
+ {
+ FormatTime, TGTime,, MM/dd hh:mm:ss
+ FileAppend, %TGTime%: Race failed - Lap %TokyoLapCount% - %location% - Clip saved.`n, log.txt
+ url := "https://api.telegram.org/bot" TelegramBotToken "/sendMessage?text=" TGTime ": Race failed - Lap " TokyoLapCount " - " location ". Clip saved.&chat_id=" TelegramChatID
+ hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
+ hObject.Open("GET",url)
+ hObject.Send()
+ SB_SetText(" Saving clip (past 3 minutes)...",2)
+ Sleep(500)
+ PressShare()
+ Sleep(1000)
+ Press_Left()
+ Sleep(200)
+ Press_X()
+ Sleep(200)
+ Press_X()
+ Sleep(200)
+ Press_Down()
+ Sleep(200)
+ Press_Down()
+ Sleep(200)
+ Press_Down()
+ Sleep(200)
+ Press_X()
+ Sleep(1000)
+ PressShare()
+ Sleep(1000)
+ Press_O()
+ Sleep(200)
+ Press_Right()
+ Sleep(200)
+ Press_X()
+ }
+ else {
+ FormatTime, TGTime,, MM/dd hh:mm:ss
+ FileAppend, %TGTime%: Race failed - Lap %TokyoLapCount% - %location%.`n, log.txt
+ url := "https://api.telegram.org/bot" TelegramBotToken "/sendMessage?text=" TGTime ": Race failed - Lap " TokyoLapCount " - " location ". Clip saved.&chat_id=" TelegramChatID
+ hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
+ hObject.Open("GET",url)
+ hObject.Send()
+ SB_SetText(" Saving clip (past 3 minutes)...",2)
+ Sleep(500)
+ Press_Options()
+ Sleep(1000)
+ Press_Right()
+ Sleep(500)
+ Press_X()
+ }
+ controller.Axes.LX.SetState(65)
+ IniRead, ResetCounterTotal, config.ini, Stats, resetcountertotal, 0
+ SetFormat, integerfast, d
+ resetcounter++
+ resetcountertotal++
+ IniWrite, %resetcountertotal%, config.ini,Stats, ResetCounterTotal
+ guicontrol,, ResetCounterTotal, Races failed: %resetcountertotal%
+ guicontrol,, ResetCounterSession, Races failed: %resetcounter%
+ guicontrol,, RaceProgress, 0
+ Race_Tokyo()
+ return
+
+
+MouseHelp:
+
+ coord=relative
+ sleep, 1000
+ CoordMode, ToolTip, %coord%
+ CoordMode, Pixel, %coord%
+ CoordMode, Mouse, %coord%
+ CoordMode, Caret, %coord%
+ CoordMode, Menu, %coord%
+return
+
+Refresh:
+ MouseGetPos, x, y
+ PixelGetColor, cBGR, %x%, %y%,, Alt RGB
+ WinGetPos,,, w, h, A
+ ToolTip,Location: %x% x %y%`nRGB: %cBGR%`nWindow Size: %w% x %h%
+return
+
+MouseColor:
+ gosub, MouseHelp
+ SetTimer, Refresh, 75
+return
+
+GuiClose:
+ gosub, PauseLoop
+ExitApp
+^Esc::ExitApp
+
+GUIReset:
+if (GetKeyState("LShift", "P") AND GetKeyState("LAlt", "P")){
+ MsgBox, 4,, Reset all data?
+ IfMsgBox Yes
+ {
+ IniWrite, 0, config.ini,Stats, RaceCounterTotal
+ IniWrite, 0, config.ini,Stats, ResetCounterTotal
+ }
+}
+Sleep(500)
+gosub, PauseLoop
+Reload
+
+
+
+
+
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/AHK-ViGEm-Bus.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/AHK-ViGEm-Bus.ahk
new file mode 100644
index 0000000..858cb3d
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/AHK-ViGEm-Bus.ahk
@@ -0,0 +1,211 @@
+#include %A_LineFile%\..\CLR.ahk
+
+; Static class, holds ViGEm Client instance
+class ViGEmWrapper {
+ static asm := 0
+ static client := 0
+
+ Init(){
+ if (this.client == 0){
+ this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
+ }
+ }
+
+ CreateInstance(cls){
+ return this.asm.CreateInstance(cls)
+ }
+
+}
+
+; Base class for ViGEm "Targets" (Controller types - eg xb360 / ds4) to inherit from
+class ViGEmTarget {
+ target := 0
+ helperClass := ""
+ controllerClass := ""
+
+ __New(){
+ ;~ this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
+ ViGEmWrapper.Init()
+ this.Instance := ViGEmWrapper.CreateInstance(this.helperClass)
+
+ if (this.Instance.OkCheck() != "OK"){
+ msgbox ViGEmWrapper.dll failed to load!
+ ExitApp
+ }
+ }
+
+ SendReport(){
+ this.Instance.SendReport()
+ }
+
+ SubscribeFeedback(callback){
+ this.Instance.SubscribeFeedback(callback)
+ }
+}
+
+; DS4 (DualShock 4 for Playstation 4)
+class ViGEmDS4 extends ViGEmTarget {
+ helperClass := "ViGEmWrapper.Ds4"
+ __New(){
+ static buttons := {Square: 16, Cross: 32, Circle: 64, Triangle: 128, L1: 256, R1: 512, L2: 1024, R2: 2048
+ , Share: 4096, Options: 8192, LS: 16384, RS: 32768 }
+ static specialButtons := {Ps: 1, TouchPad: 2}
+ static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
+
+ this.Buttons := {}
+ for name, id in buttons {
+ this.Buttons[name] := new this._ButtonHelper(this, id)
+ }
+ for name, id in specialButtons {
+ this.Buttons[name] := new this._SpecialButtonHelper(this, id)
+ }
+
+ this.Axes := {}
+ for name, id in axes {
+ this.Axes[name] := new this._AxisHelper(this, id)
+ }
+
+ this.Dpad := new this._DpadHelper(this)
+ base.__New()
+ }
+
+ class _ButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _SpecialButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetSpecialButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _AxisHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+
+ ConvertAxis(state){
+ return round(state * 2.55)
+ }
+ }
+
+ class _DpadHelper {
+ __New(parent){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ static dPadDirections := {Up: 0, UpRight: 1, Right: 2, DownRight: 3, Down: 4, DownLeft: 5, Left: 6, UpLeft: 7, None: 8}
+ this._Parent.Instance.SetDpadState(dPadDirections[state])
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+}
+
+; Xb360
+class ViGEmXb360 extends ViGEmTarget {
+ helperClass := "ViGEmWrapper.Xb360"
+ __New(){
+ static buttons := {A: 4096, B: 8192, X: 16384, Y: 32768, LB: 256, RB: 512, LS: 64, RS: 128, Back: 32, Start: 16, Xbox: 1024}
+ static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
+
+ this.Buttons := {}
+ for name, id in buttons {
+ this.Buttons[name] := new this._ButtonHelper(this, id)
+ }
+
+ this.Axes := {}
+ for name, id in axes {
+ this.Axes[name] := new this._AxisHelper(this, id)
+ }
+
+ this.Dpad := new this._DpadHelper(this)
+
+ base.__New()
+ }
+
+ class _ButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _AxisHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
+ this._Parent.Instance.SendReport()
+ }
+
+ ConvertAxis(state){
+ value := round((state * 655.36) - 32768)
+ if (value == 32768)
+ return 32767
+ return value
+ }
+ }
+
+ class _DpadHelper {
+ _DpadStates := {1:0, 8:0, 2:0, 4:0} ; Up, Right, Down, Left
+ __New(parent){
+ this._Parent := parent
+ }
+
+ SetState(state){
+ static dpadDirections := { None: {1:0, 8:0, 2:0, 4:0}
+ , Up: {1:1, 8:0, 2:0, 4:0}
+ , UpRight: {1:1, 8:1, 2:0, 4:0}
+ , Right: {1:0, 8:1, 2:0, 4:0}
+ , DownRight: {1:0, 8:1, 2:1, 4:0}
+ , Down: {1:0, 8:0, 2:1, 4:0}
+ , DownLeft: {1:0, 8:0, 2:1, 4:1}
+ , Left: {1:0, 8:0, 2:0, 4:1}
+ , UpLeft: {1:1, 8:0, 2:0, 4:1}}
+ newStates := dpadDirections[state]
+ for id, newState in newStates {
+ oldState := this._DpadStates[id]
+ if (oldState != newState){
+ this._DpadStates[id] := newState
+ this._Parent.Instance.SetButtonState(id, newState)
+ }
+ this._Parent.SendReport()
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/CLR.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/CLR.ahk
new file mode 100644
index 0000000..d16ab68
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/CLR.ahk
@@ -0,0 +1,151 @@
+; ==========================================================
+; .NET Framework Interop
+; https://autohotkey.com/boards/viewtopic.php?t=4633
+; ==========================================================
+;
+; Author: Lexikos
+; Version: 1.2
+; Requires: AutoHotkey_L v1.0.96+
+;
+
+CLR_LoadLibrary(AssemblyName, AppDomain=0)
+{
+ if !AppDomain
+ AppDomain := CLR_GetDefaultDomain()
+ e := ComObjError(0)
+ Loop 1 {
+ if assembly := AppDomain.Load_2(AssemblyName)
+ break
+ static null := ComObject(13,0)
+ args := ComObjArray(0xC, 1), args[0] := AssemblyName
+ typeofAssembly := AppDomain.GetType().Assembly.GetType()
+ if assembly := typeofAssembly.InvokeMember_3("LoadWithPartialName", 0x158, null, null, args)
+ break
+ if assembly := typeofAssembly.InvokeMember_3("LoadFrom", 0x158, null, null, args)
+ break
+ }
+ ComObjError(e)
+ return assembly
+}
+
+CLR_CreateObject(Assembly, TypeName, Args*)
+{
+ if !(argCount := Args.MaxIndex())
+ return Assembly.CreateInstance_2(TypeName, true)
+
+ vargs := ComObjArray(0xC, argCount)
+ Loop % argCount
+ vargs[A_Index-1] := Args[A_Index]
+
+ static Array_Empty := ComObjArray(0xC,0), null := ComObject(13,0)
+
+ return Assembly.CreateInstance_3(TypeName, true, 0, null, vargs, null, Array_Empty)
+}
+
+CLR_CompileC#(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
+{
+ return CLR_CompileAssembly(Code, References, "System", "Microsoft.CSharp.CSharpCodeProvider", AppDomain, FileName, CompilerOptions)
+}
+
+CLR_CompileVB(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
+{
+ return CLR_CompileAssembly(Code, References, "System", "Microsoft.VisualBasic.VBCodeProvider", AppDomain, FileName, CompilerOptions)
+}
+
+CLR_StartDomain(ByRef AppDomain, BaseDirectory="")
+{
+ static null := ComObject(13,0)
+ args := ComObjArray(0xC, 5), args[0] := "", args[2] := BaseDirectory, args[4] := ComObject(0xB,false)
+ AppDomain := CLR_GetDefaultDomain().GetType().InvokeMember_3("CreateDomain", 0x158, null, null, args)
+ return A_LastError >= 0
+}
+
+CLR_StopDomain(ByRef AppDomain)
+{ ; ICorRuntimeHost::UnloadDomain
+ DllCall("SetLastError", "uint", hr := DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+20*A_PtrSize), "ptr", RtHst, "ptr", ComObjValue(AppDomain))), AppDomain := ""
+ return hr >= 0
+}
+
+; NOTE: IT IS NOT NECESSARY TO CALL THIS FUNCTION unless you need to load a specific version.
+CLR_Start(Version="") ; returns ICorRuntimeHost*
+{
+ static RtHst := 0
+ ; The simple method gives no control over versioning, and seems to load .NET v2 even when v4 is present:
+ ; return RtHst ? RtHst : (RtHst:=COM_CreateObject("CLRMetaData.CorRuntimeHost","{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}"), DllCall(NumGet(NumGet(RtHst+0)+40),"uint",RtHst))
+ if RtHst
+ return RtHst
+ EnvGet SystemRoot, SystemRoot
+ if Version =
+ Loop % SystemRoot "\Microsoft.NET\Framework" (A_PtrSize=8?"64":"") "\*", 2
+ if (FileExist(A_LoopFileFullPath "\mscorlib.dll") && A_LoopFileName > Version)
+ Version := A_LoopFileName
+ if DllCall("mscoree\CorBindToRuntimeEx", "wstr", Version, "ptr", 0, "uint", 0
+ , "ptr", CLR_GUID(CLSID_CorRuntimeHost, "{CB2F6723-AB3A-11D2-9C40-00C04FA30A3E}")
+ , "ptr", CLR_GUID(IID_ICorRuntimeHost, "{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}")
+ , "ptr*", RtHst) >= 0
+ DllCall(NumGet(NumGet(RtHst+0)+10*A_PtrSize), "ptr", RtHst) ; Start
+ return RtHst
+}
+
+;
+; INTERNAL FUNCTIONS
+;
+
+CLR_GetDefaultDomain()
+{
+ static defaultDomain := 0
+ if !defaultDomain
+ { ; ICorRuntimeHost::GetDefaultDomain
+ if DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+13*A_PtrSize), "ptr", RtHst, "ptr*", p:=0) >= 0
+ defaultDomain := ComObject(p), ObjRelease(p)
+ }
+ return defaultDomain
+}
+
+CLR_CompileAssembly(Code, References, ProviderAssembly, ProviderType, AppDomain=0, FileName="", CompilerOptions="")
+{
+ if !AppDomain
+ AppDomain := CLR_GetDefaultDomain()
+
+ if !(asmProvider := CLR_LoadLibrary(ProviderAssembly, AppDomain))
+ || !(codeProvider := asmProvider.CreateInstance(ProviderType))
+ || !(codeCompiler := codeProvider.CreateCompiler())
+ return 0
+
+ if !(asmSystem := (ProviderAssembly="System") ? asmProvider : CLR_LoadLibrary("System", AppDomain))
+ return 0
+
+ ; Convert | delimited list of references into an array.
+ StringSplit, Refs, References, |, %A_Space%%A_Tab%
+ aRefs := ComObjArray(8, Refs0)
+ Loop % Refs0
+ aRefs[A_Index-1] := Refs%A_Index%
+
+ ; Set parameters for compiler.
+ prms := CLR_CreateObject(asmSystem, "System.CodeDom.Compiler.CompilerParameters", aRefs)
+ , prms.OutputAssembly := FileName
+ , prms.GenerateInMemory := FileName=""
+ , prms.GenerateExecutable := SubStr(FileName,-3)=".exe"
+ , prms.CompilerOptions := CompilerOptions
+ , prms.IncludeDebugInformation := true
+
+ ; Compile!
+ compilerRes := codeCompiler.CompileAssemblyFromSource(prms, Code)
+
+ if error_count := (errors := compilerRes.Errors).Count
+ {
+ error_text := ""
+ Loop % error_count
+ error_text .= ((e := errors.Item[A_Index-1]).IsWarning ? "Warning " : "Error ") . e.ErrorNumber " on line " e.Line ": " e.ErrorText "`n`n"
+ MsgBox, 16, Compilation Failed, %error_text%
+ return 0
+ }
+ ; Success. Return Assembly object or path.
+ return compilerRes[FileName="" ? "CompiledAssembly" : "PathToAssembly"]
+}
+
+CLR_GUID(ByRef GUID, sGUID)
+{
+ VarSetCapacity(GUID, 16, 0)
+ return DllCall("ole32\CLSIDFromString", "wstr", sGUID, "ptr", &GUID) >= 0 ? &GUID : ""
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/Gdip.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/Gdip.ahk
new file mode 100644
index 0000000..3efb7ae
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/Gdip.ahk
@@ -0,0 +1,2714 @@
+; Gdip standard library v1.45 by tic (Tariq Porter) 07/09/11
+; Modifed by Rseding91 using fincs 64 bit compatible Gdip library 5/1/2013
+; Supports: Basic, _L ANSi, _L Unicode x86 and _L Unicode x64
+;
+; Updated 2/20/2014 - fixed Gdip_CreateRegion() and Gdip_GetClipRegion() on AHK Unicode x86
+; Updated 5/13/2013 - fixed Gdip_SetBitmapToClipboard() on AHK Unicode x64
+;
+;#####################################################################################
+;#####################################################################################
+; STATUS ENUMERATION
+; Return values for functions specified to have status enumerated return type
+;#####################################################################################
+;
+; Ok = = 0
+; GenericError = 1
+; InvalidParameter = 2
+; OutOfMemory = 3
+; ObjectBusy = 4
+; InsufficientBuffer = 5
+; NotImplemented = 6
+; Win32Error = 7
+; WrongState = 8
+; Aborted = 9
+; FileNotFound = 10
+; ValueOverflow = 11
+; AccessDenied = 12
+; UnknownImageFormat = 13
+; FontFamilyNotFound = 14
+; FontStyleNotFound = 15
+; NotTrueTypeFont = 16
+; UnsupportedGdiplusVersion = 17
+; GdiplusNotInitialized = 18
+; PropertyNotFound = 19
+; PropertyNotSupported = 20
+; ProfileNotFound = 21
+;
+;#####################################################################################
+;#####################################################################################
+; FUNCTIONS
+;#####################################################################################
+;
+; UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255)
+; BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+; StretchBlt(dDC, dx, dy, dw, dh, sDC, sx, sy, sw, sh, Raster="")
+; SetImage(hwnd, hBitmap)
+; Gdip_BitmapFromScreen(Screen=0, Raster="")
+; CreateRectF(ByRef RectF, x, y, w, h)
+; CreateSizeF(ByRef SizeF, w, h)
+; CreateDIBSection
+;
+;#####################################################################################
+
+; Function: UpdateLayeredWindow
+; Description: Updates a layered window with the handle to the DC of a gdi bitmap
+;
+; hwnd Handle of the layered window to update
+; hdc Handle to the DC of the GDI bitmap to update the window with
+; Layeredx x position to place the window
+; Layeredy y position to place the window
+; Layeredw Width of the window
+; Layeredh Height of the window
+; Alpha Default = 255 : The transparency (0-255) to set the window transparency
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If x or y omitted, then layered window will use its current coordinates
+; If w or h omitted then current width and height will be used
+
+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)
+}
+
+;#####################################################################################
+
+; Function BitBlt
+; Description The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle
+; of pixels from the specified source device context into a destination device context.
+;
+; dDC handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of the area to copy
+; dh height of the area to copy
+; sDC handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used, which copies the source directly to the destination rectangle
+;
+; BLACKNESS = 0x00000042
+; NOTSRCERASE = 0x001100A6
+; NOTSRCCOPY = 0x00330008
+; SRCERASE = 0x00440328
+; DSTINVERT = 0x00550009
+; PATINVERT = 0x005A0049
+; SRCINVERT = 0x00660046
+; SRCAND = 0x008800C6
+; MERGEPAINT = 0x00BB0226
+; MERGECOPY = 0x00C000CA
+; SRCCOPY = 0x00CC0020
+; SRCPAINT = 0x00EE0086
+; PATCOPY = 0x00F00021
+; PATPAINT = 0x00FB0A09
+; WHITENESS = 0x00FF0062
+; CAPTUREBLT = 0x40000000
+; NOMIRRORBITMAP = 0x80000000
+
+BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\BitBlt"
+ , Ptr, dDC
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sDC
+ , "int", sx
+ , "int", sy
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function StretchBlt
+; Description The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle,
+; stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary.
+; The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.
+;
+; ddc handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination rectangle
+; dh height of destination rectangle
+; sdc handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used. It uses the same raster operations as BitBlt
+
+StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\StretchBlt"
+ , Ptr, ddc
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sdc
+ , "int", sx
+ , "int", sy
+ , "int", sw
+ , "int", sh
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function SetStretchBltMode
+; Description The SetStretchBltMode function sets the bitmap stretching mode in the specified device context
+;
+; hdc handle to the DC
+; iStretchMode The stretching mode, describing how the target will be stretched
+;
+; return If the function succeeds, the return value is the previous stretching mode. If it fails it will return 0
+;
+; STRETCH_ANDSCANS = 0x01
+; STRETCH_ORSCANS = 0x02
+; STRETCH_DELETESCANS = 0x03
+; STRETCH_HALFTONE = 0x04
+
+SetStretchBltMode(hdc, iStretchMode=4)
+{
+ return DllCall("gdi32\SetStretchBltMode"
+ , A_PtrSize ? "UPtr" : "UInt", hdc
+ , "int", iStretchMode)
+}
+
+;#####################################################################################
+
+; Function SetImage
+; Description Associates a new image with a static control
+;
+; hwnd handle of the control to update
+; hBitmap a gdi bitmap to associate the static control with
+;
+; return If the function succeeds, the return value is nonzero
+
+SetImage(hwnd, hBitmap)
+{
+ SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
+ E := ErrorLevel
+ DeleteObject(E)
+ return E
+}
+
+;#####################################################################################
+
+; Function SetSysColorToControl
+; Description Sets a solid colour to a control
+;
+; hwnd handle of the control to update
+; SysColor A system colour to set to the control
+;
+; return If the function succeeds, the return value is zero
+;
+; notes A control must have the 0xE style set to it so it is recognised as a bitmap
+; By default SysColor=15 is used which is COLOR_3DFACE. This is the standard background for a control
+;
+; COLOR_3DDKSHADOW = 21
+; COLOR_3DFACE = 15
+; COLOR_3DHIGHLIGHT = 20
+; COLOR_3DHILIGHT = 20
+; COLOR_3DLIGHT = 22
+; COLOR_3DSHADOW = 16
+; COLOR_ACTIVEBORDER = 10
+; COLOR_ACTIVECAPTION = 2
+; COLOR_APPWORKSPACE = 12
+; COLOR_BACKGROUND = 1
+; COLOR_BTNFACE = 15
+; COLOR_BTNHIGHLIGHT = 20
+; COLOR_BTNHILIGHT = 20
+; COLOR_BTNSHADOW = 16
+; COLOR_BTNTEXT = 18
+; COLOR_CAPTIONTEXT = 9
+; COLOR_DESKTOP = 1
+; COLOR_GRADIENTACTIVECAPTION = 27
+; COLOR_GRADIENTINACTIVECAPTION = 28
+; COLOR_GRAYTEXT = 17
+; COLOR_HIGHLIGHT = 13
+; COLOR_HIGHLIGHTTEXT = 14
+; COLOR_HOTLIGHT = 26
+; COLOR_INACTIVEBORDER = 11
+; COLOR_INACTIVECAPTION = 3
+; COLOR_INACTIVECAPTIONTEXT = 19
+; COLOR_INFOBK = 24
+; COLOR_INFOTEXT = 23
+; COLOR_MENU = 4
+; COLOR_MENUHILIGHT = 29
+; COLOR_MENUBAR = 30
+; COLOR_MENUTEXT = 7
+; COLOR_SCROLLBAR = 0
+; COLOR_WINDOW = 5
+; COLOR_WINDOWFRAME = 6
+; COLOR_WINDOWTEXT = 8
+
+SetSysColorToControl(hwnd, SysColor=15)
+{
+ WinGetPos,,, w, h, ahk_id %hwnd%
+ bc := DllCall("GetSysColor", "Int", SysColor, "UInt")
+ pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc >> 16 | bc & 0xff00 | (bc & 0xff) << 16))
+ pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap)
+ Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h)
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ SetImage(hwnd, hBitmap)
+ Gdip_DeleteBrush(pBrushClear)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap)
+ return 0
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromScreen
+; Description Gets a gdi+ bitmap from the screen
+;
+; Screen 0 = All screens
+; Any numerical value = Just that screen
+; x|y|w|h = Take specific coordinates with a width and height
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1: one or more of x,y,w,h not passed properly
+;
+; notes If no raster operation is specified, then SRCCOPY is used to the returned bitmap
+
+Gdip_BitmapFromScreen(Screen=0, Raster="")
+{
+ if (Screen = 0)
+ {
+ Sysget, x, 76
+ Sysget, y, 77
+ Sysget, w, 78
+ Sysget, h, 79
+ }
+ else if (SubStr(Screen, 1, 5) = "hwnd:")
+ {
+ Screen := SubStr(Screen, 6)
+ if !WinExist( "ahk_id " Screen)
+ return -2
+ WinGetPos,,, w, h, ahk_id %Screen%
+ x := y := 0
+ hhdc := GetDCEx(Screen, 3)
+ }
+ else if (Screen&1 != "")
+ {
+ Sysget, M, Monitor, %Screen%
+ x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
+ }
+ else
+ {
+ StringSplit, S, Screen, |
+ x := S1, y := S2, w := S3, h := S4
+ }
+
+ if (x = "") || (y = "") || (w = "") || (h = "")
+ return -1
+
+ chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
+ BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
+ ReleaseDC(hhdc)
+
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromHWND
+; Description Uses PrintWindow to get a handle to the specified window and return a bitmap from it
+;
+; hwnd handle to the window to get a bitmap from
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+;
+; notes Window must not be not minimised in order to get a handle to it's client area
+
+Gdip_BitmapFromHWND(hwnd)
+{
+ WinGetPos,,, Width, Height, ahk_id %hwnd%
+ hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ RegExMatch(A_OsVersion, "\d+", Version)
+ PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function CreateRectF
+; Description Creates a RectF object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+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")
+}
+
+;#####################################################################################
+
+; Function CreateRect
+; Description Creates a Rect object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+CreateRect(ByRef Rect, x, y, w, h)
+{
+ VarSetCapacity(Rect, 16)
+ NumPut(x, Rect, 0, "uint"), NumPut(y, Rect, 4, "uint"), NumPut(w, Rect, 8, "uint"), NumPut(h, Rect, 12, "uint")
+}
+;#####################################################################################
+
+; Function CreateSizeF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreateSizeF(ByRef SizeF, w, h)
+{
+ VarSetCapacity(SizeF, 8)
+ NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreatePointF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreatePointF(ByRef PointF, x, y)
+{
+ VarSetCapacity(PointF, 8)
+ NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreateDIBSection
+; Description The CreateDIBSection function creates a DIB (Device Independent Bitmap) that applications can write to directly
+;
+; w width of the bitmap to create
+; h height of the bitmap to create
+; hdc a handle to the device context to use the palette from
+; bpp bits per pixel (32 = ARGB)
+; ppvBits A pointer to a variable that receives a pointer to the location of the DIB bit values
+;
+; return returns a DIB. A gdi bitmap
+;
+; notes ppvBits will receive the location of the pixels in the DIB
+
+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
+}
+
+;#####################################################################################
+
+; Function PrintWindow
+; Description The PrintWindow function copies a visual window into the specified device context (DC), typically a printer DC
+;
+; hwnd A handle to the window that will be copied
+; hdc A handle to the device context
+; Flags Drawing options
+;
+; return If the function succeeds, it returns a nonzero value
+;
+; PW_CLIENTONLY = 1
+
+PrintWindow(hwnd, hdc, Flags=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("PrintWindow", Ptr, hwnd, Ptr, hdc, "uint", Flags)
+}
+
+;#####################################################################################
+
+; Function DestroyIcon
+; Description Destroys an icon and frees any memory the icon occupied
+;
+; hIcon Handle to the icon to be destroyed. The icon must not be in use
+;
+; return If the function succeeds, the return value is nonzero
+
+DestroyIcon(hIcon)
+{
+ return DllCall("DestroyIcon", A_PtrSize ? "UPtr" : "UInt", hIcon)
+}
+
+;#####################################################################################
+
+PaintDesktop(hdc)
+{
+ return DllCall("PaintDesktop", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+CreateCompatibleBitmap(hdc, w, h)
+{
+ return DllCall("gdi32\CreateCompatibleBitmap", A_PtrSize ? "UPtr" : "UInt", hdc, "int", w, "int", h)
+}
+
+;#####################################################################################
+
+; Function CreateCompatibleDC
+; Description This function creates a memory device context (DC) compatible with the specified device
+;
+; hdc Handle to an existing device context
+;
+; return returns the handle to a device context or 0 on failure
+;
+; notes If this handle is 0 (by default), the function creates a memory device context compatible with the application's current screen
+
+CreateCompatibleDC(hdc=0)
+{
+ return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+; Function SelectObject
+; Description The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type
+;
+; hdc Handle to a DC
+; hgdiobj A handle to the object to be selected into the DC
+;
+; return If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced
+;
+; notes The specified object must have been created by using one of the following functions
+; Bitmap - CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection (A single bitmap cannot be selected into more than one DC at the same time)
+; Brush - CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush
+; Font - CreateFont, CreateFontIndirect
+; Pen - CreatePen, CreatePenIndirect
+; Region - CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirect
+;
+; notes If the selected object is a region and the function succeeds, the return value is one of the following value
+;
+; SIMPLEREGION = 2 Region consists of a single rectangle
+; COMPLEXREGION = 3 Region consists of more than one rectangle
+; NULLREGION = 1 Region is empty
+
+SelectObject(hdc, hgdiobj)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
+}
+
+;#####################################################################################
+
+; Function DeleteObject
+; Description This function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object
+; After the object is deleted, the specified handle is no longer valid
+;
+; hObject Handle to a logical pen, brush, font, bitmap, region, or palette to delete
+;
+; return Nonzero indicates success. Zero indicates that the specified handle is not valid or that the handle is currently selected into a device context
+
+DeleteObject(hObject)
+{
+ return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject)
+}
+
+;#####################################################################################
+
+; Function GetDC
+; Description This function retrieves a handle to a display device context (DC) for the client area of the specified window.
+; The display device context can be used in subsequent graphics display interface (GDI) functions to draw in the client area of the window.
+;
+; hwnd Handle to the window whose device context is to be retrieved. If this value is NULL, GetDC retrieves the device context for the entire screen
+;
+; return The handle the device context for the specified window's client area indicates success. NULL indicates failure
+
+GetDC(hwnd=0)
+{
+ return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
+}
+
+;#####################################################################################
+
+; DCX_CACHE = 0x2
+; DCX_CLIPCHILDREN = 0x8
+; DCX_CLIPSIBLINGS = 0x10
+; DCX_EXCLUDERGN = 0x40
+; DCX_EXCLUDEUPDATE = 0x100
+; DCX_INTERSECTRGN = 0x80
+; DCX_INTERSECTUPDATE = 0x200
+; DCX_LOCKWINDOWUPDATE = 0x400
+; DCX_NORECOMPUTE = 0x100000
+; DCX_NORESETATTRS = 0x4
+; DCX_PARENTCLIP = 0x20
+; DCX_VALIDATE = 0x200000
+; DCX_WINDOW = 0x1
+
+GetDCEx(hwnd, flags=0, hrgnClip=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("GetDCEx", Ptr, hwnd, Ptr, hrgnClip, "int", flags)
+}
+
+;#####################################################################################
+
+; Function ReleaseDC
+; Description This function releases a device context (DC), freeing it for use by other applications. The effect of ReleaseDC depends on the type of device context
+;
+; hdc Handle to the device context to be released
+; hwnd Handle to the window whose device context is to be released
+;
+; return 1 = released
+; 0 = not released
+;
+; notes The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common device context
+; An application cannot use the ReleaseDC function to release a device context that was created by calling the CreateDC function; instead, it must use the DeleteDC function.
+
+ReleaseDC(hdc, hwnd=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function DeleteDC
+; Description The DeleteDC function deletes the specified device context (DC)
+;
+; hdc A handle to the device context
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC
+
+DeleteDC(hdc)
+{
+ return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+;#####################################################################################
+
+; Function Gdip_LibraryVersion
+; Description Get the current library version
+;
+; return the library version
+;
+; notes This is useful for non compiled programs to ensure that a person doesn't run an old version when testing your scripts
+
+Gdip_LibraryVersion()
+{
+ return 1.45
+}
+
+;#####################################################################################
+
+; Function Gdip_LibrarySubVersion
+; Description Get the current library sub version
+;
+; return the library sub version
+;
+; notes This is the sub-version currently maintained by Rseding91
+Gdip_LibrarySubVersion()
+{
+ return 1.47
+}
+
+;#####################################################################################
+
+; Function: Gdip_BitmapFromBRA
+; Description: Gets a pointer to a gdi+ bitmap from a BRA file
+;
+; BRAFromMemIn The variable for a BRA file read to memory
+; File The name of the file, or its number that you would like (This depends on alternate parameter)
+; Alternate Changes whether the File parameter is the file name or its number
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1 = The BRA variable is empty
+; -2 = The BRA has an incorrect header
+; -3 = The BRA has information missing
+; -4 = Could not find file inside the BRA
+
+Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate=0)
+{
+ Static FName = "ObjRelease"
+
+ if !BRAFromMemIn
+ return -1
+ Loop, Parse, BRAFromMemIn, `n
+ {
+ if (A_Index = 1)
+ {
+ StringSplit, Header, A_LoopField, |
+ if (Header0 != 4 || Header2 != "BRA!")
+ return -2
+ }
+ else if (A_Index = 2)
+ {
+ StringSplit, Info, A_LoopField, |
+ if (Info0 != 3)
+ return -3
+ }
+ else
+ break
+ }
+ if !Alternate
+ StringReplace, File, File, \, \\, All
+ RegExMatch(BRAFromMemIn, "mi`n)^" (Alternate ? File "\|.+?\|(\d+)\|(\d+)" : "\d+\|" File "\|(\d+)\|(\d+)") "$", FileInfo)
+ if !FileInfo
+ return -4
+
+ hData := DllCall("GlobalAlloc", "uint", 2, Ptr, FileInfo2, Ptr)
+ pData := DllCall("GlobalLock", Ptr, hData, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pData, Ptr, &BRAFromMemIn+Info2+FileInfo1, Ptr, FileInfo2)
+ DllCall("GlobalUnlock", Ptr, hData)
+ DllCall("ole32\CreateStreamOnHGlobal", Ptr, hData, "int", 1, A_PtrSize ? "UPtr*" : "UInt*", pStream)
+ DllCall("gdiplus\GdipCreateBitmapFromStream", Ptr, pStream, A_PtrSize ? "UPtr*" : "UInt*", pBitmap)
+ If (A_PtrSize)
+ %FName%(pStream)
+ Else
+ DllCall(NumGet(NumGet(1*pStream)+8), "uint", pStream)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRectangle
+; Description This function uses a pen to draw the outline of a rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRoundedRectangle
+; Description This function uses a pen to draw the outline of a rounded rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawEllipse
+; Description This function uses a pen to draw the outline of an ellipse into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle the ellipse will be drawn into
+; y y-coordinate of the top left of the rectangle the ellipse will be drawn into
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawBezier
+; Description This function uses a pen to draw the outline of a bezier (a weighted curve) into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the bezier
+; y1 y-coordinate of the start of the bezier
+; x2 x-coordinate of the first arc of the bezier
+; y2 y-coordinate of the first arc of the bezier
+; x3 x-coordinate of the second arc of the bezier
+; y3 y-coordinate of the second arc of the bezier
+; x4 x-coordinate of the end of the bezier
+; y4 y-coordinate of the end of the bezier
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawBezier"
+ , Ptr, pgraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2
+ , "float", x3
+ , "float", y3
+ , "float", x4
+ , "float", y4)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawArc
+; Description This function uses a pen to draw the outline of an arc into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the arc
+; y y-coordinate of the start of the arc
+; w width of the arc
+; h height of the arc
+; StartAngle specifies the angle between the x-axis and the starting point of the arc
+; SweepAngle specifies the angle between the starting and ending points of the arc
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawArc"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawPie
+; Description This function uses a pen to draw the outline of a pie into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the pie
+; y y-coordinate of the start of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawPie", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLine
+; Description This function uses a pen to draw a line into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the line
+; y1 y-coordinate of the start of the line
+; x2 x-coordinate of the end of the line
+; y2 y-coordinate of the end of the line
+;
+; return status enumeration. 0 = success
+
+Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawLine"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLines
+; Description This function uses a pen to draw a series of joined lines into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRectangle
+; Description This function uses a brush to fill a rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRoundedRectangle
+; Description This function uses a brush to fill a rounded rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPolygon
+; Description This function uses a brush to fill a polygon in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+;
+; notes Alternate will fill the polygon as a whole, wheras winding will fill each new "segment"
+; Alternate = 0
+; Winding = 1
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPie
+; Description This function uses a brush to fill a pie in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the pie
+; y y-coordinate of the top left of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPie"
+ , Ptr, pGraphics
+ , Ptr, pBrush
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillEllipse
+; Description This function uses a brush to fill an ellipse in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the ellipse
+; y y-coordinate of the top left of the ellipse
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRegion
+; Description This function uses a brush to fill a region in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Region
+;
+; return status enumeration. 0 = success
+;
+; notes You can create a region Gdip_CreateRegion() and then add to this
+
+Gdip_FillRegion(pGraphics, pBrush, Region)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillRegion", Ptr, pGraphics, Ptr, pBrush, Ptr, Region)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPath
+; Description This function uses a brush to fill a path in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Path
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPath(pGraphics, pBrush, Path)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPath", Ptr, pGraphics, Ptr, pBrush, Ptr, Path)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImagePointsRect
+; Description This function draws a bitmap into the Graphics of another bitmap and skews it
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; Points Points passed as x1,y1|x2,y2|x3,y3 (3 points: top left, top right, bottom left) describing the drawing of the bitmap
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter
+
+Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1)
+{
+ 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")
+ }
+
+ 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 = "")
+ {
+ sx := 0, sy := 0
+ sw := Gdip_GetImageWidth(pBitmap)
+ sh := Gdip_GetImageHeight(pBitmap)
+ }
+
+ E := DllCall("gdiplus\GdipDrawImagePointsRect"
+ , Ptr, pGraphics
+ , Ptr, pBitmap
+ , Ptr, &PointF
+ , "int", Points0
+ , "float", sx
+ , "float", sy
+ , "float", sw
+ , "float", sh
+ , "int", 2
+ , Ptr, ImageAttr
+ , Ptr, 0
+ , Ptr, 0)
+ if ImageAttr
+ Gdip_DisposeImageAttributes(ImageAttr)
+ return E
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImage
+; Description This function draws a bitmap into the Graphics of another bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination image
+; dh height of destination image
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source image
+; sh height of source image
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Gdip_DrawImage performs faster
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter. For example:
+; MatrixBright=
+; (
+; 1.5 |0 |0 |0 |0
+; 0 |1.5 |0 |0 |0
+; 0 |0 |1.5 |0 |0
+; 0 |0 |0 |1 |0
+; 0.05 |0.05 |0.05 |0 |1
+; )
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_SetImageAttributesColorMatrix
+; Description This function creates an image matrix ready for drawing
+;
+; Matrix a matrix used to alter image attributes when drawing
+; passed with any delimeter
+;
+; return returns an image matrix on sucess or 0 if it fails
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromImage
+; Description This function gets the graphics for a bitmap used for drawing functions
+;
+; pBitmap Pointer to a bitmap to get the pointer to its graphics
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes a bitmap can be drawn into the graphics of another bitmap
+
+Gdip_GraphicsFromImage(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromHDC
+; Description This function gets the graphics from the handle to a device context
+;
+; hdc This is the handle to the device context
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes You can draw a bitmap into the graphics of another bitmap
+
+Gdip_GraphicsFromHDC(hdc)
+{
+ DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDC
+; Description This function gets the device context of the passed Graphics
+;
+; hdc This is the handle to the device context
+;
+; return returns the device context for the graphics of a bitmap
+
+Gdip_GetDC(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDC", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", hdc)
+ return hdc
+}
+
+;#####################################################################################
+
+; Function Gdip_ReleaseDC
+; Description This function releases a device context from use for further use
+;
+; pGraphics Pointer to the graphics of a bitmap
+; hdc This is the handle to the device context
+;
+; return status enumeration. 0 = success
+
+Gdip_ReleaseDC(pGraphics, hdc)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipReleaseDC", Ptr, pGraphics, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsClear
+; Description Clears the graphics of a bitmap ready for further drawing
+;
+; pGraphics Pointer to the graphics of a bitmap
+; ARGB The colour to clear the graphics to
+;
+; return status enumeration. 0 = success
+;
+; notes By default this will make the background invisible
+; Using clipping regions you can clear a particular area on the graphics rather than clearing the entire graphics
+
+Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff)
+{
+ return DllCall("gdiplus\GdipGraphicsClear", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_BlurBitmap
+; Description Gives a pointer to a blurred bitmap from a pointer to a bitmap
+;
+; pBitmap Pointer to a bitmap to be blurred
+; Blur The Amount to blur a bitmap by from 1 (least blur) to 100 (most blur)
+;
+; return If the function succeeds, the return value is a pointer to the new blurred bitmap
+; -1 = The blur parameter is outside the range 1-100
+;
+; notes This function will not dispose of the original bitmap
+
+Gdip_BlurBitmap(pBitmap, Blur)
+{
+ if (Blur > 100) || (Blur < 1)
+ return -1
+
+ sWidth := Gdip_GetImageWidth(pBitmap), sHeight := Gdip_GetImageHeight(pBitmap)
+ dWidth := sWidth//Blur, dHeight := sHeight//Blur
+
+ pBitmap1 := Gdip_CreateBitmap(dWidth, dHeight)
+ G1 := Gdip_GraphicsFromImage(pBitmap1)
+ Gdip_SetInterpolationMode(G1, 7)
+ Gdip_DrawImage(G1, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight)
+
+ Gdip_DeleteGraphics(G1)
+
+ pBitmap2 := Gdip_CreateBitmap(sWidth, sHeight)
+ G2 := Gdip_GraphicsFromImage(pBitmap2)
+ Gdip_SetInterpolationMode(G2, 7)
+ Gdip_DrawImage(G2, pBitmap1, 0, 0, sWidth, sHeight, 0, 0, dWidth, dHeight)
+
+ Gdip_DeleteGraphics(G2)
+ Gdip_DisposeImage(pBitmap1)
+ return pBitmap2
+}
+
+;#####################################################################################
+
+; Function: Gdip_SaveBitmapToFile
+; Description: Saves a bitmap to a file in any supported format onto disk
+;
+; pBitmap Pointer to a bitmap
+; sOutput The name of the file that the bitmap will be saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG
+; Quality If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality
+;
+; return If the function succeeds, the return value is zero, otherwise:
+; -1 = Extension supplied is not a supported file format
+; -2 = Could not get a list of encoders on system
+; -3 = Could not find matching encoder for specified file format
+; -4 = Could not get WideChar name of output file
+; -5 = Could not save file to disk
+;
+; notes This function will use the extension supplied from the sOutput parameter to determine the output format
+
+Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=75)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ SplitPath, sOutput,,, Extension
+ if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
+ return -1
+ Extension := "." Extension
+
+ DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
+ VarSetCapacity(ci, nSize)
+ DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
+ if !(nCount && nSize)
+ return -2
+
+ If (A_IsUnicode){
+ StrGet_Name := "StrGet"
+ Loop, %nCount%
+ {
+ sString := %StrGet_Name%(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
+ }
+ } else {
+ Loop, %nCount%
+ {
+ Location := NumGet(ci, 76*(A_Index-1)+44)
+ nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(sString, nSize)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0)
+ if !InStr(sString, "*" Extension)
+ continue
+
+ pCodec := &ci+76*(A_Index-1)
+ 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
+ }
+ }
+ }
+ }
+
+ if (!A_IsUnicode)
+ {
+ nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, 0, "int", 0)
+ VarSetCapacity(wOutput, nSize*2)
+ DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, &wOutput, "int", nSize)
+ VarSetCapacity(wOutput, -1)
+ if !VarSetCapacity(wOutput)
+ return -4
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &wOutput, Ptr, pCodec, "uint", p ? p : 0)
+ }
+ else
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &sOutput, Ptr, pCodec, "uint", p ? p : 0)
+ return E ? -5 : 0
+}
+
+;#####################################################################################
+
+; Function Gdip_GetPixel
+; Description Gets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return Returns the ARGB value of the pixel
+
+Gdip_GetPixel(pBitmap, x, y)
+{
+ DllCall("gdiplus\GdipBitmapGetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "uint*", ARGB)
+ return ARGB
+}
+
+;#####################################################################################
+
+; Function Gdip_SetPixel
+; Description Sets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return status enumeration. 0 = success
+
+Gdip_SetPixel(pBitmap, x, y, ARGB)
+{
+ return DllCall("gdiplus\GdipBitmapSetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageWidth
+; Description Gives the width of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the width in pixels of the supplied bitmap
+
+Gdip_GetImageWidth(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width)
+ return Width
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageHeight
+; Description Gives the height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the height in pixels of the supplied bitmap
+
+Gdip_GetImageHeight(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height)
+ return Height
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDimensions
+; Description Gives the width and height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetImageDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ DllCall("gdiplus\GdipGetImageWidth", Ptr, pBitmap, "uint*", Width)
+ DllCall("gdiplus\GdipGetImageHeight", Ptr, pBitmap, "uint*", Height)
+}
+
+;#####################################################################################
+
+Gdip_GetDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+}
+
+;#####################################################################################
+
+Gdip_GetImagePixelFormat(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImagePixelFormat", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", Format)
+ return Format
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDpiX
+; Description Gives the horizontal dots per inch of the graphics of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetDpiX(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiX", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetDpiY(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiY", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_GetImageHorizontalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHorizontalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetImageVerticalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageVerticalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_BitmapSetResolution(pBitmap, dpix, dpiy)
+{
+ return DllCall("gdiplus\GdipBitmapSetResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float", dpix, "float", dpiy)
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromFile(sFile, IconNumber=1, IconSize="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ SplitPath, sFile,,, ext
+ if ext in exe,dll
+ {
+ Sizes := IconSize ? IconSize : 256 "|" 128 "|" 64 "|" 48 "|" 32 "|" 16
+ BufSize := 16 + (2*(A_PtrSize ? A_PtrSize : 4))
+
+ VarSetCapacity(buf, BufSize, 0)
+ Loop, Parse, Sizes, |
+ {
+ DllCall("PrivateExtractIcons", "str", sFile, "int", IconNumber-1, "int", A_LoopField, "int", A_LoopField, PtrA, hIcon, PtrA, 0, "uint", 1, "uint", 0)
+
+ if !hIcon
+ continue
+
+ if !DllCall("GetIconInfo", Ptr, hIcon, Ptr, &buf)
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+
+ hbmMask := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4))
+ hbmColor := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4) + (A_PtrSize ? A_PtrSize : 4))
+ if !(hbmColor && DllCall("GetObject", Ptr, hbmColor, "int", BufSize, Ptr, &buf))
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+ break
+ }
+ if !hIcon
+ return -1
+
+ Width := NumGet(buf, 4, "int"), Height := NumGet(buf, 8, "int")
+ hbm := CreateDIBSection(Width, -Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ if !DllCall("DrawIconEx", Ptr, hdc, "int", 0, "int", 0, Ptr, hIcon, "uint", Width, "uint", Height, "uint", 0, Ptr, 0, "uint", 3)
+ {
+ DestroyIcon(hIcon)
+ return -2
+ }
+
+ VarSetCapacity(dib, 104)
+ DllCall("GetObject", Ptr, hbm, "int", A_PtrSize = 8 ? 104 : 84, Ptr, &dib) ; sizeof(DIBSECTION) = 76+2*(A_PtrSize=8?4:0)+2*A_PtrSize
+ Stride := NumGet(dib, 12, "Int"), Bits := NumGet(dib, 20 + (A_PtrSize = 8 ? 4 : 0)) ; padding
+ DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", Stride, "int", 0x26200A, Ptr, Bits, PtrA, pBitmapOld)
+ pBitmap := Gdip_CreateBitmap(Width, Height)
+ G := Gdip_GraphicsFromImage(pBitmap)
+ , Gdip_DrawImage(G, pBitmapOld, 0, 0, Width, Height, 0, 0, Width, Height)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapOld)
+ DestroyIcon(hIcon)
+ }
+ else
+ {
+ if (!A_IsUnicode)
+ {
+ VarSetCapacity(wFile, 1024)
+ DllCall("kernel32\MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sFile, "int", -1, Ptr, &wFile, "int", 512)
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &wFile, PtrA, pBitmap)
+ }
+ else
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &sFile, PtrA, pBitmap)
+ }
+
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", Ptr, hBitmap, Ptr, Palette, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff)
+{
+ DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hbm, "int", Background)
+ return hbm
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHICON(hIcon)
+{
+ DllCall("gdiplus\GdipCreateBitmapFromHICON", A_PtrSize ? "UPtr" : "UInt", hIcon, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHICONFromBitmap(pBitmap)
+{
+ DllCall("gdiplus\GdipCreateHICONFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hIcon)
+ return hIcon
+}
+
+;#####################################################################################
+
+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_CreateBitmapFromClipboard()
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if !DllCall("OpenClipboard", Ptr, 0)
+ return -1
+ if !DllCall("IsClipboardFormatAvailable", "uint", 8)
+ return -2
+ if !hBitmap := DllCall("GetClipboardData", "uint", 2, Ptr)
+ return -3
+ if !pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap)
+ return -4
+ if !DllCall("CloseClipboard")
+ return -5
+ DeleteObject(hBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_SetBitmapToClipboard(pBitmap)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ off1 := A_PtrSize = 8 ? 52 : 44, off2 := A_PtrSize = 8 ? 32 : 24
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ DllCall("GetObject", Ptr, hBitmap, "int", VarSetCapacity(oi, A_PtrSize = 8 ? 104 : 84, 0), Ptr, &oi)
+ hdib := DllCall("GlobalAlloc", "uint", 2, Ptr, 40+NumGet(oi, off1, "UInt"), Ptr)
+ pdib := DllCall("GlobalLock", Ptr, hdib, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pdib, Ptr, &oi+off2, Ptr, 40)
+ DllCall("RtlMoveMemory", Ptr, pdib+40, Ptr, NumGet(oi, off2 - (A_PtrSize ? A_PtrSize : 4), Ptr), Ptr, NumGet(oi, off1, "UInt"))
+ DllCall("GlobalUnlock", Ptr, hdib)
+ DllCall("DeleteObject", Ptr, hBitmap)
+ DllCall("OpenClipboard", Ptr, 0)
+ DllCall("EmptyClipboard")
+ DllCall("SetClipboardData", "uint", 8, Ptr, hdib)
+ DllCall("CloseClipboard")
+}
+
+;#####################################################################################
+
+Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format=0x26200A)
+{
+ DllCall("gdiplus\GdipCloneBitmapArea"
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "int", Format
+ , A_PtrSize ? "UPtr" : "UInt", pBitmap
+ , A_PtrSize ? "UPtr*" : "UInt*", pBitmapDest)
+ return pBitmapDest
+}
+
+;#####################################################################################
+; Create resources
+;#####################################################################################
+
+Gdip_CreatePen(ARGB, w)
+{
+ DllCall("gdiplus\GdipCreatePen1", "UInt", ARGB, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_CreatePenFromBrush(pBrush, w)
+{
+ DllCall("gdiplus\GdipCreatePen2", A_PtrSize ? "UPtr" : "UInt", pBrush, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_BrushCreateSolid(ARGB=0xff000000)
+{
+ DllCall("gdiplus\GdipCreateSolidFill", "UInt", ARGB, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; HatchStyleHorizontal = 0
+; HatchStyleVertical = 1
+; HatchStyleForwardDiagonal = 2
+; HatchStyleBackwardDiagonal = 3
+; HatchStyleCross = 4
+; HatchStyleDiagonalCross = 5
+; HatchStyle05Percent = 6
+; HatchStyle10Percent = 7
+; HatchStyle20Percent = 8
+; HatchStyle25Percent = 9
+; HatchStyle30Percent = 10
+; HatchStyle40Percent = 11
+; HatchStyle50Percent = 12
+; HatchStyle60Percent = 13
+; HatchStyle70Percent = 14
+; HatchStyle75Percent = 15
+; HatchStyle80Percent = 16
+; HatchStyle90Percent = 17
+; HatchStyleLightDownwardDiagonal = 18
+; HatchStyleLightUpwardDiagonal = 19
+; HatchStyleDarkDownwardDiagonal = 20
+; HatchStyleDarkUpwardDiagonal = 21
+; HatchStyleWideDownwardDiagonal = 22
+; HatchStyleWideUpwardDiagonal = 23
+; HatchStyleLightVertical = 24
+; HatchStyleLightHorizontal = 25
+; HatchStyleNarrowVertical = 26
+; HatchStyleNarrowHorizontal = 27
+; HatchStyleDarkVertical = 28
+; HatchStyleDarkHorizontal = 29
+; HatchStyleDashedDownwardDiagonal = 30
+; HatchStyleDashedUpwardDiagonal = 31
+; HatchStyleDashedHorizontal = 32
+; HatchStyleDashedVertical = 33
+; HatchStyleSmallConfetti = 34
+; HatchStyleLargeConfetti = 35
+; HatchStyleZigZag = 36
+; HatchStyleWave = 37
+; HatchStyleDiagonalBrick = 38
+; HatchStyleHorizontalBrick = 39
+; HatchStyleWeave = 40
+; HatchStylePlaid = 41
+; HatchStyleDivot = 42
+; HatchStyleDottedGrid = 43
+; HatchStyleDottedDiamond = 44
+; HatchStyleShingle = 45
+; HatchStyleTrellis = 46
+; HatchStyleSphere = 47
+; HatchStyleSmallGrid = 48
+; HatchStyleSmallCheckerBoard = 49
+; HatchStyleLargeCheckerBoard = 50
+; HatchStyleOutlinedDiamond = 51
+; HatchStyleSolidDiamond = 52
+; HatchStyleTotal = 53
+Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0)
+{
+ DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "UInt", ARGBfront, "UInt", ARGBback, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+Gdip_CreateTextureBrush(pBitmap, WrapMode=1, x=0, y=0, w="", h="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ if !(w && h)
+ DllCall("gdiplus\GdipCreateTexture", Ptr, pBitmap, "int", WrapMode, PtrA, pBrush)
+ else
+ DllCall("gdiplus\GdipCreateTexture2", Ptr, pBitmap, "int", WrapMode, "float", x, "float", y, "float", w, "float", h, PtrA, pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; WrapModeTile = 0
+; WrapModeTileFlipX = 1
+; WrapModeTileFlipY = 2
+; WrapModeTileFlipXY = 3
+; WrapModeClamp = 4
+Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2)
+ DllCall("gdiplus\GdipCreateLineBrush", Ptr, &PointF1, Ptr, &PointF2, "Uint", ARGB1, "Uint", ARGB2, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
+ return LGpBrush
+}
+
+;#####################################################################################
+
+; LinearGradientModeHorizontal = 0
+; LinearGradientModeVertical = 1
+; LinearGradientModeForwardDiagonal = 2
+; LinearGradientModeBackwardDiagonal = 3
+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_CloneBrush(pBrush)
+{
+ DllCall("gdiplus\GdipCloneBrush", A_PtrSize ? "UPtr" : "UInt", pBrush, A_PtrSize ? "UPtr*" : "UInt*", pBrushClone)
+ return pBrushClone
+}
+
+;#####################################################################################
+; Delete resources
+;#####################################################################################
+
+Gdip_DeletePen(pPen)
+{
+ return DllCall("gdiplus\GdipDeletePen", A_PtrSize ? "UPtr" : "UInt", pPen)
+}
+
+;#####################################################################################
+
+Gdip_DeleteBrush(pBrush)
+{
+ return DllCall("gdiplus\GdipDeleteBrush", A_PtrSize ? "UPtr" : "UInt", pBrush)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImage(pBitmap)
+{
+ return DllCall("gdiplus\GdipDisposeImage", A_PtrSize ? "UPtr" : "UInt", pBitmap)
+}
+
+;#####################################################################################
+
+Gdip_DeleteGraphics(pGraphics)
+{
+ return DllCall("gdiplus\GdipDeleteGraphics", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImageAttributes(ImageAttr)
+{
+ return DllCall("gdiplus\GdipDisposeImageAttributes", A_PtrSize ? "UPtr" : "UInt", ImageAttr)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFont(hFont)
+{
+ return DllCall("gdiplus\GdipDeleteFont", A_PtrSize ? "UPtr" : "UInt", hFont)
+}
+
+;#####################################################################################
+
+Gdip_DeleteStringFormat(hFormat)
+{
+ return DllCall("gdiplus\GdipDeleteStringFormat", A_PtrSize ? "UPtr" : "UInt", hFormat)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFontFamily(hFamily)
+{
+ return DllCall("gdiplus\GdipDeleteFontFamily", A_PtrSize ? "UPtr" : "UInt", hFamily)
+}
+
+;#####################################################################################
+
+Gdip_DeleteMatrix(Matrix)
+{
+ return DllCall("gdiplus\GdipDeleteMatrix", A_PtrSize ? "UPtr" : "UInt", Matrix)
+}
+
+;#####################################################################################
+; Text functions
+;#####################################################################################
+
+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_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_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
+}
+
+; Near = 0
+; Center = 1
+; Far = 2
+Gdip_SetStringFormatAlign(hFormat, Align)
+{
+ return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align)
+}
+
+; StringFormatFlagsDirectionRightToLeft = 0x00000001
+; StringFormatFlagsDirectionVertical = 0x00000002
+; StringFormatFlagsNoFitBlackBox = 0x00000004
+; StringFormatFlagsDisplayFormatControl = 0x00000020
+; StringFormatFlagsNoFontFallback = 0x00000400
+; StringFormatFlagsMeasureTrailingSpaces = 0x00000800
+; StringFormatFlagsNoWrap = 0x00001000
+; StringFormatFlagsLineLimit = 0x00002000
+; StringFormatFlagsNoClip = 0x00004000
+Gdip_StringFormatCreate(Format=0, Lang=0)
+{
+ DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat)
+ return hFormat
+}
+
+; Regular = 0
+; Bold = 1
+; Italic = 2
+; BoldItalic = 3
+; Underline = 4
+; Strikeout = 8
+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
+}
+
+;#####################################################################################
+; Matrix functions
+;#####################################################################################
+
+Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y)
+{
+ DllCall("gdiplus\GdipCreateMatrix2", "float", m11, "float", m12, "float", m21, "float", m22, "float", x, "float", y, A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+Gdip_CreateMatrix()
+{
+ DllCall("gdiplus\GdipCreateMatrix", A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+;#####################################################################################
+; GraphicsPath functions
+;#####################################################################################
+
+; Alternate = 0
+; Winding = 1
+Gdip_CreatePath(BrushMode=0)
+{
+ DllCall("gdiplus\GdipCreatePath", "int", BrushMode, A_PtrSize ? "UPtr*" : "UInt*", Path)
+ return Path
+}
+
+Gdip_AddPathEllipse(Path, x, y, w, h)
+{
+ return DllCall("gdiplus\GdipAddPathEllipse", A_PtrSize ? "UPtr" : "UInt", Path, "float", x, "float", y, "float", w, "float", h)
+}
+
+Gdip_AddPathPolygon(Path, 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\GdipAddPathPolygon", Ptr, Path, Ptr, &PointF, "int", Points0)
+}
+
+Gdip_DeletePath(Path)
+{
+ return DllCall("gdiplus\GdipDeletePath", A_PtrSize ? "UPtr" : "UInt", Path)
+}
+
+;#####################################################################################
+; Quality functions
+;#####################################################################################
+
+; SystemDefault = 0
+; SingleBitPerPixelGridFit = 1
+; SingleBitPerPixel = 2
+; AntiAliasGridFit = 3
+; AntiAlias = 4
+Gdip_SetTextRenderingHint(pGraphics, RenderingHint)
+{
+ return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint)
+}
+
+; Default = 0
+; LowQuality = 1
+; HighQuality = 2
+; Bilinear = 3
+; Bicubic = 4
+; NearestNeighbor = 5
+; HighQualityBilinear = 6
+; HighQualityBicubic = 7
+Gdip_SetInterpolationMode(pGraphics, InterpolationMode)
+{
+ return DllCall("gdiplus\GdipSetInterpolationMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", InterpolationMode)
+}
+
+; Default = 0
+; HighSpeed = 1
+; HighQuality = 2
+; None = 3
+; AntiAlias = 4
+Gdip_SetSmoothingMode(pGraphics, SmoothingMode)
+{
+ return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
+}
+
+; CompositingModeSourceOver = 0 (blended)
+; CompositingModeSourceCopy = 1 (overwrite)
+Gdip_SetCompositingMode(pGraphics, CompositingMode=0)
+{
+ return DllCall("gdiplus\GdipSetCompositingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", CompositingMode)
+}
+
+;#####################################################################################
+; Extra functions
+;#####################################################################################
+
+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
+}
+
+; Prepend = 0; The new operation is applied before the old operation.
+; Append = 1; The new operation is applied after the old operation.
+Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipRotateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", Angle, "int", MatrixOrder)
+}
+
+Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipScaleWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipTranslateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_ResetWorldTransform(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetRotatedTranslation(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+
+ Bound := (Angle >= 0) ? Mod(Angle, 360) : 360-Mod(-Angle, -360)
+ if ((Bound >= 0) && (Bound <= 90))
+ xTranslation := Height*Sin(TAngle), yTranslation := 0
+ else if ((Bound > 90) && (Bound <= 180))
+ xTranslation := (Height*Sin(TAngle))-(Width*Cos(TAngle)), yTranslation := -Height*Cos(TAngle)
+ else if ((Bound > 180) && (Bound <= 270))
+ xTranslation := -(Width*Cos(TAngle)), yTranslation := -(Height*Cos(TAngle))-(Width*Sin(TAngle))
+ else if ((Bound > 270) && (Bound <= 360))
+ xTranslation := 0, yTranslation := -Width*Sin(TAngle)
+}
+
+Gdip_GetRotatedDimensions(Width, Height, Angle, ByRef RWidth, ByRef RHeight)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+ if !(Width && Height)
+ return -1
+ RWidth := Ceil(Abs(Width*Cos(TAngle))+Abs(Height*Sin(TAngle)))
+ RHeight := Ceil(Abs(Width*Sin(TAngle))+Abs(Height*Cos(Tangle)))
+}
+
+; RotateNoneFlipNone = 0
+; Rotate90FlipNone = 1
+; Rotate180FlipNone = 2
+; Rotate270FlipNone = 3
+; RotateNoneFlipX = 4
+; Rotate90FlipX = 5
+; Rotate180FlipX = 6
+; Rotate270FlipX = 7
+; RotateNoneFlipY = Rotate180FlipX
+; Rotate90FlipY = Rotate270FlipX
+; Rotate180FlipY = RotateNoneFlipX
+; Rotate270FlipY = Rotate90FlipX
+; RotateNoneFlipXY = Rotate180FlipNone
+; Rotate90FlipXY = Rotate270FlipNone
+; Rotate180FlipXY = RotateNoneFlipNone
+; Rotate270FlipXY = Rotate90FlipNone
+
+Gdip_ImageRotateFlip(pBitmap, RotateFlipType=1)
+{
+ return DllCall("gdiplus\GdipImageRotateFlip", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", RotateFlipType)
+}
+
+; Replace = 0
+; Intersect = 1
+; Union = 2
+; Xor = 3
+; Exclude = 4
+; Complement = 5
+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_SetClipPath(pGraphics, Path, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ return DllCall("gdiplus\GdipSetClipPath", Ptr, pGraphics, Ptr, Path, "int", CombineMode)
+}
+
+Gdip_ResetClip(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetClipRegion(pGraphics)
+{
+ Region := Gdip_CreateRegion()
+ DllCall("gdiplus\GdipGetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics, "UInt*", Region)
+ return Region
+}
+
+Gdip_SetClipRegion(pGraphics, Region, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipSetClipRegion", Ptr, pGraphics, Ptr, Region, "int", CombineMode)
+}
+
+Gdip_CreateRegion()
+{
+ DllCall("gdiplus\GdipCreateRegion", "UInt*", Region)
+ return Region
+}
+
+Gdip_DeleteRegion(Region)
+{
+ return DllCall("gdiplus\GdipDeleteRegion", A_PtrSize ? "UPtr" : "UInt", Region)
+}
+
+;#####################################################################################
+; BitmapLockBits
+;#####################################################################################
+
+Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode = 3, PixelFormat = 0x26200a)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreateRect(Rect, x, y, w, h)
+ VarSetCapacity(BitmapData, 16+2*(A_PtrSize ? A_PtrSize : 4), 0)
+ E := DllCall("Gdiplus\GdipBitmapLockBits", Ptr, pBitmap, Ptr, &Rect, "uint", LockMode, "int", PixelFormat, Ptr, &BitmapData)
+ Stride := NumGet(BitmapData, 8, "Int")
+ Scan0 := NumGet(BitmapData, 16, Ptr)
+ return E
+}
+
+;#####################################################################################
+
+Gdip_UnlockBits(pBitmap, ByRef BitmapData)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("Gdiplus\GdipBitmapUnlockBits", Ptr, pBitmap, Ptr, &BitmapData)
+}
+
+;#####################################################################################
+
+Gdip_SetLockBitPixel(ARGB, Scan0, x, y, Stride)
+{
+ Numput(ARGB, Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_GetLockBitPixel(Scan0, x, y, Stride)
+{
+ return NumGet(Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_PixelateBitmap(pBitmap, ByRef pBitmapOut, BlockSize)
+{
+ static PixelateBitmap
+
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if (!PixelateBitmap)
+ {
+ if A_PtrSize != 8 ; x86 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 558BEC83EC3C8B4514538B5D1C99F7FB56578BC88955EC894DD885C90F8E830200008B451099F7FB8365DC008365E000894DC88955F08945E833FF897DD4
+ 397DE80F8E160100008BCB0FAFCB894DCC33C08945F88945FC89451C8945143BD87E608B45088D50028BC82BCA8BF02BF2418945F48B45E02955F4894DC4
+ 8D0CB80FAFCB03CA895DD08BD1895DE40FB64416030145140FB60201451C8B45C40FB604100145FC8B45F40FB604020145F883C204FF4DE475D6034D18FF
+ 4DD075C98B4DCC8B451499F7F98945148B451C99F7F989451C8B45FC99F7F98945FC8B45F899F7F98945F885DB7E648B450C8D50028BC82BCA83C103894D
+ C48BC82BCA41894DF48B4DD48945E48B45E02955E48D0C880FAFCB03CA895DD08BD18BF38A45148B7DC48804178A451C8B7DF488028A45FC8804178A45F8
+ 8B7DE488043A83C2044E75DA034D18FF4DD075CE8B4DCC8B7DD447897DD43B7DE80F8CF2FEFFFF837DF0000F842C01000033C08945F88945FC89451C8945
+ 148945E43BD87E65837DF0007E578B4DDC034DE48B75E80FAF4D180FAFF38B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945CC0F
+ B6440E030145140FB60101451C0FB6440F010145FC8B45F40FB604010145F883C104FF4DCC75D8FF45E4395DE47C9B8B4DF00FAFCB85C9740B8B451499F7
+ F9894514EB048365140033F63BCE740B8B451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB
+ 038975F88975E43BDE7E5A837DF0007E4C8B4DDC034DE48B75E80FAF4D180FAFF38B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955CC8A55
+ 1488540E038A551C88118A55FC88540F018A55F888140183C104FF4DCC75DFFF45E4395DE47CA68B45180145E0015DDCFF4DC80F8594FDFFFF8B451099F7
+ FB8955F08945E885C00F8E450100008B45EC0FAFC38365DC008945D48B45E88945CC33C08945F88945FC89451C8945148945103945EC7E6085DB7E518B4D
+ D88B45080FAFCB034D108D50020FAF4D18034DDC8BF08BF88945F403CA2BF22BFA2955F4895DC80FB6440E030145140FB60101451C0FB6440F010145FC8B
+ 45F40FB604080145F883C104FF4DC875D8FF45108B45103B45EC7CA08B4DD485C9740B8B451499F7F9894514EB048365140033F63BCE740B8B451C99F7F9
+ 89451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975103975EC7E5585DB7E468B4DD88B450C
+ 0FAFCB034D108D50020FAF4D18034DDC8BF08BF803CA2BF22BFA2BC2895DC88A551488540E038A551C88118A55FC88540F018A55F888140183C104FF4DC8
+ 75DFFF45108B45103B45EC7CAB8BC3C1E0020145DCFF4DCC0F85CEFEFFFF8B4DEC33C08945F88945FC89451C8945148945103BC87E6C3945F07E5C8B4DD8
+ 8B75E80FAFCB034D100FAFF30FAF4D188B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945C80FB6440E030145140FB60101451C0F
+ B6440F010145FC8B45F40FB604010145F883C104FF4DC875D833C0FF45108B4DEC394D107C940FAF4DF03BC874068B451499F7F933F68945143BCE740B8B
+ 451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975083975EC7E63EB0233F639
+ 75F07E4F8B4DD88B75E80FAFCB034D080FAFF30FAF4D188B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955108A551488540E038A551C8811
+ 8A55FC88540F018A55F888140883C104FF4D1075DFFF45088B45083B45EC7C9F5F5E33C05BC9C21800
+ )
+ else ; x64 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 4489442418488954241048894C24085355565741544155415641574883EC28418BC1448B8C24980000004C8BDA99488BD941F7F9448BD0448BFA8954240C
+ 448994248800000085C00F8E9D020000418BC04533E4458BF299448924244C8954241041F7F933C9898C24980000008BEA89542404448BE889442408EB05
+ 4C8B5C24784585ED0F8E1A010000458BF1418BFD48897C2418450FAFF14533D233F633ED4533E44533ED4585C97E5B4C63BC2490000000418D040A410FAF
+ C148984C8D441802498BD9498BD04D8BD90FB642010FB64AFF4403E80FB60203E90FB64AFE4883C2044403E003F149FFCB75DE4D03C748FFCB75D0488B7C
+ 24188B8C24980000004C8B5C2478418BC59941F7FE448BE8418BC49941F7FE448BE08BC59941F7FE8BE88BC69941F7FE8BF04585C97E4048639C24900000
+ 004103CA4D8BC1410FAFC94863C94A8D541902488BCA498BC144886901448821408869FF408871FE4883C10448FFC875E84803D349FFC875DA8B8C249800
+ 0000488B5C24704C8B5C24784183C20448FFCF48897C24180F850AFFFFFF8B6C2404448B2424448B6C24084C8B74241085ED0F840A01000033FF33DB4533
+ DB4533D24533C04585C97E53488B74247085ED7E42438D0C04418BC50FAF8C2490000000410FAFC18D04814863C8488D5431028BCD0FB642014403D00FB6
+ 024883C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC17CB28BCD410FAFC985C9740A418BC299F7F98BF0EB0233F685C9740B418BC3
+ 99F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585C97E4D4C8B74247885ED7E3841
+ 8D0C14418BC50FAF8C2490000000410FAFC18D04814863C84A8D4431028BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2413BD17CBD
+ 4C8B7424108B8C2498000000038C2490000000488B5C24704503E149FFCE44892424898C24980000004C897424100F859EFDFFFF448B7C240C448B842480
+ 000000418BC09941F7F98BE8448BEA89942498000000896C240C85C00F8E3B010000448BAC2488000000418BCF448BF5410FAFC9898C248000000033FF33
+ ED33F64533DB4533D24533C04585FF7E524585C97E40418BC5410FAFC14103C00FAF84249000000003C74898488D541802498BD90FB642014403D00FB602
+ 4883C2044403D80FB642FB03F00FB642FA03E848FFCB75DE488B5C247041FFC0453BC77CAE85C9740B418BC299F7F9448BE0EB034533E485C9740A418BC3
+ 99F7F98BD8EB0233DB85C9740A8BC699F7F9448BD8EB034533DB85C9740A8BC599F7F9448BD0EB034533D24533C04585FF7E4E488B4C24784585C97E3541
+ 8BC5410FAFC14103C00FAF84249000000003C74898488D540802498BC144886201881A44885AFF448852FE4883C20448FFC875E941FFC0453BC77CBE8B8C
+ 2480000000488B5C2470418BC1C1E00203F849FFCE0F85ECFEFFFF448BAC24980000008B6C240C448BA4248800000033FF33DB4533DB4533D24533C04585
+ FF7E5A488B7424704585ED7E48418BCC8BC5410FAFC94103C80FAF8C2490000000410FAFC18D04814863C8488D543102418BCD0FB642014403D00FB60248
+ 83C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC77CAB418BCF410FAFCD85C9740A418BC299F7F98BF0EB0233F685C9740B418BC399
+ F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585FF7E4E4585ED7E42418BCC8BC541
+ 0FAFC903CA0FAF8C2490000000410FAFC18D04814863C8488B442478488D440102418BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2
+ 413BD77CB233C04883C428415F415E415D415C5F5E5D5BC3
+ )
+
+ VarSetCapacity(PixelateBitmap, StrLen(MCode_PixelateBitmap)//2)
+ Loop % StrLen(MCode_PixelateBitmap)//2 ;%
+ NumPut("0x" SubStr(MCode_PixelateBitmap, (2*A_Index)-1, 2), PixelateBitmap, A_Index-1, "UChar")
+ DllCall("VirtualProtect", Ptr, &PixelateBitmap, Ptr, VarSetCapacity(PixelateBitmap), "uint", 0x40, A_PtrSize ? "UPtr*" : "UInt*", 0)
+ }
+
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+
+ if (Width != Gdip_GetImageWidth(pBitmapOut) || Height != Gdip_GetImageHeight(pBitmapOut))
+ return -1
+ if (BlockSize > Width || BlockSize > Height)
+ return -2
+
+ E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1)
+ E2 := Gdip_LockBits(pBitmapOut, 0, 0, Width, Height, Stride2, Scan02, BitmapData2)
+ if (E1 || E2)
+ return -3
+
+ E := DllCall(&PixelateBitmap, Ptr, Scan01, Ptr, Scan02, "int", Width, "int", Height, "int", Stride1, "int", BlockSize)
+
+ Gdip_UnlockBits(pBitmap, BitmapData1), Gdip_UnlockBits(pBitmapOut, BitmapData2)
+ return 0
+}
+
+;#####################################################################################
+
+Gdip_ToARGB(A, R, G, B)
+{
+ return (A << 24) | (R << 16) | (G << 8) | B
+}
+
+;#####################################################################################
+
+Gdip_FromARGB(ARGB, ByRef A, ByRef R, ByRef G, ByRef B)
+{
+ A := (0xff000000 & ARGB) >> 24
+ R := (0x00ff0000 & ARGB) >> 16
+ G := (0x0000ff00 & ARGB) >> 8
+ B := 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+Gdip_AFromARGB(ARGB)
+{
+ return (0xff000000 & ARGB) >> 24
+}
+
+;#####################################################################################
+
+Gdip_RFromARGB(ARGB)
+{
+ return (0x00ff0000 & ARGB) >> 16
+}
+
+;#####################################################################################
+
+Gdip_GFromARGB(ARGB)
+{
+ return (0x0000ff00 & ARGB) >> 8
+}
+
+;#####################################################################################
+
+Gdip_BFromARGB(ARGB)
+{
+ return 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+StrGetB(Address, Length=-1, Encoding=0)
+{
+ ; Flexible parameter handling:
+ if Length is not integer
+ Encoding := Length, Length := -1
+
+ ; Check for obvious errors.
+ if (Address+0 < 1024)
+ return
+
+ ; Ensure 'Encoding' contains a numeric identifier.
+ if Encoding = UTF-16
+ Encoding = 1200
+ else if Encoding = UTF-8
+ Encoding = 65001
+ else if SubStr(Encoding,1,2)="CP"
+ Encoding := SubStr(Encoding,3)
+
+ if !Encoding ; "" or 0
+ {
+ ; No conversion necessary, but we might not want the whole string.
+ if (Length == -1)
+ Length := DllCall("lstrlen", "uint", Address)
+ VarSetCapacity(String, Length)
+ DllCall("lstrcpyn", "str", String, "uint", Address, "int", Length + 1)
+ }
+ else if Encoding = 1200 ; UTF-16
+ {
+ char_count := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "uint", 0, "uint", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(String, char_count)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "str", String, "int", char_count, "uint", 0, "uint", 0)
+ }
+ else if Encoding is integer
+ {
+ ; Convert from target encoding to UTF-16 then to the active code page.
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", 0, "int", 0)
+ VarSetCapacity(String, char_count * 2)
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", &String, "int", char_count * 2)
+ String := StrGetB(&String, char_count, 1200)
+ }
+
+ return String
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/SuperSleep.dll b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/SuperSleep.dll
new file mode 100644
index 0000000..535d320
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/SuperSleep.dll differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/ViGEmWrapper.dll b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/ViGEmWrapper.dll
new file mode 100644
index 0000000..2a08e3a
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/ViGEmWrapper.dll differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/__controller_functions__.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/__controller_functions__.ahk
new file mode 100644
index 0000000..14d30c3
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/__controller_functions__.ahk
@@ -0,0 +1,191 @@
+
+/**********************************************
+* Controller methods for simplicity *
+***********************************************/
+*/
+
+GoTo EndControllerFunctionsDef
+
+;;;;;;;;;;;; Turning functions
+;;;;;;;;;;;; For holding the stick in a specific position for a period of time
+;;;;;;;;;;;; Note no other button may be pressed or released when these functions are ran
+
+; Set the time you want to turn for in miliseconds and how hard (50, 100), 100 being the most, 50 being neutral
+Turn_Right(sleept, inten){
+ t := sleept
+ controller.Axes.LX.SetState(inten)
+ gosub, Turn
+ controller.Axes.LX.SetState(50)
+}
+
+; Set the time you want to turn for in miliseconds and how hard (0, 50), 0 being the most
+Turn_Left(sleept, inten){
+ t := sleept
+ controller.Axes.LX.SetState(inten)
+ gosub, Turn
+ controller.Axes.LX.SetState(50)
+}
+
+;;;;;;;;;;;; Simple button press functions
+;;;;;;;;;;;; You can pass a delay amount or leave it blank
+;;;;;;;;;;;; Longer delays hold the button longer
+
+; Press X button
+Press_X(delay:=200){
+ controller.Buttons.Cross.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.Cross.SetState(false)
+ return
+}
+
+; Press O button
+Press_O(delay:=200){
+ controller.Buttons.Circle.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.Circle.SetState(false)
+ return
+}
+
+; Press Triangle button
+Press_Triangle(delay:=200){
+ controller.Buttons.Triangle.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.Triangle.SetState(false)
+ return
+}
+
+; Press Square button
+Press_Square(delay:=200){
+ controller.Buttons.Square.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.Square.SetState(false)
+ return
+}
+
+; Press R1 button
+Press_L1(delay:=200){
+ controller.Buttons.L1.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.L1.SetState(false)
+ return
+}
+
+; Press R1 button
+Press_R1(delay:=200){
+ controller.Buttons.R1.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.R1.SetState(false)
+ return
+}
+
+; Press Right on D-pad
+Press_Right(delay:=200){
+ controller.Dpad.SetState("Right")
+ DllCall("Sleep", "UInt", delay)
+ controller.Dpad.SetState("None")
+ return
+}
+
+; Press Left on D-pad
+Press_Left(delay:=200){
+ controller.Dpad.SetState("Left")
+ DllCall("Sleep", "UInt", delay)
+ controller.Dpad.SetState("None")
+ return
+}
+
+; Press Up on D-pad
+Press_Up(delay:=200){
+ controller.Dpad.SetState("Up")
+ DllCall("Sleep", "UInt", delay)
+ controller.Dpad.SetState("None")
+ return
+}
+
+; Press Down on D-pad
+Press_Down(delay:=200){
+ controller.Dpad.SetState("Down")
+ DllCall("Sleep", "UInt", delay)
+ controller.Dpad.SetState("None")
+ return
+}
+
+;;;;;;;;;;; Other functions specific to GT7
+
+; Turn on nitrous
+Nitrous_On(){
+ controller.Buttons.RS.SetState(true)
+}
+
+; Turn off nitrous
+Nitrous_Off(){
+ controller.Buttons.RS.SetState(false)
+}
+
+Accel_On(control:=100){
+ controller.Buttons.R2.SetState(true)
+ controller.Axes.RT.SetState(control)
+}
+
+Accel_Off(){
+ controller.Buttons.R2.SetState(false)
+ controller.Axes.RT.SetState(0)
+}
+
+Brake_On(control:=100){
+ controller.Buttons.L2.SetState(true)
+ controller.Axes.LT.SetState(control)
+}
+
+Brake_Off(){
+ controller.Buttons.L2.SetState(false)
+ controller.Axes.LT.SetState(0)
+}
+; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
+Turn:
+ t0 := A_TickCount
+ tf := t0+t
+ loop {
+ Sleep(100)
+ } until A_TickCount > tf
+ return
+
+
+Press_Options(){
+ controller.Buttons.Options.SetState(true)
+ Sleep, 50
+ controller.Buttons.Options.SetState(false)
+ }
+
+PressShare(){
+ controller.Buttons.Share.SetState(true)
+ Sleep, 50
+ controller.Buttons.Share.SetState(false)
+ }
+
+PressX:
+; Just for menuing, does not hold X down
+ controller.Buttons.Cross.SetState(true)
+ DllCall("Sleep", "UInt", 200)
+ controller.Buttons.Cross.SetState(false)
+ return
+
+PressO:
+; Just for menuing, does not hold O down
+ controller.Buttons.Circle.SetState(true)
+ DllCall("Sleep", "UInt", 200)
+ controller.Buttons.Circle.SetState(false)
+ return
+
+PressRight:
+; For turning
+ controller.Dpad.SetState("Right")
+ Sleep, 50
+ controller.Dpad.SetState("None")
+
+
+ return
+
+
+
+EndControllerFunctionsDef:
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/__utility__.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/__utility__.ahk
new file mode 100644
index 0000000..1d0470d
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Lib/__utility__.ahk
@@ -0,0 +1,136 @@
+/**********************************************
+* Only place functions here, no sub routines *
+***********************************************/
+
+
+; Grabs the colors of the pixels (x-b, y-b) to (x+b, y+b)
+; returns the array of colors
+*/
+
+BitGrab(x, y, b)
+{
+ HWND := WinExist("PS Remote Play")
+ pToken := Gdip_Startup()
+ pBitmap := Gdip_BitmapFromHWND2(hwnd)
+
+ pixs := []
+ for i in range(-1*b, b+1){
+ for j in range(-1*b, b+1){
+ pixel := Gdip_GetPixel(pBitmap,x+i,y+j)
+ rgb := ConvertARGB( pixel )
+ pixs.Push(rgb)
+ }
+ }
+
+ Gdip_DisposeImage(pBitmap)
+ Gdip_Shutdown(pToken)
+ return pixs
+}
+
+Gdip_BitmapFromHWND2(hwnd)
+{
+ WinGetPos,,, Width, Height, ahk_id %hwnd%
+ hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ RegExMatch(A_OsVersion, "\d+", Version)
+ PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ return pBitmap
+}
+
+range(start, stop:="", step:=1) {
+ static range := { _NewEnum: Func("_RangeNewEnum") }
+ if !step
+ throw "range(): Parameter 'step' must not be 0 or blank"
+ if (stop == "")
+ stop := start, start := 0
+ ; Formula: r[i] := start + step*i ; r = range object, i = 0-based index
+ ; For a postive 'step', the constraints are i >= 0 and r[i] < stop
+ ; For a negative 'step', the constraints are i >= 0 and r[i] > stop
+ ; No result is returned if r[0] does not meet the value constraint
+ if (step > 0 ? start < stop : start > stop) ;// start == start + step*0
+ return { base: range, start: start, stop: stop, step: step }
+}
+
+_RangeNewEnum(r) {
+ static enum := { "Next": Func("_RangeEnumNext") }
+ return { base: enum, r: r, i: 0 }
+}
+
+_RangeEnumNext(enum, ByRef k, ByRef v:="") {
+ stop := enum.r.stop, step := enum.r.step
+ , k := enum.r.start + step*enum.i
+ if (ret := step > 0 ? k < stop : k > stop)
+ enum.i += 1
+ return ret
+}
+
+
+Sleep(ms=1)
+{
+ global timeBeginPeriodHasAlreadyBeenCalled
+ if (timeBeginPeriodHasAlreadyBeenCalled != 1)
+ {
+ DllCall("Winmm.dll\timeBeginPeriod", UInt, 1)
+ timeBeginPeriodHasAlreadyBeenCalled := 1
+ }
+
+ DllCall("Sleep", UInt, ms)
+}
+
+
+
+PixelColorSimple(pc_x, pc_y)
+{
+ WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
+ if (remotePlay_id = 0)
+ {
+ MsgBox, PS4 Remote Play not found
+ return
+ }
+ if remotePlay_id
+ {
+ pc_wID := remotePlay_id[0]
+ pc_hDC := DllCall("GetDC", "UInt", pc_wID)
+ pc_fmtI := A_FormatInteger
+ SetFormat, IntegerFast, Hex
+ pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
+ pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
+ pc_c .= ""
+ SetFormat, IntegerFast, %pc_fmtI%
+ DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
+ return pc_c
+
+ }
+}
+
+GetClientSize(hWnd, ByRef w := "", ByRef h := "")
+{
+ VarSetCapacity(rect, 16)
+ DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
+ w := NumGet(rect, 8, "int")
+ h := NumGet(rect, 12, "int")
+}
+
+Distance(c1, c2)
+{ ; function by [VxE], return value range = [0, 441.67295593006372]
+return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
+}
+
+ConvertARGB(ARGB, Convert := 0)
+{
+ SetFormat, IntegerFast, Hex
+ RGB += ARGB
+ RGB := RGB & 0x00FFFFFF
+ if (Convert)
+ RGB := (RGB & 0xFF000000) | ((RGB & 0xFF0000) >> 16) | (RGB & 0x00FF00) | ((RGB & 0x0000FF) << 16)
+
+ return RGB
+}
+
+ToolTipper(msg, x := 100, y := 100)
+{
+ if (debug_mode = 1)
+ ToolTip, %msg%, x, y, Screen
+ return
+}
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Mod/TokyoDetections.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Mod/TokyoDetections.ahk
new file mode 100644
index 0000000..0ce6778
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Mod/TokyoDetections.ahk
@@ -0,0 +1,376 @@
+__enableTokyoDetections_mod__ := 1
+IniRead, color_pitstop1, config.ini, Vars, color_pitstop1, 0
+IniRead, color_pitstop2, config.ini, Vars, color_pitstop2, 0
+
+class TokyoTurnContainer
+{
+ __New(startX, startY, endX := 0, endY := 0)
+ {
+ this.startX := startX
+ this.startY := startY
+ this.endX := endX
+ this.endY := endY
+ }
+}
+
+GoTo EndTokyoDetectionsDef
+
+CheckTokyoMFD(x,y, b_size := 1)
+{
+ color_dot := 0x8D8B8C
+ TokyoMFD := false
+ tries := 1000 ; we shouldn't need more than 6 tries, but I have seen it loop passed
+ loop {
+
+ tc := BitGrab(x, y, b_size)
+ SB_SetText(" Searching... " td " < 120",2)
+ for i, c in tc
+ {
+ td := Distance(c, color_dot)
+
+ if (td < 120){
+ SB_SetText(" Found: " td " < 120",2)
+ TokyoMFD := true
+ break
+ }
+ else {
+ ; Gonna try to automate the mfd checker, why not right?
+ if (tries > 0){
+ SB_SetText(" Searching MFD " td " < 110",2)
+ Press_Left()
+ Sleep(100)
+ tries--
+ break
+ }
+ tries := 1000
+ TokyoMFD := true
+ break
+ }
+ }
+
+ } until TokyoMFD = true
+ return
+}
+
+
+CheckTokyoTurn(x,y, b_size := 1)
+{
+ turnStart := A_TickCount
+ color_player := 0xDE6E70
+ TokyoTurnComplete := false
+ loop {
+ SB_SetText(" Searching... " td " < 50",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_player)
+
+ if (td < 50 ){
+ SB_SetText(" Found: " td " < 50",2)
+ TokyoTurnComplete := true
+ break
+ }
+ }
+ ; add recovery so we don't kill run looking for turn. Gonna start with a high number, can adjust lower later.
+ ; added some press down, x's and waits just in case we are in the pit stop
+ if (A_TickCount - turnStart > 90000) {
+ Press_Down()
+ Sleep(300)
+ Press_X()
+ Sleep(500)
+ Press_X()
+ Sleep(7000)
+ GoSub, ResetRace
+ break
+ }
+
+ } until TokyoTurnComplete = true
+ return
+}
+
+CheckTokyoPen1(x,y, b_size := 1)
+{
+ pen1Start := A_TickCount
+
+ color_pen := 0xFFC10B
+ TokyoPen1 := false
+ loop {
+ SB_SetText(" Searching... " td " < 50",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_pen)
+
+ if (td < 50 ){
+ SB_SetText(" Found: " td " < 50",2)
+ TokyoPen1 := true
+ break
+ }
+ }
+ ; add recovery so we don't kill run looking for Pen1. Gonna start with a high number, can adjust lower later.
+ ; started with 1.5 mins, i had these set to 3:33 on other file and still won.
+ if (A_TickCount - pen1Start > 90000) {
+ GoSub, ResetRace
+ break
+ }
+
+ } until TokyoPen1 = true
+ return
+}
+
+CheckTokyoHairpinTurn(x,y, b_size := 1)
+{
+ hairpinStart := A_TickCount
+
+ color_hairpinturn := 0xB3B1B2
+ TokyoHairpinTurn := false
+ loop {
+ SB_SetText(" Searching... " td " < 5",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_hairpinturn)
+
+ if (td < 5){
+ SB_SetText(" Found: " td " < 5",2)
+ TokyoHairpinTurn := true
+ break
+ }
+ }
+ ; add recovery so we don't kill run sitting in hairpin
+ ; set to 1 minute to start, I had this at 3:33 (200000) on my other file and still won.
+ if (A_TickCount - hairpinStart > 90000) {
+
+ GoSub, ResetRace
+ break
+ }
+
+ } until TokyoHairpinTurn = true
+ return
+}
+
+CheckTokyoPen2(x,y, b_size := 1)
+{
+ start := A_TickCount
+ color_pen := 0xFFC10B
+ RecoveryTried := false
+ TokyoPen2 := false
+
+ loop {
+ SB_SetText(" Searching... " td " > 60",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_pen)
+
+ if (td > 60 ){
+ SB_SetText(" Found: " td " > 60",2)
+ TokyoPen2 := true
+ break
+ }
+
+ }
+ if (A_TickCount - start > 35000 AND RecoveryTried = false) {
+ SB_SetText(" We stuck? Starting recovery try.",2)
+ Accel_off()
+ controller.Axes.LX.SetState(50)
+ loop 7 {
+ Press_Square(delay:=50)
+ Sleep(100)
+ }
+ Accel_on(80)
+ Sleep(500)
+ loop 9 {
+ Press_Triangle(delay:=50)
+ Sleep(100)
+ }
+ controller.Axes.LX.SetState(30)
+ RecoveryTried := true
+ }
+
+ if (A_TickCount - start > 60000) {
+ gosub, ResetRace
+ break
+ }
+
+ } until TokyoPen2 = true
+ return
+}
+
+CheckTokyoPenServed(x,y, b_size := 1)
+{
+ color_penserved := 0xAE1B1E
+ TokyoPenServed := false
+ loop {
+ SB_SetText(" Searching... " td " > 60",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_penserved)
+
+ if (td > 60 ){
+ SB_SetText(" Found: " td " > 60",2)
+ TokyoPenServed := true
+ break
+ }
+ }
+
+ } until TokyoPenServed = true
+ return
+}
+
+CheckTokyoPenReceived(x,y, b_size := 1)
+{
+ start := A_TickCount
+ color_penreceived := 0xAE1B1E
+ TokyoPenReceived := false
+ loop {
+ SB_SetText(" Searching... " td " < 40",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_penreceived)
+
+ if (td < 40 ){
+ SB_SetText(" Found: " td " < 40",2)
+ guicontrol,, CurrentLoop, Pen received
+ TokyoPenReceived := true
+ break
+ }
+ if (TokyoLapCount != 6 AND A_TickCount - start > 36000)
+ {
+ SB_SetText(" Not found in time. Shifting up.",2)
+ loop 6 {
+ Press_Triangle(delay:=50)
+ Sleep(200)
+ TokyoPenReceived := true
+ break
+ }
+ break
+ }
+ if (TokyoLapCount = 6 AND A_TickCount - start > 46000)
+ {
+ SB_SetText(" Not found in time. Shifting up.",2)
+ loop 20 {
+ Press_Triangle(delay:=50)
+ Sleep(200)
+ TokyoPenReceived := true
+ break
+ }
+ break
+ }
+
+ }
+ } until TokyoPenReceived = true
+ return
+}
+
+CheckTokyoPitstopDone(x,y, b_size := 1)
+{
+ pitstopDoneStart := A_TickCount
+
+ color_pitstopdone := 0xFFFFFF
+ TokyoPitstopDone := false
+ loop {
+ SB_SetText(" Searching... " td " > 10",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_pitstopdone)
+
+ if (td > 10 ){
+ SB_SetText(" Found: " td " > 10",2)
+ TokyoPitstopDone := true
+ break
+ }
+ }
+ ; add recovery so we don't kill run sitting in pit, havent tested if press down works to get us out
+ if (A_TickCount - pitstopDoneStart > 60000) {
+ Press_Down()
+ Sleep(300)
+ Press_X()
+ Sleep(500)
+ Press_X()
+ Sleep(7000)
+ GoSub, ResetRace
+ }
+ } until TokyoPitstopDone = true
+ return
+}
+
+CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+{
+if ( A_TickCount - loopStartTime > maxTime AND TokyoLapCount <= 10) {
+ gosub, ResetRace
+ }
+else if (A_TickCount - loopStartTime > maxTime+90000 AND TokyoLapCount > 10)
+ {
+ gosub, ResetRace
+ }
+}
+
+CheckTokyoPitstop1(x,y, b_size := 1)
+{
+ pitstop1Start := A_TickCount
+
+ ;color_pitstop1 := 0xFFFFFF
+ ;color_pitstop1 := 0x818002
+ ;color_pitstop1 := 0xFBFB00 ; old color
+ TokyoPitstop := false
+ loop {
+ SB_SetText(" Searching... " td " < 10",2)
+ tc := BitGrab(x, y, b_size)
+ for i, c in tc
+ {
+ td := Distance(c, color_pitstop1)
+
+ if (td < 10 ){
+ SB_SetText(" Found: " td " < 10",2)
+ TokyoPitstop := true
+ break
+ }
+ }
+ ; add recovery so we don't kill run sitting in pit, havent tested if press down works to get us out
+ if (A_TickCount - pitstop1Start > 60000) {
+ Press_Down()
+ Sleep(300)
+ Press_X()
+ Sleep(500)
+ Press_X()
+ Sleep(7000)
+ GoSub, ResetRace
+ }
+ guicontrol,, CurrentLoop, Stuck in pit? Press GUI Button.
+
+ } until TokyoPitstop = true
+ return
+}
+UpdateAVG(racecounter, script_start)
+{
+ SetFormat, integerfast, d
+ creditcountersession := (835000*racecounter)/1000000
+ SetFormat, integerfast, d
+ SetFormat, FloatFast, 0.2
+ creditavg := creditcountersession/(A_TickCount-script_start)*3600000
+ guicontrol,, CreditAVG, Avg./h: ~%creditavg% M
+ return
+}
+
+UpdateTimer()
+{
+ElapsedTime := A_TickCount - script_start
+ VarSetCapacity(t,256),DllCall("GetDurationFormat","uint",2048,"uint",0,"ptr",0,"int64",ElapsedTime*10000,"wstr","d' day(s) 'h':'mm':'ss","wstr",t,"int",256)
+ SB_SetText("Runtime: " t,3)
+ return
+}
+
+HexToDec(hex)
+{
+ VarSetCapacity(dec, 66, 0)
+ , val := DllCall("msvcrt.dll\_wcstoui64", "Str", hex, "UInt", 0, "UInt", 16, "CDECL Int64")
+ , DllCall("msvcrt.dll\_i64tow", "Int64", val, "Str", dec, "UInt", 10, "CDECL")
+ return dec
+}
+
+
+EndTokyoDetectionsDef:
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Race.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Race.ahk
new file mode 100644
index 0000000..f948f41
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Race.ahk
@@ -0,0 +1,86 @@
+#Include Races\PanAm.ahk
+#Include Races\Tokyo.ahk
+
+GoTo EndRaceDef
+
+Race:
+
+ Switch RaceChoice
+ {
+ case "PanAm":
+ Race_PANAM()
+ return
+ case "Tokyo":
+ Race_Tokyo()
+ return
+ }
+
+ return
+
+SettingsSheet:
+
+ Gui, 4: Show, AutoSize, Settings Sheet
+ ;/////////////////////////////////////////////////////////
+ ; Add images to your setup here and in the Src folder
+ ;
+ ;/////////////////////////////////////////////////////////
+ Switch RaceChoice
+ {
+ case "PanAm":
+
+ assist_1 = %A_ScriptDir%\Src\PanAm\Assist1.jpg
+ assist_2 = %A_ScriptDir%\Src\PanAm\Assist2.jpg
+ tune_1 = %A_ScriptDir%\Src\PanAm\CarSetup.jpg
+ tune_2 = %A_ScriptDir%\Src\PanAm\CarGearRatio.jpg
+ controls = %A_ScriptDir%\Src\PanAm\Controller.jpg
+ return
+ case "Tokyo":
+
+ assist_1 = %A_ScriptDir%\Src\Tokyo\Assist_Settings.png
+ assist_2 = %A_ScriptDir%\Src\Tokyo\Misc_Settings.png
+ controls = %A_ScriptDir%\Src\Tokyo\Controller_Settings.png
+ tune_1 = %A_ScriptDir%\Src\Tokyo\Settings_Car1.png
+ tune_2 = %A_ScriptDir%\Src\Tokyo\Settings_Car2.png
+ tune_3 = %A_ScriptDir%\Src\Tokyo\Settings_Car3.png
+ return
+ }
+
+
+ return
+
+Assists1:
+ GuiControl, 4:, CurrentPic, %assist_1%
+ gosub, Guisizer
+ return
+
+Assists2:
+ GuiControl, 4:, CurrentPic, %assist_2%
+ gosub, Guisizer
+ return
+
+Tune1:
+ GuiControl, 4:, CurrentPic, %tune_1%
+ gosub, Guisizer
+ return
+
+Tune2:
+ GuiControl, 4:, CurrentPic, %tune_2%
+ gosub, Guisizer
+ return
+
+Tune3:
+ GuiControl, 4:, CurrentPic, %tune_2%
+ gosub, Guisizer
+ return
+
+ControllerSetting:
+ GuiControl, 4:, CurrentPic, %controls%
+ gosub, Guisizer
+ return
+
+Guisizer:
+ GuiControl, 4: Move, CurrentPic, % "x" 10 "y" 40 "w" 1200 . " h" . 800
+ Gui, 4: Show, AutoSize, Settings Sheet
+ return
+
+EndRaceDef:
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Races/Tokyo.ahk b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Races/Tokyo.ahk
new file mode 100644
index 0000000..4d9f82e
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Races/Tokyo.ahk
@@ -0,0 +1,509 @@
+GoTo EndRace_Tokyo_Def
+
+Race_Tokyo()
+{
+ IniRead, hairpin_delay, config.ini, Vars, hairpin_delay, 0
+ IniRead, RaceCounterTotal, config.ini, Stats, racecountertotal, 0
+ IniRead, ResetCounterTotal, config.ini, Stats, resetcountertotal, 0
+ SetFormat, integerfast, d
+ TokyoStart:
+ ;- VARIABLES -----------------------------------------------------------------------------
+ SetFormat, integerfast, d
+ TokyoLapCount := 1
+ maxTime := 200000
+ StringSplit, PitstopTimingsArray, PitstopTimings, `,
+ ;- COORDINATES: TURNS --------------------------------------------------------------------
+ TokyoTurn1 := new TokyoTurnContainer(611, 59+remote_play_offsetY, 622, 69+remote_play_offsetY)
+ TokyoTurn2 := new TokyoTurnContainer(618, 70+remote_play_offsetY, 601, 76+remote_play_offsetY)
+ TokyoTurn3 := new TokyoTurnContainer(599, 79+remote_play_offsetY, 591, 87+remote_play_offsetY)
+ TokyoTurn4 := new TokyoTurnContainer(589, 88+remote_play_offsetY, 571, 96+remote_play_offsetY)
+ TokyoTurn5 := new TokyoTurnContainer(567, 96+remote_play_offsetY, 556, 90+remote_play_offsetY)
+ TokyoTurn6 := new TokyoTurnContainer(554, 86+remote_play_offsetY, 543, 82+remote_play_offsetY)
+ TokyoTurn7 := new TokyoTurnContainer(538, 81+remote_play_offsetY, 530, 75+remote_play_offsetY)
+ TokyoTurn8 := new TokyoTurnContainer(530, 75+remote_play_offsetY, 510, 72+remote_play_offsetY)
+ ;- COORDINATES: PENALTY WARNINGS ---------------------------------------------------------
+ TokyoPenWarning := new TokyoTurnContainer(360, 154+remote_play_offsetY, 408, 154+remote_play_offsetY)
+ TokyoPenIndicator := new TokyoTurnContainer(366, 132+remote_play_offsetY)
+ ;- COORDINATES: HAIRPIN TURN -------------------------------------------------------------
+ TokyoHairpinTurn := new TokyoTurnContainer(606, 334+remote_play_offsetY)
+ ;- COORDINATES: PENALTY WARNINGS ---------------------------------------------------------
+ TokyoPen := new TokyoTurnContainer(360, 154+remote_play_offsetY, 408, 154+remote_play_offsetY)
+ TokyoPenServed := new TokyoTurnContainer(366, 132+remote_play_offsetY)
+ ;- COORDINATES: HAIRPIN TURN--------------------------------------------------------------
+ TokyoHairpinTurn := new TokyoTurnContainer(606, 334+remote_play_offsetY)
+ ;- MISC ----------------------------------------------------------------------------------
+ TokyoPitstop := new TokyoTurnContainer(191, 316+remote_play_offsetY, 580, 383+remote_play_offsetY)
+ TokyoPitstopEnter := new TokyoTurnContainer(530, 70+remote_play_offsetY)
+ TokyoPitstopDone := new TokyoTurnContainer(57, 329+remote_play_offsetY)
+ TokyoRestartRace := new TokyoTurnContainer(405,465+remote_play_offsetY)
+ TokyoMFD := new TokyoTurnContainer(557, 382+remote_play_offsetY)
+ ;- RACE START ----------------------------------------------------------------------------
+ controller.Axes.LX.SetState(65)
+ Sleep(7400)
+ FormatTime, TGTime,, MM/dd hh:mm:ss
+ FileAppend, %TGTime%: Race started.`n, log.txt
+ url := "https://api.telegram.org/bot" TelegramBotToken "/sendMessage?text=" TGTime ": Race started.&chat_id=" TelegramChatID
+ hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
+ hObject.Open("GET",url)
+ hObject.Send()
+ guicontrol,, CurrentLoop, Race started. Good luck!
+ guicontrol,, CurrentLap, Current Lap: %TokyoLapCount% /12
+ Accel_On(100)
+ loop 3 {
+ Press_Triangle(delay:=50)
+ Sleep(200)
+ }
+ Sleep(800)
+ controller.Axes.LX.SetState(65)
+ CheckTokyoMFD(TokyoMFD.startX, TokyoMFD.startY)
+;- 12 LAP LOOP ---------------------------------------------------------------------------
+ loop 12
+ {
+ location := "Start/Finish"
+ guicontrol,, CurrentLoop, Current Location: %location%
+ loopStartTime := A_TickCount
+ ; Turn 1
+ location := "T1 Start"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn1.startX, TokyoTurn1.startY)
+ loop 3 {
+ Press_Triangle(delay:=50)
+ Sleep(200)
+ }
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(36)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ Sleep(1000)
+ location := "T1 End"
+ CheckTokyoTurn(TokyoTurn1.endX, TokyoTurn1.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(35)
+ Sleep(1000)
+ ; Turn 2
+ location := "T2 Start"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn2.startX, TokyoTurn2.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(52)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ Sleep(1000)
+ location := "T2 End"
+ CheckTokyoTurn(TokyoTurn2.endX, TokyoTurn2.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(40)
+ Sleep(1000)
+ ; Turn 3
+ location := "T3 Start"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn3.startX, TokyoTurn3.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ Sleep(1000)
+ controller.Axes.LX.SetState(40)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn3.endX, TokyoTurn3.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(70)
+ Sleep(1000)
+ ; Turn 4
+ location := "T4 Start"
+ Accel_On(85)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn4.startX, TokyoTurn4.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ Sleep(1000)
+ controller.Axes.LX.SetState(68)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn4.endX, TokyoTurn4.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(60)
+ Accel_On(70)
+ Sleep(1000)
+ ; Turn 5
+ location := "T5 Start"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn5.startX, TokyoTurn5.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(42)
+ Sleep(1000)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn5.endX, TokyoTurn5.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(63)
+ Sleep(1000)
+ ; Turn 6
+ location := "T6 Start"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn6.startX, TokyoTurn6.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(70)
+ Sleep(1000)
+ Accel_on(75)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn6.endX, TokyoTurn6.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(40)
+ Sleep(1000)
+ ; Turn 7
+ location := "T7 Start"
+ Accel_On(100)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn7.startX, TokyoTurn7.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(40)
+ Sleep(1000)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn7.endX, TokyoTurn7.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(70)
+ Sleep(1000)
+ ; Turn 8
+ location := "T8 Start"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn8.startX, TokyoTurn8.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(65)
+ Sleep(1000)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoTurn8.endX, TokyoTurn8.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(30)
+ Sleep(2000)
+ Brake_on(100)
+ Sleep(2200)
+ Brake_off()
+ Accel_On(35)
+ ; Penalty Warning 1
+ location := "Hairpin Entrance"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoPen1(TokyoPenWarning.startX, TokyoPenWarning.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ Accel_On(32)
+ if (TokyoLapCount=12) {
+ Accel_On(34)
+ }
+ controller.Axes.LX.SetState(40)
+ Sleep(1000)
+ ; Hairpin Turn
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ location := "Hairpin Turn"
+ CheckTokyoHairpinTurn(TokyoHairpinTurn.startX, TokyoHairpinTurn.startY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+
+ if (DynTurnDelay)
+ {
+ if ((ThairpinS - 6000) > 0) {
+ hairpin_delayn := HexToDec(hairpin_delay - 20 - ( 50 * Floor((ThairpinS - 6000)/1000)))
+ If ( hairpin_delayn <0 ){
+ hairpin_delayn := 0
+ }
+ guicontrol,, CurrentLoop, Turn delay: %hairpin_delayn% (Dynamic)
+ }
+ if ((ThairpinS - 5000) < 0) {
+ hairpin_delayn := HexToDec(hairpin_delay + 50 + ( 20 * Floor((5000 - ThairpinS)/1000) ))
+ guicontrol,, CurrentLoop, Turn delay: %hairpin_delayn% (Dynamic)
+ }
+ if (6000<=ThairpinS>=5000) {
+ hairpin_delayn := HexToDec(hairpin_delay)
+ guicontrol,, CurrentLoop, Turn delay: %hairpin_delayn% (Default)
+ }
+ Sleep(hairpin_delayn)
+ }
+ else
+ {
+ Sleep(hairpin_delay)
+ }
+ controller.Axes.LX.SetState(100)
+ Sleep(200)
+ Accel_Off()
+ Sleep(4200)
+ Accel_On(45) ;was 40
+ controller.Axes.LX.SetState(60)
+ Accel_Off()
+ Sleep(800)
+ controller.Axes.LX.SetState(40)
+ Accel_On(50)
+ Sleep(5000)
+ controller.Axes.LX.SetState(30)
+ Sleep(5500)
+ Accel_On(80)
+ loop 30 { ; failsafe, if we ever get a reset caused by a cone under the car
+ Press_Triangle(delay:=100)
+ Sleep(200)
+ }
+ ; Penalty Warning 2
+ location := "Hairpin exit"
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoPen2(TokyoPen.endX, TokyoPen.endY)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ Sleep(1000)
+ if (TokyoLapCount <= 11)
+ {
+ location := "Pit entrance"
+ Accel_On(53)
+ controller.Axes.LX.SetState(30)
+ guicontrol,, CurrentLoop, Current Location: %location%
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoTurn(TokyoPitstopEnter.startX, TokyoPitstopEnter.startY)
+ controller.Axes.LX.SetState(0)
+ Accel_On(55)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoPitstop1(TokyoPitstop.startX, TokyoPitstop.startY)
+ location := "In pit"
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(50)
+
+ if (TokyoLapCount = 1)
+ {
+ SetFormat, integerfast, d
+ location := "In pit: Waiting " Round(PitstopTimingsArray1/1000) " seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (PitstopTimingsArray1)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 2)
+ {
+ SetFormat, integerfast, d
+ location := "In pit: Waiting " Round(PitstopTimingsArray2/1000) " seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (PitstopTimingsArray2)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 3)
+ {
+ SetFormat, integerfast, d
+ location := "In pit: Waiting " Round(PitstopTimingsArray3/1000) " seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (PitstopTimingsArray3)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 4)
+ {
+ SetFormat, integerfast, d
+ location := "In pit: Waiting " Round(PitstopTimingsArray4/1000) " seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (PitstopTimingsArray4)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 5)
+ {
+ SetFormat, integerfast, d
+ location := "In pit: Waiting " Round(PitstopTimingsArray5/1000) " seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (PitstopTimingsArray5)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 6)
+ {
+ SetFormat, integerfast, d
+ location := "In pit: Waiting " Round(PitstopTimingsArray6/1000) " seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (PitstopTimingsArray6)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 7)
+ {
+ SetFormat, integerfast, d
+ location := "In pit: Waiting " Round(PitstopTimingsArray7/1000) " seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (PitstopTimingsArray7)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 8)
+ {
+ SetFormat, integerfast, d
+ location := "In pit: Waiting " Round(PitstopTimingsArray8/1000) " seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (PitstopTimingsArray8)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 9)
+ {
+ SetFormat, integerfast, d
+ location := "In pit: Waiting " Round(PitstopTimingsArray9/1000) " seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (PitstopTimingsArray9)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 10)
+ {
+ SetFormat, integerfast, d
+ location := "In pit: Waiting " Round(PitstopTimingsArray10/1000) " seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (PitstopTimingsArray10)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 11)
+ {
+ SetFormat, integerfast, d
+ location := "In pit: Waiting " Round(PitstopTimingsArray11/1000) " seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (PitstopTimingsArray11)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ if (TokyoLapCount = 12)
+ {
+ SetFormat, integerfast, d
+ location := "In pit: Waiting " Round(PitstopTimingsArray12/1000) " seconds."
+ guicontrol,, CurrentLoop, %location%
+ Sleep (PitstopTimingsArray12)
+ Press_Up()
+ Sleep (100)
+ Press_X()
+ Sleep (100)
+ Press_X()
+ }
+ controller.Axes.LX.SetState(20)
+ Accel_On(100)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoPenReceived(TokyoPenServed.startX, TokyoPenServed.startY)
+ location := "Start/Finish"
+ guicontrol,, CurrentLoop, Current Location: %location%
+ controller.Axes.LX.SetState(38)
+ Sleep (500)
+ loop 10 {
+ Press_Triangle(delay:=200)
+ sleep, 200
+ }
+ }
+ else {
+ location := "Start/Finish"
+ guicontrol,, CurrentLoop, Current Location: %location%
+ Accel_On(100)
+ controller.Axes.LX.SetState(60)
+ CheckMaxTime(maxTime, loopStartTime, TokyoLapCount)
+ CheckTokyoPenServed(TokyoPenServed.startX, TokyoPenServed.startY)
+ }
+ SetFormat, integerfast, d
+ TokyoLapCount++
+ guicontrol,, CurrentLap, Current Lap: %TokyoLapCount% /12
+ ProgressRace := (100/13)*TokyoLapCount
+ guicontrol,, RaceProgress, %ProgressRace%
+
+ if(TokyoLapCount = "13")
+ {
+ location := "Finish line"
+
+ FormatTime, TGTime,, MM/dd hh:mm:ss
+ FileAppend, %TGTime% Race finished.`n, log.txt
+ url := "https://api.telegram.org/bot" TelegramBotToken "/sendMessage?text=" TGTime ": Race finished.&chat_id=" TelegramChatID
+ hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
+ hObject.Open("GET",url)
+ hObject.Send()
+
+ guicontrol,, CurrentLoop, Current Location: %location%
+ guicontrol,, CurrentLap, GG!
+ controller.Axes.LX.SetState(50)
+ SetFormat, integerfast, d
+ racecounter++
+ SetFormat, integerfast, d
+ racecountertotal++
+
+ ; // THIS SESSION
+ SetFormat, integerfast, d
+ SetFormat, FloatFast, 0.2
+ creditcountersession := (835000*racecounter)/1000000
+ SetFormat, integerfast, d
+ SetFormat, FloatFast, 0.2
+ creditavg := creditcountersession/(A_TickCount-script_start)*3600000
+ guicontrol,, RaceCounterSession, Races completed: %racecounter%
+ guicontrol,, ResetCounterSession, Races failed: %resetcounter%
+ guicontrol,, CreditCounterSession, Credits: %creditcountersession% M
+ guicontrol,, CreditAVGSession, Avg./h: %creditavg% M
+
+ ; // ALL TIME
+ SetFormat, integerfast, d
+ SetFormat, FloatFast, 0.2
+ creditcountertotal := (835000*racecountertotal)/1000000
+ IniWrite, %racecountertotal%, config.ini,Stats, RaceCounterTotal
+ IniWrite, %resetcountertotal%, config.ini,Stats, ResetCounterTotal
+ guicontrol,, RaceCounterTotal, Races completed: %racecountertotal%
+ guicontrol,, ResetCounterTotal, Races failed: %resetcountertotal%
+ guicontrol,, CreditCounterTotal, Credits: %creditcountertotal% M
+ UpdateAVG(racecounter, script_start)
+ lapcounter =
+ ProgressRace =
+ guicontrol,, RaceProgress, %ProgressRace%
+ loop
+ {
+ restart_found := false
+ c2 := BitGrab(162, 43+remote_play_offsetY, 2)
+ for i, c in c2
+ {
+ d2 := Distance(c, color_restart)
+ SB_SetText(" Searching... " d2 " < 50",2)
+ if (d2 < 10 )
+ {
+ SB_SetText(" Found: Restart Color " d2 " < 50",2)
+ restart_found := true
+ break
+ }
+ }
+ if (restart_found)
+ break
+ Press_X()
+ Sleep(500)
+ }
+ Sleep(400)
+ Press_O()
+ Sleep(500)
+ Press_Right()
+ Sleep(3000)
+ Press_X()
+ Sleep(4000)
+ Press_X()
+ Sleep(4000)
+ guicontrol,, CurrentLoop, Setting up next race.
+ Press_Options()
+ Sleep(1000)
+ Press_Right()
+ Sleep(500)
+ Press_X()
+ controller.Axes.LX.SetState(50)
+ UpdateAVG(racecounter, script_start)
+ Goto, TokyoStart
+ }
+ }
+}
+EndRace_Tokyo_Def:
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Src/Tokyo/tokyo_car1.png b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Src/Tokyo/tokyo_car1.png
new file mode 100644
index 0000000..57b21c5
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/Src/Tokyo/tokyo_car1.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/config.ini b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/config.ini
new file mode 100644
index 0000000..22a41d0
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/config.ini differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/log.txt b/bnowakow/old versions/5 Tokyo/GT7-TOKYO-9.4/log.txt
new file mode 100644
index 0000000..e69de29
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/GT7_Tokyo.ico b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/GT7_Tokyo.ico
new file mode 100644
index 0000000..94b799c
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/GT7_Tokyo.ico differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/doc.html b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/doc.html
new file mode 100644
index 0000000..dad474f
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/doc.html
@@ -0,0 +1,336 @@
+
+
+
+
+
+
+ GT7 - Tokyo X by problemz.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Konnichiwa friend o/
+
In this documentation you learn how the Tokyo WTC 600 race works and how to set up the Tokyo X AHK script to farm GT7 credits when you are away from your computer or busy doing other tasks.Please read carefully and double-check everything in this documentation if something isn't working as described. The PSNProfiles Discord has many helpful members that will assist you in getting the script running for your configuration, provided you have read and followed the directions below first.
Problemz, what is happening and why does it all work?
+
Some time ago i started to look for the race with the best credits per hour ratio. After an update, the WTC 600 - Tokyo Race became the clear winner and i started writing the script.
For this race we have different obstacles:
+
+
+
Obstacle
+
Description
+
+
+
PP restriction
+
We are only allowed to enter a car with a maximum of 600 PP.
+
+
+
Tire/fuel consumption
+
Tire (9x) and fuel (3x) consumption is active. That means we must find the best way to finish the race with the least RNG possible. (Worn tires can lead to spinouts, we must not not run out of fuel, etc.)
+
+
+
Track condition
+
Track conditions There are 12 laps total, and the race starts with a very wet track. The track dries throughout the race and and we must react accordingly in order to not spin out or run into obstacles that we can’t recover from (mainly barrels in the hairpin turn).
+
+
+
AI/Opponents
+
You start the race with 15 other opponents. We try to avoid them as much as possible in order to not spin out or miss set detection pixels (explained later).
+
+
+
Hairpin turn
+
There is a hairpin in this track. And it is here to make our scripting lives horrible.The inner side is blocked by big cones, hindering us from just grinding the inner part of the turn.On the outer side we have small cones and 90° walls. The walls are hindering us from just grinding the outside, the small cones often resets our car (when stuck under the car), spawning us back in the first gear.
+
+
+
Let's start explaining how we mastered this race to earn some good credits:
+
+
Overcoming the obstacles. 1 by 1.
+
+
+
+
PP restriction
+
Track condition
+
Tire/fuel consumptions
+
AI/Opponents
+
Final boss: Hairpin
+
+
+ We use a bug in the code to jump below the allowed PP, but still having the fastest car ( Dodge SRT Tomahawk X VGT). We manipulate the gear ratios to a point, where the PP calculation shows PP.From there we fiddle with values until the PP calculation is under 600 PP.This still works after the PP-Patch.
+ The race starts with a very wet track. We have to start with intermediates.After a few laps, the track starts to get dryer, but we can't just switch to Hards. We are not driving the ideal line. We hit some wet spots here and there, therefore we stay on intermediates for the whole race. Otherwise we would risk to RNG-Spin at many different spots, which endangers ours consistency.
+ I found out, that there is an internal cooldown for the penalty counter.If you receive a penalty and hit or grind a wall/part of the track within 6 seconds, the internal cooldown gets reset.You still collect penalties in a internal penalty storage.The first time you're not hitting something for 6 seconds, the penalty gets triggered and is added to your current penalty.I also found out, that if you keep grinding the wall while serving a penalty, your penalty storage gets reset. If we just keep collecting penalties and finish the race without ever triggering/serving them, we end in a blackscreen and have to close the game and never receive credits.We use all of this to our advantage:We only trigger and serve a 5 second penalty every lap and reset our internal penalty storage, even if we are grinding walls 90% of the time, filling our internal storage.
+ The tires consumption rate is at 9x.We already know that we keep the Intermediates. We use the pit stop to always, consistently, trigger a new 5 second penaltyWe're switching tires every lap - to always have the same behaviour on track, with our set timings/speeds. The fuel consumtion rate is at 3x.Because of our frequent pit visits, we can drive with the fuel map setting 1 (Power).We fill up completely in Lap 6 and continiue driving until the race is finish, after lap 12.
+ We mainly use the pit stops to control our distance to the AI cars.We are using set wait times, depending on our current lap and AI position at this time of the race. There are 2 timings at the momement. Safest: This one always stays behind AI, therefore its slower but we never see AI. Risky: With this timings, we overtake AI on different parts of the track, but never in the hairpin turn.
+ Welcome to the run/consisteny killer #1, the hairpin. After many hours and iterations, our current most consistent way to handle the hairpin is this:We place our car on the left wall, controlling our speed, when reaching the turn detection point. We then steer to the right, release acceleration and reach the other side's left wall. This reads so simple, but it's really much more complicated.You will see why, pretty soon, running the script.
+
+
+
About pixel detection:
This script relies on the detection of specific color pixels at given coordinates to determine the position of the car relative to the racetrack, also some UI elements and respond accordingly. Pixel detection can be affected by a number of factors such as PlayStation version, PC performance, and network throughput, latency and stability.
+There is also a degree of variance that happens with every race. Although we have tried to remove as much of this as possible by pitting every lap and avoiding AI in the hairpin, there is still randomness in AI behavior or in things like how the cones in the hairpin react when hit.
+As such, although we have included a number of variables that allow you to fine tune the script for your specific setup (hairpin turn delay/pit timings), but do not expect to see a 100% completion/win rate. A 75%-90% success is achievable for most people when the correct hairpin turn delay was found.
+
+
+
+
+
Requirements & Informations
+
Hardware:
+
A computer running Microsoft Windows (must be X86 processor, ARM is not supported!)
+
Do NOT connect a Controller to your Playstation or Computer
+
Wired internet connection for stable operation of the script. If you do not have both, PC and Playstation connected by wired internet, you may experience all kinds of different problems. If you use WiFi, we cannot guarantee good operation.
Do NOT minimize Remote Play. Having other windows or programs on top of it is okay, minimizing is NOT.
+
+
Playstation settings:
+
Turn off Playstation system notifications (these can cover the track map, causing issues with our detections)[Example: "Your friend had come online"]
+ IMPORTANT FOR YOUR OWN SAFETY:
+
Turn ON a password requirement for making any purchases on PlayStation.This way, when the script has any problems, it will not be possible to buy any MTX by accident.
THEREFORE, WE ARE NOT RESPONSIBLE FOR ACCIDENTAL PURCHASES IF YOU DON’T TURN THIS ON AS A PRECAUTION.
+
+
Ingame:
+
Player must have finished all Café Menu Books and the final championship (the one with 5 races). This makes sure you have the Tokyo WTC600 championship unlocked.
+
Player has the Dodge SRT Tomahawk X VGT. ($1.000.000)
+
Player has tuning parts for the Dodge SRT Tomahawk X VGT: Ballast, customisable racing transmission, fully adjustable LSD, Racing Hard tires, Intermediate tires. (~$150.000)
+
+ You start after entering the WTC 600 Tokyo race, pause and hover over "Retry".Tokyo WTC600 championship can be found in Asia, it is (currently) the last race option at the Tokyo Expressway track.
In the main GUI you can see your current location on the track, in which lap you are (also visualized by a progress bar) and check out your session/all time stats.
+ Select between 2 different pit stop timings.Safe (slower): You always stay behind the AI cars after you are in first place.
+ Risky (faster): You overtake AI cars, exception: hairpin turn.
Select an option from the dropdown menu, the values are instantly saved and active.You can check out both timings and decide whats suits you better.
+
...myths says there is even a 3rd option
+
Hairpin settings:The hairpin turn delay in ms dictates how fast the script reacts and turns right after fining the pixel we defined. Start with default settings and watch how your hairpin turns look. In the first lap, the hairpin turn can be pretty wide, they will then be good/perfect for the remaining laps.You can try out the option "Dynamic Turn Delay" and find your perfect setup. It measures the time between two detection points and increases/decreases the delay depending on your speed.
Set detection colors:Grab: Pit stop Color - here you can grab the current color when you are stuck in the pit menu (tire selection).You can also manually enter the Hex-Color code when double-clicking on the colored rectangle.Grab: Restart color - here you can grab the current color when you are stuck in the replay window.You can also manually enter the Hex-Color code when double-clicking on the colored rectangle.
Other Features:Save clip after reset - use the Playstation feature to record a 3 minutes clip after a reset is triggered.
+
You can send race reports to your Telegram Account.Here is a quick guide how to set it up:
+
Open Telegram, and start a conversation with @BotFather
+
In the conversation with @BotFather, type ‘/newbot’.
+
Give your bot a nickname, like BotFather instructs you.
+
Pick a username for the bot as BotFather instructs you.
+
BotFather congratulates you and gives you the HTTP API token. This is what you plug into ‘Telegram Bot Token’ inside the Notifications/API settings in the script.
+
Create a new group chat in Telegram, where you invite your bot and @RawDataBot
+
Type ‘/start’ and the Raw Data Bot will spit out some data. Look for “chat” and specifically “id”. This is what you plug into ‘Telegram Chat ID’. Caution: the ID is not just a number, it also has a special character before the number that you MUST include!
+
+
You can set the number of wins until the script stops. Default value is 0 (infinite). To activate this feature, enter your wanted number with the Up-Down control and HIT the button below. It is changing its text, depending on how many wins you set.
+
+
+
+
+
FAQ
+
Can i change the pit stop timings while the script is running? Yes, you can do it and the script will pull the correct timing for the coming pit stop.
+
My race failed. Is something wrong? No. Failures will happen due to Randomness. Script is designed to work most of the time, but failures are inevitable.
+
I can't get my PP to match yours! Help?! CHECK THE TOE!!!!!
+
Why do I pit every lap? Wouldn't it be faster to not pit so much? Faster, yes. But slow is more reliable and the benefit doesn't outweigh the risk.
+
How long can I safely keep my Playstation running? That's not up to us. Your mileage may vary. Be responsible.
+
What do I do with all these credits? You do you, pikachu.
+
How long do I have before this gets fixed? Probably best to think of a patch coming immediately.
+
Why are you doing this? To show that we can.
+
Can I get a beta version of whatever you are working on next? If this lives long enough for updates to be made, they will be released as they are finished.
+
Do starting grids matter? No.
+
How fast are the laps? Anywhere between 2:00 and 3:00 depending on pit delay timings and if you happen to get stuck on something for a moment. Before you @ us... slow is reliable. Reliable is enriching.
+
What should I do if I can't get it to work? Clubman is great. Panam still works. Ask in the Discord, but know you have options.
+
+
Changelog
+
+
+
Tokyo X
+
+
+
+
+
Initial public release
+ Please provide as much information as possible when asking for help (last status text, lap, location - optimally with a video clip).
+
+
+
+
+
+
+
+
+
+
+ Shoutout (alphabetic order) to all these AMAZING PEOPLE from the Discord Tokyo Beta Channel. Thank you for helping me bringing the TOKYO X script to life - it was a great time!
+
+ andow
+ //
+ Atoms4Piece
+ //
+ BeefSupreme
+ //
+ BobGT
+ //
+ CarapauCorrida
+ //
+ Chester
+ //
+ 🐐 (you know)
+ //
+ GTMaster
+ //
+ heidi
+ //
+ hitomi
+ //
+ j0shjones
+ //
+ JordanD123
+ //
+ Krazyy
+ //
+ NavS
+ //
+ Rossey
+ //
+ Scany
+ //
+ Septomor
+ //
+ Sevencuts
+ //
+ Solisu
+ //
+ TheScythed
+ //
+ x34uvc
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/scribbler-doc.css b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/scribbler-doc.css
new file mode 100644
index 0000000..a3f8c96
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/scribbler-doc.css
@@ -0,0 +1,115 @@
+html, body {
+ display: flex;
+ flex-direction: column;
+ min-height: 100vh;
+}
+
+/* layout */
+.header {
+ border-bottom: 1px solid var(--code-bg-color);
+ grid-template-columns: 1fr 150px 60% 1fr;
+}
+
+.wrapper {
+ display: flex;
+ flex-grow: 1;
+}
+
+/* logo */
+.logo {
+ font-weight: 900;
+ color: var(--primary-color);
+ font-size: 1.4em;
+ grid-column: 2;
+}
+
+.logo__thin {
+ font-weight: 300;
+}
+
+/* menu */
+.menu {
+ grid-template-columns: 1fr 180px 60% 1fr;
+}
+
+.menu__item {
+ padding: 1.5rem 1rem;
+}
+
+/* doc */
+.doc__bg {
+ position: fixed;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ width: 28%;
+ background-color: var(--bg-color);
+ z-index: -1;
+}
+
+.doc__nav {
+ flex-basis: 20%;
+ font-weight: 200;
+}
+
+.doc__nav ul {
+ list-style: none;
+ padding-left: 0;
+ line-height: 1.8;
+}
+
+.doc__nav ul.fixed {
+ position: fixed;
+ top: 2rem;
+}
+
+.doc__nav li:hover {
+ color: var(--primary-color-light);
+ cursor: pointer;
+ transition: color .3s ease-in-out;
+}
+
+.doc__nav .selected {
+ color: var(--accent-color);
+ position: relative;
+}
+
+.doc__nav .selected:after {
+ position: absolute;
+ content: "";
+ width: 1rem;
+ height: 1rem;
+ background-color: var(--accent-color);
+ left: -1.5rem;
+ top: 0.3rem;
+}
+
+.doc__content {
+ flex-basis: 80%;
+ padding: 0 0 5rem 1rem;
+}
+
+@media (max-width: 750px) {
+ .wrapper {
+ flex-direction: column;
+ }
+ .doc__content {
+ padding-left: 0;
+ }
+ .doc__nav ul {
+ border-bottom: 1px solid var(--code-bg-color);
+ padding-bottom: 0.5rem;
+ }
+ .doc__nav ul.fixed {
+ /* nutralized the fixed menu for mobile*/
+ position: relative;
+ top: 0;
+ }
+ .doc__nav li {
+ display: inline-block;
+ padding-right: 1rem;
+ }
+ .doc__nav .selected:after {
+ display: none;
+ }
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/scribbler-global.css b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/scribbler-global.css
new file mode 100644
index 0000000..d20acc8
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/scribbler-global.css
@@ -0,0 +1,376 @@
+/* css variables*/
+:root {
+ --primary-color: #432E30;
+ --primary-color-light: #8E7474;
+ --accent-color: #FE6A6B;
+ --accent-color-light: #FFE4E4;
+ --accent-color-dark: #B94B4C;
+ --white-color: #FAFBFC;
+ --light-gray-color: #C6CBD1;
+ --medium-gray-color: #959DA5;
+ --dark-gray-color: #444D56;
+ --bg-color: #F8F8FA;
+ --code-bg-color: #F0E8E8;
+}
+
+/* normalized */
+html, body {
+ padding: 0;
+ margin: 0;
+ font-family: 'Nunito Sans', sans-serif;
+ background-color: white;
+}
+
+p {
+ font-weight: 300;
+ color: #4A4A4A;
+}
+
+a, a:hover {
+ text-decoration: none;
+ color: var(--primary-color);
+}
+
+hr {
+ padding: 1rem 0;
+ border: 0;
+ border-bottom: 1px solid var(--bg-color);
+}
+
+* {
+ box-sizing: border-box;
+}
+
+/* global components */
+
+/* typography */
+.section__title {
+ color: var(--primary-color);
+}
+
+/* tabs */
+.tab__container {
+ position: relative;
+}
+
+.tab__container > ul {
+ position: absolute;
+ list-style: none;
+ margin: 0;
+ right: 1rem;
+ top: -2rem;
+ padding-left: 0;
+}
+
+.tab__container .code {
+ white-space: normal;
+ padding: 1rem 1.5rem;
+}
+
+.tab {
+ display: inline-block;
+ padding: 0.3rem 0.5rem;
+ font-weight: 200;
+ cursor: pointer;
+}
+
+.tab.active {
+ border-bottom: 1px solid var(--primary-color);
+ font-weight: 700;
+ display: inline-block;
+}
+
+.tab__pane {
+ display: none;
+}
+
+.tab__pane.active {
+ display: block;
+}
+
+/* code */
+.code {
+ border-radius: 3px;
+ font-family: Space Mono, SFMono-Regular, Menlo,Monaco, Consolas, Liberation Mono, Courier New, monospace;
+ background: var(--bg-color);
+ border: 1px solid var(--code-bg-color);
+ color: var(--primary-color-light);
+}
+
+.code--block {
+ white-space: pre-line;
+ padding: 0 1.5rem;
+}
+
+.code--inline {
+ padding: 3px 6px;
+ font-size: 80%;
+}
+
+/* buttons */
+.button--primary {
+ padding: 10px 22px;
+ background-color: var(--accent-color);
+ color: white;
+ position: relative;
+ text-decoration: none;
+ border: 0;
+ transition: all .3s ease-out;
+}
+
+.button--primary:after {
+ position: absolute;
+ content: "";
+ width: 1rem;
+ height: 1rem;
+ background-color: var(--accent-color-light);
+ right: -0.4rem;
+ top: -0.4rem;
+ transition: all 0.3s ease-out;
+}
+
+.button--primary:hover {
+ text-shadow: 0px 1px 1px var(--accent-color-dark);
+ color: white;
+ transform: translate3D(0, -3px, 0);
+}
+
+.button--primary:hover::after {
+ transform: rotate(90deg);
+}
+
+.button--secondary {
+ padding: 10px 22px;
+ border: 2px solid var(--primary-color);
+ transition: all 0.5s ease-out;
+}
+
+.button--secondary:hover {
+ border-color: var(--accent-color);
+ color: var(--accent-color);
+}
+
+/* links */
+.link {
+ text-decoration: none;
+ transition: all 0.3s ease-out;
+}
+
+.link:hover {
+ color: var(--accent-color);
+}
+
+.link--dark {
+ color: var(--primary-color);
+}
+
+.link--light {
+ color: var(--accent-color);
+}
+
+/* menu */
+nav {
+ display: grid;
+ grid-template-columns: 70px auto;
+}
+
+.menu {
+ margin: 0;
+ text-align: right;
+ overflow: hidden;
+ list-style: none;
+}
+
+.toggle {
+ display: none;
+ position: relative;
+}
+
+.toggle span,
+.toggle span:before,
+.toggle span:after {
+ content: '';
+ position: absolute;
+ height: 2px;
+ width: 18px;
+ border-radius: 2px;
+ background: var(--primary-color);
+ display: block;
+ cursor: pointer;
+ transition: all 0.3s ease-in-out;
+ right: 0;
+}
+
+.toggle span:before {
+ top: -6px;
+}
+
+.toggle span:after {
+ bottom: -6px;
+}
+
+.toggle.open span{
+ background-color: transparent;
+}
+
+.toggle.open span:before,
+.toggle.open span:after {
+ top: 0;
+}
+
+.toggle.open span:before {
+ transform: rotate(45deg);
+}
+
+.toggle.open span:after {
+ transform: rotate(-45deg);
+}
+
+.menu__item {
+ padding: 1rem;
+ display: inline-block;
+}
+
+.menu__item.toggle {
+ display: none;
+}
+
+/* table */
+table {
+ border-collapse: collapse;
+ width: 100%;
+ transition: color .3s ease-out;
+ margin-bottom: 2rem;
+}
+
+table td, table th {
+ border: 1px solid var(--code-bg-color);
+ padding: 0.8rem;
+ font-weight: 300;
+}
+
+table th {
+ text-align: left;
+ background-color: white;
+ border-color: white;
+ border-bottom-color: var(--code-bg-color);
+}
+
+table td:first-child {
+ background-color: var(--bg-color);
+ font-weight: 600;
+}
+
+@media screen and (max-width: 600px) {
+ nav {
+ grid-template-columns: 70px auto;
+ }
+
+ .menu__item{
+ display: none;
+ }
+
+ .menu__item.toggle {
+ display: inline-block;
+ }
+
+ .menu {
+ text-align: right;
+ padding: 0.5rem 1rem;
+ }
+
+ .toggle {
+ display: block;
+ }
+
+ .menu.responsive .menu__item:not(:first-child) {
+ display: block;
+ padding: 0 0 0.5rem 0;
+ }
+}
+
+/* layout */
+.wrapper {
+ margin: 0 auto;
+ width: 70%;
+}
+
+.footer {
+ text-align: center;
+ background-color: var(--primary-color);
+ padding: 2rem;
+ color: white;
+}
+
+@keyframes fadeUp {
+ 0% {
+ opacity: 0;
+ transform: translate3d(0,30px,0);
+ }
+ 100% {
+ transform: translate3d(0,0,0);
+ }
+}
+
+
+.enlarge-image {
+ margin-top: 0px;
+ width: 32%;
+ float: center;
+ -webkit-transition: all 0.5s ease-in-out;
+ -moz-transition: all 0.5s ease-in-out;
+ transition: all 0.5s ease-in-out;
+}
+.enlarge-image:hover {
+ -webkit-transition: all 0.5s ease-in-out;
+ -moz-transition: all 0.5s ease-in-out;
+ transition: all 0.5s ease-in-out;
+ -moz-transform: scale(3);
+-webkit-transform: scale(3);
+-o-transform: scale(3);
+-ms-transform: scale(3);
+transform: scale(3);
+
+}
+
+.marquee-container {
+ height: 20px;
+ overflow: hidden;
+ line-height: 20px;
+}
+.marquee-container .marquee {
+ left: 100%;
+ width: 100%;
+ overflow: hidden;
+ position: absolute;
+ white-space: nowrap;
+ animation: marquee 25s linear infinite;
+}
+.marquee-container .marquee2 {
+ animation-delay: 20s;
+}
+.marquee-container shadow {
+ color: #ffffff;
+color: #616161;
+text-shadow: #e0e0e0 1px 1px 0;
+font-size: 1em;
+vertical-align: middle;
+
+}
+.marquee-container shadow2 {
+color: #fe6a6b;
+font-size: 1em;
+text-shadow: rgba(255,255,255,.1) -1px -1px 1px,rgba(0,0,0,.5) 1px 1px 1px;
+vertical-align: middle;
+
+
+}
+
+@keyframes marquee {
+ 0% {
+ left: 100%;
+ }
+ 100% {
+ left: -100%;
+ }
+}
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/scribbler.js b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/scribbler.js
new file mode 100644
index 0000000..d862fc4
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/scribbler.js
@@ -0,0 +1,145 @@
+// utilities
+var get = function (selector, scope) {
+ scope = scope ? scope : document;
+ return scope.querySelector(selector);
+};
+
+var getAll = function (selector, scope) {
+ scope = scope ? scope : document;
+ return scope.querySelectorAll(selector);
+};
+
+// setup typewriter effect in the terminal demo
+if (document.getElementsByClassName('demo').length > 0) {
+ var i = 0;
+ var txt = `scribbler
+ [Entry mode; press Ctrl+D to save and quit; press Ctrl+C to quit without saving]
+
+ ###todo for new year dinner party
+
+ - milk
+ - butter
+ - green onion
+ - lots and lots of kiwis 🥝`;
+ var speed = 60;
+
+ function typeItOut () {
+ if (i < txt.length) {
+ document.getElementsByClassName('demo')[0].innerHTML += txt.charAt(i);
+ i++;
+ setTimeout(typeItOut, speed);
+ }
+ }
+
+ setTimeout(typeItOut, 1800);
+}
+
+// toggle tabs on codeblock
+window.addEventListener("load", function() {
+ // get all tab_containers in the document
+ var tabContainers = getAll(".tab__container");
+
+ // bind click event to each tab container
+ for (var i = 0; i < tabContainers.length; i++) {
+ get('.tab__menu', tabContainers[i]).addEventListener("click", tabClick);
+ }
+
+ // each click event is scoped to the tab_container
+ function tabClick (event) {
+ var scope = event.currentTarget.parentNode;
+ var clickedTab = event.target;
+ var tabs = getAll('.tab', scope);
+ var panes = getAll('.tab__pane', scope);
+ var activePane = get(`.${clickedTab.getAttribute('data-tab')}`, scope);
+
+ // remove all active tab classes
+ for (var i = 0; i < tabs.length; i++) {
+ tabs[i].classList.remove('active');
+ }
+
+ // remove all active pane classes
+ for (var i = 0; i < panes.length; i++) {
+ panes[i].classList.remove('active');
+ }
+
+ // apply active classes on desired tab and pane
+ clickedTab.classList.add('active');
+ activePane.classList.add('active');
+ }
+});
+
+//in page scrolling for documentaiton page
+var btns = getAll('.js-btn');
+var sections = getAll('.js-section');
+
+function setActiveLink(event) {
+ // remove all active tab classes
+ for (var i = 0; i < btns.length; i++) {
+ btns[i].classList.remove('selected');
+ }
+
+ event.target.classList.add('selected');
+}
+
+function smoothScrollTo(element, event) {
+ setActiveLink(event);
+
+ window.scrollTo({
+ 'behavior': 'smooth',
+ 'top': element.offsetTop - 20,
+ 'left': 0
+ });
+}
+
+if (btns.length && sections.length > 0) {
+// for (var i = 0; i ul');
+
+ if( docNav) {
+ if (window.pageYOffset > 63) {
+ docNav.classList.add('fixed');
+ } else {
+ docNav.classList.remove('fixed');
+ }
+ }
+});
+
+// responsive navigation
+var topNav = get('.menu');
+var icon = get('.toggle');
+
+window.addEventListener('load', function(){
+ function showNav() {
+ if (topNav.className === 'menu') {
+ topNav.className += ' responsive';
+ icon.className += ' open';
+ } else {
+ topNav.className = 'menu';
+ icon.classList.remove('open');
+ }
+ }
+ icon.addEventListener('click', showNav);
+});
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_assists1.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_assists1.png
new file mode 100644
index 0000000..c98c443
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_assists1.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_assists2.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_assists2.png
new file mode 100644
index 0000000..d4a25d0
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_assists2.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_car1.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_car1.png
new file mode 100644
index 0000000..bdf8e52
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_car1.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_car2.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_car2.png
new file mode 100644
index 0000000..c1a169a
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_car2.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_car3.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_car3.png
new file mode 100644
index 0000000..280e405
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_car3.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_cockpitview.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_cockpitview.png
new file mode 100644
index 0000000..840656b
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_cockpitview.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_controller1.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_controller1.png
new file mode 100644
index 0000000..5a0a481
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_controller1.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_controller2.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_controller2.png
new file mode 100644
index 0000000..968b026
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_controller2.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_difficulty.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_difficulty.png
new file mode 100644
index 0000000..86f133d
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_difficulty.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_display.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_display.png
new file mode 100644
index 0000000..9b20d30
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_display.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_drivinggear.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_drivinggear.png
new file mode 100644
index 0000000..dc3b546
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_drivinggear.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_gui.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_gui.png
new file mode 100644
index 0000000..8d5b5c0
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_gui.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script1.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script1.png
new file mode 100644
index 0000000..51d318a
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script1.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script2.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script2.png
new file mode 100644
index 0000000..28f6562
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script2.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script3-.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script3-.png
new file mode 100644
index 0000000..e7f3ce1
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script3-.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script3.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script3.png
new file mode 100644
index 0000000..bc7c383
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script3.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script4-.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script4-.png
new file mode 100644
index 0000000..e9d7c2f
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script4-.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script4.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script4.png
new file mode 100644
index 0000000..0440ef3
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script4.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script5-.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script5-.png
new file mode 100644
index 0000000..c1f913a
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script5-.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script5.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script5.png
new file mode 100644
index 0000000..f6644af
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script5.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script6-.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script6-.png
new file mode 100644
index 0000000..3eb9455
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script6-.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script6.png b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script6.png
new file mode 100644
index 0000000..882fd94
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/Assets/tokyo_script6.png differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/AutoHotkey.exe b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/AutoHotkey.exe
new file mode 100644
index 0000000..12750f7
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/AutoHotkey.exe differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/GT7-TokyoX.exe b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/GT7-TokyoX.exe
new file mode 100644
index 0000000..45455bb
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/GT7-TokyoX.exe differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/config.ini b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/config.ini
new file mode 100644
index 0000000..b214eb7
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/config.ini differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/AHK-ViGEm-Bus.ahk b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/AHK-ViGEm-Bus.ahk
new file mode 100644
index 0000000..858cb3d
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/AHK-ViGEm-Bus.ahk
@@ -0,0 +1,211 @@
+#include %A_LineFile%\..\CLR.ahk
+
+; Static class, holds ViGEm Client instance
+class ViGEmWrapper {
+ static asm := 0
+ static client := 0
+
+ Init(){
+ if (this.client == 0){
+ this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
+ }
+ }
+
+ CreateInstance(cls){
+ return this.asm.CreateInstance(cls)
+ }
+
+}
+
+; Base class for ViGEm "Targets" (Controller types - eg xb360 / ds4) to inherit from
+class ViGEmTarget {
+ target := 0
+ helperClass := ""
+ controllerClass := ""
+
+ __New(){
+ ;~ this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
+ ViGEmWrapper.Init()
+ this.Instance := ViGEmWrapper.CreateInstance(this.helperClass)
+
+ if (this.Instance.OkCheck() != "OK"){
+ msgbox ViGEmWrapper.dll failed to load!
+ ExitApp
+ }
+ }
+
+ SendReport(){
+ this.Instance.SendReport()
+ }
+
+ SubscribeFeedback(callback){
+ this.Instance.SubscribeFeedback(callback)
+ }
+}
+
+; DS4 (DualShock 4 for Playstation 4)
+class ViGEmDS4 extends ViGEmTarget {
+ helperClass := "ViGEmWrapper.Ds4"
+ __New(){
+ static buttons := {Square: 16, Cross: 32, Circle: 64, Triangle: 128, L1: 256, R1: 512, L2: 1024, R2: 2048
+ , Share: 4096, Options: 8192, LS: 16384, RS: 32768 }
+ static specialButtons := {Ps: 1, TouchPad: 2}
+ static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
+
+ this.Buttons := {}
+ for name, id in buttons {
+ this.Buttons[name] := new this._ButtonHelper(this, id)
+ }
+ for name, id in specialButtons {
+ this.Buttons[name] := new this._SpecialButtonHelper(this, id)
+ }
+
+ this.Axes := {}
+ for name, id in axes {
+ this.Axes[name] := new this._AxisHelper(this, id)
+ }
+
+ this.Dpad := new this._DpadHelper(this)
+ base.__New()
+ }
+
+ class _ButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _SpecialButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetSpecialButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _AxisHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+
+ ConvertAxis(state){
+ return round(state * 2.55)
+ }
+ }
+
+ class _DpadHelper {
+ __New(parent){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ static dPadDirections := {Up: 0, UpRight: 1, Right: 2, DownRight: 3, Down: 4, DownLeft: 5, Left: 6, UpLeft: 7, None: 8}
+ this._Parent.Instance.SetDpadState(dPadDirections[state])
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+}
+
+; Xb360
+class ViGEmXb360 extends ViGEmTarget {
+ helperClass := "ViGEmWrapper.Xb360"
+ __New(){
+ static buttons := {A: 4096, B: 8192, X: 16384, Y: 32768, LB: 256, RB: 512, LS: 64, RS: 128, Back: 32, Start: 16, Xbox: 1024}
+ static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
+
+ this.Buttons := {}
+ for name, id in buttons {
+ this.Buttons[name] := new this._ButtonHelper(this, id)
+ }
+
+ this.Axes := {}
+ for name, id in axes {
+ this.Axes[name] := new this._AxisHelper(this, id)
+ }
+
+ this.Dpad := new this._DpadHelper(this)
+
+ base.__New()
+ }
+
+ class _ButtonHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._Id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetButtonState(this._Id, state)
+ this._Parent.Instance.SendReport()
+ return this._Parent
+ }
+ }
+
+ class _AxisHelper {
+ __New(parent, id){
+ this._Parent := parent
+ this._id := id
+ }
+
+ SetState(state){
+ this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
+ this._Parent.Instance.SendReport()
+ }
+
+ ConvertAxis(state){
+ value := round((state * 655.36) - 32768)
+ if (value == 32768)
+ return 32767
+ return value
+ }
+ }
+
+ class _DpadHelper {
+ _DpadStates := {1:0, 8:0, 2:0, 4:0} ; Up, Right, Down, Left
+ __New(parent){
+ this._Parent := parent
+ }
+
+ SetState(state){
+ static dpadDirections := { None: {1:0, 8:0, 2:0, 4:0}
+ , Up: {1:1, 8:0, 2:0, 4:0}
+ , UpRight: {1:1, 8:1, 2:0, 4:0}
+ , Right: {1:0, 8:1, 2:0, 4:0}
+ , DownRight: {1:0, 8:1, 2:1, 4:0}
+ , Down: {1:0, 8:0, 2:1, 4:0}
+ , DownLeft: {1:0, 8:0, 2:1, 4:1}
+ , Left: {1:0, 8:0, 2:0, 4:1}
+ , UpLeft: {1:1, 8:0, 2:0, 4:1}}
+ newStates := dpadDirections[state]
+ for id, newState in newStates {
+ oldState := this._DpadStates[id]
+ if (oldState != newState){
+ this._DpadStates[id] := newState
+ this._Parent.Instance.SetButtonState(id, newState)
+ }
+ this._Parent.SendReport()
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/CLR.ahk b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/CLR.ahk
new file mode 100644
index 0000000..d16ab68
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/CLR.ahk
@@ -0,0 +1,151 @@
+; ==========================================================
+; .NET Framework Interop
+; https://autohotkey.com/boards/viewtopic.php?t=4633
+; ==========================================================
+;
+; Author: Lexikos
+; Version: 1.2
+; Requires: AutoHotkey_L v1.0.96+
+;
+
+CLR_LoadLibrary(AssemblyName, AppDomain=0)
+{
+ if !AppDomain
+ AppDomain := CLR_GetDefaultDomain()
+ e := ComObjError(0)
+ Loop 1 {
+ if assembly := AppDomain.Load_2(AssemblyName)
+ break
+ static null := ComObject(13,0)
+ args := ComObjArray(0xC, 1), args[0] := AssemblyName
+ typeofAssembly := AppDomain.GetType().Assembly.GetType()
+ if assembly := typeofAssembly.InvokeMember_3("LoadWithPartialName", 0x158, null, null, args)
+ break
+ if assembly := typeofAssembly.InvokeMember_3("LoadFrom", 0x158, null, null, args)
+ break
+ }
+ ComObjError(e)
+ return assembly
+}
+
+CLR_CreateObject(Assembly, TypeName, Args*)
+{
+ if !(argCount := Args.MaxIndex())
+ return Assembly.CreateInstance_2(TypeName, true)
+
+ vargs := ComObjArray(0xC, argCount)
+ Loop % argCount
+ vargs[A_Index-1] := Args[A_Index]
+
+ static Array_Empty := ComObjArray(0xC,0), null := ComObject(13,0)
+
+ return Assembly.CreateInstance_3(TypeName, true, 0, null, vargs, null, Array_Empty)
+}
+
+CLR_CompileC#(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
+{
+ return CLR_CompileAssembly(Code, References, "System", "Microsoft.CSharp.CSharpCodeProvider", AppDomain, FileName, CompilerOptions)
+}
+
+CLR_CompileVB(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
+{
+ return CLR_CompileAssembly(Code, References, "System", "Microsoft.VisualBasic.VBCodeProvider", AppDomain, FileName, CompilerOptions)
+}
+
+CLR_StartDomain(ByRef AppDomain, BaseDirectory="")
+{
+ static null := ComObject(13,0)
+ args := ComObjArray(0xC, 5), args[0] := "", args[2] := BaseDirectory, args[4] := ComObject(0xB,false)
+ AppDomain := CLR_GetDefaultDomain().GetType().InvokeMember_3("CreateDomain", 0x158, null, null, args)
+ return A_LastError >= 0
+}
+
+CLR_StopDomain(ByRef AppDomain)
+{ ; ICorRuntimeHost::UnloadDomain
+ DllCall("SetLastError", "uint", hr := DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+20*A_PtrSize), "ptr", RtHst, "ptr", ComObjValue(AppDomain))), AppDomain := ""
+ return hr >= 0
+}
+
+; NOTE: IT IS NOT NECESSARY TO CALL THIS FUNCTION unless you need to load a specific version.
+CLR_Start(Version="") ; returns ICorRuntimeHost*
+{
+ static RtHst := 0
+ ; The simple method gives no control over versioning, and seems to load .NET v2 even when v4 is present:
+ ; return RtHst ? RtHst : (RtHst:=COM_CreateObject("CLRMetaData.CorRuntimeHost","{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}"), DllCall(NumGet(NumGet(RtHst+0)+40),"uint",RtHst))
+ if RtHst
+ return RtHst
+ EnvGet SystemRoot, SystemRoot
+ if Version =
+ Loop % SystemRoot "\Microsoft.NET\Framework" (A_PtrSize=8?"64":"") "\*", 2
+ if (FileExist(A_LoopFileFullPath "\mscorlib.dll") && A_LoopFileName > Version)
+ Version := A_LoopFileName
+ if DllCall("mscoree\CorBindToRuntimeEx", "wstr", Version, "ptr", 0, "uint", 0
+ , "ptr", CLR_GUID(CLSID_CorRuntimeHost, "{CB2F6723-AB3A-11D2-9C40-00C04FA30A3E}")
+ , "ptr", CLR_GUID(IID_ICorRuntimeHost, "{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}")
+ , "ptr*", RtHst) >= 0
+ DllCall(NumGet(NumGet(RtHst+0)+10*A_PtrSize), "ptr", RtHst) ; Start
+ return RtHst
+}
+
+;
+; INTERNAL FUNCTIONS
+;
+
+CLR_GetDefaultDomain()
+{
+ static defaultDomain := 0
+ if !defaultDomain
+ { ; ICorRuntimeHost::GetDefaultDomain
+ if DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+13*A_PtrSize), "ptr", RtHst, "ptr*", p:=0) >= 0
+ defaultDomain := ComObject(p), ObjRelease(p)
+ }
+ return defaultDomain
+}
+
+CLR_CompileAssembly(Code, References, ProviderAssembly, ProviderType, AppDomain=0, FileName="", CompilerOptions="")
+{
+ if !AppDomain
+ AppDomain := CLR_GetDefaultDomain()
+
+ if !(asmProvider := CLR_LoadLibrary(ProviderAssembly, AppDomain))
+ || !(codeProvider := asmProvider.CreateInstance(ProviderType))
+ || !(codeCompiler := codeProvider.CreateCompiler())
+ return 0
+
+ if !(asmSystem := (ProviderAssembly="System") ? asmProvider : CLR_LoadLibrary("System", AppDomain))
+ return 0
+
+ ; Convert | delimited list of references into an array.
+ StringSplit, Refs, References, |, %A_Space%%A_Tab%
+ aRefs := ComObjArray(8, Refs0)
+ Loop % Refs0
+ aRefs[A_Index-1] := Refs%A_Index%
+
+ ; Set parameters for compiler.
+ prms := CLR_CreateObject(asmSystem, "System.CodeDom.Compiler.CompilerParameters", aRefs)
+ , prms.OutputAssembly := FileName
+ , prms.GenerateInMemory := FileName=""
+ , prms.GenerateExecutable := SubStr(FileName,-3)=".exe"
+ , prms.CompilerOptions := CompilerOptions
+ , prms.IncludeDebugInformation := true
+
+ ; Compile!
+ compilerRes := codeCompiler.CompileAssemblyFromSource(prms, Code)
+
+ if error_count := (errors := compilerRes.Errors).Count
+ {
+ error_text := ""
+ Loop % error_count
+ error_text .= ((e := errors.Item[A_Index-1]).IsWarning ? "Warning " : "Error ") . e.ErrorNumber " on line " e.Line ": " e.ErrorText "`n`n"
+ MsgBox, 16, Compilation Failed, %error_text%
+ return 0
+ }
+ ; Success. Return Assembly object or path.
+ return compilerRes[FileName="" ? "CompiledAssembly" : "PathToAssembly"]
+}
+
+CLR_GUID(ByRef GUID, sGUID)
+{
+ VarSetCapacity(GUID, 16, 0)
+ return DllCall("ole32\CLSIDFromString", "wstr", sGUID, "ptr", &GUID) >= 0 ? &GUID : ""
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/Gdip.ahk b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/Gdip.ahk
new file mode 100644
index 0000000..3efb7ae
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/Gdip.ahk
@@ -0,0 +1,2714 @@
+; Gdip standard library v1.45 by tic (Tariq Porter) 07/09/11
+; Modifed by Rseding91 using fincs 64 bit compatible Gdip library 5/1/2013
+; Supports: Basic, _L ANSi, _L Unicode x86 and _L Unicode x64
+;
+; Updated 2/20/2014 - fixed Gdip_CreateRegion() and Gdip_GetClipRegion() on AHK Unicode x86
+; Updated 5/13/2013 - fixed Gdip_SetBitmapToClipboard() on AHK Unicode x64
+;
+;#####################################################################################
+;#####################################################################################
+; STATUS ENUMERATION
+; Return values for functions specified to have status enumerated return type
+;#####################################################################################
+;
+; Ok = = 0
+; GenericError = 1
+; InvalidParameter = 2
+; OutOfMemory = 3
+; ObjectBusy = 4
+; InsufficientBuffer = 5
+; NotImplemented = 6
+; Win32Error = 7
+; WrongState = 8
+; Aborted = 9
+; FileNotFound = 10
+; ValueOverflow = 11
+; AccessDenied = 12
+; UnknownImageFormat = 13
+; FontFamilyNotFound = 14
+; FontStyleNotFound = 15
+; NotTrueTypeFont = 16
+; UnsupportedGdiplusVersion = 17
+; GdiplusNotInitialized = 18
+; PropertyNotFound = 19
+; PropertyNotSupported = 20
+; ProfileNotFound = 21
+;
+;#####################################################################################
+;#####################################################################################
+; FUNCTIONS
+;#####################################################################################
+;
+; UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255)
+; BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+; StretchBlt(dDC, dx, dy, dw, dh, sDC, sx, sy, sw, sh, Raster="")
+; SetImage(hwnd, hBitmap)
+; Gdip_BitmapFromScreen(Screen=0, Raster="")
+; CreateRectF(ByRef RectF, x, y, w, h)
+; CreateSizeF(ByRef SizeF, w, h)
+; CreateDIBSection
+;
+;#####################################################################################
+
+; Function: UpdateLayeredWindow
+; Description: Updates a layered window with the handle to the DC of a gdi bitmap
+;
+; hwnd Handle of the layered window to update
+; hdc Handle to the DC of the GDI bitmap to update the window with
+; Layeredx x position to place the window
+; Layeredy y position to place the window
+; Layeredw Width of the window
+; Layeredh Height of the window
+; Alpha Default = 255 : The transparency (0-255) to set the window transparency
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If x or y omitted, then layered window will use its current coordinates
+; If w or h omitted then current width and height will be used
+
+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)
+}
+
+;#####################################################################################
+
+; Function BitBlt
+; Description The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle
+; of pixels from the specified source device context into a destination device context.
+;
+; dDC handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of the area to copy
+; dh height of the area to copy
+; sDC handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used, which copies the source directly to the destination rectangle
+;
+; BLACKNESS = 0x00000042
+; NOTSRCERASE = 0x001100A6
+; NOTSRCCOPY = 0x00330008
+; SRCERASE = 0x00440328
+; DSTINVERT = 0x00550009
+; PATINVERT = 0x005A0049
+; SRCINVERT = 0x00660046
+; SRCAND = 0x008800C6
+; MERGEPAINT = 0x00BB0226
+; MERGECOPY = 0x00C000CA
+; SRCCOPY = 0x00CC0020
+; SRCPAINT = 0x00EE0086
+; PATCOPY = 0x00F00021
+; PATPAINT = 0x00FB0A09
+; WHITENESS = 0x00FF0062
+; CAPTUREBLT = 0x40000000
+; NOMIRRORBITMAP = 0x80000000
+
+BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\BitBlt"
+ , Ptr, dDC
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sDC
+ , "int", sx
+ , "int", sy
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function StretchBlt
+; Description The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle,
+; stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary.
+; The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.
+;
+; ddc handle to destination DC
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination rectangle
+; dh height of destination rectangle
+; sdc handle to source DC
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes If no raster operation is specified, then SRCCOPY is used. It uses the same raster operations as BitBlt
+
+StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdi32\StretchBlt"
+ , Ptr, ddc
+ , "int", dx
+ , "int", dy
+ , "int", dw
+ , "int", dh
+ , Ptr, sdc
+ , "int", sx
+ , "int", sy
+ , "int", sw
+ , "int", sh
+ , "uint", Raster ? Raster : 0x00CC0020)
+}
+
+;#####################################################################################
+
+; Function SetStretchBltMode
+; Description The SetStretchBltMode function sets the bitmap stretching mode in the specified device context
+;
+; hdc handle to the DC
+; iStretchMode The stretching mode, describing how the target will be stretched
+;
+; return If the function succeeds, the return value is the previous stretching mode. If it fails it will return 0
+;
+; STRETCH_ANDSCANS = 0x01
+; STRETCH_ORSCANS = 0x02
+; STRETCH_DELETESCANS = 0x03
+; STRETCH_HALFTONE = 0x04
+
+SetStretchBltMode(hdc, iStretchMode=4)
+{
+ return DllCall("gdi32\SetStretchBltMode"
+ , A_PtrSize ? "UPtr" : "UInt", hdc
+ , "int", iStretchMode)
+}
+
+;#####################################################################################
+
+; Function SetImage
+; Description Associates a new image with a static control
+;
+; hwnd handle of the control to update
+; hBitmap a gdi bitmap to associate the static control with
+;
+; return If the function succeeds, the return value is nonzero
+
+SetImage(hwnd, hBitmap)
+{
+ SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
+ E := ErrorLevel
+ DeleteObject(E)
+ return E
+}
+
+;#####################################################################################
+
+; Function SetSysColorToControl
+; Description Sets a solid colour to a control
+;
+; hwnd handle of the control to update
+; SysColor A system colour to set to the control
+;
+; return If the function succeeds, the return value is zero
+;
+; notes A control must have the 0xE style set to it so it is recognised as a bitmap
+; By default SysColor=15 is used which is COLOR_3DFACE. This is the standard background for a control
+;
+; COLOR_3DDKSHADOW = 21
+; COLOR_3DFACE = 15
+; COLOR_3DHIGHLIGHT = 20
+; COLOR_3DHILIGHT = 20
+; COLOR_3DLIGHT = 22
+; COLOR_3DSHADOW = 16
+; COLOR_ACTIVEBORDER = 10
+; COLOR_ACTIVECAPTION = 2
+; COLOR_APPWORKSPACE = 12
+; COLOR_BACKGROUND = 1
+; COLOR_BTNFACE = 15
+; COLOR_BTNHIGHLIGHT = 20
+; COLOR_BTNHILIGHT = 20
+; COLOR_BTNSHADOW = 16
+; COLOR_BTNTEXT = 18
+; COLOR_CAPTIONTEXT = 9
+; COLOR_DESKTOP = 1
+; COLOR_GRADIENTACTIVECAPTION = 27
+; COLOR_GRADIENTINACTIVECAPTION = 28
+; COLOR_GRAYTEXT = 17
+; COLOR_HIGHLIGHT = 13
+; COLOR_HIGHLIGHTTEXT = 14
+; COLOR_HOTLIGHT = 26
+; COLOR_INACTIVEBORDER = 11
+; COLOR_INACTIVECAPTION = 3
+; COLOR_INACTIVECAPTIONTEXT = 19
+; COLOR_INFOBK = 24
+; COLOR_INFOTEXT = 23
+; COLOR_MENU = 4
+; COLOR_MENUHILIGHT = 29
+; COLOR_MENUBAR = 30
+; COLOR_MENUTEXT = 7
+; COLOR_SCROLLBAR = 0
+; COLOR_WINDOW = 5
+; COLOR_WINDOWFRAME = 6
+; COLOR_WINDOWTEXT = 8
+
+SetSysColorToControl(hwnd, SysColor=15)
+{
+ WinGetPos,,, w, h, ahk_id %hwnd%
+ bc := DllCall("GetSysColor", "Int", SysColor, "UInt")
+ pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc >> 16 | bc & 0xff00 | (bc & 0xff) << 16))
+ pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap)
+ Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h)
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ SetImage(hwnd, hBitmap)
+ Gdip_DeleteBrush(pBrushClear)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap)
+ return 0
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromScreen
+; Description Gets a gdi+ bitmap from the screen
+;
+; Screen 0 = All screens
+; Any numerical value = Just that screen
+; x|y|w|h = Take specific coordinates with a width and height
+; Raster raster operation code
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1: one or more of x,y,w,h not passed properly
+;
+; notes If no raster operation is specified, then SRCCOPY is used to the returned bitmap
+
+Gdip_BitmapFromScreen(Screen=0, Raster="")
+{
+ if (Screen = 0)
+ {
+ Sysget, x, 76
+ Sysget, y, 77
+ Sysget, w, 78
+ Sysget, h, 79
+ }
+ else if (SubStr(Screen, 1, 5) = "hwnd:")
+ {
+ Screen := SubStr(Screen, 6)
+ if !WinExist( "ahk_id " Screen)
+ return -2
+ WinGetPos,,, w, h, ahk_id %Screen%
+ x := y := 0
+ hhdc := GetDCEx(Screen, 3)
+ }
+ else if (Screen&1 != "")
+ {
+ Sysget, M, Monitor, %Screen%
+ x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
+ }
+ else
+ {
+ StringSplit, S, Screen, |
+ x := S1, y := S2, w := S3, h := S4
+ }
+
+ if (x = "") || (y = "") || (w = "") || (h = "")
+ return -1
+
+ chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
+ BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
+ ReleaseDC(hhdc)
+
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_BitmapFromHWND
+; Description Uses PrintWindow to get a handle to the specified window and return a bitmap from it
+;
+; hwnd handle to the window to get a bitmap from
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+;
+; notes Window must not be not minimised in order to get a handle to it's client area
+
+Gdip_BitmapFromHWND(hwnd)
+{
+ WinGetPos,,, Width, Height, ahk_id %hwnd%
+ hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ RegExMatch(A_OsVersion, "\d+", Version)
+ PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function CreateRectF
+; Description Creates a RectF object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+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")
+}
+
+;#####################################################################################
+
+; Function CreateRect
+; Description Creates a Rect object, containing a the coordinates and dimensions of a rectangle
+;
+; RectF Name to call the RectF object
+; x x-coordinate of the upper left corner of the rectangle
+; y y-coordinate of the upper left corner of the rectangle
+; w Width of the rectangle
+; h Height of the rectangle
+;
+; return No return value
+
+CreateRect(ByRef Rect, x, y, w, h)
+{
+ VarSetCapacity(Rect, 16)
+ NumPut(x, Rect, 0, "uint"), NumPut(y, Rect, 4, "uint"), NumPut(w, Rect, 8, "uint"), NumPut(h, Rect, 12, "uint")
+}
+;#####################################################################################
+
+; Function CreateSizeF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreateSizeF(ByRef SizeF, w, h)
+{
+ VarSetCapacity(SizeF, 8)
+ NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreatePointF
+; Description Creates a SizeF object, containing an 2 values
+;
+; SizeF Name to call the SizeF object
+; w w-value for the SizeF object
+; h h-value for the SizeF object
+;
+; return No Return value
+
+CreatePointF(ByRef PointF, x, y)
+{
+ VarSetCapacity(PointF, 8)
+ NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float")
+}
+;#####################################################################################
+
+; Function CreateDIBSection
+; Description The CreateDIBSection function creates a DIB (Device Independent Bitmap) that applications can write to directly
+;
+; w width of the bitmap to create
+; h height of the bitmap to create
+; hdc a handle to the device context to use the palette from
+; bpp bits per pixel (32 = ARGB)
+; ppvBits A pointer to a variable that receives a pointer to the location of the DIB bit values
+;
+; return returns a DIB. A gdi bitmap
+;
+; notes ppvBits will receive the location of the pixels in the DIB
+
+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
+}
+
+;#####################################################################################
+
+; Function PrintWindow
+; Description The PrintWindow function copies a visual window into the specified device context (DC), typically a printer DC
+;
+; hwnd A handle to the window that will be copied
+; hdc A handle to the device context
+; Flags Drawing options
+;
+; return If the function succeeds, it returns a nonzero value
+;
+; PW_CLIENTONLY = 1
+
+PrintWindow(hwnd, hdc, Flags=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("PrintWindow", Ptr, hwnd, Ptr, hdc, "uint", Flags)
+}
+
+;#####################################################################################
+
+; Function DestroyIcon
+; Description Destroys an icon and frees any memory the icon occupied
+;
+; hIcon Handle to the icon to be destroyed. The icon must not be in use
+;
+; return If the function succeeds, the return value is nonzero
+
+DestroyIcon(hIcon)
+{
+ return DllCall("DestroyIcon", A_PtrSize ? "UPtr" : "UInt", hIcon)
+}
+
+;#####################################################################################
+
+PaintDesktop(hdc)
+{
+ return DllCall("PaintDesktop", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+CreateCompatibleBitmap(hdc, w, h)
+{
+ return DllCall("gdi32\CreateCompatibleBitmap", A_PtrSize ? "UPtr" : "UInt", hdc, "int", w, "int", h)
+}
+
+;#####################################################################################
+
+; Function CreateCompatibleDC
+; Description This function creates a memory device context (DC) compatible with the specified device
+;
+; hdc Handle to an existing device context
+;
+; return returns the handle to a device context or 0 on failure
+;
+; notes If this handle is 0 (by default), the function creates a memory device context compatible with the application's current screen
+
+CreateCompatibleDC(hdc=0)
+{
+ return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+
+;#####################################################################################
+
+; Function SelectObject
+; Description The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type
+;
+; hdc Handle to a DC
+; hgdiobj A handle to the object to be selected into the DC
+;
+; return If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced
+;
+; notes The specified object must have been created by using one of the following functions
+; Bitmap - CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection (A single bitmap cannot be selected into more than one DC at the same time)
+; Brush - CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush
+; Font - CreateFont, CreateFontIndirect
+; Pen - CreatePen, CreatePenIndirect
+; Region - CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirect
+;
+; notes If the selected object is a region and the function succeeds, the return value is one of the following value
+;
+; SIMPLEREGION = 2 Region consists of a single rectangle
+; COMPLEXREGION = 3 Region consists of more than one rectangle
+; NULLREGION = 1 Region is empty
+
+SelectObject(hdc, hgdiobj)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
+}
+
+;#####################################################################################
+
+; Function DeleteObject
+; Description This function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object
+; After the object is deleted, the specified handle is no longer valid
+;
+; hObject Handle to a logical pen, brush, font, bitmap, region, or palette to delete
+;
+; return Nonzero indicates success. Zero indicates that the specified handle is not valid or that the handle is currently selected into a device context
+
+DeleteObject(hObject)
+{
+ return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject)
+}
+
+;#####################################################################################
+
+; Function GetDC
+; Description This function retrieves a handle to a display device context (DC) for the client area of the specified window.
+; The display device context can be used in subsequent graphics display interface (GDI) functions to draw in the client area of the window.
+;
+; hwnd Handle to the window whose device context is to be retrieved. If this value is NULL, GetDC retrieves the device context for the entire screen
+;
+; return The handle the device context for the specified window's client area indicates success. NULL indicates failure
+
+GetDC(hwnd=0)
+{
+ return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
+}
+
+;#####################################################################################
+
+; DCX_CACHE = 0x2
+; DCX_CLIPCHILDREN = 0x8
+; DCX_CLIPSIBLINGS = 0x10
+; DCX_EXCLUDERGN = 0x40
+; DCX_EXCLUDEUPDATE = 0x100
+; DCX_INTERSECTRGN = 0x80
+; DCX_INTERSECTUPDATE = 0x200
+; DCX_LOCKWINDOWUPDATE = 0x400
+; DCX_NORECOMPUTE = 0x100000
+; DCX_NORESETATTRS = 0x4
+; DCX_PARENTCLIP = 0x20
+; DCX_VALIDATE = 0x200000
+; DCX_WINDOW = 0x1
+
+GetDCEx(hwnd, flags=0, hrgnClip=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("GetDCEx", Ptr, hwnd, Ptr, hrgnClip, "int", flags)
+}
+
+;#####################################################################################
+
+; Function ReleaseDC
+; Description This function releases a device context (DC), freeing it for use by other applications. The effect of ReleaseDC depends on the type of device context
+;
+; hdc Handle to the device context to be released
+; hwnd Handle to the window whose device context is to be released
+;
+; return 1 = released
+; 0 = not released
+;
+; notes The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common device context
+; An application cannot use the ReleaseDC function to release a device context that was created by calling the CreateDC function; instead, it must use the DeleteDC function.
+
+ReleaseDC(hdc, hwnd=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function DeleteDC
+; Description The DeleteDC function deletes the specified device context (DC)
+;
+; hdc A handle to the device context
+;
+; return If the function succeeds, the return value is nonzero
+;
+; notes An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC
+
+DeleteDC(hdc)
+{
+ return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc)
+}
+;#####################################################################################
+
+; Function Gdip_LibraryVersion
+; Description Get the current library version
+;
+; return the library version
+;
+; notes This is useful for non compiled programs to ensure that a person doesn't run an old version when testing your scripts
+
+Gdip_LibraryVersion()
+{
+ return 1.45
+}
+
+;#####################################################################################
+
+; Function Gdip_LibrarySubVersion
+; Description Get the current library sub version
+;
+; return the library sub version
+;
+; notes This is the sub-version currently maintained by Rseding91
+Gdip_LibrarySubVersion()
+{
+ return 1.47
+}
+
+;#####################################################################################
+
+; Function: Gdip_BitmapFromBRA
+; Description: Gets a pointer to a gdi+ bitmap from a BRA file
+;
+; BRAFromMemIn The variable for a BRA file read to memory
+; File The name of the file, or its number that you would like (This depends on alternate parameter)
+; Alternate Changes whether the File parameter is the file name or its number
+;
+; return If the function succeeds, the return value is a pointer to a gdi+ bitmap
+; -1 = The BRA variable is empty
+; -2 = The BRA has an incorrect header
+; -3 = The BRA has information missing
+; -4 = Could not find file inside the BRA
+
+Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate=0)
+{
+ Static FName = "ObjRelease"
+
+ if !BRAFromMemIn
+ return -1
+ Loop, Parse, BRAFromMemIn, `n
+ {
+ if (A_Index = 1)
+ {
+ StringSplit, Header, A_LoopField, |
+ if (Header0 != 4 || Header2 != "BRA!")
+ return -2
+ }
+ else if (A_Index = 2)
+ {
+ StringSplit, Info, A_LoopField, |
+ if (Info0 != 3)
+ return -3
+ }
+ else
+ break
+ }
+ if !Alternate
+ StringReplace, File, File, \, \\, All
+ RegExMatch(BRAFromMemIn, "mi`n)^" (Alternate ? File "\|.+?\|(\d+)\|(\d+)" : "\d+\|" File "\|(\d+)\|(\d+)") "$", FileInfo)
+ if !FileInfo
+ return -4
+
+ hData := DllCall("GlobalAlloc", "uint", 2, Ptr, FileInfo2, Ptr)
+ pData := DllCall("GlobalLock", Ptr, hData, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pData, Ptr, &BRAFromMemIn+Info2+FileInfo1, Ptr, FileInfo2)
+ DllCall("GlobalUnlock", Ptr, hData)
+ DllCall("ole32\CreateStreamOnHGlobal", Ptr, hData, "int", 1, A_PtrSize ? "UPtr*" : "UInt*", pStream)
+ DllCall("gdiplus\GdipCreateBitmapFromStream", Ptr, pStream, A_PtrSize ? "UPtr*" : "UInt*", pBitmap)
+ If (A_PtrSize)
+ %FName%(pStream)
+ Else
+ DllCall(NumGet(NumGet(1*pStream)+8), "uint", pStream)
+ return pBitmap
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRectangle
+; Description This function uses a pen to draw the outline of a rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawRoundedRectangle
+; Description This function uses a pen to draw the outline of a rounded rectangle into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawEllipse
+; Description This function uses a pen to draw the outline of an ellipse into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the top left of the rectangle the ellipse will be drawn into
+; y y-coordinate of the top left of the rectangle the ellipse will be drawn into
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawBezier
+; Description This function uses a pen to draw the outline of a bezier (a weighted curve) into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the bezier
+; y1 y-coordinate of the start of the bezier
+; x2 x-coordinate of the first arc of the bezier
+; y2 y-coordinate of the first arc of the bezier
+; x3 x-coordinate of the second arc of the bezier
+; y3 y-coordinate of the second arc of the bezier
+; x4 x-coordinate of the end of the bezier
+; y4 y-coordinate of the end of the bezier
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawBezier"
+ , Ptr, pgraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2
+ , "float", x3
+ , "float", y3
+ , "float", x4
+ , "float", y4)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawArc
+; Description This function uses a pen to draw the outline of an arc into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the arc
+; y y-coordinate of the start of the arc
+; w width of the arc
+; h height of the arc
+; StartAngle specifies the angle between the x-axis and the starting point of the arc
+; SweepAngle specifies the angle between the starting and ending points of the arc
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawArc"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawPie
+; Description This function uses a pen to draw the outline of a pie into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x x-coordinate of the start of the pie
+; y y-coordinate of the start of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+;
+; notes as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
+
+Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawPie", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLine
+; Description This function uses a pen to draw a line into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; x1 x-coordinate of the start of the line
+; y1 y-coordinate of the start of the line
+; x2 x-coordinate of the end of the line
+; y2 y-coordinate of the end of the line
+;
+; return status enumeration. 0 = success
+
+Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipDrawLine"
+ , Ptr, pGraphics
+ , Ptr, pPen
+ , "float", x1
+ , "float", y1
+ , "float", x2
+ , "float", y2)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawLines
+; Description This function uses a pen to draw a series of joined lines into the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pPen Pointer to a pen
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRectangle
+; Description This function uses a brush to fill a rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rectangle
+; y y-coordinate of the top left of the rectangle
+; w width of the rectanlge
+; h height of the rectangle
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRoundedRectangle
+; Description This function uses a brush to fill a rounded rectangle in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the rounded rectangle
+; y y-coordinate of the top left of the rounded rectangle
+; w width of the rectanlge
+; h height of the rectangle
+; r radius of the rounded corners
+;
+; return status enumeration. 0 = success
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPolygon
+; Description This function uses a brush to fill a polygon in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Points the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
+;
+; return status enumeration. 0 = success
+;
+; notes Alternate will fill the polygon as a whole, wheras winding will fill each new "segment"
+; Alternate = 0
+; Winding = 1
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPie
+; Description This function uses a brush to fill a pie in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the pie
+; y y-coordinate of the top left of the pie
+; w width of the pie
+; h height of the pie
+; StartAngle specifies the angle between the x-axis and the starting point of the pie
+; SweepAngle specifies the angle between the starting and ending points of the pie
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPie"
+ , Ptr, pGraphics
+ , Ptr, pBrush
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "float", StartAngle
+ , "float", SweepAngle)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillEllipse
+; Description This function uses a brush to fill an ellipse in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; x x-coordinate of the top left of the ellipse
+; y y-coordinate of the top left of the ellipse
+; w width of the ellipse
+; h height of the ellipse
+;
+; return status enumeration. 0 = success
+
+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)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillRegion
+; Description This function uses a brush to fill a region in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Region
+;
+; return status enumeration. 0 = success
+;
+; notes You can create a region Gdip_CreateRegion() and then add to this
+
+Gdip_FillRegion(pGraphics, pBrush, Region)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillRegion", Ptr, pGraphics, Ptr, pBrush, Ptr, Region)
+}
+
+;#####################################################################################
+
+; Function Gdip_FillPath
+; Description This function uses a brush to fill a path in the Graphics of a bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBrush Pointer to a brush
+; Region Pointer to a Path
+;
+; return status enumeration. 0 = success
+
+Gdip_FillPath(pGraphics, pBrush, Path)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipFillPath", Ptr, pGraphics, Ptr, pBrush, Ptr, Path)
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImagePointsRect
+; Description This function draws a bitmap into the Graphics of another bitmap and skews it
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; Points Points passed as x1,y1|x2,y2|x3,y3 (3 points: top left, top right, bottom left) describing the drawing of the bitmap
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source rectangle
+; sh height of source rectangle
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter
+
+Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1)
+{
+ 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")
+ }
+
+ 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 = "")
+ {
+ sx := 0, sy := 0
+ sw := Gdip_GetImageWidth(pBitmap)
+ sh := Gdip_GetImageHeight(pBitmap)
+ }
+
+ E := DllCall("gdiplus\GdipDrawImagePointsRect"
+ , Ptr, pGraphics
+ , Ptr, pBitmap
+ , Ptr, &PointF
+ , "int", Points0
+ , "float", sx
+ , "float", sy
+ , "float", sw
+ , "float", sh
+ , "int", 2
+ , Ptr, ImageAttr
+ , Ptr, 0
+ , Ptr, 0)
+ if ImageAttr
+ Gdip_DisposeImageAttributes(ImageAttr)
+ return E
+}
+
+;#####################################################################################
+
+; Function Gdip_DrawImage
+; Description This function draws a bitmap into the Graphics of another bitmap
+;
+; pGraphics Pointer to the Graphics of a bitmap
+; pBitmap Pointer to a bitmap to be drawn
+; dx x-coord of destination upper-left corner
+; dy y-coord of destination upper-left corner
+; dw width of destination image
+; dh height of destination image
+; sx x-coordinate of source upper-left corner
+; sy y-coordinate of source upper-left corner
+; sw width of source image
+; sh height of source image
+; Matrix a matrix used to alter image attributes when drawing
+;
+; return status enumeration. 0 = success
+;
+; notes if sx,sy,sw,sh are missed then the entire source bitmap will be used
+; Gdip_DrawImage performs faster
+; Matrix can be omitted to just draw with no alteration to ARGB
+; Matrix may be passed as a digit from 0 - 1 to change just transparency
+; Matrix can be passed as a matrix with any delimiter. For example:
+; MatrixBright=
+; (
+; 1.5 |0 |0 |0 |0
+; 0 |1.5 |0 |0 |0
+; 0 |0 |1.5 |0 |0
+; 0 |0 |0 |1 |0
+; 0.05 |0.05 |0.05 |0 |1
+; )
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_SetImageAttributesColorMatrix
+; Description This function creates an image matrix ready for drawing
+;
+; Matrix a matrix used to alter image attributes when drawing
+; passed with any delimeter
+;
+; return returns an image matrix on sucess or 0 if it fails
+;
+; notes MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
+; MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
+; MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
+
+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
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromImage
+; Description This function gets the graphics for a bitmap used for drawing functions
+;
+; pBitmap Pointer to a bitmap to get the pointer to its graphics
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes a bitmap can be drawn into the graphics of another bitmap
+
+Gdip_GraphicsFromImage(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsFromHDC
+; Description This function gets the graphics from the handle to a device context
+;
+; hdc This is the handle to the device context
+;
+; return returns a pointer to the graphics of a bitmap
+;
+; notes You can draw a bitmap into the graphics of another bitmap
+
+Gdip_GraphicsFromHDC(hdc)
+{
+ DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
+ return pGraphics
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDC
+; Description This function gets the device context of the passed Graphics
+;
+; hdc This is the handle to the device context
+;
+; return returns the device context for the graphics of a bitmap
+
+Gdip_GetDC(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDC", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", hdc)
+ return hdc
+}
+
+;#####################################################################################
+
+; Function Gdip_ReleaseDC
+; Description This function releases a device context from use for further use
+;
+; pGraphics Pointer to the graphics of a bitmap
+; hdc This is the handle to the device context
+;
+; return status enumeration. 0 = success
+
+Gdip_ReleaseDC(pGraphics, hdc)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipReleaseDC", Ptr, pGraphics, Ptr, hdc)
+}
+
+;#####################################################################################
+
+; Function Gdip_GraphicsClear
+; Description Clears the graphics of a bitmap ready for further drawing
+;
+; pGraphics Pointer to the graphics of a bitmap
+; ARGB The colour to clear the graphics to
+;
+; return status enumeration. 0 = success
+;
+; notes By default this will make the background invisible
+; Using clipping regions you can clear a particular area on the graphics rather than clearing the entire graphics
+
+Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff)
+{
+ return DllCall("gdiplus\GdipGraphicsClear", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_BlurBitmap
+; Description Gives a pointer to a blurred bitmap from a pointer to a bitmap
+;
+; pBitmap Pointer to a bitmap to be blurred
+; Blur The Amount to blur a bitmap by from 1 (least blur) to 100 (most blur)
+;
+; return If the function succeeds, the return value is a pointer to the new blurred bitmap
+; -1 = The blur parameter is outside the range 1-100
+;
+; notes This function will not dispose of the original bitmap
+
+Gdip_BlurBitmap(pBitmap, Blur)
+{
+ if (Blur > 100) || (Blur < 1)
+ return -1
+
+ sWidth := Gdip_GetImageWidth(pBitmap), sHeight := Gdip_GetImageHeight(pBitmap)
+ dWidth := sWidth//Blur, dHeight := sHeight//Blur
+
+ pBitmap1 := Gdip_CreateBitmap(dWidth, dHeight)
+ G1 := Gdip_GraphicsFromImage(pBitmap1)
+ Gdip_SetInterpolationMode(G1, 7)
+ Gdip_DrawImage(G1, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight)
+
+ Gdip_DeleteGraphics(G1)
+
+ pBitmap2 := Gdip_CreateBitmap(sWidth, sHeight)
+ G2 := Gdip_GraphicsFromImage(pBitmap2)
+ Gdip_SetInterpolationMode(G2, 7)
+ Gdip_DrawImage(G2, pBitmap1, 0, 0, sWidth, sHeight, 0, 0, dWidth, dHeight)
+
+ Gdip_DeleteGraphics(G2)
+ Gdip_DisposeImage(pBitmap1)
+ return pBitmap2
+}
+
+;#####################################################################################
+
+; Function: Gdip_SaveBitmapToFile
+; Description: Saves a bitmap to a file in any supported format onto disk
+;
+; pBitmap Pointer to a bitmap
+; sOutput The name of the file that the bitmap will be saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG
+; Quality If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality
+;
+; return If the function succeeds, the return value is zero, otherwise:
+; -1 = Extension supplied is not a supported file format
+; -2 = Could not get a list of encoders on system
+; -3 = Could not find matching encoder for specified file format
+; -4 = Could not get WideChar name of output file
+; -5 = Could not save file to disk
+;
+; notes This function will use the extension supplied from the sOutput parameter to determine the output format
+
+Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=75)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ SplitPath, sOutput,,, Extension
+ if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
+ return -1
+ Extension := "." Extension
+
+ DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
+ VarSetCapacity(ci, nSize)
+ DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
+ if !(nCount && nSize)
+ return -2
+
+ If (A_IsUnicode){
+ StrGet_Name := "StrGet"
+ Loop, %nCount%
+ {
+ sString := %StrGet_Name%(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
+ }
+ } else {
+ Loop, %nCount%
+ {
+ Location := NumGet(ci, 76*(A_Index-1)+44)
+ nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(sString, nSize)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0)
+ if !InStr(sString, "*" Extension)
+ continue
+
+ pCodec := &ci+76*(A_Index-1)
+ 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
+ }
+ }
+ }
+ }
+
+ if (!A_IsUnicode)
+ {
+ nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, 0, "int", 0)
+ VarSetCapacity(wOutput, nSize*2)
+ DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, &wOutput, "int", nSize)
+ VarSetCapacity(wOutput, -1)
+ if !VarSetCapacity(wOutput)
+ return -4
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &wOutput, Ptr, pCodec, "uint", p ? p : 0)
+ }
+ else
+ E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &sOutput, Ptr, pCodec, "uint", p ? p : 0)
+ return E ? -5 : 0
+}
+
+;#####################################################################################
+
+; Function Gdip_GetPixel
+; Description Gets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return Returns the ARGB value of the pixel
+
+Gdip_GetPixel(pBitmap, x, y)
+{
+ DllCall("gdiplus\GdipBitmapGetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "uint*", ARGB)
+ return ARGB
+}
+
+;#####################################################################################
+
+; Function Gdip_SetPixel
+; Description Sets the ARGB of a pixel in a bitmap
+;
+; pBitmap Pointer to a bitmap
+; x x-coordinate of the pixel
+; y y-coordinate of the pixel
+;
+; return status enumeration. 0 = success
+
+Gdip_SetPixel(pBitmap, x, y, ARGB)
+{
+ return DllCall("gdiplus\GdipBitmapSetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "int", ARGB)
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageWidth
+; Description Gives the width of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the width in pixels of the supplied bitmap
+
+Gdip_GetImageWidth(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width)
+ return Width
+}
+
+;#####################################################################################
+
+; Function Gdip_GetImageHeight
+; Description Gives the height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+;
+; return Returns the height in pixels of the supplied bitmap
+
+Gdip_GetImageHeight(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height)
+ return Height
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDimensions
+; Description Gives the width and height of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetImageDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ DllCall("gdiplus\GdipGetImageWidth", Ptr, pBitmap, "uint*", Width)
+ DllCall("gdiplus\GdipGetImageHeight", Ptr, pBitmap, "uint*", Height)
+}
+
+;#####################################################################################
+
+Gdip_GetDimensions(pBitmap, ByRef Width, ByRef Height)
+{
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+}
+
+;#####################################################################################
+
+Gdip_GetImagePixelFormat(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImagePixelFormat", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", Format)
+ return Format
+}
+
+;#####################################################################################
+
+; Function Gdip_GetDpiX
+; Description Gives the horizontal dots per inch of the graphics of a bitmap
+;
+; pBitmap Pointer to a bitmap
+; Width ByRef variable. This variable will be set to the width of the bitmap
+; Height ByRef variable. This variable will be set to the height of the bitmap
+;
+; return No return value
+; Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
+
+Gdip_GetDpiX(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiX", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetDpiY(pGraphics)
+{
+ DllCall("gdiplus\GdipGetDpiY", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_GetImageHorizontalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageHorizontalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpix)
+ return Round(dpix)
+}
+
+;#####################################################################################
+
+Gdip_GetImageVerticalResolution(pBitmap)
+{
+ DllCall("gdiplus\GdipGetImageVerticalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpiy)
+ return Round(dpiy)
+}
+
+;#####################################################################################
+
+Gdip_BitmapSetResolution(pBitmap, dpix, dpiy)
+{
+ return DllCall("gdiplus\GdipBitmapSetResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float", dpix, "float", dpiy)
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromFile(sFile, IconNumber=1, IconSize="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ SplitPath, sFile,,, ext
+ if ext in exe,dll
+ {
+ Sizes := IconSize ? IconSize : 256 "|" 128 "|" 64 "|" 48 "|" 32 "|" 16
+ BufSize := 16 + (2*(A_PtrSize ? A_PtrSize : 4))
+
+ VarSetCapacity(buf, BufSize, 0)
+ Loop, Parse, Sizes, |
+ {
+ DllCall("PrivateExtractIcons", "str", sFile, "int", IconNumber-1, "int", A_LoopField, "int", A_LoopField, PtrA, hIcon, PtrA, 0, "uint", 1, "uint", 0)
+
+ if !hIcon
+ continue
+
+ if !DllCall("GetIconInfo", Ptr, hIcon, Ptr, &buf)
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+
+ hbmMask := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4))
+ hbmColor := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4) + (A_PtrSize ? A_PtrSize : 4))
+ if !(hbmColor && DllCall("GetObject", Ptr, hbmColor, "int", BufSize, Ptr, &buf))
+ {
+ DestroyIcon(hIcon)
+ continue
+ }
+ break
+ }
+ if !hIcon
+ return -1
+
+ Width := NumGet(buf, 4, "int"), Height := NumGet(buf, 8, "int")
+ hbm := CreateDIBSection(Width, -Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ if !DllCall("DrawIconEx", Ptr, hdc, "int", 0, "int", 0, Ptr, hIcon, "uint", Width, "uint", Height, "uint", 0, Ptr, 0, "uint", 3)
+ {
+ DestroyIcon(hIcon)
+ return -2
+ }
+
+ VarSetCapacity(dib, 104)
+ DllCall("GetObject", Ptr, hbm, "int", A_PtrSize = 8 ? 104 : 84, Ptr, &dib) ; sizeof(DIBSECTION) = 76+2*(A_PtrSize=8?4:0)+2*A_PtrSize
+ Stride := NumGet(dib, 12, "Int"), Bits := NumGet(dib, 20 + (A_PtrSize = 8 ? 4 : 0)) ; padding
+ DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", Stride, "int", 0x26200A, Ptr, Bits, PtrA, pBitmapOld)
+ pBitmap := Gdip_CreateBitmap(Width, Height)
+ G := Gdip_GraphicsFromImage(pBitmap)
+ , Gdip_DrawImage(G, pBitmapOld, 0, 0, Width, Height, 0, 0, Width, Height)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapOld)
+ DestroyIcon(hIcon)
+ }
+ else
+ {
+ if (!A_IsUnicode)
+ {
+ VarSetCapacity(wFile, 1024)
+ DllCall("kernel32\MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sFile, "int", -1, Ptr, &wFile, "int", 512)
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &wFile, PtrA, pBitmap)
+ }
+ else
+ DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &sFile, PtrA, pBitmap)
+ }
+
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", Ptr, hBitmap, Ptr, Palette, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff)
+{
+ DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hbm, "int", Background)
+ return hbm
+}
+
+;#####################################################################################
+
+Gdip_CreateBitmapFromHICON(hIcon)
+{
+ DllCall("gdiplus\GdipCreateBitmapFromHICON", A_PtrSize ? "UPtr" : "UInt", hIcon, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_CreateHICONFromBitmap(pBitmap)
+{
+ DllCall("gdiplus\GdipCreateHICONFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hIcon)
+ return hIcon
+}
+
+;#####################################################################################
+
+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_CreateBitmapFromClipboard()
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if !DllCall("OpenClipboard", Ptr, 0)
+ return -1
+ if !DllCall("IsClipboardFormatAvailable", "uint", 8)
+ return -2
+ if !hBitmap := DllCall("GetClipboardData", "uint", 2, Ptr)
+ return -3
+ if !pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap)
+ return -4
+ if !DllCall("CloseClipboard")
+ return -5
+ DeleteObject(hBitmap)
+ return pBitmap
+}
+
+;#####################################################################################
+
+Gdip_SetBitmapToClipboard(pBitmap)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ off1 := A_PtrSize = 8 ? 52 : 44, off2 := A_PtrSize = 8 ? 32 : 24
+ hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
+ DllCall("GetObject", Ptr, hBitmap, "int", VarSetCapacity(oi, A_PtrSize = 8 ? 104 : 84, 0), Ptr, &oi)
+ hdib := DllCall("GlobalAlloc", "uint", 2, Ptr, 40+NumGet(oi, off1, "UInt"), Ptr)
+ pdib := DllCall("GlobalLock", Ptr, hdib, Ptr)
+ DllCall("RtlMoveMemory", Ptr, pdib, Ptr, &oi+off2, Ptr, 40)
+ DllCall("RtlMoveMemory", Ptr, pdib+40, Ptr, NumGet(oi, off2 - (A_PtrSize ? A_PtrSize : 4), Ptr), Ptr, NumGet(oi, off1, "UInt"))
+ DllCall("GlobalUnlock", Ptr, hdib)
+ DllCall("DeleteObject", Ptr, hBitmap)
+ DllCall("OpenClipboard", Ptr, 0)
+ DllCall("EmptyClipboard")
+ DllCall("SetClipboardData", "uint", 8, Ptr, hdib)
+ DllCall("CloseClipboard")
+}
+
+;#####################################################################################
+
+Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format=0x26200A)
+{
+ DllCall("gdiplus\GdipCloneBitmapArea"
+ , "float", x
+ , "float", y
+ , "float", w
+ , "float", h
+ , "int", Format
+ , A_PtrSize ? "UPtr" : "UInt", pBitmap
+ , A_PtrSize ? "UPtr*" : "UInt*", pBitmapDest)
+ return pBitmapDest
+}
+
+;#####################################################################################
+; Create resources
+;#####################################################################################
+
+Gdip_CreatePen(ARGB, w)
+{
+ DllCall("gdiplus\GdipCreatePen1", "UInt", ARGB, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_CreatePenFromBrush(pBrush, w)
+{
+ DllCall("gdiplus\GdipCreatePen2", A_PtrSize ? "UPtr" : "UInt", pBrush, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
+ return pPen
+}
+
+;#####################################################################################
+
+Gdip_BrushCreateSolid(ARGB=0xff000000)
+{
+ DllCall("gdiplus\GdipCreateSolidFill", "UInt", ARGB, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; HatchStyleHorizontal = 0
+; HatchStyleVertical = 1
+; HatchStyleForwardDiagonal = 2
+; HatchStyleBackwardDiagonal = 3
+; HatchStyleCross = 4
+; HatchStyleDiagonalCross = 5
+; HatchStyle05Percent = 6
+; HatchStyle10Percent = 7
+; HatchStyle20Percent = 8
+; HatchStyle25Percent = 9
+; HatchStyle30Percent = 10
+; HatchStyle40Percent = 11
+; HatchStyle50Percent = 12
+; HatchStyle60Percent = 13
+; HatchStyle70Percent = 14
+; HatchStyle75Percent = 15
+; HatchStyle80Percent = 16
+; HatchStyle90Percent = 17
+; HatchStyleLightDownwardDiagonal = 18
+; HatchStyleLightUpwardDiagonal = 19
+; HatchStyleDarkDownwardDiagonal = 20
+; HatchStyleDarkUpwardDiagonal = 21
+; HatchStyleWideDownwardDiagonal = 22
+; HatchStyleWideUpwardDiagonal = 23
+; HatchStyleLightVertical = 24
+; HatchStyleLightHorizontal = 25
+; HatchStyleNarrowVertical = 26
+; HatchStyleNarrowHorizontal = 27
+; HatchStyleDarkVertical = 28
+; HatchStyleDarkHorizontal = 29
+; HatchStyleDashedDownwardDiagonal = 30
+; HatchStyleDashedUpwardDiagonal = 31
+; HatchStyleDashedHorizontal = 32
+; HatchStyleDashedVertical = 33
+; HatchStyleSmallConfetti = 34
+; HatchStyleLargeConfetti = 35
+; HatchStyleZigZag = 36
+; HatchStyleWave = 37
+; HatchStyleDiagonalBrick = 38
+; HatchStyleHorizontalBrick = 39
+; HatchStyleWeave = 40
+; HatchStylePlaid = 41
+; HatchStyleDivot = 42
+; HatchStyleDottedGrid = 43
+; HatchStyleDottedDiamond = 44
+; HatchStyleShingle = 45
+; HatchStyleTrellis = 46
+; HatchStyleSphere = 47
+; HatchStyleSmallGrid = 48
+; HatchStyleSmallCheckerBoard = 49
+; HatchStyleLargeCheckerBoard = 50
+; HatchStyleOutlinedDiamond = 51
+; HatchStyleSolidDiamond = 52
+; HatchStyleTotal = 53
+Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0)
+{
+ DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "UInt", ARGBfront, "UInt", ARGBback, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+Gdip_CreateTextureBrush(pBitmap, WrapMode=1, x=0, y=0, w="", h="")
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
+
+ if !(w && h)
+ DllCall("gdiplus\GdipCreateTexture", Ptr, pBitmap, "int", WrapMode, PtrA, pBrush)
+ else
+ DllCall("gdiplus\GdipCreateTexture2", Ptr, pBitmap, "int", WrapMode, "float", x, "float", y, "float", w, "float", h, PtrA, pBrush)
+ return pBrush
+}
+
+;#####################################################################################
+
+; WrapModeTile = 0
+; WrapModeTileFlipX = 1
+; WrapModeTileFlipY = 2
+; WrapModeTileFlipXY = 3
+; WrapModeClamp = 4
+Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2)
+ DllCall("gdiplus\GdipCreateLineBrush", Ptr, &PointF1, Ptr, &PointF2, "Uint", ARGB1, "Uint", ARGB2, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
+ return LGpBrush
+}
+
+;#####################################################################################
+
+; LinearGradientModeHorizontal = 0
+; LinearGradientModeVertical = 1
+; LinearGradientModeForwardDiagonal = 2
+; LinearGradientModeBackwardDiagonal = 3
+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_CloneBrush(pBrush)
+{
+ DllCall("gdiplus\GdipCloneBrush", A_PtrSize ? "UPtr" : "UInt", pBrush, A_PtrSize ? "UPtr*" : "UInt*", pBrushClone)
+ return pBrushClone
+}
+
+;#####################################################################################
+; Delete resources
+;#####################################################################################
+
+Gdip_DeletePen(pPen)
+{
+ return DllCall("gdiplus\GdipDeletePen", A_PtrSize ? "UPtr" : "UInt", pPen)
+}
+
+;#####################################################################################
+
+Gdip_DeleteBrush(pBrush)
+{
+ return DllCall("gdiplus\GdipDeleteBrush", A_PtrSize ? "UPtr" : "UInt", pBrush)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImage(pBitmap)
+{
+ return DllCall("gdiplus\GdipDisposeImage", A_PtrSize ? "UPtr" : "UInt", pBitmap)
+}
+
+;#####################################################################################
+
+Gdip_DeleteGraphics(pGraphics)
+{
+ return DllCall("gdiplus\GdipDeleteGraphics", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+;#####################################################################################
+
+Gdip_DisposeImageAttributes(ImageAttr)
+{
+ return DllCall("gdiplus\GdipDisposeImageAttributes", A_PtrSize ? "UPtr" : "UInt", ImageAttr)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFont(hFont)
+{
+ return DllCall("gdiplus\GdipDeleteFont", A_PtrSize ? "UPtr" : "UInt", hFont)
+}
+
+;#####################################################################################
+
+Gdip_DeleteStringFormat(hFormat)
+{
+ return DllCall("gdiplus\GdipDeleteStringFormat", A_PtrSize ? "UPtr" : "UInt", hFormat)
+}
+
+;#####################################################################################
+
+Gdip_DeleteFontFamily(hFamily)
+{
+ return DllCall("gdiplus\GdipDeleteFontFamily", A_PtrSize ? "UPtr" : "UInt", hFamily)
+}
+
+;#####################################################################################
+
+Gdip_DeleteMatrix(Matrix)
+{
+ return DllCall("gdiplus\GdipDeleteMatrix", A_PtrSize ? "UPtr" : "UInt", Matrix)
+}
+
+;#####################################################################################
+; Text functions
+;#####################################################################################
+
+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_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_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
+}
+
+; Near = 0
+; Center = 1
+; Far = 2
+Gdip_SetStringFormatAlign(hFormat, Align)
+{
+ return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align)
+}
+
+; StringFormatFlagsDirectionRightToLeft = 0x00000001
+; StringFormatFlagsDirectionVertical = 0x00000002
+; StringFormatFlagsNoFitBlackBox = 0x00000004
+; StringFormatFlagsDisplayFormatControl = 0x00000020
+; StringFormatFlagsNoFontFallback = 0x00000400
+; StringFormatFlagsMeasureTrailingSpaces = 0x00000800
+; StringFormatFlagsNoWrap = 0x00001000
+; StringFormatFlagsLineLimit = 0x00002000
+; StringFormatFlagsNoClip = 0x00004000
+Gdip_StringFormatCreate(Format=0, Lang=0)
+{
+ DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat)
+ return hFormat
+}
+
+; Regular = 0
+; Bold = 1
+; Italic = 2
+; BoldItalic = 3
+; Underline = 4
+; Strikeout = 8
+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
+}
+
+;#####################################################################################
+; Matrix functions
+;#####################################################################################
+
+Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y)
+{
+ DllCall("gdiplus\GdipCreateMatrix2", "float", m11, "float", m12, "float", m21, "float", m22, "float", x, "float", y, A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+Gdip_CreateMatrix()
+{
+ DllCall("gdiplus\GdipCreateMatrix", A_PtrSize ? "UPtr*" : "UInt*", Matrix)
+ return Matrix
+}
+
+;#####################################################################################
+; GraphicsPath functions
+;#####################################################################################
+
+; Alternate = 0
+; Winding = 1
+Gdip_CreatePath(BrushMode=0)
+{
+ DllCall("gdiplus\GdipCreatePath", "int", BrushMode, A_PtrSize ? "UPtr*" : "UInt*", Path)
+ return Path
+}
+
+Gdip_AddPathEllipse(Path, x, y, w, h)
+{
+ return DllCall("gdiplus\GdipAddPathEllipse", A_PtrSize ? "UPtr" : "UInt", Path, "float", x, "float", y, "float", w, "float", h)
+}
+
+Gdip_AddPathPolygon(Path, 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\GdipAddPathPolygon", Ptr, Path, Ptr, &PointF, "int", Points0)
+}
+
+Gdip_DeletePath(Path)
+{
+ return DllCall("gdiplus\GdipDeletePath", A_PtrSize ? "UPtr" : "UInt", Path)
+}
+
+;#####################################################################################
+; Quality functions
+;#####################################################################################
+
+; SystemDefault = 0
+; SingleBitPerPixelGridFit = 1
+; SingleBitPerPixel = 2
+; AntiAliasGridFit = 3
+; AntiAlias = 4
+Gdip_SetTextRenderingHint(pGraphics, RenderingHint)
+{
+ return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint)
+}
+
+; Default = 0
+; LowQuality = 1
+; HighQuality = 2
+; Bilinear = 3
+; Bicubic = 4
+; NearestNeighbor = 5
+; HighQualityBilinear = 6
+; HighQualityBicubic = 7
+Gdip_SetInterpolationMode(pGraphics, InterpolationMode)
+{
+ return DllCall("gdiplus\GdipSetInterpolationMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", InterpolationMode)
+}
+
+; Default = 0
+; HighSpeed = 1
+; HighQuality = 2
+; None = 3
+; AntiAlias = 4
+Gdip_SetSmoothingMode(pGraphics, SmoothingMode)
+{
+ return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
+}
+
+; CompositingModeSourceOver = 0 (blended)
+; CompositingModeSourceCopy = 1 (overwrite)
+Gdip_SetCompositingMode(pGraphics, CompositingMode=0)
+{
+ return DllCall("gdiplus\GdipSetCompositingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", CompositingMode)
+}
+
+;#####################################################################################
+; Extra functions
+;#####################################################################################
+
+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
+}
+
+; Prepend = 0; The new operation is applied before the old operation.
+; Append = 1; The new operation is applied after the old operation.
+Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipRotateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", Angle, "int", MatrixOrder)
+}
+
+Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipScaleWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder=0)
+{
+ return DllCall("gdiplus\GdipTranslateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
+}
+
+Gdip_ResetWorldTransform(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetRotatedTranslation(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+
+ Bound := (Angle >= 0) ? Mod(Angle, 360) : 360-Mod(-Angle, -360)
+ if ((Bound >= 0) && (Bound <= 90))
+ xTranslation := Height*Sin(TAngle), yTranslation := 0
+ else if ((Bound > 90) && (Bound <= 180))
+ xTranslation := (Height*Sin(TAngle))-(Width*Cos(TAngle)), yTranslation := -Height*Cos(TAngle)
+ else if ((Bound > 180) && (Bound <= 270))
+ xTranslation := -(Width*Cos(TAngle)), yTranslation := -(Height*Cos(TAngle))-(Width*Sin(TAngle))
+ else if ((Bound > 270) && (Bound <= 360))
+ xTranslation := 0, yTranslation := -Width*Sin(TAngle)
+}
+
+Gdip_GetRotatedDimensions(Width, Height, Angle, ByRef RWidth, ByRef RHeight)
+{
+ pi := 3.14159, TAngle := Angle*(pi/180)
+ if !(Width && Height)
+ return -1
+ RWidth := Ceil(Abs(Width*Cos(TAngle))+Abs(Height*Sin(TAngle)))
+ RHeight := Ceil(Abs(Width*Sin(TAngle))+Abs(Height*Cos(Tangle)))
+}
+
+; RotateNoneFlipNone = 0
+; Rotate90FlipNone = 1
+; Rotate180FlipNone = 2
+; Rotate270FlipNone = 3
+; RotateNoneFlipX = 4
+; Rotate90FlipX = 5
+; Rotate180FlipX = 6
+; Rotate270FlipX = 7
+; RotateNoneFlipY = Rotate180FlipX
+; Rotate90FlipY = Rotate270FlipX
+; Rotate180FlipY = RotateNoneFlipX
+; Rotate270FlipY = Rotate90FlipX
+; RotateNoneFlipXY = Rotate180FlipNone
+; Rotate90FlipXY = Rotate270FlipNone
+; Rotate180FlipXY = RotateNoneFlipNone
+; Rotate270FlipXY = Rotate90FlipNone
+
+Gdip_ImageRotateFlip(pBitmap, RotateFlipType=1)
+{
+ return DllCall("gdiplus\GdipImageRotateFlip", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", RotateFlipType)
+}
+
+; Replace = 0
+; Intersect = 1
+; Union = 2
+; Xor = 3
+; Exclude = 4
+; Complement = 5
+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_SetClipPath(pGraphics, Path, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+ return DllCall("gdiplus\GdipSetClipPath", Ptr, pGraphics, Ptr, Path, "int", CombineMode)
+}
+
+Gdip_ResetClip(pGraphics)
+{
+ return DllCall("gdiplus\GdipResetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics)
+}
+
+Gdip_GetClipRegion(pGraphics)
+{
+ Region := Gdip_CreateRegion()
+ DllCall("gdiplus\GdipGetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics, "UInt*", Region)
+ return Region
+}
+
+Gdip_SetClipRegion(pGraphics, Region, CombineMode=0)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("gdiplus\GdipSetClipRegion", Ptr, pGraphics, Ptr, Region, "int", CombineMode)
+}
+
+Gdip_CreateRegion()
+{
+ DllCall("gdiplus\GdipCreateRegion", "UInt*", Region)
+ return Region
+}
+
+Gdip_DeleteRegion(Region)
+{
+ return DllCall("gdiplus\GdipDeleteRegion", A_PtrSize ? "UPtr" : "UInt", Region)
+}
+
+;#####################################################################################
+; BitmapLockBits
+;#####################################################################################
+
+Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode = 3, PixelFormat = 0x26200a)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ CreateRect(Rect, x, y, w, h)
+ VarSetCapacity(BitmapData, 16+2*(A_PtrSize ? A_PtrSize : 4), 0)
+ E := DllCall("Gdiplus\GdipBitmapLockBits", Ptr, pBitmap, Ptr, &Rect, "uint", LockMode, "int", PixelFormat, Ptr, &BitmapData)
+ Stride := NumGet(BitmapData, 8, "Int")
+ Scan0 := NumGet(BitmapData, 16, Ptr)
+ return E
+}
+
+;#####################################################################################
+
+Gdip_UnlockBits(pBitmap, ByRef BitmapData)
+{
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ return DllCall("Gdiplus\GdipBitmapUnlockBits", Ptr, pBitmap, Ptr, &BitmapData)
+}
+
+;#####################################################################################
+
+Gdip_SetLockBitPixel(ARGB, Scan0, x, y, Stride)
+{
+ Numput(ARGB, Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_GetLockBitPixel(Scan0, x, y, Stride)
+{
+ return NumGet(Scan0+0, (x*4)+(y*Stride), "UInt")
+}
+
+;#####################################################################################
+
+Gdip_PixelateBitmap(pBitmap, ByRef pBitmapOut, BlockSize)
+{
+ static PixelateBitmap
+
+ Ptr := A_PtrSize ? "UPtr" : "UInt"
+
+ if (!PixelateBitmap)
+ {
+ if A_PtrSize != 8 ; x86 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 558BEC83EC3C8B4514538B5D1C99F7FB56578BC88955EC894DD885C90F8E830200008B451099F7FB8365DC008365E000894DC88955F08945E833FF897DD4
+ 397DE80F8E160100008BCB0FAFCB894DCC33C08945F88945FC89451C8945143BD87E608B45088D50028BC82BCA8BF02BF2418945F48B45E02955F4894DC4
+ 8D0CB80FAFCB03CA895DD08BD1895DE40FB64416030145140FB60201451C8B45C40FB604100145FC8B45F40FB604020145F883C204FF4DE475D6034D18FF
+ 4DD075C98B4DCC8B451499F7F98945148B451C99F7F989451C8B45FC99F7F98945FC8B45F899F7F98945F885DB7E648B450C8D50028BC82BCA83C103894D
+ C48BC82BCA41894DF48B4DD48945E48B45E02955E48D0C880FAFCB03CA895DD08BD18BF38A45148B7DC48804178A451C8B7DF488028A45FC8804178A45F8
+ 8B7DE488043A83C2044E75DA034D18FF4DD075CE8B4DCC8B7DD447897DD43B7DE80F8CF2FEFFFF837DF0000F842C01000033C08945F88945FC89451C8945
+ 148945E43BD87E65837DF0007E578B4DDC034DE48B75E80FAF4D180FAFF38B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945CC0F
+ B6440E030145140FB60101451C0FB6440F010145FC8B45F40FB604010145F883C104FF4DCC75D8FF45E4395DE47C9B8B4DF00FAFCB85C9740B8B451499F7
+ F9894514EB048365140033F63BCE740B8B451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB
+ 038975F88975E43BDE7E5A837DF0007E4C8B4DDC034DE48B75E80FAF4D180FAFF38B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955CC8A55
+ 1488540E038A551C88118A55FC88540F018A55F888140183C104FF4DCC75DFFF45E4395DE47CA68B45180145E0015DDCFF4DC80F8594FDFFFF8B451099F7
+ FB8955F08945E885C00F8E450100008B45EC0FAFC38365DC008945D48B45E88945CC33C08945F88945FC89451C8945148945103945EC7E6085DB7E518B4D
+ D88B45080FAFCB034D108D50020FAF4D18034DDC8BF08BF88945F403CA2BF22BFA2955F4895DC80FB6440E030145140FB60101451C0FB6440F010145FC8B
+ 45F40FB604080145F883C104FF4DC875D8FF45108B45103B45EC7CA08B4DD485C9740B8B451499F7F9894514EB048365140033F63BCE740B8B451C99F7F9
+ 89451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975103975EC7E5585DB7E468B4DD88B450C
+ 0FAFCB034D108D50020FAF4D18034DDC8BF08BF803CA2BF22BFA2BC2895DC88A551488540E038A551C88118A55FC88540F018A55F888140183C104FF4DC8
+ 75DFFF45108B45103B45EC7CAB8BC3C1E0020145DCFF4DCC0F85CEFEFFFF8B4DEC33C08945F88945FC89451C8945148945103BC87E6C3945F07E5C8B4DD8
+ 8B75E80FAFCB034D100FAFF30FAF4D188B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945C80FB6440E030145140FB60101451C0F
+ B6440F010145FC8B45F40FB604010145F883C104FF4DC875D833C0FF45108B4DEC394D107C940FAF4DF03BC874068B451499F7F933F68945143BCE740B8B
+ 451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975083975EC7E63EB0233F639
+ 75F07E4F8B4DD88B75E80FAFCB034D080FAFF30FAF4D188B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955108A551488540E038A551C8811
+ 8A55FC88540F018A55F888140883C104FF4D1075DFFF45088B45083B45EC7C9F5F5E33C05BC9C21800
+ )
+ else ; x64 machine code
+ MCode_PixelateBitmap =
+ (LTrim Join
+ 4489442418488954241048894C24085355565741544155415641574883EC28418BC1448B8C24980000004C8BDA99488BD941F7F9448BD0448BFA8954240C
+ 448994248800000085C00F8E9D020000418BC04533E4458BF299448924244C8954241041F7F933C9898C24980000008BEA89542404448BE889442408EB05
+ 4C8B5C24784585ED0F8E1A010000458BF1418BFD48897C2418450FAFF14533D233F633ED4533E44533ED4585C97E5B4C63BC2490000000418D040A410FAF
+ C148984C8D441802498BD9498BD04D8BD90FB642010FB64AFF4403E80FB60203E90FB64AFE4883C2044403E003F149FFCB75DE4D03C748FFCB75D0488B7C
+ 24188B8C24980000004C8B5C2478418BC59941F7FE448BE8418BC49941F7FE448BE08BC59941F7FE8BE88BC69941F7FE8BF04585C97E4048639C24900000
+ 004103CA4D8BC1410FAFC94863C94A8D541902488BCA498BC144886901448821408869FF408871FE4883C10448FFC875E84803D349FFC875DA8B8C249800
+ 0000488B5C24704C8B5C24784183C20448FFCF48897C24180F850AFFFFFF8B6C2404448B2424448B6C24084C8B74241085ED0F840A01000033FF33DB4533
+ DB4533D24533C04585C97E53488B74247085ED7E42438D0C04418BC50FAF8C2490000000410FAFC18D04814863C8488D5431028BCD0FB642014403D00FB6
+ 024883C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC17CB28BCD410FAFC985C9740A418BC299F7F98BF0EB0233F685C9740B418BC3
+ 99F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585C97E4D4C8B74247885ED7E3841
+ 8D0C14418BC50FAF8C2490000000410FAFC18D04814863C84A8D4431028BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2413BD17CBD
+ 4C8B7424108B8C2498000000038C2490000000488B5C24704503E149FFCE44892424898C24980000004C897424100F859EFDFFFF448B7C240C448B842480
+ 000000418BC09941F7F98BE8448BEA89942498000000896C240C85C00F8E3B010000448BAC2488000000418BCF448BF5410FAFC9898C248000000033FF33
+ ED33F64533DB4533D24533C04585FF7E524585C97E40418BC5410FAFC14103C00FAF84249000000003C74898488D541802498BD90FB642014403D00FB602
+ 4883C2044403D80FB642FB03F00FB642FA03E848FFCB75DE488B5C247041FFC0453BC77CAE85C9740B418BC299F7F9448BE0EB034533E485C9740A418BC3
+ 99F7F98BD8EB0233DB85C9740A8BC699F7F9448BD8EB034533DB85C9740A8BC599F7F9448BD0EB034533D24533C04585FF7E4E488B4C24784585C97E3541
+ 8BC5410FAFC14103C00FAF84249000000003C74898488D540802498BC144886201881A44885AFF448852FE4883C20448FFC875E941FFC0453BC77CBE8B8C
+ 2480000000488B5C2470418BC1C1E00203F849FFCE0F85ECFEFFFF448BAC24980000008B6C240C448BA4248800000033FF33DB4533DB4533D24533C04585
+ FF7E5A488B7424704585ED7E48418BCC8BC5410FAFC94103C80FAF8C2490000000410FAFC18D04814863C8488D543102418BCD0FB642014403D00FB60248
+ 83C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC77CAB418BCF410FAFCD85C9740A418BC299F7F98BF0EB0233F685C9740B418BC399
+ F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585FF7E4E4585ED7E42418BCC8BC541
+ 0FAFC903CA0FAF8C2490000000410FAFC18D04814863C8488B442478488D440102418BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2
+ 413BD77CB233C04883C428415F415E415D415C5F5E5D5BC3
+ )
+
+ VarSetCapacity(PixelateBitmap, StrLen(MCode_PixelateBitmap)//2)
+ Loop % StrLen(MCode_PixelateBitmap)//2 ;%
+ NumPut("0x" SubStr(MCode_PixelateBitmap, (2*A_Index)-1, 2), PixelateBitmap, A_Index-1, "UChar")
+ DllCall("VirtualProtect", Ptr, &PixelateBitmap, Ptr, VarSetCapacity(PixelateBitmap), "uint", 0x40, A_PtrSize ? "UPtr*" : "UInt*", 0)
+ }
+
+ Gdip_GetImageDimensions(pBitmap, Width, Height)
+
+ if (Width != Gdip_GetImageWidth(pBitmapOut) || Height != Gdip_GetImageHeight(pBitmapOut))
+ return -1
+ if (BlockSize > Width || BlockSize > Height)
+ return -2
+
+ E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1)
+ E2 := Gdip_LockBits(pBitmapOut, 0, 0, Width, Height, Stride2, Scan02, BitmapData2)
+ if (E1 || E2)
+ return -3
+
+ E := DllCall(&PixelateBitmap, Ptr, Scan01, Ptr, Scan02, "int", Width, "int", Height, "int", Stride1, "int", BlockSize)
+
+ Gdip_UnlockBits(pBitmap, BitmapData1), Gdip_UnlockBits(pBitmapOut, BitmapData2)
+ return 0
+}
+
+;#####################################################################################
+
+Gdip_ToARGB(A, R, G, B)
+{
+ return (A << 24) | (R << 16) | (G << 8) | B
+}
+
+;#####################################################################################
+
+Gdip_FromARGB(ARGB, ByRef A, ByRef R, ByRef G, ByRef B)
+{
+ A := (0xff000000 & ARGB) >> 24
+ R := (0x00ff0000 & ARGB) >> 16
+ G := (0x0000ff00 & ARGB) >> 8
+ B := 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+Gdip_AFromARGB(ARGB)
+{
+ return (0xff000000 & ARGB) >> 24
+}
+
+;#####################################################################################
+
+Gdip_RFromARGB(ARGB)
+{
+ return (0x00ff0000 & ARGB) >> 16
+}
+
+;#####################################################################################
+
+Gdip_GFromARGB(ARGB)
+{
+ return (0x0000ff00 & ARGB) >> 8
+}
+
+;#####################################################################################
+
+Gdip_BFromARGB(ARGB)
+{
+ return 0x000000ff & ARGB
+}
+
+;#####################################################################################
+
+StrGetB(Address, Length=-1, Encoding=0)
+{
+ ; Flexible parameter handling:
+ if Length is not integer
+ Encoding := Length, Length := -1
+
+ ; Check for obvious errors.
+ if (Address+0 < 1024)
+ return
+
+ ; Ensure 'Encoding' contains a numeric identifier.
+ if Encoding = UTF-16
+ Encoding = 1200
+ else if Encoding = UTF-8
+ Encoding = 65001
+ else if SubStr(Encoding,1,2)="CP"
+ Encoding := SubStr(Encoding,3)
+
+ if !Encoding ; "" or 0
+ {
+ ; No conversion necessary, but we might not want the whole string.
+ if (Length == -1)
+ Length := DllCall("lstrlen", "uint", Address)
+ VarSetCapacity(String, Length)
+ DllCall("lstrcpyn", "str", String, "uint", Address, "int", Length + 1)
+ }
+ else if Encoding = 1200 ; UTF-16
+ {
+ char_count := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "uint", 0, "uint", 0, "uint", 0, "uint", 0)
+ VarSetCapacity(String, char_count)
+ DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "str", String, "int", char_count, "uint", 0, "uint", 0)
+ }
+ else if Encoding is integer
+ {
+ ; Convert from target encoding to UTF-16 then to the active code page.
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", 0, "int", 0)
+ VarSetCapacity(String, char_count * 2)
+ char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", &String, "int", char_count * 2)
+ String := StrGetB(&String, char_count, 1200)
+ }
+
+ return String
+}
\ No newline at end of file
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/SuperSleep.dll b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/SuperSleep.dll
new file mode 100644
index 0000000..535d320
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/SuperSleep.dll differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/ViGEmWrapper.dll b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/ViGEmWrapper.dll
new file mode 100644
index 0000000..2a08e3a
Binary files /dev/null and b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/ViGEmWrapper.dll differ
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/__controller_functions__.ahk b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/__controller_functions__.ahk
new file mode 100644
index 0000000..14d30c3
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/__controller_functions__.ahk
@@ -0,0 +1,191 @@
+
+/**********************************************
+* Controller methods for simplicity *
+***********************************************/
+*/
+
+GoTo EndControllerFunctionsDef
+
+;;;;;;;;;;;; Turning functions
+;;;;;;;;;;;; For holding the stick in a specific position for a period of time
+;;;;;;;;;;;; Note no other button may be pressed or released when these functions are ran
+
+; Set the time you want to turn for in miliseconds and how hard (50, 100), 100 being the most, 50 being neutral
+Turn_Right(sleept, inten){
+ t := sleept
+ controller.Axes.LX.SetState(inten)
+ gosub, Turn
+ controller.Axes.LX.SetState(50)
+}
+
+; Set the time you want to turn for in miliseconds and how hard (0, 50), 0 being the most
+Turn_Left(sleept, inten){
+ t := sleept
+ controller.Axes.LX.SetState(inten)
+ gosub, Turn
+ controller.Axes.LX.SetState(50)
+}
+
+;;;;;;;;;;;; Simple button press functions
+;;;;;;;;;;;; You can pass a delay amount or leave it blank
+;;;;;;;;;;;; Longer delays hold the button longer
+
+; Press X button
+Press_X(delay:=200){
+ controller.Buttons.Cross.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.Cross.SetState(false)
+ return
+}
+
+; Press O button
+Press_O(delay:=200){
+ controller.Buttons.Circle.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.Circle.SetState(false)
+ return
+}
+
+; Press Triangle button
+Press_Triangle(delay:=200){
+ controller.Buttons.Triangle.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.Triangle.SetState(false)
+ return
+}
+
+; Press Square button
+Press_Square(delay:=200){
+ controller.Buttons.Square.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.Square.SetState(false)
+ return
+}
+
+; Press R1 button
+Press_L1(delay:=200){
+ controller.Buttons.L1.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.L1.SetState(false)
+ return
+}
+
+; Press R1 button
+Press_R1(delay:=200){
+ controller.Buttons.R1.SetState(true)
+ DllCall("Sleep", "UInt", delay)
+ controller.Buttons.R1.SetState(false)
+ return
+}
+
+; Press Right on D-pad
+Press_Right(delay:=200){
+ controller.Dpad.SetState("Right")
+ DllCall("Sleep", "UInt", delay)
+ controller.Dpad.SetState("None")
+ return
+}
+
+; Press Left on D-pad
+Press_Left(delay:=200){
+ controller.Dpad.SetState("Left")
+ DllCall("Sleep", "UInt", delay)
+ controller.Dpad.SetState("None")
+ return
+}
+
+; Press Up on D-pad
+Press_Up(delay:=200){
+ controller.Dpad.SetState("Up")
+ DllCall("Sleep", "UInt", delay)
+ controller.Dpad.SetState("None")
+ return
+}
+
+; Press Down on D-pad
+Press_Down(delay:=200){
+ controller.Dpad.SetState("Down")
+ DllCall("Sleep", "UInt", delay)
+ controller.Dpad.SetState("None")
+ return
+}
+
+;;;;;;;;;;; Other functions specific to GT7
+
+; Turn on nitrous
+Nitrous_On(){
+ controller.Buttons.RS.SetState(true)
+}
+
+; Turn off nitrous
+Nitrous_Off(){
+ controller.Buttons.RS.SetState(false)
+}
+
+Accel_On(control:=100){
+ controller.Buttons.R2.SetState(true)
+ controller.Axes.RT.SetState(control)
+}
+
+Accel_Off(){
+ controller.Buttons.R2.SetState(false)
+ controller.Axes.RT.SetState(0)
+}
+
+Brake_On(control:=100){
+ controller.Buttons.L2.SetState(true)
+ controller.Axes.LT.SetState(control)
+}
+
+Brake_Off(){
+ controller.Buttons.L2.SetState(false)
+ controller.Axes.LT.SetState(0)
+}
+; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
+Turn:
+ t0 := A_TickCount
+ tf := t0+t
+ loop {
+ Sleep(100)
+ } until A_TickCount > tf
+ return
+
+
+Press_Options(){
+ controller.Buttons.Options.SetState(true)
+ Sleep, 50
+ controller.Buttons.Options.SetState(false)
+ }
+
+PressShare(){
+ controller.Buttons.Share.SetState(true)
+ Sleep, 50
+ controller.Buttons.Share.SetState(false)
+ }
+
+PressX:
+; Just for menuing, does not hold X down
+ controller.Buttons.Cross.SetState(true)
+ DllCall("Sleep", "UInt", 200)
+ controller.Buttons.Cross.SetState(false)
+ return
+
+PressO:
+; Just for menuing, does not hold O down
+ controller.Buttons.Circle.SetState(true)
+ DllCall("Sleep", "UInt", 200)
+ controller.Buttons.Circle.SetState(false)
+ return
+
+PressRight:
+; For turning
+ controller.Dpad.SetState("Right")
+ Sleep, 50
+ controller.Dpad.SetState("None")
+
+
+ return
+
+
+
+EndControllerFunctionsDef:
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/__utility__.ahk b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/__utility__.ahk
new file mode 100644
index 0000000..1d0470d
--- /dev/null
+++ b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/lib/__utility__.ahk
@@ -0,0 +1,136 @@
+/**********************************************
+* Only place functions here, no sub routines *
+***********************************************/
+
+
+; Grabs the colors of the pixels (x-b, y-b) to (x+b, y+b)
+; returns the array of colors
+*/
+
+BitGrab(x, y, b)
+{
+ HWND := WinExist("PS Remote Play")
+ pToken := Gdip_Startup()
+ pBitmap := Gdip_BitmapFromHWND2(hwnd)
+
+ pixs := []
+ for i in range(-1*b, b+1){
+ for j in range(-1*b, b+1){
+ pixel := Gdip_GetPixel(pBitmap,x+i,y+j)
+ rgb := ConvertARGB( pixel )
+ pixs.Push(rgb)
+ }
+ }
+
+ Gdip_DisposeImage(pBitmap)
+ Gdip_Shutdown(pToken)
+ return pixs
+}
+
+Gdip_BitmapFromHWND2(hwnd)
+{
+ WinGetPos,,, Width, Height, ahk_id %hwnd%
+ hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
+ RegExMatch(A_OsVersion, "\d+", Version)
+ PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
+ pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
+ SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
+ return pBitmap
+}
+
+range(start, stop:="", step:=1) {
+ static range := { _NewEnum: Func("_RangeNewEnum") }
+ if !step
+ throw "range(): Parameter 'step' must not be 0 or blank"
+ if (stop == "")
+ stop := start, start := 0
+ ; Formula: r[i] := start + step*i ; r = range object, i = 0-based index
+ ; For a postive 'step', the constraints are i >= 0 and r[i] < stop
+ ; For a negative 'step', the constraints are i >= 0 and r[i] > stop
+ ; No result is returned if r[0] does not meet the value constraint
+ if (step > 0 ? start < stop : start > stop) ;// start == start + step*0
+ return { base: range, start: start, stop: stop, step: step }
+}
+
+_RangeNewEnum(r) {
+ static enum := { "Next": Func("_RangeEnumNext") }
+ return { base: enum, r: r, i: 0 }
+}
+
+_RangeEnumNext(enum, ByRef k, ByRef v:="") {
+ stop := enum.r.stop, step := enum.r.step
+ , k := enum.r.start + step*enum.i
+ if (ret := step > 0 ? k < stop : k > stop)
+ enum.i += 1
+ return ret
+}
+
+
+Sleep(ms=1)
+{
+ global timeBeginPeriodHasAlreadyBeenCalled
+ if (timeBeginPeriodHasAlreadyBeenCalled != 1)
+ {
+ DllCall("Winmm.dll\timeBeginPeriod", UInt, 1)
+ timeBeginPeriodHasAlreadyBeenCalled := 1
+ }
+
+ DllCall("Sleep", UInt, ms)
+}
+
+
+
+PixelColorSimple(pc_x, pc_y)
+{
+ WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
+ if (remotePlay_id = 0)
+ {
+ MsgBox, PS4 Remote Play not found
+ return
+ }
+ if remotePlay_id
+ {
+ pc_wID := remotePlay_id[0]
+ pc_hDC := DllCall("GetDC", "UInt", pc_wID)
+ pc_fmtI := A_FormatInteger
+ SetFormat, IntegerFast, Hex
+ pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
+ pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
+ pc_c .= ""
+ SetFormat, IntegerFast, %pc_fmtI%
+ DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
+ return pc_c
+
+ }
+}
+
+GetClientSize(hWnd, ByRef w := "", ByRef h := "")
+{
+ VarSetCapacity(rect, 16)
+ DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
+ w := NumGet(rect, 8, "int")
+ h := NumGet(rect, 12, "int")
+}
+
+Distance(c1, c2)
+{ ; function by [VxE], return value range = [0, 441.67295593006372]
+return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
+}
+
+ConvertARGB(ARGB, Convert := 0)
+{
+ SetFormat, IntegerFast, Hex
+ RGB += ARGB
+ RGB := RGB & 0x00FFFFFF
+ if (Convert)
+ RGB := (RGB & 0xFF000000) | ((RGB & 0xFF0000) >> 16) | (RGB & 0x00FF00) | ((RGB & 0x0000FF) << 16)
+
+ return RGB
+}
+
+ToolTipper(msg, x := 100, y := 100)
+{
+ if (debug_mode = 1)
+ ToolTip, %msg%, x, y, Screen
+ return
+}
diff --git a/bnowakow/old versions/5 Tokyo/GT7-TokyoX/log.txt b/bnowakow/old versions/5 Tokyo/GT7-TokyoX/log.txt
new file mode 100644
index 0000000..e69de29