Hex Calc and Cube Calc
Hex Calc and Cube Calc
This is more of an experiment than something I expect people will find useful. It's an odd shaped calculator with hexagon buttons. Each button is it's own gui, all are linked together wi
Last edited by x32 on 06 Mar 2023, 18:04, edited 2 times in total.
Re: Hex Calc
Nice!
After looking closer, I noticed all *.png files have a height of 72, and in code you resize them to h70. This causes the edges to be smeared out.
I tried with searching for h70 and replacing with h72, which seems to clean the edges for me. Is there any reason not to do so?
Thanks for sharing.
After looking closer, I noticed all *.png files have a height of 72, and in code you resize them to h70. This causes the edges to be smeared out.
I tried with searching for h70 and replacing with h72, which seems to clean the edges for me. Is there any reason not to do so?
Thanks for sharing.
Re: Hex Calc
No reason they can't be set back to 72. I changed it because the images looked taller than their width and it fixed a spacing issue.wolf_II wrote:After looking closer, I noticed all *.png files have a height of 72, and in code you resize them to h70. This causes the edges to be smeared out.
I tried with searching for h70 and replacing with h72, which seems to clean the edges for me. Is there any reason not to do so?.
Re: Hex Calc
Very nice indeed, thank you.
Thank you for sharing this with us.
Bravo!
Thank you for sharing this with us.
Bravo!
Re: Hex Calc
Why use separate guis?
Re: Hex Calc
It's the only way I could find to use the odd shaped buttons. Even if I used pics with transparent backgrounds they are still square. If the transparent corner of one button is on top of another button the transparent corner receives the click.kczx3 wrote:Why use separate guis?
Re: Hex Calc
Very interesting! Thanks for sharing!
My Stuff: mousey; volume; ahkinfo; instantbirder; npp highlighter; Dynamic File Menu; tv - a treeview library;
- SpeedMaster
- Posts: 494
- Joined: 12 Nov 2016, 16:09
Re: Hex Calc
Very interesting
for those who are interested here is a tutorial (maybe too complicated) but well explained:
https://www.redblobgames.com/grids/hexagons/
Cheers
In theory it is possible take a pixel location (such as a mouse click) and convert it into a hex grid coordinate.x32 wrote:It's the only way I could find to use the odd shaped buttons. Even if I used pics with transparent backgrounds they are still square. If the transparent corner of one button is on top of another button the transparent corner receives the click.kczx3 wrote:Why use separate guis?
for those who are interested here is a tutorial (maybe too complicated) but well explained:
https://www.redblobgames.com/grids/hexagons/
Cheers
Re: Hex Calc
That is interesting but beyond my level. However I'm going to study it and see if I can make it work in AHK.
Re: Hex Calc
I’d think this could done with gdi as well. It’d be super easy with html/js/css
Re: Hex Calc
I made this script years ago, using GDIP, where you could load an image for a background, draw the shape of your controls on the image and it would produce transparent windows over the background image which would received the click. In short, you could draw your own buttons on your background.kczx3 wrote:I’d think this could done with gdi as well. It’d be super easy with html/js/css
That was here;
https://autohotkey.com/board/topic/7034 ... e-buttons/
Re: Hex Calc
And just because I was reminded about an old script...
Cube Calc. Created using my old script Area as Control.ahk. This took a fraction of the time as creating it from scratch.
Uses DockA to keep it all together and Eval for the calculations.
The scripts, libraries and pics can be found in the zip file, Cube Calc
This code was mostly written automatically. The edit box and transparent background were added.
The subroutines were automatically added but empty. The commands had to be added.
Cube Calc. Created using my old script Area as Control.ahk. This took a fraction of the time as creating it from scratch.
Uses DockA to keep it all together and Eval for the calculations.
The scripts, libraries and pics can be found in the zip file, Cube Calc
This code was mostly written automatically. The edit box and transparent background were added.
Code: Select all
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance , Force
DetectHiddenWindows, On
Gui, Color, aabbcc
WinSet, TransColor, aabbcc, Cube_Calc
Gui, Add, Edit, x90 y0 w150 r1 Right vedit1,
Gui, Add, Pic, x0 y0 w325 h325 vMoveGui gPic1, cube.png
Gui, +LastFound -Caption
Gui, Show, w325 h325, Cube_Calc
GoSub AddControls
OnMessage(0x201, "WM_LBUTTONDOWN")
Return
#Include Cube_Calc_Subroutines.ahk
WM_LBUTTONDOWN()
{
MouseGetPos, , , OverWin,
WinGetTitle, title, ahk_id%OverWin%
StringReplace, title, title, %A_Space%, _, All
If IsLabel(title)
Gosub, %title%
}
Return
Esc::
Exit:
GuiClose:
Gui, Destroy
ExitApp
Pic1:
WinActivate, Cube_Calc
PostMessage, 0xA1, 2,,, A
Loop,
{
KeyIsDown := GetKeyState("LButton")
If KeyIsDown = 1
Sleep, 50
If KeyIsDown = 0
Break
}
Return
AddControls:
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 11:Color, Black
Gui, 11:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, 1
WinSet, Transparent, 1, 1
WinSet, Region, 42-239 41-189 71-205 73-257 46-240 42-239, 1
Gui, 11:+LastFound +Toolwindow -Caption
Gui, 11:Show, , 1
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, 1
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 12:Color, Black
Gui, 12:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, 2
WinSet, Transparent, 1, 2
WinSet, Region, 74-261 74-208 109-227 110-278 77-257 74-261, 2
Gui, 12:+LastFound +Toolwindow -Caption
Gui, 12:Show, , 2
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, 2
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 13:Color, Black
Gui, 13:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, 3
WinSet, Transparent, 1, 3
WinSet, Region, 117-282 116-230 156-248 156-248 155-299 117-276 117-276 117-282, 3
Gui, 13:+LastFound +Toolwindow -Caption
Gui, 13:Show, , 3
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, 3
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 14:Color, Black
Gui, 14:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, 4
WinSet, Transparent, 1, 4
WinSet, Region, 40-183 36-133 70-151 70-198 40-180 40-183, 4
Gui, 14:+LastFound +Toolwindow -Caption
Gui, 14:Show, , 4
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, 4
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 16:Color, Black
Gui, 16:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, 5
WinSet, Transparent, 1, 5
WinSet, Region, 75-203 73-151 110-167 111-167 110-220 74-200 74-200 75-203, 5
Gui, 16:+LastFound +Toolwindow -Caption
Gui, 16:Show, , 5
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, 5
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 17:Color, Black
Gui, 17:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, 6
WinSet, Transparent, 1, 6
WinSet, Region, 113-225 114-170 158-191 156-245 156-245 113-222 113-225, 6
Gui, 17:+LastFound +Toolwindow -Caption
Gui, 17:Show, , 6
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, 6
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 18:Color, Black
Gui, 18:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, 7
WinSet, Transparent, 1, 7
WinSet, Region, 34-126 34-76 34-76 67-91 69-142 38-126 34-126, 7
Gui, 18:+LastFound +Toolwindow -Caption
Gui, 18:Show, , 7
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, 7
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 19:Color, Black
Gui, 19:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, 8
WinSet, Transparent, 1, 8
WinSet, Region, 72-143 72-92 110-109 110-161 74-144 72-143, 8
Gui, 19:+LastFound +Toolwindow -Caption
Gui, 19:Show, , 8
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, 8
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 20:Color, Black
Gui, 20:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, 9
WinSet, Transparent, 1, 9
WinSet, Region, 113-166 113-112 113-111 152-128 152-128 154-183 114-164 114-164 113-166, 9
Gui, 20:+LastFound +Toolwindow -Caption
Gui, 20:Show, , 9
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, 9
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 21:Color, Black
Gui, 21:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, 0
WinSet, Transparent, 1, 0
WinSet, Region, 158-299 158-250 203-231 204-277 160-297 160-297 158-299, 0
Gui, 21:+LastFound +Toolwindow -Caption
Gui, 21:Show, , 0
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, 0
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 22:Color, Black
Gui, 22:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, plusl
WinSet, Transparent, 1, plusl
WinSet, Region, 158-244 160-194 202-175 205-222 161-243 158-244, plusl
Gui, 22:+LastFound +Toolwindow -Caption
Gui, 22:Show, , plusl
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, plusl
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 23:Color, Black
Gui, 23:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, minus
WinSet, Transparent, 1, minus
WinSet, Region, 157-180 156-131 200-115 201-163 157-180 157-180, minus
Gui, 23:+LastFound +Toolwindow -Caption
Gui, 23:Show, , minus
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, minus
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 24:Color, Black
Gui, 24:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, dot
WinSet, Transparent, 1, dot
WinSet, Region, 211-277 207-229 207-229 250-211 250-211 251-259 213-277 211-277, dot
Gui, 24:+LastFound +Toolwindow -Caption
Gui, 24:Show, , dot
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, dot
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 25:Color, Black
Gui, 25:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, mult
WinSet, Transparent, 1, mult
WinSet, Region, 209-218 210-172 250-154 250-204 250-204 210-217 209-218, mult
Gui, 25:+LastFound +Toolwindow -Caption
Gui, 25:Show, , mult
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, mult
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 26:Color, Black
Gui, 26:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, div
WinSet, Transparent, 1, div
WinSet, Region, 210-158 207-109 207-109 252-94 252-94 250-144 250-144 207-162 207-162 210-158, div
Gui, 26:+LastFound +Toolwindow -Caption
Gui, 26:Show, , div
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, div
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 27:Color, Black
Gui, 27:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, equ
WinSet, Transparent, 1, equ
WinSet, Region, 257-258 256-206 292-195 292-238 256-253 257-258, equ
Gui, 27:+LastFound +Toolwindow -Caption
Gui, 27:Show, , equ
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, equ
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 29:Color, Black
Gui, 29:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, pl
WinSet, Transparent, 1, pl
WinSet, Region, 255-199 257-153 294-136 293-184 256-199 255-199, pl
Gui, 29:+LastFound +Toolwindow -Caption
Gui, 29:Show, , pl
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, pl
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 30:Color, Black
Gui, 30:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, pr
WinSet, Transparent, 1, pr
WinSet, Region, 257-142 256-92 256-92 293-79 297-127 254-140 254-140 257-142, pr
Gui, 30:+LastFound +Toolwindow -Caption
Gui, 30:Show, , pr
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, pr
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 31:Color, Black
Gui, 31:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, xcopy
WinSet, Transparent, 1, xcopy
WinSet, Region, 157-123 117-104 159-89 198-108 157-123 157-123, xcopy
Gui, 31:+LastFound +Toolwindow -Caption
Gui, 31:Show, , xcopy
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, xcopy
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 32:Color, Black
Gui, 32:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, zcut
WinSet, Transparent, 1, zcut
WinSet, Region, 110-102 82-87 82-87 119-74 155-87 113-102 110-102, zcut
Gui, 32:+LastFound +Toolwindow -Caption
Gui, 32:Show, , zcut
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, zcut
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 33:Color, Black
Gui, 33:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, help
WinSet, Transparent, 1, help
WinSet, Region, 70-84 43-69 81-54 114-72 114-72 68-87 70-84, help
Gui, 33:+LastFound +Toolwindow -Caption
Gui, 33:Show, , help
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, help
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 34:Color, Black
Gui, 34:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, xpaste
WinSet, Transparent, 1, xpaste
WinSet, Region, 208-105 171-87 207-73 207-73 245-88 245-88 210-104 208-105, xpaste
Gui, 34:+LastFound +Toolwindow -Caption
Gui, 34:Show, , xpaste
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, xpaste
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 35:Color, Black
Gui, 35:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, selall
WinSet, Transparent, 1, selall
WinSet, Region, 162-86 125-68 125-68 163-58 163-58 203-70 204-70 163-86 163-86 162-86, selall
Gui, 35:+LastFound +Toolwindow -Caption
Gui, 35:Show, , selall
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, selall
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 36:Color, Black
Gui, 36:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, xbs
WinSet, Transparent, 1, xbs
WinSet, Region, 119-67 88-53 126-41 126-41 158-51 120-66 119-67, xbs
Gui, 36:+LastFound +Toolwindow -Caption +E0x08000000
Gui, 36:Show, NoActivate, xbs
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, xbs
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 37:Color, Black
Gui, 37:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, Exit
WinSet, Transparent, 1, Exit
WinSet, Region, 253-88 215-73 253-57 290-74 290-74 254-84 253-88, Exit
Gui, 37:+LastFound +Toolwindow -Caption
Gui, 37:Show, , Exit
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, Exit
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 38:Color, Black
Gui, 38:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, xdel
WinSet, Transparent, 1, xdel
WinSet, Region, 211-69 173-53 209-40 247-56 209-68 211-69, xdel
Gui, 38:+LastFound +Toolwindow -Caption
Gui, 38:Show, , xdel
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, xdel
DockA(IDG1, IDG, "x(0) y(0) w() h()")
WinGetPos , ShowX, ShowY, ShowW, ShowH, Cube_Calc
Gui, 39:Color, Black
Gui, 39:Show, x%ShowX% y%ShowY% w%ShowW% h%ShowH% Hide, xclr
WinSet, Transparent, 1, xclr
WinSet, Region, 164-54 132-40 165-24 165-24 205-41 205-41 164-50 164-50 164-54, xclr
Gui, 39:+LastFound +Toolwindow -Caption
Gui, 39:Show, , xclr
WinGet, IDG1, ID, Cube_Calc
WinGet, IDG, ID, xclr
DockA(IDG1, IDG, "x(0) y(0) w() h()")
Return
Code: Select all
1:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%1
Return
2:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%2
Return
3:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%3
Return
4:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%4
Return
5:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%5
Return
6:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%6
Return
7:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%7
Return
8:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%8
Return
9:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%9
Return
0:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%0
Return
plusl:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%+
Return
minus:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%-
Return
dot:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%.
Return
mult:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%*
Return
div:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%/
Return
equ:
Gui, 1:Submit, NoHide
answer := Eval(edit1)
GuiControl, 1:, edit1, %answer%
Return
pl:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%(
Return
pr:
Gui, 1:Submit, NoHide
GuiControl, 1:, edit1, %edit1%)
Return
xcopy:
Gui, 1:Submit, NoHide
ClipBoard = %edit1%
Return
zcut:
Gui, 1:Submit, NoHide
ClipBoard = %edit1%
GuiControl, 1:, edit1,
Return
help:
Run, Cube Calc Help.ahk
Return
xpaste:
GuiControl, 1:, edit1, %ClipBoard%
Return
selall:
GuiControl, 1:Focus, edit1,
Send, ^a
Return
xbs:
GuiControl, 1:Focus, edit1,
Send, {BS}
Return
xdel:
GuiControl, 1:Focus, edit1,
Send, {Del}
Return
xclr:
GuiControl, 1:, edit1,
Return
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 153 guests