Is it possible to position a progressbar diagonally? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Is it possible to position a progressbar diagonally?

Post by AHKStudent » 15 Sep 2021, 20:48

Is there a way to do this in the XY parameter or another way?

Code: Select all

#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%

Gui Add, Progress, x105 y46 w287 h20 -Smooth, 33
Gui Add, Text, x36 y122 w63 h23 +0x200, From here
Gui Add, Text, x328 y302 w120 h23 +0x200, To here

Gui Show, w481 h381, Window
Return

GuiEscape:
GuiClose:
    ExitApp

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Is it possible to position a progressbar diagonally?  Topic is solved

Post by Hellbent » 15 Sep 2021, 21:30

Very possible.

Example with gdip. (ok it's not a progress bar but w/e lol)
Temp (1).gif
Temp (1).gif (179.33 KiB) Viewed 257 times


Just create a bitmap with a few lines.

Like this for example.

Code: Select all

HB_BITMAP_MAKER(){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap := Gdip_CreateBitmap( 200 , 200 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	Pen := Gdip_CreatePen( "0xFF3399FF" , 9 ) , Gdip_DrawLine( G , Pen , 10 , 10 , 190 , 190 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xFF880000" , 5 ) , Gdip_DrawLine( G , Pen , 15 , 15 , 175 , 175 ) , Gdip_DeletePen( Pen )
	Gdip_DeleteGraphics( G )
	return pBitmap
}
20210915222923.png
20210915222923.png (2.67 KiB) Viewed 257 times

AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Is it possible to position a progressbar diagonally?

Post by AHKStudent » 15 Sep 2021, 22:40

Hellbent wrote:
15 Sep 2021, 21:30

Code: Select all

HB_BITMAP_MAKER(){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap := Gdip_CreateBitmap( 200 , 200 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	Pen := Gdip_CreatePen( "0xFF3399FF" , 9 ) , Gdip_DrawLine( G , Pen , 10 , 10 , 190 , 190 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xFF880000" , 5 ) , Gdip_DrawLine( G , Pen , 15 , 15 , 175 , 175 ) , Gdip_DeletePen( Pen )
	Gdip_DeleteGraphics( G )
	return pBitmap
}
20210915222923.png
Can you share the gui code for the above graphic?
thanks

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Is it possible to position a progressbar diagonally?

Post by Hellbent » 15 Sep 2021, 22:52

AHKStudent wrote:
15 Sep 2021, 22:40
Can you share the gui code for the above graphic?
thanks
This was just a POC so the code isn't organized etc. Just wanted to try to make a slider that I could pull in any direction and had a tiny footprint.

Requires GDIP

it also requires my old layered window class found here: viewtopic.php?f=6&t=72588

Code: Select all

;***************************************************************************************************
#Include <My Altered Gdip Lib>
#Include <LayeredWindow Class>
;***************************************************************************************************
#SingleInstance, Force
SetBatchLines, -1
#NoEnv
HUD := New LayeredWindow( x := "" , y := "" , w := 500 , h := 500 , window := "2" , title := "Crazy Slider" , smoothing := 2 , options := "+AlwaysOnTop -DpiScale " , autoShow := 1 , GdipStart := 1 , WinMover := { x: 0 , y: 0 , w: w , h: 20 })



HUD.Draw( CrazySlider( ) , { X: 0 , Y: 0 , W: 500 , H: 500 } , update := 1 , disposeBitmap := 1 )

x := ( 500 / 2 ) - floor( 51 / 2 )
y := (500 / 2 ) - floor( 51 / 2 )
w := 51
h := 51
Gui, 2:Add, Text, % "x" x " y" y " w" w " h" h " hwndhwnd gTestLabel"



return
2GuiClose:
2GuiContextMenu:
*ESC::ExitApp


TestLabel:
	SetTimer, WatchCursor, 60
	Active := 1
	return


WatchCursor:
	if(!GetKeyState("LButton")){
		Active := 0
		SetTimer, WatchCursor, Off
		Output := "New"
	}else{
		Output := "123"
	}
	CoordMode, Mouse, Client
	MouseGetPos, x, y
	HUD.ClearWindow()
	HUD.Draw( CrazySlider( Active , x , y , Output ) , { X: 0 , Y: 0 , W: 500 , H: 500 } , update := 1 , disposeBitmap := 1 )
	
	return




CrazySlider( Active := 0 , x2 := 0 , y2 := 0 , text := "123"){
	;Bitmap Created Using: HB Bitmap Maker
	local x := ( 500 / 2 ) - floor( 51 / 2 )
	, y := (500 / 2 ) - floor( 51 / 2 )
	, w := 51
	, h := 51
	
	pBitmap := Gdip_CreateBitmap( 500 , 500 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	
	Brush := Gdip_BrushCreateSolid( "0xFF02060a" ) , Gdip_FillRectangle( G , Brush , -1 , -1 , 555 , 555 ) , Gdip_DeleteBrush( Brush )
	
	Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , x , y , 51 , 51 ) , Gdip_DeleteBrush( Brush )
	Brush := Gdip_BrushCreateSolid( "0xFF33383f" ) , Gdip_FillRectangle( G , Brush , x + 2 , y + 2 , w - 4 , h - 4 ) , Gdip_DeleteBrush( Brush )
	Pen := Gdip_CreatePen( "0xFF222222" , 1 ) , Gdip_DrawRectangle( G , Pen , x + 2 , y + 2 , w - 4 , h - 4 ) , Gdip_DeletePen( Pen )
	x1 := x + 26
	, y1 := y + 26
	
	SPosition := New HB_Vector(x1 , y1)
	STarget := New HB_Vector( x2 , y2 )
	SVel := New HB_Vector()
	SVel.X := STarget.X, SVel.Y := STarget.Y
	SVel.Sub(SPosition)
	if( STarget.Dist(SPosition) >= 195 )
		SVel.SetMag(195)
	SPosition.Add(SVel)
	
	;Border 
	Position := New HB_Vector(x1 , y1)
	Target := New HB_Vector( x2 , y2 )
	Vel := New HB_Vector()
	Vel.X := Target.X , Vel.Y := Target.Y
	Vel.Sub( Position )
	Vel.SetMag(200)
	Position.Add(Vel)
	
	;~ Min := 1
	Max := 195
	Items := 15
	interval := Max / Items 
	center := New HB_Vector(x1 , y1)
	mouse := New HB_Vector( x2 , y2 )
	text := ((temp := floor(center.Dist(mouse))) > 195 )?( Floor( 195 / Interval ) ):( Floor( temp / Interval ) )
	
	count := 1
	if(Text < ( count += 5 ) ){
		SliderColor := "0xFF00FF00"
		BGColor := "0x66006600"
		Output := "Mild"
	}else if(Text < ( count += 5 ) ){
		SliderColor := "0xFFFFFF00"
		BGColor := "0x66666600"
		Output := "Mod"
	}else if(Text < ( count += 5 ) ){
		SliderColor := "0xFFFF0000"
		BGColor := "0x66660000"
		Output := "omg"
	}
		;~ SoundBeep, 500
	Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( G , Text , "s18 Center vCenter Bold c" Brush " x" x + 2 " y" y + 3 , "Segoe ui" , w - 4 , h - 4 ) , Gdip_DeleteBrush( Brush )
	
	if(Active){
		;~ Pen := Gdip_CreatePen( "0x66222222" , 19 ) , Gdip_DrawLine( G , Pen , x1 , y1 , Position.X , Position.Y ) , Gdip_DeletePen( Pen )
		Pen := Gdip_CreatePen( BGColor , 19 ) , Gdip_DrawLine( G , Pen , x1 , y1 , Position.X , Position.Y ) , Gdip_DeletePen( Pen )
		
		
		;~ Pen := Gdip_CreatePen( "0x99880000" , 5 ) , Gdip_DrawLine( G , Pen , x1 , y1 , SPosition.X , SPosition.Y ) , Gdip_DeletePen( Pen )
		Pen := Gdip_CreatePen( SliderColor , 5 ) , Gdip_DrawLine( G , Pen , x1 , y1 , SPosition.X , SPosition.Y ) , Gdip_DeletePen( Pen )
		
		
		Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , SPosition.X + 20 , SPosition.Y , 50 , 20 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , SPosition.X + 20 + 1 , SPosition.Y + 1 , 50 - 2 , 20 - 2) , Gdip_DeleteBrush( Brush )
		;~ Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( G , Text , "s18 Center vCenter Bold c" Brush " x" SPosition.X + 20 " y" SPosition.Y + 1, "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
		Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( G , output , "s18 Center vCenter Bold c" Brush " x" SPosition.X + 20 " y" SPosition.Y + 1, "Segoe ui" , 50 , 20 ) , Gdip_DeleteBrush( Brush )
	
		
	}
	
	Gdip_DeleteGraphics( G )
	return pBitmap
}





Class HB_Vector	{
	__New(x:=0,y:=0){
		This.X:=x
		This.Y:=y
	}
	Add(Other_HB_Vector){
		This.X+=Other_HB_Vector.X
		This.Y+=Other_HB_Vector.Y
	}
	Sub(Other_HB_Vector){
		This.X-=Other_HB_Vector.X
		This.Y-=Other_HB_Vector.Y
	}
	mag(){
		return Sqrt(This.X*This.X + This.Y*This.Y)
	}
	magsq(){
		return This.Mag()**2
	}	
	setMag(in1){
		m:=This.Mag()
		This.X := This.X * in1/m
		This.Y := This.Y * in1/m
		return This
	}
	mult(in1,in2:="",in3:="",in4:="",in5:=""){
		if(IsObject(in1)&&in2=""){
			This.X*=In1.X 
			This.Y*=In1.Y 
		}else if(!IsObject(In1)&&In2=""){
			This.X*=In1
			This.Y*=In1
		}else if(!IsObject(In1)&&IsObject(In2)){
			This.X*=In1*In2.X
			This.Y*=In1*In2.Y
		}else if(IsObject(In1)&&IsObject(In2)){
			This.X*=In1.X*In2.X
			This.Y*=In1.Y*In2.Y
		}	
	}
	div(in1,in2:="",in3:="",in4:="",in5:=""){
		if(IsObject(in1)&&in2=""){
			This.X/=In1.X 
			This.Y/=In1.Y 
		}else if(!IsObject(In1)&&In2=""){
			This.X/=In1
			This.Y/=In1
		}else if(!IsObject(In1)&&IsObject(In2)){
			This.X/=In1/In2.X
			This.Y/=In1/In2.Y
		}else if(IsObject(In1)&&IsObject(In2)){
			This.X/=In1.X/In2.X
			This.Y/=In1.Y/In2.Y
		}	
	}
	dist(in1){
		return Sqrt(((This.X-In1.X)**2) + ((This.Y-In1.Y)**2))
	}
	dot(in1){
		return (This.X*in1.X)+(This.Y*In1.Y)
	}
	cross(in1){
		return This.X*In1.Y-This.Y*In1.X
	}
	Norm(){
		m:=This.Mag()
		This.X/=m
		This.Y/=m
	}
}


If you need any help with any of the steps, be it with the math, or with the graphics just LEMMiNO.

*EDIT* Misunderstood what you meant, give me a few mins to whip something up.

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Is it possible to position a progressbar diagonally?

Post by Hellbent » 15 Sep 2021, 23:12

This is the code to draw it, still needs the math done.
Would you know how to wire the slider to control the progress bar?

Code: Select all

#Include <My Altered GDIP lib>
#SingleInstance, Force
SetBatchlines, -1

GDIP_StartUp()

Gui, 1:+AlwaysOnTop

Gui, 1:Add, Picture, xm ym w200 h200 0xE hwndPicHwnd
DiagonalProgressBar( PicHwnd )

Gui, 1:Add, Slider, xm w200 Range1-100 vSlider1 gAdjustProgress, 10


Gui, 1:Show,, Demo

return 
GuiClose:
GuiContextMenu:
*ESC::ExitApp

AdjustProgress:
	DiagonalProgressBar( PicHwnd )
	
	return

DiagonalProgressBar( hwnd , Add_In_More_Things := "To pass to the function, such as positions, and colors" ){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap := Gdip_CreateBitmap( 200 , 200 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	Pen := Gdip_CreatePen( "0xFF3399FF" , 9 ) , Gdip_DrawLine( G , Pen , 10 , 10 , 190 , 190 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xFF880000" , 5 ) , Gdip_DrawLine( G , Pen , 15 , 15 , 175 , 175 ) , Gdip_DeletePen( Pen )
	Gdip_DeleteGraphics( G )
	hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
	Gdip_DisposeImage(pBitmap)
	SetImage( hwnd , hBitmap )
	DeleteObject( hBitmap )

}







AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Is it possible to position a progressbar diagonally?

Post by AHKStudent » 16 Sep 2021, 00:02

Hellbent wrote:
15 Sep 2021, 23:12
This is the code to draw it, still needs the math done.
Would you know how to wire the slider to control the progress bar?

Code: Select all

#Include <My Altered GDIP lib>
#SingleInstance, Force
SetBatchlines, -1

GDIP_StartUp()

Gui, 1:+AlwaysOnTop

Gui, 1:Add, Picture, xm ym w200 h200 0xE hwndPicHwnd
DiagonalProgressBar( PicHwnd )

Gui, 1:Add, Slider, xm w200 Range1-100 vSlider1 gAdjustProgress, 10


Gui, 1:Show,, Demo

return 
GuiClose:
GuiContextMenu:
*ESC::ExitApp

AdjustProgress:
	DiagonalProgressBar( PicHwnd )
	
	return

DiagonalProgressBar( hwnd , Add_In_More_Things := "To pass to the function, such as positions, and colors" ){
	;Bitmap Created Using: HB Bitmap Maker
	pBitmap := Gdip_CreateBitmap( 200 , 200 ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
	Pen := Gdip_CreatePen( "0xFF3399FF" , 9 ) , Gdip_DrawLine( G , Pen , 10 , 10 , 190 , 190 ) , Gdip_DeletePen( Pen )
	Pen := Gdip_CreatePen( "0xFF880000" , 5 ) , Gdip_DrawLine( G , Pen , 15 , 15 , 175 , 175 ) , Gdip_DeletePen( Pen )
	Gdip_DeleteGraphics( G )
	hBitmap := Gdip_CreateHBITMAPFromBitmap( pBitmap )
	Gdip_DisposeImage(pBitmap)
	SetImage( hwnd , hBitmap )
	DeleteObject( hBitmap )

}






thanks so much!

Post Reply

Return to “Ask for Help (v1)”