/*
  Written By: Hellbent aka. CivReborn
  Date Started: Feb 12th, 2020
  Date Of Last Edit: Dec 28th, 2020 (apr 14th, 2021)
  Name: Toggle Clicker v2.0
  ;Credits: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=77617&p=337602#p337602
  ;Credits: flyingDman, JoeWinograd, BoBo
*/
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
SetMouseDelay, 10
OnExit, GuiClose
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global LongClick := 30
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global  LBB64 := "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"
, RBB64 := "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"
global ToggleClicker := New TCV2
return
GuiClose:
  ToggleClicker.MainWindow.DeleteWindow(1)
  ExitApp
class TCV2	{
  __New(){
      ;Set Default Object Values
      This._ObjectSetup()
      ;Create all the window objects
      This._CreateWindows()
      ;Add Window controls
      This._AddControls()
      ;Setup the binds for all the timers
      This._SetUpTimers()
      ;Setup the blob object and start the blob animation
      This._SetUpBlobObject()
      This._ToggleTimers(This.BlobTimer,50)
      ;Setup Banner object and start animation
      This._SetUpBannerWindowObject()
      This._ToggleTimers(This.BannerTimer,50)
      ;Draw Main Window Controls and start control hover timer
      This._DrawWindows(Window := 1, Value := 0)
      This._ToggleTimers(This.HoverTimer,50)
      ;Add Min and Close Buttons
      This._AddMinAndClose()
  }
  _ObjectSetup(){
      This.Buttons := []
      This.AlwaysState := 1
      This.CurrentWindow := 1
      This.LastCtrl := ""
      This.Active := 0
      This.HKTog := 0
      This.STime := 0
      This.CDelay := 0
      ;Test clicker active state color change
      This.StateColor := 1
      ;Settings
      This.MouseButtonHwnds := []
      This.MouseButton := 1 ;(1 = left, 2 = right)
      ;~ This.HotkeyDisplayValue := "Alt + a"
      This.HotkeyDisplayValue := "Ctrl + F1"
      ;~ This.LastHotkeyDisplayValue := "Alt + a"
      This.LastHotkeyDisplayValue := "Ctrl + F1"
      
      ;~ This.HotkeyValue := "!a"
      This.HotkeyValue := "^F1"
      ;~ This.LastHotkeyValue := "!a"
      This.LastHotkeyValue := "^F1"
      Hotkey, % This.HotkeyValue, TF, On
      
      
      ;Sliders
      This.SliderTrigger := []
      This.SliderValue1 := 10
      This.SliderValue2 := 10
      This.SliderPosition1 := 68
      This.SliderPosition2 := 68
      This.ClickDurationValue := 2 ;(1=Fast,2=Med,3=Long)
      
      ;Options
      This.SoundState := 1
      This.AutoSaveState := 1
      
    }

  _Data(){
      ToolTip, In Saved Data
  }

  _CreateWindows(){
      ;This main window containing the blobs
      This.MainWindow := New LayeredWindow( x := "" , y := "" , w := 300 , h := 200 , window := 1 , title := "Toggle Clicker v2" , smoothing := 2 , options := "+AlwaysOnTop -DPIScale" , autoShow := 1 , GdipStart := 1 , WinMover := "" , BackgroundColor := "" )
      ;The moving title window
      This.BannerWindow := New LayeredWindow( x := 30 , y := 0 , w := 240 , h := 40 , window := 2 , title := " " , smoothing := 2 , options := "-DPIScale +Parent1" , autoShow := 1 , GdipStart := 0 )
      ;The inner window containing all the main window controls
      This.MainWindowControls := New LayeredWindow( x := 10 , y := 40 , w := 280 , h := 150 , window := 3 , title := " " , smoothing := 2 , options := "-DPIScale +Parent1" , autoShow := 1 , GdipStart := 0 )
      ;The Minimize and close buttons
      This.MinsCloseWindow := New LayeredWindow( x := 0 , y := 0 , w := 300 , h := 30 , window := 4 , title := " " , smoothing := 2 , options := "-DPIScale +Parent1" , autoShow := 1 , GdipStart := 0 )
      ;The hotkey window
      This.HotkeyWindow := New LayeredWindow( x := 10 , y := 40 , w := 280 , h := 150 , window := 5 , title := " " , smoothing := 2 , options := "+Parent1 -DPIScale" , autoShow := 1 , GdipStart := 0 )
      ;The Click speed options window
      This.SpeedWindow := New LayeredWindow( x := 10 , y := 40 , w := 280 , h := 150 , window := 6 , title := " " , smoothing := 2 , options := "+Parent1 -DPIScale" , autoShow := 1 , GdipStart := 0 )
      ;The More Options window
      This.MoreOptionsWindow := New LayeredWindow( x := 10 , y := 40 , w := 280 , h := 150 , window := 7 , title := " " , smoothing := 2 , options := "+Parent1 -DPIScale" , autoShow := 1 , GdipStart := 0 )
      Gui,5:Hide
      Gui,6:Hide
      Gui,7:Hide
    }

  _AddMinAndClose(){
      This.MinsCloseWindow.Draw( MinAndCloseButtons() , Positions := {x:0,y:0,w:300,h:30} , update := 1 , disposeBitmap := 1  , PaintBackground := 0)
      This.MinsCloseWindow.ShowWindow()
    }

  _AddControls(){
      local bd, hwnd
      
      ;Banner control (move Window)
      Gui,2:Add,Text,x0 y0 w240 h30 hwndhwnd 
      bd := This._MoveWindow.Bind( This )
      GuiControl, 2: +G , % hwnd , % bd
      
      ;Minimize and Close Buttons
      Gui,4:Add,Text,x5 y5 w20 h20 hwndhwnd 
      bd := This._MinimizeWindow.Bind( This )
      GuiControl, 4: +G , % hwnd , % bd
      
      Gui,4:Add,Text,x275 y5 w20 h20 hwndhwnd 
      bd := This._CloseWindow.Bind( This )
      GuiControl, 4: +G , % hwnd , % bd
      
      ;Main Window Controls (Buttons and always switch)
      Gui,3:Add,Text,x10 y7 w130 h20 BackgroundTrans hwndhwnd
      bd := This._SetAlways.Bind( This )
      GuiControl, 3: +G , % hwnd , % bd
      
      Gui,3:Add,Text,x30 y35 w220 h30 hwndhwnd 
      This.Buttons[hwnd] := 1
      bd := This._SwitchWindows.Bind( This )
      GuiControl, 3: +G , % hwnd , % bd
      
      Gui,3:Add,Text,x30 y75 w220 h30 hwndhwnd 
      This.Buttons[hwnd] := 2
      bd := This._SwitchWindows.Bind( This )
      GuiControl, 3: +G , % hwnd , % bd
      
      Gui,3:Add,Text,x30 y115 w220 h30 hwndhwnd 
      This.Buttons[hwnd] := 3
      bd := This._SwitchWindows.Bind( This )
      GuiControl, 3: +G , % hwnd , % bd
      
      ;Hotkeys Window Controls
      ;--------------------------------------------------------------------------------------
      Gui,5:Add,Text, x25 y110 w120 h30 hwndhwnd 
      This.Buttons[hwnd] := 4
      bd := This._SwitchWindows.Bind( This )
      GuiControl, 5: +G , % hwnd , % bd

      Gui,5:Add,Text, x30 y15 w110 h15 hwndhwnd 
      This.MouseButtonHwnds[hwnd] := 1
      bd := This._SetClickButton.Bind( This )
      GuiControl, 5: +G , % hwnd , % bd
      
      Gui,5:Add,Text, x150 y15 w110 h15 hwndhwnd 
      This.MouseButtonHwnds[hwnd] := 2
      bd := This._SetClickButton.Bind( This )
      GuiControl, 5: +G , % hwnd , % bd
      This.Gui5FocusText := hwnd
      
      Gui,5:Add,Hotkey,x10 y65 w130 h30 hwndhwnd 
      This.HKHwnd := hwnd
      bd := This._SetUpHK.Bind( This )
      GuiControl, 5: +G , % hwnd , % bd
      
      ;Click Speed window controls
      ;----------------------------------------------------------------------------------------
      Gui,6:Add,Text,x28 y30 w22 h82 hwndhwnd 
      This.SliderTrigger[hwnd] := 1
      bd := This._AdjustSlider.Bind( This )
      GuiControl, 6: +G , % hwnd , % bd
      
      Gui,6:Add,Text,x229 y30 w22 h82 hwndhwnd 
      This.SliderTrigger[hwnd] := 2
      bd := This._AdjustSlider.Bind( This )
      GuiControl, 6: +G , % hwnd , % bd
      
      Gui,6:Add,Text,x80 y110 w120 h30 hwndhwnd 
      This.Buttons[hwnd] := 5
      bd := This._SwitchWindows.Bind( This )
      GuiControl, 6: +G , % hwnd , % bd
      
      Gui,6:Add,Text,x80 y40 w30 h30 hwndhwnd 
      This.Buttons[hwnd] := 6
      bd := This._SetClickDuration.Bind( This )
      GuiControl, 6: +G , % hwnd , % bd
      
      Gui,6:Add,Text,x170 y40 w30 h30 hwndhwnd 
      This.Buttons[hwnd] := 7
      bd := This._SetClickDuration.Bind( This )
      GuiControl, 6: +G , % hwnd , % bd
      
      ;More Options Window Controls
      Gui,7:Add,Text,x50 y25 w180 h23 hwndhwnd ;gShareClickerLink
      This.Buttons[hwnd] := 8
      bd := This._ShareLink.Bind( This )
      GuiControl, 7: +G , % hwnd , % bd
      
      Gui,7:Add,Text,x50 y55 w180 h23 hwndhwnd ;gMoreClickers
      This.Buttons[hwnd] := 9
      bd := This._MoreClickers.Bind( This )
      GuiControl, 7: +G , % hwnd , % bd
      
      Gui,7:Add,Text,x50 y85 w180 h23 hwndhwnd ;gAdvancedOptions
      This.Buttons[hwnd] := 10
      bd := This._AdvancedOptions.Bind( This )
      GuiControl, 7: +G , % hwnd , % bd
      
      Gui,7:Add,Text,x50 y115 w180 h23 hwndhwnd ;gMoreOptionsWindowBack
      This.Buttons[hwnd] := 11
      bd := This._SwitchWindows.Bind( This )
      GuiControl, 7: +G , % hwnd , % bd
      
      
      
      Gui,7:Add,Text,x10 y5 w80 h15 hwndhwnd ;gSounds
      bd := This._ToggleSounds.Bind( This )
      GuiControl, 7: +G , % hwnd , % bd
      
      Gui,7:Add,Text,x164 y5 w100 h15 hwndhwnd ;gAutoSave
      bd := This._ToggleAutoSave.Bind( This )
      GuiControl, 7: +G , % hwnd , % bd
    }
    
  _SetUpHK(){
      GuiControlGet, tempout,5:, % This.HKHwnd 
      This.HotkeyDisplayValue := tempout
      This.HotkeyDisplayValue := StrReplace(This.HotkeyDisplayValue, "+" , "Shift + ")
      This.HotkeyDisplayValue := StrReplace(This.HotkeyDisplayValue, "!" , "Alt + ")
      This.HotkeyDisplayValue := StrReplace(This.HotkeyDisplayValue, "^" , "Ctrl + ")
      if(This.HotkeyDisplayValue != ""){
        This.HotkeyValue := tempout
      }else{
        This.HotkeyValue := ""
      }
      This._DrawWindows()
    }

  _TestHK2(){
      static togg:=1
      if(togg:=!togg){
        HK := This.HK
        Hotkey, Numpad1,% HK, Off
        ToolTip, Hotkey 1 off
      }else{
        HK := This.HK
        Hotkey, Numpad1,% HK, On
        ToolTip, Hotkey 1 on
      }
      This._ToggleTimers(This.Tooltips,1000)
    }

  _ToggleAutoSave(){
      if(This.AutoSaveState:=!This.AutoSaveState){
        ToolTip, Auto Save On`nThis feature is currently unavailable
      }else{
        ToolTip, Auto Save OFF`nThis feature is currently unavailable
      }
      This._ToggleTimers(This.Tooltips,1000)
      This._DrawWindows()
    }

  _ToggleSounds(){
      if(This.SoundState:=!This.SoundState){
        ToolTip, Sounds ON
      }else{
        ToolTip, Sounds OFF
      }
      This._ToggleTimers(This.Tooltips,1000)
      This._DrawWindows()
    }

  _ShareLink(){
      ;Place video link here once the video is complete
      ;~ ToolTip, In share link
      This._ToggleTimers(This.Tooltips,1000)
      Try{
        Run, https://youtu.be/cFKpZyIC7Tg
      }catch{
        MsgBox, Failed to run video.
      }
    }

  _MoreClickers(){
      Try{
        run, https://www.youtube.com/playlist?list=PLPI5C2_hIGGw7poIqgox3rDnyocwTxcY_
      }catch{
        Msgbox,Unable to run Auto Clicker Youtube Page
      }
    }

  _AdvancedOptions(){
      Tooltip,This feature is currently unavailable
      This._ToggleTimers(This.Tooltips,1000)
    }
    
  _SetHotkey(){
      
    }
    
  _SetClickDuration(){
      local ctrl, rd:=1
      MouseGetPos,,,,ctrl,2
      (This.Buttons[ctrl]=6)?((--This.ClickDurationValue=0)?(This.ClickDurationValue:=1,rd:=0)):((++This.ClickDurationValue=4)?(This.ClickDurationValue:=3,rd:=0))
      if(rd)
        This._DrawWindows()
    }
    
  _AdjustSlider(){
      local ctrl, activeSlider, tty, tx, ty2
      This._ToggleTimers(This.HoverTimer,"Off")
      MouseGetPos,,,,ctrl,2
      activeSlider := This.SliderTrigger[ctrl]
      Coordmode,Mouse,Client
      tty := 999
      While(GetKeyState("LButton")){
        MouseGetPos,tx,ty2
        if(tty=ty2){
          sleep,50
          continue
        }
        tty:=ty2
        (ty2<84)?(ty2:=84):(ty2>144)?(ty2:=144)
        if(activeSlider=1){
          This.SliderValue1 := ((ty2-84)//(60//20)-20)*-1
          (This.SliderValue1=0)?(This.SliderValue1:=1)
          This.SliderPosition1 := ty2-45
          if(GetKeyState("Shift")){
            This.SliderPosition2 := This.SliderPosition1 
            This.SliderValue2 := This.SliderValue1 
          }
        }else{
          This.SliderValue2 := ((ty2-84)//(60//20)-20)*-1
          (This.SliderValue2=0)?(This.SliderValue2:=1)
          This.SliderPosition2 := ty2-45
          if(GetKeyState("Shift")){
            This.SliderPosition1 := This.SliderPosition2 
            This.SliderValue1 := This.SliderValue2 
          }
        }
        This._DrawWindows()
        sleep, 50
      }
      This._ToggleTimers(This.HoverTimer,50)
    }
    
  _SetClickButton(){
      local ctrl
      MouseGetPos,,,,ctrl,2
      This.MouseButton := This.MouseButtonHwnds[ctrl]
      This._DrawWindows()
    }
    
  _MinimizeWindow(){
      Gui,1:Minimize
    }
    
  _CloseWindow(){
      This.MainWindow.DeleteWindow(1)
      ExitApp
    }

  _SetAlways(){
      Gui,% (This.AlwaysState:=!This.AlwaysState)?("1:+AlwaysOnTop",This._DrawWindows()):("1:-AlwaysOnTop",This._DrawWindows())
    }

  _SetUpTimers(){
      This.HoverTimer := HoverTimer := ObjBindMethod( This , "_ControlHoverTimer" )
      This.BlobTimer := BlobTimer := ObjBindMethod( This , "_AnimateBlobs" )
      This.BannerTimer := BannerTimer := ObjBindMethod( This , "_AnimateBanner" )
      This.Tooltips := Tooltips := ObjBindMethod( This , "_TooltipsOff" )
      
      ;~ This.HK := HK := ObjBindMethod( This , "_TestHK" )
      ;~ This.HK2 := HK2 := ObjBindMethod( This , "_TestHK2" )
      ;~ Hotkey, Numpad1,% HK, On
      ;~ Hotkey, Numpad2,% HK2, On
    }

  _TooltipsOff(){
      ToolTip,
      This._ToggleTimers(This.Tooltips,"Off")
  }

  _ToggleTimers(Timer,Value){
      CurrentTimer := Timer
      SetTimer, %CurrentTimer%, %Value%
  }

  _DrawWindows(){
      if(This.CurrentWindow=1){
        This.MainWindowControls.ClearWindow()
        This.Pen1 := Gdip_CreatePen( "0xFF440000" , 1 )
        Gdip_DrawRectangle(This.MainWindowControls.G, This.Pen1, 0, 0, This.MainWindowControls.W-1, This.MainWindowControls.H-1)
        Gdip_DeletePen( This.Pen1 )
        Gdip_DrawImage(This.MainWindowControls.G, This.AlwaysBit := AlwaysSwitch(This.AlwaysState), 0, 0, This.MainWindowControls.W, 30) 
        Gdip_DisposeImage( This.AlwaysBit )
        Gdip_DrawImage(This.MainWindowControls.G, This.ButtonsBit := TogClButtSet1(This.Active), 0, 0, This.MainWindowControls.W, This.MainWindowControls.H)
        Gdip_DisposeImage( This.ButtonsBit )
        This.MainWindowControls.ShowWindow()
      }else if(This.CurrentWindow=2){
        ;~ Settings := {SLV1:10,SLV2:10,CDV:2,SLP1:68,SLP2:68,BackH:0,PlusH:0,MinusH:0,HKUpdate:This.Active,HKButton:1,MWShareLink:0,MoreClickers:0,AdvancedOptions:0,MOWBack:0,Sounds:1,AutoSave:1,HK:"Alt + a",LHK:"!a",HKValue:"!a"}
        ;~ This.Settings := Settings
        This.HotkeyWindow.ClearWindow()
        This.HotkeyWindow.Draw( HKWindow(This) , Positions := {x:0,y:0,w:280,h:150} , update := 1 , disposeBitmap := 1  , PaintBackground := 0)
        This.HotkeyWindow.ShowWindow()
        ;~ Gui, 5:-Disabled
        ;~ Settings := "", This.Settings := ""
      }else if(This.CurrentWindow=3){
        This.SpeedWindow.ClearWindow()
        This.SpeedWindow.Draw( ClickWindow(This) , Positions := {x:0,y:0,w:280,h:150} , update := 1 , disposeBitmap := 1 )
        This.SpeedWindow.ShowWindow()
      }else if(This.CurrentWindow=4){
        This.MoreOptionsWindow.ClearWindow()
        This.MoreOptionsWindow.Draw( OptionsWindow(This) , Positions := {x:0,y:0,w:280,h:150} , update := 1 , disposeBitmap := 1  , PaintBackground := 0)
        This.MoreOptionsWindow.ShowWindow()
      }
    }

  _SwitchWindows(){
      local Ctrl
      This.Active := 0
      MouseGetPos,,,,ctrl,2
      If(This.CurrentWindow=1){
        Gui, 3:Hide
        This.CurrentWindow := This.Buttons[ctrl] + 1
      }else if(This.CurrentWindow=2){
        ;~ Gui, 5:+Disabled
        Guicontrol, 5:Focus, % This.Gui5FocusText
        Gui, 5:Hide
        This.CurrentWindow := 1
        if(This.LastHotkeyValue != ""){
          Hotkey, % This.LastHotkeyValue, TF, Off
          This.LastHotkeyValue := ""
        }
        if(This.HotkeyValue != ""){
          Hotkey, % This.HotkeyValue, TF, On
          This.LastHotkeyValue := This.HotkeyValue
        }
      }else if(This.CurrentWindow=3){
        Gui, 6:Hide
        This.CurrentWindow := 1
      }else if(This.CurrentWindow=4){
        Gui, 7:Hide
        This.CurrentWindow := 1
      }
      This._DrawWindows()
      
    }

  _SetUpBlobObject(){
      This.Blobs := []
      Loop, 50	
        This.Blobs.Push({X:This._Random(-10,300),Y:This._Random(-10,200),W:This._Random(5,30),Phase:This._Random(0,1),Co:This._Random(0,3),Max: Max:=This._Random(10,50),Min: This._Random(3,Max)})
      This.BackgroundBrush := Gdip_BrushCreateSolid( "0xFF880000" )
      This.BackgroundPen := Gdip_CreatePen( "0xFF440000" , 1 )
    }

  _SetUpBannerWindowObject(){
      This.BannerWindow.Bitmap1 := BannerTag("Wash Your Hands"), This.BannerWindow.Bitmap2 := BannerTag("HB Toggle Clicker"), This.Bit := This.BannerWindow.Bitmap2
      This.BannerWindow.X := 20, This.BannerWindow.Y := 0, This.BannerWindow.W := 160, This.BannerWindow.H := 30
      This.BannerWindow.Dir1 := 1, This.BannerWindow.Dir2 := 1
      This.BannerWindow.PhaseCo := 0, This.BannerWindow.Phase := 1
      Gdip_DrawImage(This.BannerWindow.G, This.BannerWindow.Bitmap2, This.BannerWindow.X, This.BannerWindow.Y, This.BannerWindow.W, This.BannerWindow.H) 
    }

  _AnimateBlobs(){
      This.MainWindow.PaintBackground( BackgroundColor := "0x19171719" )
      loop, % This.Blobs.Length(){
        (This.Blobs[A_Index].Phase=1&&This.Blobs[A_Index].W<This.Blobs[A_Index].Min)?(This.Blobs[A_Index].Phase := 0):(This.Blobs[A_Index].Phase=0&&This.Blobs[A_Index].W>This.Blobs[A_Index].Max)?(This.Blobs[A_Index].Phase := 1 , This.Blobs[A_Index].Co += 1)
        (This.Blobs[A_Index].Phase=1)?(This.Blobs[A_Index].X += 1,This.Blobs[A_Index].Y += 1,This.Blobs[A_Index].W -= 2,This.Blobs[A_Index].H -= 2):(This.Blobs[A_Index].X -= 1,This.Blobs[A_Index].Y -= 1,This.Blobs[A_Index].W += 2,This.Blobs[A_Index].H += 2)
        (This.Blobs[A_Index].Co>4)?(This.Blobs[A_Index] := {X:This._Random(-10,300),Y:This._Random(-10,200),W:This._Random(5,30),Phase:This._Random(0,1),Co:This._Random(0,3),Max: Max:=This._Random(10,50),Min:This._Random(3,Max)})
        Brush3 := Gdip_CreateLineBrushFromRect( This.Blobs[A_Index].x, This.Blobs[A_Index].y, This.Blobs[A_Index].w, This.Blobs[A_Index].w , "0xff660000" , "0xff000000" , 1 , 1 )
        Gdip_FillEllipse(This.MainWindow.G, Brush3, This.Blobs[A_Index].x, This.Blobs[A_Index].y, This.Blobs[A_Index].w, This.Blobs[A_Index].w)
        Gdip_DeleteBrush( Brush3 )
        Gdip_DrawRectangle(This.MainWindow.G, This.BackgroundPen,0, 0, 299, 199)
      }
      This.MainWindow.UpdateWindow()
    }

  _AnimateBanner(){
      (This.BannerWindow.Dir1=1&&This.BannerWindow.X>=10)?(This.BannerWindow.X-=2):(This.BannerWindow.Dir1=1&&This.BannerWindow.X<10)?(This.BannerWindow.Dir1:=2)
      (This.BannerWindow.Dir1=2&&This.BannerWindow.X<=70)?(This.BannerWindow.X+=3):(This.BannerWindow.Dir1=2&&This.BannerWindow.X>70)?(This.BannerWindow.Dir1:=1)
      (This.BannerWindow.Dir2=1&&This.BannerWindow.Y<=10)?(This.BannerWindow.Y+=.3):(This.BannerWindow.Dir2=1&&This.BannerWindow.Y>10)?(This.BannerWindow.Dir2:=2)
      (This.BannerWindow.Dir2=2&&This.BannerWindow.Y>=2)?(This.BannerWindow.Y-=.3):(This.BannerWindow.Dir2=2&&This.BannerWindow.Y<2)?(This.BannerWindow.Dir2:=1)
      (++This.BannerWindow.PhaseCo>30)?(This.BannerWindow.PhaseCo:=0,(This.BannerWindow.Phase=1)?(This.Bit:=This.BannerWindow.Bitmap2,This.BannerWindow.Phase:=2):(This.Bit:=This.BannerWindow.Bitmap1,This.BannerWindow.Phase:=1))
      This.BannerWindow.ClearWindow()
      if(This.StateColor=1){
        Gdip_DrawImage(This.BannerWindow.G, This.Bit, This.BannerWindow.X, This.BannerWindow.Y, This.BannerWindow.W, This.BannerWindow.H)
      }else{
        bitt := BannerTag("HB Toggle Clicker",This)
        ;~ This.MoreOptionsWindow.Draw( BannerTag("HB Toggle Clicker",This) , Positions := {x:This.BannerWindow.X,y:This.BannerWindow.Y,w:This.BannerWindow.W,h:This.BannerWindow.H} , update := 1 , disposeBitmap := 1  , PaintBackground := 0)
        Gdip_DrawImage(This.BannerWindow.G, bitt, This.BannerWindow.X, This.BannerWindow.Y, This.BannerWindow.W, This.BannerWindow.H)
        Gdip_DisposeImage( Bitt )
      }
      This.BannerWindow.UpdateWindow()
    }

  _ControlHoverTimer(){
      local ctrl
      MouseGetPos,,,,ctrl,2
      if(This.Buttons[ctrl]&&!This.Active){
        This.LastCtrl := ctrl
        This.Active := This.Buttons[ctrl]
        This._DrawWindows()
      }else if(This.Buttons[This.LastCtrl]!=This.Buttons[ctrl]&&This.Active){
        This.Active := 0
        This._DrawWindows()
      }
      ;~ ToolTip,% " in hover timer `n" This.Active "`n" This.LastCtrl 
    }

  _Random(Min,Max){
      random,Out,Min,Max
      return Out
    }

  _MoveWindow(){
    PostMessage, 0xA1, 2,,,Toggle Clicker v2
    This._ToggleTimers(This.HoverTimer,"Off")
    KeyWait, LButton
    This._ToggleTimers(This.HoverTimer,50)
  }
  ToggleFunctionality(){
    local hz := 600
    if(This.HKTog:=!This.HKTog){
      This._ToggleTimers(This.BlobTimer,"Off")
      This._ToggleTimers(This.BannerTimer,"Off")
      if(This.SoundState)
        SoundBeep, 450
    }else{
      if(This.SoundState)
        Loop, 3
          SoundBeep, % hz
      This._ToggleTimers(This.BlobTimer,50)
      This._ToggleTimers(This.BannerTimer,50)
    }
  }
  ClickFunctionality(){
    SetMouseDelay, % ttt := ((This.ClickDurationValue=1)?(-1):(This.ClickDurationValue=2)?(10):(LongClick))
    This.STime := A_TickCount
    This.CDelay := 1000 / This._Random(This.SliderValue1,This.SliderValue2)
    if(This.MouseButton=1){
      While(GetKeyState("LButton","P")){
        Sleep, 10
        if(Winactive("AHK_ID " This.MainWindow.Hwnd)){
          Gosub, TF
          break
        }
        if(This.STime+This.CDelay<=A_TickCount){
          This.CDelay := (1000 / This._Random(This.SliderValue1,This.SliderValue2)) - (A_TickCount - (This.STime+This.CDelay))
          This.STime := A_TickCount
          Click,
        }
      }
    }else if(This.MouseButton=2){
      While(GetKeyState("RButton","P")){
        Sleep, 10
        if(Winactive("AHK_ID " This.MainWindow.Hwnd)){
          Gosub, TF
          break
        }
        if(This.STime+This.CDelay<=A_TickCount){
          This.CDelay := (1000 / This._Random(This.SliderValue1,This.SliderValue2)) - (A_TickCount - (This.STime+This.CDelay))
          This.STime := A_TickCount
          Click Right,
        }
      }
    }
  }
}
TF:
  ToggleClicker.ToggleFunctionality()
  return

#IF (ToggleClicker.HKTog && ToggleClicker.MouseButton=1)
~$LButton::
  ToggleClicker.ClickFunctionality()
  return
#IF

#IF (ToggleClicker.HKTog && ToggleClicker.MouseButton=2)
~$RButton::
  ToggleClicker.ClickFunctionality()
  return
#IF
;<<<<<<<<<<<<<<<<<<<<<<<  Assets  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;***********************************************************************************************************************************************************************
;***																																								 ***
;***																		Layered Window Class																	 ***
;***																																								 ***
;***********************************************************************************************************************************************************************

class LayeredWindow	{
;LayeredWindow class By: Hellbent
  __New( x := 0 , y := 0 , w := 100 , h := 100 , window := 1 , title := " " , smoothing := 4 , options := "" , autoShow := 1 , GdipStart := 0 , WinMover := "" , BackgroundColor := "" ){
    This.X := x , This.Y := y , This.W := w , This.H := h 
    This.Window := window , This.Title := title
    This.Options := options , This.Smoothing := smoothing
    ( GdipStart ) ? ( This.Token := Gdip_Startup() )
    This._CreateWindow()
    ( autoShow ) ? ( This.ShowWindow() )
    This._SetUpdateLayeredWindow()
    ( WinMover ) ? ( This._AddMoveTrigger( WinMover ) )
    ( BackgroundColor ) ? ( This.PaintBackground( BackgroundColor , 1 ) )
  }
  _CreateWindow(){
    Gui , % This.Window ": New" , % " +E0x80000 +LastFound -Caption " This.Options 
    This.Hwnd := WinExist()
    This.hbm := CreateDIBSection( This.W , This.H )
    This.hdc := CreateCompatibleDC()
    This.obm := SelectObject( This.hdc , This.hbm )
    This.G := Gdip_GraphicsFromHDC( This.hdc )
    Gdip_SetSmoothingMode( This.G , This.Smoothing )
  }
  _SetUpdateLayeredWindow(){
    UpdateLayeredWindow( This.hwnd , This.hdc , This.X , This.Y , This.W , This.H )
  }
  UpdateWindow(){
    UpdateLayeredWindow( This.hwnd , This.hdc )
  }
  ShowWindow( update := 1 , Position := "" ){ 
    if( !Position )
      Gui , % This.Window ": Show" , % "w" This.W " h" This.H  , % ( This.Title ) ? ( This.Title ) : ( "" )
    else
      Gui , % This.Window ": Show" , % "x" Position.X " y" Position.Y "w" Position.W " h" Position.H  , % ( This.Title ) ? ( This.Title )  : ( "" )
    ( update ) ? ( This.UpdateWindow() )
  }
  _AddMoveTrigger( positons ){ 
    local hwnd , bd
    Gui , % This.Window " : Add" , Text , % "x" positons.x " y" positons.y " w" positons.w " h" positons.h " hwndhwnd"
    This.MoveHwnd := hwnd
    bd := This._WindowMover.Bind( This )
    GuiControl , % This.Window ": +G" , % This.MoveHwnd , % bd
  }
  _WindowMover(){ 
    PostMessage, 0xA1 , 2
  }
  PaintBackground( BackgroundColor := "0xFF000000" , update := 0){ 
    local Brush
    This.BackgroundColor := BackgroundColor
    Brush := Gdip_BrushCreateSolid( BackgroundColor )
    Gdip_FillRectangle( This.G , Brush , 0 , 0 , This.W , This.H )
    Gdip_DeleteBrush( Brush )
    ( update ) ? ( This.UpdateWindow() )
  }
  Draw( pBitmap , Positions := "" , update := 1 , disposeBitmap := 0  , PaintBackground := 0){ 
  (PaintBackground) ? ( This.PaintBackground( This.BackgroundColor ) )	
    Gdip_DrawImage( This.G 
            , pBitmap 
            , ( Positions.X1 ) ? ( Positions.X1 ) : ( Positions.X ) ? ( Positions.X ) : ( "" )
            , ( Positions.Y1 ) ? ( Positions.Y1 ) : ( Positions.Y ) ? ( Positions.Y ) : ( "" ) 
            , ( Positions.W1 ) ? ( Positions.W1 ) : ( Positions.W ) ? ( Positions.W ) : ( "" ) 
            , ( Positions.H1 ) ? ( Positions.H1 ) : ( Positions.H ) ? ( Positions.H ) : ( "" ) 
            , ( Positions.X2 ) ? ( Positions.X2 ) : ( Positions.SX ) ? ( Positions.SX ) : ( "" )
            , ( Positions.Y2 ) ? ( Positions.Y2 ) : ( Positions.SY ) ? ( Positions.SY ) : ( "" )
            , ( Positions.W2 ) ? ( Positions.W2 ) : ( Positions.SW ) ? ( Positions.SW ) : ( "" )
            , ( Positions.H2 ) ? ( Positions.H2 ) : ( Positions.SH ) ? ( Positions.SH ) : ( "" ) )
    ( update ) ? ( This.UpdateWindow() )
    ( disposeBitmap ) ? ( Gdip_DisposeImage( pBitmap ) )
  }
  ClearWindow( update := "" ){ 
    Gdip_GraphicsClear( This.G )
    ( update ) ? ( This.UpdateWindow() )
  }
  Add_Trigger(PositionObject,Label:="GuiClose"){
    Gui, % This.Window ": Add", Text, % "x" PositionObject.X " y" PositionObject.Y " w" PositionObject.W " h" PositionObject.H " g" Label " BackgroundTrans"
  }
  Draw_Text(PosObj,Text,Font:="Arial",FontSize:="12",Color1:="0xFFFFFFFF",Color2:="",PosObj2:="",update:=0){
    local Brush
    (!color2&&color2!="000000")?(Color2:=Color1)
    (StrLen(Color1)=6)?( Color1 := "0xFF" Color1 )
    (StrLen(Color2)=6)?( Color2 := "0xFF" Color2 )
    (PosObj2="")?(PosObj2:=PosObj)
    Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , PosObj2.W , PosObj2.H , Color1 , Color2 , 1 , 1 )
    Gdip_TextToGraphics(This.G, Text, "s" FontSize " c" Brush " Center vCenter Bold x" PosObj.X " y" PosObj.Y, Font , PosObj.W, PosObj.H)
    Gdip_DeleteBrush( Brush )
    ( update ) ? ( This.UpdateWindow() )
  }
  Draw_Rectangle(Thickness:="5",PosObj:="",Color1:=0xFFFFFFFF,Color2:="",PosObj2:="",update:=0){
    local Brush, pPen
    (!color2)?(Color2:=Color1)
    (StrLen(Color1)=6)?( Color1 := "0xFF" Color1 )
    (StrLen(Color2)=6)?( Color2 := "0xFF" Color2 )
    (PosObj2="")?(PosObj2:=PosObj)
    Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , PosObj2.W , PosObj2.H , Color1 , Color2 , 1 , 1 )
    pPen := Gdip_CreatePenFromBrush(Brush, Thickness)
    Gdip_DrawRectangle( This.G, pPen, PosObj.X , PosObj.Y , PosObj.W , PosObj.H )
    Gdip_DeleteBrush( Brush )
    Gdip_DeletePen(pPen)
    ( update ) ? ( This.UpdateWindow() )
  }
  DeleteWindow( TurnOffGdip := 0 ){
    Gui, % This.Window " : Destroy"
    SelectObject( This.hdc , This.obm )
    DeleteObject( This.hbm )
    DeleteDC( This.hdc )
    Gdip_DeleteGraphics( This.G )
    ( TurnOffGdip && This.Token ) ? ( Gdip_Shutdown( This.Token ) )
  }
}



;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
; Banner
;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
BannerTag(txt := "Wash Your Hands" , OBJ := "" ){
  ;Bitmap Created Using: HB Bitmap Maker
  pBitmap:=Gdip_CreateBitmap( 160 , 30 ),G := Gdip_GraphicsFromImage( pBitmap ),Gdip_SetSmoothingMode( G , 2 )
  ;~ Brush := Gdip_BrushCreateSolid( "0xFF888888" )
  Brush := Gdip_BrushCreateSolid((OBJ.StateColor=2)?("0xFFff0000"):(OBJ.StateColor=3)?("0xFFff0000"):("0xFF888888"))
  Gdip_FillRoundedRectangle( G , Brush , 1 , 2 , 157 , 26 , 4 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF171719" )
  ;~ Brush := Gdip_BrushCreateSolid( (OBJ.StateColor=2)?("0xFFFFFF00"):(OBJ.StateColor=3)?("0xFF00FF00"):("0xFF171719") )
  Gdip_FillRoundedRectangle( G , Brush , 2 , 3 , 155 , 24 , 3 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_BrushCreateSolid( "0xFFaaaaaa" )
  Brush := Gdip_BrushCreateSolid( (OBJ.StateColor=2)?("0xFFff0000"):(OBJ.StateColor=3)?("0xFFff0000"):("0xFFaaaaaa") )
  Gdip_TextToGraphics( G , txt , "s16 Center vCenter Bold c" Brush " x-1 y0" , "Segoe ui" , 160 , 30 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_BrushCreateSolid( "0xFF770000" )
  Brush := Gdip_BrushCreateSolid( (OBJ.StateColor=2)?("0xFFffff00"):(OBJ.StateColor=3)?("0xFF00FF00"):("0xFF770000") )
  Gdip_TextToGraphics( G , txt , "s16 Center vCenter Bold c" Brush " x0 y1" , "Segoe ui" , 160 , 30 )
  Gdip_DeleteBrush( Brush )
  Gdip_DeleteGraphics( G )
  return pBitmap
}

;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
; Always on top graphics
;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
AlwaysSwitch(val := 1){
  ;Bitmap Created Using: HB Bitmap Maker
  pBitmap:=Gdip_CreateBitmap( 280 , 30 ) 
  G := Gdip_GraphicsFromImage( pBitmap )
  Gdip_SetSmoothingMode( G , 2 )
  Brush := Gdip_CreateLineBrushFromRect( 11 , 7 , 15 , 16 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Gdip_FillRectangle( G , Brush , 10 , 7 , 15 , 15 )
  Gdip_DeleteBrush( Brush )
  if(val=1)
    ;~ Brush := Gdip_CreateLineBrushFromRect( 11 , 7 , 15 , 16 , "0xFF990000" , "0xFF000000" , 1 , 1 )
    Brush := Gdip_CreateLineBrushFromRect( 11 , 7 , 15 , 16 , "0xFFff0000" , "0xFF000000" , 1 , 1 )
  else
    Brush := Gdip_CreateLineBrushFromRect( 11 , 7 , 15 , 16 , "0x66171719" , "0x66000000" , 1 , 1 )
  Gdip_FillRectangle( G , Brush , 11 , 8 , 13 , 13 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "AlwaysOnTop" , "s16  vCenter Bold c" Brush " x27 y0" , "Segoe ui" , 150 , 30 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 29 , 7 , 107 , 16 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 29 , 7 , 107 , 16 , "0xFFff0000" , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 29 , 7 , 107 , 16 , (val=1)?("0xFFff0000"):("0xFF880000") , "0xFF000000" , 1 , 1 )
  Gdip_TextToGraphics( G , "AlwaysOnTop" , "s16  vCenter Bold c" Brush " x28 y1" , "Segoe ui" , 150 , 30 )
  Gdip_DeleteBrush( Brush )
  Gdip_DeleteGraphics( G )
  return pBitmap
}
;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
; Min and close button set
;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
MinAndCloseButtons(){
  ;Bitmap Created Using: HB Bitmap Maker
  pBitmap:=Gdip_CreateBitmap( 300 , 30 ) 
  G := Gdip_GraphicsFromImage( pBitmap )
  Gdip_SetSmoothingMode( G , 4 )
  ;min ;x5 y5 w20 h20
  Brush := Gdip_BrushCreateSolid( "0x88666666" )
  Gdip_FillEllipse( G , Brush , 5 , 5 , 20 , 20 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0x88171719" )
  Gdip_FillEllipse( G , Brush , 6 , 6 , 18 , 18 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFFaaaaaa" )
  Gdip_TextToGraphics( G , "_" , "s28 Center vCenter Bold c" Brush " x5 y-7" , "Segoe ui" , 20 , 20 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF770000" )
  Gdip_TextToGraphics( G , "_" , "s28 Center vCenter Bold c" Brush " x6 y-6" , "Segoe ui" , 20 , 20 )
  Gdip_DeleteBrush( Brush )
  ;close ;x275 y5 w20 h20
  Brush := Gdip_BrushCreateSolid( "0x88888888" )
  Gdip_FillEllipse( G , Brush , 275 , 5 , 20 , 20 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0x88171719" )
  Gdip_FillEllipse( G , Brush , 276 , 6 , 18 , 18 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFFaaaaaa" )
  Gdip_TextToGraphics( G , "x" , "s16 Center vCenter Bold c" Brush " x275 y4" , "Segoe ui" , 20 , 20 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF770000" )
  Gdip_TextToGraphics( G , "x" , "s16 Center vCenter Bold c" Brush " x276 y5" , "Segoe ui" , 20 , 20 )
  Gdip_DeleteBrush( Brush )
  Gdip_DeleteGraphics( G )
  return pBitmap
}

;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
; Main window button set
;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
TogClButtSet1(value:=0){
  ;Bitmap Created Using: HB Bitmap Maker
  pBitmap:=Gdip_CreateBitmap( 280 , 150 ) 
  G := Gdip_GraphicsFromImage( pBitmap )
  Gdip_SetSmoothingMode( G , 2 )
  Brush := Gdip_BrushCreateSolid( "0x01777777" )
  Gdip_FillRectangle( G , Brush , 0 , 0 , 280 , 150 )
  Gdip_DeleteBrush( Brush )
  ;Hotkeys
  Brush := Gdip_CreateLineBrushFromRect( 29 , 36 , 221 , 28 , (Value=1)?("0xFFaa0000"):("0xFF880000")  , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 30 , 35 , 220 , 30 , 5 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( (Value=1)?("0x44000000"):("0x44222222") )
  Gdip_FillRoundedRectangle( G , Brush , 31 , 36 , 218 , 28 , 4 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "Hotkeys" , "s16 Center vCenter Bold c" Brush " x30 y35" , "Segoe ui" , 218 , 28 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 109 , 38 , 72 , 14 , (Value=1)?("0xFF000000"):("0xFF880000") , (Value=1)?("0xFF880000"):("0xFF000000") , 1 , 1 )
  Gdip_TextToGraphics( G , "Hotkeys" , "s16 Center vCenter Bold c" Brush " x31 y36" , "Segoe ui" , 218 , 28 )
  Gdip_DeleteBrush( Brush )
  ;Click Speed
  Brush := Gdip_CreateLineBrushFromRect( 30 , 74 , 219 , 29 ,(Value=2)?("0xFFaa0000"):("0xFF880000") , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 30 , 75 , 220 , 30 , 4 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( (Value=2)?("0x44000000"):("0x44222222") )
  Gdip_FillRoundedRectangle( G , Brush , 31 , 76 , 218 , 28 , 4 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "Click Speed" , "s16 Center vCenter Bold c" Brush " x30 y75" , "Segoe ui" , 218 , 28 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 92 , 77 , 94 , 17 ,(Value=2)?("0xFF000000"):("0xFF880000") ,(Value=2)?("0xFF880000"):("0xFF000000") , 1 , 1 )
  Gdip_TextToGraphics( G , "Click Speed" , "s16 Center vCenter Bold c" Brush " x31 y76" , "Segoe ui" , 218 , 28 )
  Gdip_DeleteBrush( Brush )
  ;More Options
  Brush := Gdip_CreateLineBrushFromRect( 31 , 115 , 216 , 27 ,(Value=3)?("0xFFaa0000"):("0xFF880000") , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 30 , 115 , 220 , 30 , 4 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( (Value=3)?("0x44000000"):("0x44222222") )
  Gdip_FillRoundedRectangle( G , Brush , 31 , 116 , 218 , 28 , 4 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "More Options" , "s16 Center vCenter Bold c" Brush " x30 y115" , "Segoe ui" , 218 , 28 )
  Gdip_DeleteBrush( Brush )
  if(Value=3)
    Brush := Gdip_CreateLineBrushFromRect( 87 , 116 , 105 , 18 , "0xFF000000" , "0xFF880000" , 1 , 1 )
  else
    Brush := Gdip_CreateLineBrushFromRect( 87 , 116 , 105 , 18 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Gdip_TextToGraphics( G , "More Options" , "s16 Center vCenter Bold c" Brush " x31 y116" , "Segoe ui" , 218 , 28 )
  Gdip_DeleteBrush( Brush )
  Gdip_DeleteGraphics( G )
  return pBitmap 
}
;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
; Hotkeys Window
;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
HKWindow(obj){
  ;Bitmap Created Using: HB Bitmap Maker
  pBitmap:=Gdip_CreateBitmap( 280 , 150 ) 
  G := Gdip_GraphicsFromImage( pBitmap )
  Gdip_SetSmoothingMode( G , 2 )
  
  Brush := Gdip_BrushCreateSolid( "0x01777777" )
  Gdip_FillRectangle( G , Brush , 0 , 0 , 280 , 150 )
  Gdip_DeleteBrush( Brush )
  
  
  Pen := Gdip_CreatePen( "0xFF440000" , 1 )
  Gdip_DrawRectangle( G , Pen , 0 , 0 , 279 , 149 )
  Gdip_DeletePen( Pen )
  Pen := Gdip_CreatePen( "0xFF440000" , 1 )
  Gdip_DrawRectangle( G , Pen , 10 , 5 , 259 , 31 )
  Gdip_DeletePen( Pen )
  Brush := Gdip_CreateLineBrushFromRect( 30 , 15 , 15 , 15 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Gdip_FillRectangle( G , Brush , 30 , 15 , 15 , 15 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 31 , 16 , 14 , 12 , "0xffff0000" , "0xff000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 31 , 16 , 14 , 12 ,(obj.MouseButton=1)?("0xffff0000"):("0x55ff0000") , "0xff000000" , 1 , 1 )
  Gdip_FillRectangle( G , Brush , 31 , 16 , 13 , 13 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "Left Click" , "s16 Center vCenter Bold c" Brush " x37 y-3" , "Segoe ui" , 100 , 50 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 53 , 16 , 70 , 12 , "0xFFff0000" , "0xFF440000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 53 , 16 , 70 , 12 , (obj.MouseButton=1)?("0xFFff0000"):("0xff880000") , (obj.MouseButton=1)?("0xFF440000"):("0xFF220000") , 1 , 1 )
  Gdip_TextToGraphics( G , "Left Click" , "s16 Center vCenter Bold c" Brush " x38 y-2" , "Segoe ui" , 100 , 50 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 151 , 15 , 14 , 14 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Gdip_FillRectangle( G , Brush , 150 , 15 , 15 , 15 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 150 , 15 , 14 , 13 , "0x55ff0000" , "0xff000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 150 , 15 , 14 , 13 , (obj.MouseButton=2)?("0xffff0000"):("0x55ff0000")  , "0xff000000" , 1 , 1 )
  Gdip_FillRectangle( G , Brush , 151 , 16 , 13 , 13 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "Right Click" , "s16 Center vCenter Bold c" Brush " x160 y-3" , "Segoe ui" , 100 , 50 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 179 , 21 , 82 , 13 , "0xff880000" , "0xFF220000" , 1 , 1 )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 179 , 21 , 82 , 13 , (obj.HKButton=2)?("0xFFff0000"):("0xff880000") , (obj.HKButton=2)?("0xFF440000"):("0xFF220000") , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 179 , 21 , 82 , 13 , (obj.MouseButton=2)?("0xFFff0000"):("0xff880000") , (obj.MouseButton=2)?("0xFF440000"):("0xFF220000") , 1 , 1 )
  Gdip_TextToGraphics( G , "Right Click" , "s16 Center vCenter Bold c" Brush " x161 y-2" , "Segoe ui" , 100 , 50 )
  Gdip_DeleteBrush( Brush )
  ;toggle text
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  ;toggle text
  Gdip_TextToGraphics( G , "Toggle" , "s16 Center vCenter Bold c" Brush " x0 y27" , "Segoe ui" , 140 , 50 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 44 , 46 , 54 , 13 , "0xFFff0000" , "0xFF000000" , 1 , 1 )
  Gdip_TextToGraphics( G , "Toggle" , "s16 Center vCenter Bold c" Brush " x1 y28" , "Segoe ui" , 140 , 50 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 11 , 64 , 130 , 32 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Pen := Gdip_CreatePenFromBrush( Brush , 1 )
  Gdip_DeleteBrush( Brush )
  Gdip_DrawRectangle( G , Pen , 10 , 65 , 130 , 30 )
  Gdip_DeletePen( Pen )
  ;~ Brush := Gdip_BrushCreateSolid( "0xFFff0000" )
  Brush := Gdip_BrushCreateSolid( "0xFFffffff" )
  ;~ Gdip_TextToGraphics( G , "Shift + Ctrl + A" , "s12 Center vCenter Bold c" Brush " x10 y65" , "Segoe ui" , 130 , 30 )
  Gdip_TextToGraphics( G , Obj.HotkeyDisplayValue , "s12 Center vCenter Bold c" Brush " x10 y65" , "Segoe ui" , 130 , 30 )
  Gdip_DeleteBrush( Brush )
  ;Click text
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  ;Click text
  Gdip_TextToGraphics( G , "Activate" , "s16 Center vCenter Bold c" Brush " x140 y27" , "Segoe ui" , 140 , 50 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 193 , 44 , 34 , 13 , "0xFFff0000" , "0xFF000000" , 1 , 1 )
  Gdip_TextToGraphics( G , "Activate" , "s16 Center vCenter Bold c" Brush " x141 y28" , "Segoe ui" , 140 , 50 )
  Gdip_DeleteBrush( Brush )

  ;Update Button ;<-----------------------------------------
  ;~ Brush := Gdip_CreateLineBrushFromRect( 25 , 110 , 120 , 30 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 25 , 110 , 120 , 30 , (obj.Active=0)?("0xFF880000"):("0xFFAA0000") , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 25 , 110 , 120 , 30 , 5 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_BrushCreateSolid( "0x44222222" )
  Brush := Gdip_BrushCreateSolid( (obj.Active=0)?("0x44222222"):("0x44000000") )
  Gdip_FillRoundedRectangle( G , Brush , 26 , 111 , 118 , 28 , 4 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "< Update" , "s16 Center vCenter Bold c" Brush " x25 y110" , "Segoe ui" , 120 , 30 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 49 , 120 , 76 , 12 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 49 , 120 , 76 , 12 , (obj.HKUpdate=0)?("0xFF880000"):("0xFF000000") , (obj.HKUpdate=0)?("0xFF000000"):("0xFF880000") , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 49 , 115 , 76 , 22 , (obj.Active=0)?("0xFF880000"):("0xFF000000") , (obj.Active=0)?("0xFF000000"):("0xFF880000") , 1 , 1 )
  Gdip_TextToGraphics( G , "< Update" , "s16 Center vCenter Bold c" Brush " x26 y111" , "Segoe ui" , 120 , 30 )
  Gdip_DeleteBrush( Brush )
  
  ;~ pLB := Create_Sheets( LBB64 )
  Gdip_DrawImage(G, (obj.MouseButton=1)?(pLB := Create_Sheets( LBB64 )):(pLB := Create_Sheets( RBB64 )), 185, 70, 50, 50) ;, sx="", sy="", sw="", sh="", Matrix=1)
  Gdip_DisposeImage( pLB )
  Gdip_DeleteGraphics( G )
  return pBitmap
}
Create_Sheets( B65 ){
  local ptr , uptr , pBitmap
  VarSetCapacity(B64, strlen( B65 ) << !!A_IsUnicode)
  B64 := B65
  If !DllCall("Crypt32.dll\CryptStringToBinary" (A_IsUnicode ? "W" : "A"), Ptr := A_PtrSize ? "Ptr" : "UInt" , &B64, "UInt", 0, "UInt", 0x01, Ptr, 0, "UIntP", DecLen, Ptr, 0, Ptr, 0)
    Return False
  VarSetCapacity(Dec, DecLen, 0)
  If !DllCall("Crypt32.dll\CryptStringToBinary" (A_IsUnicode ? "W" : "A"), Ptr, &B64, "UInt", 0, "UInt", 0x01, Ptr, &Dec, "UIntP", DecLen, Ptr, 0, Ptr, 0)
    Return False
  DllCall("Kernel32.dll\RtlMoveMemory", Ptr, pData := DllCall("Kernel32.dll\GlobalLock", Ptr, hData := DllCall("Kernel32.dll\GlobalAlloc", "UInt", 2,  UPtr := A_PtrSize ? "UPtr" : "UInt" , DecLen, UPtr), UPtr) , Ptr, &Dec, UPtr, DecLen)
  DllCall("Kernel32.dll\GlobalUnlock", Ptr, hData)
  DllCall("Ole32.dll\CreateStreamOnHGlobal", Ptr, hData, "Int", True, Ptr "P", pStream)
  DllCall("Gdiplus.dll\GdipCreateBitmapFromStream",  Ptr, pStream, Ptr "P", pBitmap)
  return pBitmap
}

;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
; Click Speed Window
;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
ClickWindow(obj){
  ;Bitmap Created Using: HB Bitmap Maker
  pBitmap:=Gdip_CreateBitmap( 280 , 150 ) 
  G := Gdip_GraphicsFromImage( pBitmap )
  Gdip_SetSmoothingMode( G , 2 )
  Pen := Gdip_CreatePen( "0xFF440000" , 1 )
  Gdip_DrawRectangle( G , Pen , 0 , 0 , 279 , 149 )
  Gdip_DeletePen( Pen )
  Brush := Gdip_CreateLineBrushFromRect( 13 , 2 , 51 , 141 , "0x99440000" , "0x99aa0000" , 1 , 1 )
  Pen := Gdip_CreatePenFromBrush( Brush , 1 )
  Gdip_DeleteBrush( Brush )
  Gdip_DrawRoundedRectangle( G , Pen , 14 , 5 , 50 , 138 , 5 )
  Gdip_DeletePen( Pen )
  Brush := Gdip_CreateLineBrushFromRect( 24 , 11 , 29 , 14 , "0xFF777777" , "0xFF000000" , 1 , 1 )
  Gdip_TextToGraphics( G , "Min" , "s16  Center Bold c" Brush " x13 y7" , "Segoe ui" , 50 , 50 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 25 , 10 , 29 , 16 , "0xFFff0000" , "0xFF440000" , 1 , 1 )
  Gdip_TextToGraphics( G , "Min" , "s16 Center Bold c" Brush " x14 y8" , "Segoe ui" , 50 , 50 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 28 , 30 , 22 , 82 , "0xFFff0000" , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 28 , 30 , 22 , 82 , 5 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 28 , 29 , 25 , 84 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 29 , 31 , 20 , 80 , 5 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 39 , 34 , 7 , 72 , "0xaa441111" , "0xaaffffff" , 1 , 1 )
  Gdip_FillRectangle( G , Brush , 38 , 35 , 2 , 72 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFFffffff" )
  Gdip_TextToGraphics( G , obj.SliderValue1 , "s16 Center  Bold c" Brush " x14 y116" , "Segoe ui" , 50 , 20 )
  Gdip_DeleteBrush( Brush )
  ;Slider 1 thumb
  Brush := Gdip_CreateLineBrushFromRect( 31 , obj.SliderPosition1 , 16 , 8 , "0xFF111111" , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 31 , obj.SliderPosition1 , 16 , 8 , 3 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 32 , obj.SliderPosition1+1 , 14 , 7 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 32 , obj.SliderPosition1+1 , 14 , 7 , 3 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 213 , 5 , 53 , 138 , "0x99440000" , "0x99aa0000" , 1 , 1 )
  Pen := Gdip_CreatePenFromBrush( Brush , 1 )
  Gdip_DeleteBrush( Brush )
  Gdip_DrawRoundedRectangle( G , Pen , 215 , 5 , 50 , 138 , 5 )
  Gdip_DeletePen( Pen )
  Brush := Gdip_CreateLineBrushFromRect( 24 , 11 , 29 , 14 , "0xFF777777" , "0xFF000000" , 1 , 1 )
  Gdip_TextToGraphics( G , "Max" , "s16 Center  Bold c" Brush " x214 y7" , "Segoe ui" , 50 , 50 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 223 , 12 , 33 , 14 , "0xFFff0000" , "0xFF440000" , 1 , 1 )
  Gdip_TextToGraphics( G , "Max" , "s16 Center  Bold c" Brush " x215 y8" , "Segoe ui" , 50 , 50 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 229 , 31 , 23 , 80 , "0xFFff0000" , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 229 , 30 , 22 , 82 , 5 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 28 , 29 , 25 , 84 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 230 , 31 , 20 , 80 , 5 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 39 , 34 , 7 , 72 , "0xaa441111" , "0xaaffffff" , 1 , 1 )
  Gdip_FillRectangle( G , Brush , 239 , 35 , 2 , 72 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFFffffff" )
  Gdip_TextToGraphics( G , obj.SliderValue2 , "s16 Center  Bold c" Brush " x215 y116" , "Segoe ui" , 50 , 20 )
  Gdip_DeleteBrush( Brush )
  ;Slider 2 thumb
  Brush := Gdip_CreateLineBrushFromRect( 232 , obj.SliderPosition2 , 16 , 8 , "0xFF111111" , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 232 , obj.SliderPosition2 , 16 , 8 , 3 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 233 , obj.SliderPosition2+1 , 14 , 7 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 233 , obj.SliderPosition2+1 , 14 , 7 , 3 )
  Gdip_DeleteBrush( Brush )
  ;Back Button
  Brush := Gdip_CreateLineBrushFromRect( 81 , 113 , 120 , 28 , (obj.Active!=5)?("0xFF880000"):("0xFFAA0000") , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 80 , 110 , 120 , 30 , 5 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( (obj.Active!=5)?("0x44222222"):("0x44000000") )
  Gdip_FillRoundedRectangle( G , Brush , 81 , 111 , 118 , 28 , 4 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "< Back " , "s16 Center vCenter Bold c" Brush " x79 y110" , "Segoe ui" , 120 , 30 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 121 , 117 , 38 , 12 , (obj.Active!=5)?("0xFF880000"):("0xFF000000") , (obj.Active!=5)?("0xFF000000"):("0xFF880000") , 1 , 1 )
  Gdip_TextToGraphics( G , "< Back " , "s16 Center vCenter Bold c" Brush " x80 y111" , "Segoe ui" , 120 , 30 )
  Gdip_DeleteBrush( Brush )
  ;Minus
  ;~ Brush := Gdip_CreateLineBrushFromRect( 80 , 40 , 28 , 27 , (obj.MinusH=0)?("0xFF880000"):("0xFFAA0000") , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 80 , 40 , 28 , 27 , (obj.Active!=6)?("0xFF880000"):("0xFFAA0000") , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 80 , 40 , 30 , 30 , 5 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_BrushCreateSolid( (obj.MinusH=0)?("0x44222222"):("0x44000000") )
  Brush := Gdip_BrushCreateSolid( (obj.Active!=6)?("0x44222222"):("0x44000000") )
  Gdip_FillRoundedRectangle( G , Brush , 81 , 41 , 28 , 28 , 5 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "_" , "s36 Center vCenter Bold c" Brush " x80 y25" , "Segoe ui" , 30 , 30 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 87 , 53 , 14 , 6 , (obj.MinusH=0)?("0xFF880000"):("0xFF000000") , (obj.MinusH=0)?("0xFF000000"):("0xFF880000") , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 87 , 53 , 14 , 6 , (obj.Active!=6)?("0xFF880000"):("0xFF000000") , (obj.Active!=6)?("0xFF000000"):("0xFF880000") , 1 , 1 )
  Gdip_TextToGraphics( G , "_" , "s36 Center vCenter Bold c" Brush " x81 y26" , "Segoe ui" , 30 , 30 )
  Gdip_DeleteBrush( Brush )
  ;Plus
  ;~ Brush := Gdip_CreateLineBrushFromRect( 170 , 41 , 29 , 28 , (obj.PlusH=0)?("0xFF880000"):("0xFFAA0000") , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 170 , 41 , 29 , 28 , (obj.Active!=7)?("0xFF880000"):("0xFFAA0000") , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 170 , 40 , 30 , 30 , 5 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_BrushCreateSolid( (obj.PlusH=0)?("0x44222222"):("0x44000000") )
  Brush := Gdip_BrushCreateSolid( (obj.Active!=7)?("0x44222222"):("0x44000000") )
  Gdip_FillRoundedRectangle( G , Brush , 171 , 41 , 28 , 28 , 5 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "+" , "s22 Center vCenter Bold c" Brush " x171 y39" , "Segoe ui" , 30 , 30 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 179 , 49 , 11 , 11 , (obj.PlusH=0)?("0xFF880000"):("0xFF000000") , (obj.PlusH=0)?("0xFF000000"):("0xFF880000") , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 179 , 49 , 11 , 11 , (obj.Active!=7)?("0xFF880000"):("0xFF000000") , (obj.Active!=7)?("0xFF000000"):("0xFF880000") , 1 , 1 )
  ;<-------------------------
  ;~ Gdip_TextToGraphics( G , "+" , "s22 Center vCenter Bold c" Brush " x172 y40" , "Segoe ui" , 30 , 30 )
  Gdip_TextToGraphics( G , "+" , "s22 Center vCenter Bold c" Brush " x172 y40" , "Segoe ui" , 30 , 30 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "Click Duration" , "s16 Center vCenter Bold c" Brush " x0 y0" , "Segoe ui" , 280 , 50 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 85 , 15 , 109 , 16 , "0xFFff0000" , "0xFF440000" , 1 , 1 )
  Gdip_TextToGraphics( G , "Click Duration" , "s16 Center vCenter Bold c" Brush " x1 y1" , "Segoe ui" , 280 , 50 )
  Gdip_DeleteBrush( Brush )
  ;CD
  Brush := Gdip_BrushCreateSolid( "0xFFaaaaaa" )
  ;CD
  Gdip_TextToGraphics( G , (obj.ClickDurationValue=1)?("Short"):(obj.ClickDurationValue=2)?("Med"):("Long") , "s16 Center vCenter Bold c" Brush " x110 y30" , "Segoe ui" , 60 , 50 )
  Gdip_DeleteBrush( Brush )
  Gdip_DeleteGraphics( G )
  return pBitmap
}	
;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
; More Options Window
;--------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------
OptionsWindow(OBJ){
  ;Bitmap Created Using: HB Bitmap Maker
  pBitmap:=Gdip_CreateBitmap( 280 , 150 ) 
  G := Gdip_GraphicsFromImage( pBitmap )
  Gdip_SetSmoothingMode( G , 2 )
  Brush := Gdip_BrushCreateSolid( "0x01777777" )
  Gdip_FillRectangle( G , Brush , 0 , 0 , 280 , 150 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 12 , 12 , 11 , 13 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Gdip_FillRectangle( G , Brush , 10 , 5 , 15 , 15 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 11 , 6 , 13 , 13 , "0xFFff0000" , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 11 , 6 , 13 , 13 , (obj.SoundState=1)?("0xFFff0000"):("0xFF880000") , "0xFF000000" , 1 , 1 )
  Gdip_FillRectangle( G , Brush , 11 , 6 , 13 , 13 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "Sounds" , "s16 Center vCenter Bold c" Brush " x9 y-12" , "Segoe ui" , 100 , 50 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 10 , 6 , 100 , 13 , "0xFFff0000" , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 10 , 6 , 100 , 13 , (obj.SoundState=1)?("0xFFff0000"):("0xFF880000") , "0xFF000000" , 1 , 1 )
  Gdip_TextToGraphics( G , "Sounds" , "s16 Center vCenter Bold c" Brush " x10 y-11" , "Segoe ui" , 100 , 50 )
  Gdip_DeleteBrush( Brush )
  ;Button 1
  
  ;~ Brush := Gdip_CreateLineBrushFromRect( 25 , 110 , 120 , 30 , (obj.HKUpdate=0)?("0xFF880000"):("0xFFAA0000") , "0xFF000000" , 1 , 1 )
  
  
  ;~ Brush := Gdip_CreateLineBrushFromRect( 50 , 30 , 180 , 23 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 50 , 25 , 180 , 23 ,(obj.Active!=8)?("0xff880000"):("0xFFAA0000") , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 50 , 25 , 180 , 23 , 5 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_BrushCreateSolid( "0x44222222" )
  Brush := Gdip_BrushCreateSolid( (obj.Active!=8)?("0x44222222"):("0x44000000") )
  Gdip_FillRoundedRectangle( G , Brush , 51 , 26 , 178 , 21 , 5 )
  Gdip_DeleteBrush( Brush )
  
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "<--  Share Link  -->" , "s16 Center vCenter Bold c" Brush " x50 y27" , "Segoe ui" , 180 , 23 )
  Gdip_DeleteBrush( Brush )
  
  ;~ Brush := Gdip_CreateLineBrushFromRect( 49 , 115 , 76 , 22 , (obj.HKUpdate=0)?("0xFF880000"):("0xFF000000") , (obj.HKUpdate=0)?("0xFF000000"):("0xFF880000") , 1 , 1 )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 65 , 33 , 146 , 8 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 65 , 33 , 146 , 8 , (obj.Active!=8)?("0xFF880000"):("0xFF000000") , (obj.Active!=8)?("0xFF000000"):("0xFF880000") , 1 , 1 )
  Gdip_TextToGraphics( G , "<--  Share Link  -->" , "s16 Center vCenter Bold c" Brush " x51 y28" , "Segoe ui" , 180 , 23 )
  Gdip_DeleteBrush( Brush )
  
  
  
  ;Button 2
  ;~ Brush := Gdip_CreateLineBrushFromRect( 50 , 60 , 180 , 23 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 50 , 55 , 180 , 23 , (obj.Active!=9)?("0xff880000"):("0xFFAA0000")  , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 50 , 55 , 180 , 23 , 5 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_BrushCreateSolid( "0x44222222" )
  Brush := Gdip_BrushCreateSolid( (obj.Active!=9)?("0x44222222"):("0x44000000") )
  Gdip_FillRoundedRectangle( G , Brush , 51 , 56 , 178 , 21 , 5 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "More Free Auto Clickers" , "s14 Center vCenter Bold c" Brush " x50 y57" , "Segoe ui" , 180 , 23 )
  Gdip_DeleteBrush( Brush )
  
  
  ;~ Brush := Gdip_CreateLineBrushFromRect( 60 , 64 , 161 , 8 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 60 , 64 , 161 , 8 ,  (obj.Active!=9)?("0xFF880000"):("0xFF000000") , (obj.Active!=9)?("0xFF000000"):("0xFF880000")  , 1 , 1 )
  Gdip_TextToGraphics( G , "More Free Auto Clickers" , "s14 Center vCenter Bold c" Brush " x51 y58" , "Segoe ui" , 180 , 23 )
  Gdip_DeleteBrush( Brush )
  
  
  
  ;Button 3
  ;~ Brush := Gdip_CreateLineBrushFromRect( 50 , 90 , 180 , 23 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 50 , 85 , 180 , 23 , (obj.Active!=10)?("0xff880000"):("0xFFAA0000")  , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 50 , 85 , 180 , 23 , 5 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_BrushCreateSolid( "0x44222222" )
  Brush := Gdip_BrushCreateSolid( (obj.Active!=10)?("0x44222222"):("0x44000000") )
  Gdip_FillRoundedRectangle( G , Brush , 51 , 86 , 178 , 21 , 5 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "Advaced Options" , "s16 Center vCenter Bold c" Brush " x50 y87" , "Segoe ui" , 180 , 23 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 72 , 93 , 134 , 9 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 72 , 93 , 134 , 9 ,  (obj.Active!=10)?("0xFF880000"):("0xFF000000") , (obj.Active!=10)?("0xFF000000"):("0xFF880000")  , 1 , 1 )
  Gdip_TextToGraphics( G , "Advaced Options" , "s16 Center vCenter Bold c" Brush " x51 y88" , "Segoe ui" , 180 , 23 )
  Gdip_DeleteBrush( Brush )
  
  
  
  
  ;Button 4
  ;~ Brush := Gdip_CreateLineBrushFromRect( 50 , 120 , 180 , 23 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 50 , 115 , 180 , 23 , (obj.Active!=11)?("0xff880000"):("0xFFAA0000") , "0xFF000000" , 1 , 1 )
  Gdip_FillRoundedRectangle( G , Brush , 50 , 115 , 180 , 23 , 5 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_BrushCreateSolid( "0x44222222" )
  Brush := Gdip_BrushCreateSolid( (obj.Active!=11)?("0x44222222"):("0x44000000") )
  Gdip_FillRoundedRectangle( G , Brush , 51 , 116 , 178 , 21 , 5 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "<Back" , "s16 Center vCenter Bold c" Brush " x50 y117" , "Segoe ui" , 180 , 23 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 109 , 121 , 59 , 11 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 109 , 121 , 59 , 11 , (obj.Active!=11)?("0xFF880000"):("0xFF000000") , (obj.Active!=11)?("0xFF000000"):("0xFF880000") , 1 , 1 )
  Gdip_TextToGraphics( G , "<Back" , "s16 Center vCenter Bold c" Brush " x51 y118" , "Segoe ui" , 180 , 23 )
  Gdip_DeleteBrush( Brush )
  ;------------------------------------------------------------
  
  
  Pen := Gdip_CreatePen( "0xFF880000" , 1 )
  Gdip_DrawRectangle( G , Pen , 0 , 0 , 279 , 149 )
  Gdip_DeletePen( Pen )
  Brush := Gdip_CreateLineBrushFromRect( 161 , 12 , 13 , 13 , "0xFF880000" , "0xFF000000" , 1 , 1 )
  Gdip_FillRectangle( G , Brush , 164 , 5 , 15 , 15 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_CreateLineBrushFromRect( 161 , 6 , 13 , 13 , (obj.AutoSaveState=1)?("0xFFff0000"):("0xFF880000") , "0xFF000000" , 1 , 1 )
  Gdip_FillRectangle( G , Brush , 165 , 6 , 13 , 13 )
  Gdip_DeleteBrush( Brush )
  Brush := Gdip_BrushCreateSolid( "0xFF777777" )
  Gdip_TextToGraphics( G , "Auto Save" , "s16 Center vCenter Bold c" Brush " x138 y-11" , "Segoe ui" , 170 , 50 )
  Gdip_DeleteBrush( Brush )
  ;~ Brush := Gdip_CreateLineBrushFromRect( 141 , 8 , 131 , 13 , "0xFFff0000" , "0xFF000000" , 1 , 1 )
  Brush := Gdip_CreateLineBrushFromRect( 141 , 8 , 131 , 13 , (obj.AutoSaveState=1)?("0xFFff0000"):("0xFF000000") , (obj.AutoSaveState=1)?("0xFF000000"):("0xFF880000") , 1 , 1 )
  Gdip_TextToGraphics( G , "Auto Save" , "s16 Center vCenter Bold c" Brush " x139 y-10" , "Segoe ui" , 170 , 50 )
  Gdip_DeleteBrush( Brush )
  Gdip_DeleteGraphics( G )
  return pBitmap
}
; <<<<<<<<<<<<<<<<<<<<<<   GDIP LIB   >>>>>>>>>>>>>>>>>>>>>>>>>>>>


;######################################################################################################################################
;#####################################################   					    #######################################################
;#####################################################  	  Gdip LITE		    #######################################################
;#####################################################  					    #######################################################
;######################################################################################################################################
; 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
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)
}
Gdip_DrawImage(pGraphics, pBitmap, dx="", dy="", dw="", dh="", sx="", sy="", sw="", sh="", Matrix=1){
  Ptr := A_PtrSize ? "UPtr" : "UInt"
  if (Matrix&1 = "")
    ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
  else if (Matrix != 1)
    ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1")
  if(sx = "" && sy = "" && sw = "" && sh = ""){
    if(dx = "" && dy = "" && dw = "" && dh = ""){
      sx := dx := 0, sy := dy := 0
      sw := dw := Gdip_GetImageWidth(pBitmap)
      sh := dh := Gdip_GetImageHeight(pBitmap)
    }else	{
      sx := sy := 0,sw := Gdip_GetImageWidth(pBitmap),sh := Gdip_GetImageHeight(pBitmap)
    }
  }
  E := DllCall("gdiplus\GdipDrawImageRectRect", Ptr, pGraphics, Ptr, pBitmap, "float", dx, "float", dy, "float", dw, "float", dh, "float", sx, "float", sy, "float", sw, "float", sh, "int", 2, Ptr, ImageAttr, Ptr, 0, Ptr, 0)
  if ImageAttr
    Gdip_DisposeImageAttributes(ImageAttr)
  return E
}
Gdip_SetImageAttributesColorMatrix(Matrix){
  Ptr := A_PtrSize ? "UPtr" : "UInt"
  VarSetCapacity(ColourMatrix, 100, 0)
  Matrix := RegExReplace(RegExReplace(Matrix, "^[^\d-\.]+([\d\.])", "$1", "", 1), "[^\d-\.]+", "|")
  StringSplit, Matrix, Matrix, |
  Loop, 25
  {
    Matrix := (Matrix%A_Index% != "") ? Matrix%A_Index% : Mod(A_Index-1, 6) ? 0 : 1
    NumPut(Matrix, ColourMatrix, (A_Index-1)*4, "float")
  }
  DllCall("gdiplus\GdipCreateImageAttributes", A_PtrSize ? "UPtr*" : "uint*", ImageAttr)
  DllCall("gdiplus\GdipSetImageAttributesColorMatrix", Ptr, ImageAttr, "int", 1, "int", 1, Ptr, &ColourMatrix, Ptr, 0, "int", 0)
  return ImageAttr
}
Gdip_GetImageWidth(pBitmap){
   DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width)
   return Width
}
Gdip_GetImageHeight(pBitmap){
   DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height)
   return Height
}
Gdip_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)
}
CreateCompatibleDC(hdc=0){
   return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
}
SelectObject(hdc, hgdiobj){
  Ptr := A_PtrSize ? "UPtr" : "UInt"
  return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
}
DeleteObject(hObject){
   return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject)
}
GetDC(hwnd=0){
  return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
}
GetDCEx(hwnd, flags=0, hrgnClip=0){
  Ptr := A_PtrSize ? "UPtr" : "UInt"
    return DllCall("GetDCEx", Ptr, hwnd, Ptr, hrgnClip, "int", flags)
}
ReleaseDC(hdc, hwnd=0){
  Ptr := A_PtrSize ? "UPtr" : "UInt"
  return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
}
DeleteDC(hdc){
   return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc)
}
Gdip_SetClipRegion(pGraphics, Region, CombineMode=0){
  Ptr := A_PtrSize ? "UPtr" : "UInt"
  return DllCall("gdiplus\GdipSetClipRegion", Ptr, pGraphics, Ptr, Region, "int", CombineMode)
}
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
}
Gdip_GraphicsFromImage(pBitmap){
  DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
  return pGraphics
}
Gdip_GraphicsFromHDC(hdc){
    DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
    return pGraphics
}
Gdip_GetDC(pGraphics){
  DllCall("gdiplus\GdipGetDC", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", hdc)
  return hdc
}


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_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_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
}
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
}
Gdip_FontFamilyCreate(Font){
  Ptr := A_PtrSize ? "UPtr" : "UInt"
  if (!A_IsUnicode)
  {
    nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &Font, "int", -1, "uint", 0, "int", 0)
    VarSetCapacity(wFont, nSize*2)
    DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &Font, "int", -1, Ptr, &wFont, "int", nSize)
  }
  DllCall("gdiplus\GdipCreateFontFamilyFromName", Ptr, A_IsUnicode ? &Font : &wFont, "uint", 0, A_PtrSize ? "UPtr*" : "UInt*", hFamily)
  return hFamily
}
Gdip_SetStringFormatAlign(hFormat, Align){
   return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align)
}
Gdip_StringFormatCreate(Format=0, Lang=0){
   DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat)
   return hFormat
}
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_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
}
Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0){
  DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "UInt", ARGBfront, "UInt", ARGBback, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
  return pBrush
}
CreateRectF(ByRef RectF, x, y, w, h){
   VarSetCapacity(RectF, 16)
   NumPut(x, RectF, 0, "float"), NumPut(y, RectF, 4, "float"), NumPut(w, RectF, 8, "float"), NumPut(h, RectF, 12, "float")
}
Gdip_SetTextRenderingHint(pGraphics, RenderingHint){
  return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint)
}
Gdip_MeasureString(pGraphics, sString, hFont, hFormat, ByRef RectF){
  Ptr := A_PtrSize ? "UPtr" : "UInt"
  VarSetCapacity(RC, 16)
  if !A_IsUnicode
  {
    nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, "uint", 0, "int", 0)
    VarSetCapacity(wString, nSize*2)
    DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, &wString, "int", nSize)
  }
  DllCall("gdiplus\GdipMeasureString", Ptr, pGraphics, Ptr, A_IsUnicode ? &sString : &wString, "int", -1, Ptr, hFont, Ptr, &RectF, Ptr, hFormat, Ptr, &RC, "uint*", Chars, "uint*", Lines)
  return &RC ? NumGet(RC, 0, "float") "|" NumGet(RC, 4, "float") "|" NumGet(RC, 8, "float") "|" NumGet(RC, 12, "float") "|" Chars "|" Lines : 0
}
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")
}
CreateSizeF(ByRef SizeF, w, h){
   VarSetCapacity(SizeF, 8)
   NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float")
}
CreatePointF(ByRef PointF, x, y){
   VarSetCapacity(PointF, 8)
   NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float")
}
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)
}
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)
}
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)
}
Gdip_DrawLines(pGraphics, pPen, Points){
  Ptr := A_PtrSize ? "UPtr" : "UInt"
  StringSplit, Points, Points, |
  VarSetCapacity(PointF, 8*Points0)
  Loop, %Points0%
  {
    StringSplit, Coord, Points%A_Index%, `,
    NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
  }
  return DllCall("gdiplus\GdipDrawLines", Ptr, pGraphics, Ptr, pPen, Ptr, &PointF, "int", Points0)
}
Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h){
  Ptr := A_PtrSize ? "UPtr" : "UInt"
  return DllCall("gdiplus\GdipFillRectangle", Ptr, pGraphics, Ptr, pBrush, "float", x, "float", y, "float", w, "float", h)
}
Gdip_FillRoundedRectangle(pGraphics, pBrush, x, y, w, h, r){
  Region := Gdip_GetClipRegion(pGraphics)
  Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
  Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
  Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
  Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
  E := Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h)
  Gdip_SetClipRegion(pGraphics, Region, 0)
  Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
  Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
  Gdip_FillEllipse(pGraphics, pBrush, x, y, 2*r, 2*r)
  Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y, 2*r, 2*r)
  Gdip_FillEllipse(pGraphics, pBrush, x, y+h-(2*r), 2*r, 2*r)
  Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y+h-(2*r), 2*r, 2*r)
  Gdip_SetClipRegion(pGraphics, Region, 0)
  Gdip_DeleteRegion(Region)
  return E
}
Gdip_GetClipRegion(pGraphics){
  Region := Gdip_CreateRegion()
  DllCall("gdiplus\GdipGetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics, "UInt*", Region)
  return Region
}
Gdip_SetClipRect(pGraphics, x, y, w, h, CombineMode=0){
   return DllCall("gdiplus\GdipSetClipRect",  A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "float", w, "float", h, "int", CombineMode)
}
Gdip_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_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)
}
Gdip_FillRegion(pGraphics, pBrush, Region){
  Ptr := A_PtrSize ? "UPtr" : "UInt"
  return DllCall("gdiplus\GdipFillRegion", Ptr, pGraphics, Ptr, pBrush, Ptr, Region)
}
Gdip_FillPath(pGraphics, pBrush, Path){
  Ptr := A_PtrSize ? "UPtr" : "UInt"
  return DllCall("gdiplus\GdipFillPath", Ptr, pGraphics, Ptr, pBrush, Ptr, Path)
}
Gdip_CreateRegion(){
  DllCall("gdiplus\GdipCreateRegion", "UInt*", Region)
  return Region
}
Gdip_DeleteRegion(Region){
  return DllCall("gdiplus\GdipDeleteRegion", A_PtrSize ? "UPtr" : "UInt", Region)
}
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_SetSmoothingMode(pGraphics, SmoothingMode){
   return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
}
Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h){
  Ptr := A_PtrSize ? "UPtr" : "UInt"
  return DllCall("gdiplus\GdipDrawRectangle", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h)
}
Gdip_DrawRoundedRectangle(pGraphics, pPen, x, y, w, h, r){
  Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
  Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
  Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
  Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
  E := Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h)
  Gdip_ResetClip(pGraphics)
  Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
  Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
  Gdip_DrawEllipse(pGraphics, pPen, x, y, 2*r, 2*r)
  Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y, 2*r, 2*r)
  Gdip_DrawEllipse(pGraphics, pPen, x, y+h-(2*r), 2*r, 2*r)
  Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y+h-(2*r), 2*r, 2*r)
  Gdip_ResetClip(pGraphics)
  return E
}
Gdip_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)
}
Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff){
  DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hbm, "int", Background)
  return hbm
}
SetImage(hwnd, hBitmap){
  SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
  E := ErrorLevel
  DeleteObject(E)
  return E
}
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)
}
UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255)
{
  Ptr := A_PtrSize ? "UPtr" : "UInt"
  
  if ((x != "") && (y != ""))
    VarSetCapacity(pt, 8), NumPut(x, pt, 0, "UInt"), NumPut(y, pt, 4, "UInt")

  if (w = "") ||(h = "")
    WinGetPos,,, w, h, ahk_id %hwnd%
   
  return DllCall("UpdateLayeredWindow"
          , Ptr, hwnd
          , Ptr, 0
          , Ptr, ((x = "") && (y = "")) ? 0 : &pt
          , "int64*", w|h<<32
          , Ptr, hdc
          , "int64*", 0
          , "uint", 0
          , "UInt*", Alpha<<16|1<<24
          , "uint", 2)
}
Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff)
{
    return DllCall("gdiplus\GdipGraphicsClear", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", ARGB)
}
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
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。