Skip to content

Instantly share code, notes, and snippets.

@xcloudx01
Created February 3, 2019 09:00
Show Gist options
  • Save xcloudx01/2ad505e459d1b082e6d56df32c06eee8 to your computer and use it in GitHub Desktop.
Save xcloudx01/2ad505e459d1b082e6d56df32c06eee8 to your computer and use it in GitHub Desktop.
Change the colour of a GUI Edit box via 3 separate RGB sliders in AutoHotKey
#SingleInstance force
SetFormat, integer, hex
Gui, Add, Slider , x12 y19 w90 h20 vPipboyRed gSetColour Range0-255, 128
Gui, Add, Slider, x12 y59 w90 h20 vPipboyGreen gSetColour Range0-255, 128
Gui, Add, Slider, x12 y99 w90 h20 vPipboyBlue gSetColour Range0-255, 128
gosub,SetColour ;Set the default colour to what's defined above.
Gui, Add, Edit, x112 y19 w120 h100
Gui, Show, h147 w247
SetFormat, integer, d
Return
SetColour:
SetFormat, integer, hex
gui,submit,nohide
PipboyRed := GetHexGUIColour(PipboyRed)
PipboyGreen := GetHexGUIColour(PipboyGreen)
PipboyBlue := GetHexGUIColour(PipboyBlue)
Gui, Color,, %PipboyRed%%PipboyGreen%%PipboyBlue%
tooltip Red:%PipboyRed%`nGreen:%PipboyGreen%`nBlue:%PipboyBlue%
return
GuiClose:
ExitApp
GetHexGUIColour(InputNumber) ;Converts "0x0F" to "0F" and "1" to "01"
{
InputNumber := strreplace(InputNumber,"0x")
if StrLen(InputNumber) = 1
return "0" . InputNumber
else
return InputNumber
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment