Mapping Actions over Time

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
mikeyww
Posts: 26857
Joined: 09 Sep 2014, 18:38

Re: Mapping Actions over Time

24 Sep 2021, 17:22

Thanks for the update & explanations. :thumbup:
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Mapping Actions over Time

25 Sep 2021, 12:36

I have done a first pass at the new code and adapted it to use a layered window and drawing functions.

This first draft only has one display type but I have a few other already worked out, I just need to class this to make it easier to modify it on the fly.
It does however already offer a number of properties that can be changed such as color bar width / height etc.

This version is designed to act as an screen overlay, it can be positioned anywhere, but the top left corner is the best fit atm
It can be toggled on and off with the Numpad1 hotkey.
Temp (1).gif
Temp (1).gif (222.66 KiB) Viewed 116 times

Code: Select all

;****************************************************************************************************************************************************************************
#Include <My Altered GDIP lib>  ;Gdip by Tic
#Include <PopUpWindow Class> ;https://www.autohotkey.com/boards/viewtopic.php?f=6&t=94961
;****************************************************************************************************************************************************************************
#SingleInstance, Force
SetBatchlines, -1
Gdip_Startup()

gosub, AddGui 							
gosub, Activate

return
*ESC::ExitApp

NumPad3::PopUpWindow.Helper()

#If ( Active )

~*LButton::                            
	Clicks++
	Return

#If

Numpad1::
Activate:
	if( Active := !Active ){
		clicks := 0
		Gosub, Advance                        
		SetTimer, Advance, 1000                	
		SetTimer, DrawGui, 30                
	}else{
		Gosub, Advance                         
		SetTimer, Advance, Off                	
		SetTimer, DrawGui, Off 
		Loop, % Gui1.BarCount	
			Gui1.DisplayArray[ A_Index ] := Gui1.StorageArray[ A_Index ] := ""		
		Gui1.ClearWindow()
		Gui1.UpdateWindow()
	}
	return


AddGui:
	w := 550 , h := 100
	Gui1 := New PopUpWindow( { WindowName: "2" , WindowOptions: " -DPIScale +AlwaysOnTop +E0x20" , WindowSmoothing: 2 , X: 0  , Y: "10" , W: w , H: h } )
	;~ Gui1 := New PopUpWindow( { WindowName: "2" , WindowOptions: " -DPIScale +AlwaysOnTop +E0x20" , WindowSmoothing: 2 , X: "Center" , Y: "Center" , W: w , H: h } )
	Gui1.ShowWindow()
	Gui1.DisplayArray := []
	Gui1.YMid := h / 2 
	Gui1.StorageArray := []
	Gui1.BarWidth := 2
	Gui1.BarScale := 3 ;px per click
	Gui1.BarCount := 180
	Gui1.BarColor1 := "0xFFff0000" ;BAR COLOR
	Gui1.BarCoror2 := "0x00000000"
	Gui1.BarStyle := 2 ;2 = above and below the center
	Gui1.BGRound := 10
	Gui1.BGColor1 := "0xFFaaaaaa"
	Gui1.BGColor2 := "0xFF112233"
	Loop, % Gui1.BarCount	
		Gui1.DisplayArray[ A_Index ] := Gui1.StorageArray[ A_Index ] := Random(0,9)
	HB_BITMAP_MAKER( obj , clicks )
	Gui1.UpdateWindow()
	return

Advance:
	Gui1.StorageArray.Insert( 1, Clicks  ) 
	Clicks := 0
	Gui1.StorageArray.Pop()
	Return

DrawGui:
	Loop, % Gui1.BarCount	
		Gui1.DisplayArray[ A_Index ] := Gui1.StorageArray[ A_Index ]
	Gui1.ClearWindow()
	HB_BITMAP_MAKER( Gui1 , clicks )
	Gui1.UpdateWindow()
	return

HB_BITMAP_MAKER( obj , clicks ){
	;Bitmap Created Using: HB Bitmap Maker
	Loop, % pos := Obj.BarCount
		Pen := Gdip_CreatePen( Obj.BarColor1 , Obj.BarWidth ) , Gdip_DrawLine( Obj.G , Pen ,  ( A_Index * ( Obj.BarWidth + 1 ) ) + 3  , Obj.YMid + ( ( obj.DisplayArray[A_Index] * obj.BarScale ) + 1 ) , ( A_Index * ( Obj.BarWidth + 1 ) ) + 3  , Obj.YMid - ( ( obj.DisplayArray[A_Index] * obj.BarScale ) + 1 ) ) , Gdip_DeletePen( Pen )
		;reverse order
		;~ Pen := Gdip_CreatePen( Obj.BarColor1 , Obj.BarWidth ) , Gdip_DrawLine( Obj.G , Pen ,  ( A_Index * ( Obj.BarWidth + 1 ) ) + 3  , Obj.YMid + ( ( obj.DisplayArray[pos] * obj.BarScale ) + 1 ) , ( A_Index * ( Obj.BarWidth + 1 ) ) + 3  , Obj.YMid - ( ( obj.DisplayArray[pos--] * obj.BarScale ) + 1 ) ) , Gdip_DeletePen( Pen )
	
	Brush := Gdip_BrushCreateSolid( "0x66000000" ) , Gdip_FillRoundedRectangle( Obj.G , Brush , 0 , 0 , 80 , 20 , 5 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFFFFFFFF" ) , Gdip_TextToGraphics( Obj.G , "CPS: "  , "s16  Bold c" Brush " x10 y0" , "Segoe ui" , 50 , 50 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFFffffff" ) , Gdip_TextToGraphics( Obj.G , clicks , "s16  Bold c" Brush " x54 y-1" , "Segoe ui" , 50 , 50 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFFff0000" ) , Gdip_TextToGraphics( Obj.G , clicks , "s16  Bold c" Brush " x55 y0" , "Segoe ui" , 50 , 50 ) , Gdip_DeleteBrush( Brush )
}

Random(Min, Max){
	local out 
	Random, out, min, max
	return out
}


Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: OrangeCat and 131 guests