Scalable, with left click indicator.
Code: Select all
;***************************************************************************************************
#Include, <My Altered GDIP LIB> ;GDIP.ahk
;***************************************************************************************************
#SingleInstance force
CoordMode, Mouse, screen
SetBatchLines, -1
GDIP_StartUp()
ScaleFactor := 1
MouseGetPos, x, y
global Gui1 := New PopUpWindow( { AutoShow: 1 , X: x - 65 * ScaleFactor , Y: y - 12 * ScaleFactor , W: 130 * ScaleFactor, H: 60 * ScaleFactor , Options: " -DPIScale +AlwaysOnTop Toolwindow E0x20" } )
;~ Gui1.ProgressColor := "FF0000" ;RED
;~ Gui1.ProgressColor := "FFFF00" ;YELLOW
Gui1.ProgressColor := "00FF00" ;GREEN
;~ Gui1.ProgressColor := "00FFFF" ;AQUA
;~ Gui1.ProgressColor := "0000FF" ;BLUE
;~ Gui1.ProgressColor := "FF00FF" ;PURPLE
Gui1.DrawBitmap( HB_BITMAP_MAKER( ScaleFactor ) , { X: 0 , Y: 0 , W: Gui1.W , H: Gui1.H } , dispose := 1 , 1 )
SetTimer, WatchCursor, 10
Gui1.Count := 0
return
*ESC::ExitApp
;~ RAlt::PopUpWindow.Helper()
WatchCursor:
MouseGetPos, x, y
if( x != lx || y != ly ){
Gui1.UpdateSettings( { X: x - 65 * ScaleFactor , Y: y - 12 * ScaleFactor } )
Gui1.ShowWindow()
lx := x , ly := y
}
return
~LButton::
SetTimer, CountDownAnimation, Off
sleep, 10
Gui1.Count := 180
Gui1.ClearWindow()
Gui1.DrawBitmap( HB_BITMAP_MAKER( ScaleFactor ) , { X: 0 , Y: 0 , W: Gui1.W , H: Gui1.H } , dispose := 1 , 1 )
return
~LButton Up::
SetTimer, CountDownAnimation, 30
return
CountDownAnimation:
if( !Gui1.Count -= 10 )
SetTimer, CountDownAnimation, Off
Gui1.ClearWindow()
Gui1.DrawBitmap( HB_BITMAP_MAKER( ScaleFactor ) , { X: 0 , Y: 0 , W: Gui1.W , H: Gui1.H } , dispose := 1 , 1 )
return
HB_BITMAP_MAKER( ScaleFactor := 1 ){
;Bitmap Created Using: HB Bitmap Maker
pBitmap := Gdip_CreateBitmap( 130 * ScaleFactor , 60 * ScaleFactor ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_CreateLineBrushFromRect( 6 * ScaleFactor , 7 * ScaleFactor , 124 * ScaleFactor , 48 * ScaleFactor , "0x00000000" , "0x33000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 11 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawArc( G , Pen , 10 * ScaleFactor , -30 * ScaleFactor , 110 * ScaleFactor , 80 * ScaleFactor , 0 , 180 ) , Gdip_DeletePen( Pen )
Pen := Gdip_CreatePen( "0x99000000" , 7 ) , Gdip_DrawArc( G , Pen , 10 * ScaleFactor , -30 * ScaleFactor , 110 * ScaleFactor , 80 * ScaleFactor , 0 , 180 ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrush( 6 * ScaleFactor , 46 * ScaleFactor , 127 * ScaleFactor , 83 * ScaleFactor , "0x33" Gui1.ProgressColor , "0xff" Gui1.ProgressColor , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 5 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawArc( G , Pen , 10 * ScaleFactor , -30 * ScaleFactor , 110 * ScaleFactor , 80 * ScaleFactor , -180 , -Gui1.Count ) , Gdip_DeletePen( Pen )
Brush := Gdip_BrushCreateSolid( "0xFF" Gui1.ProgressColor ) , Gdip_FillEllipse( G , Brush , 62 * ScaleFactor , 9 * ScaleFactor , 6 * ScaleFactor , 6 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_FillEllipse( G , Brush , 63 * ScaleFactor , 10 * ScaleFactor , 4 * ScaleFactor , 4 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Gdip_DeleteGraphics( G )
return pBitmap
}
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;####################################################################################################################################################################################
class PopUpWindow {
;PopUpWindow v2
;Date Written: Oct 28th, 2021
;Written By: Hellbent aka CivReborn
;SpcThanks: teadrinker , malcev
static Index := 0 , Windows := [] , Handles := [] , EditHwnd , HelperHwnd
__New( obj := "" ){
This._SetDefaults()
This.UpdateSettings( obj )
This._CreateWindow()
This._CreateWindowGraphics()
if( This.AutoShow )
This.ShowWindow( This.Title )
}
_SetDefaults(){
This.X := 10
This.Y := 10
This.W := 10
This.H := 10
This.Smoothing := 2
This.Options := " -DPIScale +AlwaysOnTop "
This.AutoShow := 0
This.GdipStartUp := 0
This.Title := ""
This.Controls := []
This.Handles := []
This.Index := 0
}
AddTrigger( obj ){
local k , v , cc , bd
This.Controls[ ++This.Index ] := { X: 10
, Y: 10
, W: 10
, H: 10 }
for k, v in obj
This.Controls[ This.Index ][ k ] := obj[ k ]
cc := This.Controls[ This.Index ]
Gui, % This.Hwnd ":Add", Text, % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " hwndhwnd"
This.Handles[ hwnd ] := This.Index
This.Controls[ This.Index ].Hwnd := hwnd
return hwnd
}
DrawTriggers( color := "0xFFFF0000" , AutoUpdate := 0 ){
local brush , cc
Brush := Gdip_BrushCreateSolid( color )
Gdip_SetSmoothingMode( This.G , 3 )
loop, % This.Controls.Length() {
cc := This.Controls[ A_Index ]
Gdip_FillRectangle( This.G , Brush , cc.x , cc.y , cc.w , cc.h )
}
Gdip_DeleteBrush( Brush )
Gdip_SetSmoothingMode( This.G , This.Smoothing )
if( AutoUpdate )
This.UpdateWindow()
}
UpdateSettings( obj := "" , UpdateGraphics := 0 ){
local k , v
if( IsObject( obj ) )
for k, v in obj
This[ k ] := obj[ k ]
( This.X = "Center" ) ? ( This.X := ( A_ScreenWidth - This.W ) / 2 )
( This.Y = "Center" ) ? ( This.Y := ( A_ScreenHeight - This.H ) / 2 )
if( UpdateGraphics ){
This._DestroyWindowsGraphics()
This._CreateWindowGraphics()
}
}
_CreateWindow(){
local hwnd
Gui , New, % " +LastFound +E0x80000 hwndhwnd -Caption " This.Options
PopUpWindow.Index++
This.Index := PopUpWindow.Index
PopUpWindow.Windows[ PopUpWindow.Index ] := This
This.Hwnd := hwnd
PopUpWindow.Handles[ hwnd ] := PopUpWindow.Index
if( This.GdipStartUp && !PopUpWindow.pToken )
PopUpWindow.pToken := GDIP_STARTUP()
}
_DestroyWindowsGraphics(){
SelectObject( This.hdc , This.obm )
DeleteObject( This.hbm )
DeleteDC( This.hdc )
}
_CreateWindowGraphics(){
This.hbm := CreateDIBSection( This.W , This.H )
This.hdc := CreateCompatibleDC()
This.obm := SelectObject( This.hdc , This.hbm )
This.G := Gdip_GraphicsFromHDC( This.hdc )
Gdip_SetSmoothingMode( This.G , This.Smoothing )
}
ShowWindow( Title := "" ){
Gui , % This.Hwnd ":Show", % "x" This.X " y" This.Y " w" This.W " h" This.H " NA", % Title
}
HideWindow(){
Gui , % This.Hwnd ":Hide",
}
UpdateWindow(){
UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H )
}
ClearWindow( AutoUpdate := 0 ){
Gdip_GraphicsClear( This.G )
if( Autoupdate )
This.UpdateWindow()
}
DrawBitmap( pBitmap , obj , dispose := 1 , AutoUpdate := 0 ){
Gdip_DrawImage( This.G , pBitmap , obj.X , obj.Y , obj.W , obj.H )
if( dispose )
Gdip_DisposeImage( pBitmap )
if( Autoupdate )
This.UpdateWindow()
}
PaintBackground( color := "0xFF000000" , AutoUpdate := 0 ){
if( isObject( color ) ){
Brush := Gdip_BrushCreateSolid( ( color.HasKey( "Color" ) ) ? ( color.Color ) : ( "0xFF000000" ) )
if( color.Haskey( "Round" ) )
Gdip_FillRoundedRectangle( This.G , Brush , color.X , color.Y , color.W , color.H , color.Round )
else
Gdip_FillRectangle( This.G , Brush , color.X , color.Y , color.W , color.H )
}else{
Brush := Gdip_BrushCreateSolid( color )
Gdip_FillRectangle( This.G , Brush , -1 , -1 , This.W + 2 , This.H + 2 )
}
Gdip_DeleteBrush( Brush )
if( AutoUpdate )
This.UpdateWindow()
}
DeleteWindow( GDIPShutdown := 0 ){
Gui, % This.Hwnd ":Destroy"
SelectObject( This.hdc , This.obm )
DeleteObject( This.hbm )
DeleteDC( This.hdc )
Gdip_DeleteGraphics( This.G )
hwnd := This.Hwnd
for k, v in PopUpWindow.Windows[ Hwnd ]
This[k] := ""
PopUpWindow.Windows[ Hwnd ] := ""
if( GDIPShutdown ){
Gdip_Shutdown( PopUpWindow.pToken )
PopUpWindow.pToken := ""
}
}
_OnClose( wParam ){
if( wParam = 0xF060 ){ ;SC_CLOSE ;[ clicking on the gui close button ]
Try{
Gui, % PopUpWindow.HelperHwnd ":Destroy"
SoundBeep, 555
}
}
}
CreateCachedBitmap( pBitmap , Dispose := 0 ){
local pCachedBitmap
if( This.CachedBitmap )
This.DisposeCachedbitmap()
DllCall( "gdiplus\GdipCreateCachedBitmap" , "Ptr" , pBitmap , "Ptr" , this.G , "PtrP" , pCachedBitmap )
This.CachedBitmap := pCachedBitmap
if( Dispose )
Gdip_DisposeImage( pBitmap )
}
DrawCachedBitmap( AutoUpdate := 0 ){
DllCall( "gdiplus\GdipDrawCachedBitmap" , "Ptr" , this.G , "Ptr" , This.CachedBitmap , "Int" , 0 , "Int" , 0 )
if( AutoUpdate )
This.UpdateWindow()
}
DisposeCachedbitmap(){
DllCall( "gdiplus\GdipDeleteCachedBitmap" , "Ptr" , This.CachedBitmap )
}
Helper(){
local hwnd , MethodList := ["__New","UpdateSettings","ShowWindow","HideWindow","UpdateWindow","ClearWindow","DrawBitmap","PaintBackground","DeleteWindow" , "AddTrigger" , "DrawTriggers", "CreateCachedBitmap" , "DrawCachedBitmap" , "DisposeCachedbitmap" ]
Gui, New, +AlwaysOnTop +ToolWindow +HwndHwnd
PopUpWindow.HelperHwnd := hwnd
Gui, Add, Edit, xm ym w250 r1 Center hwndhwnd, Gui1
PopUpWindow.EditHwnd := hwnd
loop, % MethodList.Length()
Gui, Add, Button, xm y+1 w250 r1 gPopUpWindow._HelperClip, % MethodList[ A_Index ]
Gui, Show,,
OnMessage( 0x112 , This._OnClose.Bind( hwnd ) )
}
_HelperClip(){
local ClipList
GuiControlGet, out, % PopUpWindow.HelperHwnd ":", % PopUpWindow.EditHwnd
ClipList := { __New: " := New PopUpWindow( { X: 0 , Y: 0 , W: A_ScreenWidth , H: A_ScreenHeight , Options: "" -DPIScale +AlwaysOnTop "" } )"
, UpdateSettings: ".UpdateSettings( { X: """" , Y: """" , W: """" , H: """" } , UpdateGraphics := 0 )"
, ShowWindow: ".ShowWindow( Title := """" )"
, HideWindow: ".HideWindow()"
, UpdateWindow: ".UpdateWindow()"
, ClearWindow: ".ClearWindow( AutoUpdate := 0 )"
, DrawBitmap: ".DrawBitmap( pBitmap := """" , { X: 0 , Y: 0 , W: " Out ".W , H: " Out ".H } , dispose := 1 )"
, PaintBackground: ".PaintBackground( color := ""0xFF000000"" ) " ";{ Color: ""0xFF000000"" , X: 2 , Y: 2 , W: " Out ".W - 4 , H: " Out ".H - 4 , Round: 10 }"
, DeleteWindow: ".DeleteWindow( GDIPShutdown := 0 )"
, AddTrigger: ".AddTrigger( { X: """" , Y: """" , W: """" , H: """" , Value: """" , Label: """" , BoundClass: """" , BoundMethod: """" } )"
, DrawTriggers: ".DrawTriggers( color := ""0xFFFF0000"" , AutoUpdate := 0 )"
, CreateCachedBitmap: ".CreateCachedBitmap( pBitmap , Dispose := 0 )"
, DrawCachedBitmap: ".DrawCachedBitmap( AutoUpdate := 0 )"
, DisposeCachedbitmap: ".DisposeCachedbitmap()" }
clipboard := Out ClipList[ A_GuiControl ]
}
}