GUI slider position and then destroy once clicked outside the box

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
chill8888
Posts: 43
Joined: 03 Dec 2016, 01:26

GUI slider position and then destroy once clicked outside the box

14 Apr 2021, 22:47

I'm trying to show a slider (bottom right corner aligned) at the position of the mouse when clicked on the menu item, and then have it destroyed immediately when clicked out of, similar to how windows natively does it. I'm unsure of both. What am I missing?

Also, is there a way to make the slider update the variable as it is moved by the user on a held click? Right now it only updates when I release the click.

Code: Select all

color := "0x36373F"
trans := transvar := 230
transcalc := (transvar/2.55) ; conversion from 255 to 100 for slider tooltip

OpacSlide:
Gui, Slider:New, +HwndSliderID +Owner +AlwaysOnTop -Caption
Gui, Slider:Add, Slider, vtransvar gOpac w150 TickInterval10 Page10 ToolTip, %transcalc%
Gui, Slider:Show, x-500 y-500 ; load off screen and reposition later?
WinGetPos,,, sliderW, sliderH, ahk_id %SliderID%
MouseGetPos, Xpos, Ypos
??? ; not sure how to position the GUI here
ToolTip, %SliderID%`n%sliderW%-%sliderH%`n`n%Xpos%-%Ypos% ; for testing
return

Opac:
GuiControlGet, OpacSlider
transcalc := transvar
transvar := transvar*(51/20) ; conversion from 100 to 255 for GUI opacity
WinSet, TransColor, %color% %transvar%, ahk_id %KeyboardID%
return
User avatar
mikeyww
Posts: 26854
Joined: 09 Sep 2014, 18:38

Re: GUI slider position and then destroy once clicked outside the box

15 Apr 2021, 05:51

Code: Select all

color := "0x36373F"
Gui, Slider:New, +HwndSliderID +Owner +AlwaysOnTop -Caption
Gui, Add, Slider, vtransvar gOpac w150 TickInterval10 Page10 ToolTip AltSubmit, % 230 / 2.55
OpacSlide:
MouseGetPos, xpos, ypos
Gui, Slider:Show, x%xpos% y%ypos%, Slide
Return

Opac:
Sleep, 200
ToolTip, % trans := Round(transvar * 2.55)
WinSet, TransColor, %color% %trans%, ahk_id %KeyboardID%
Return

#IfWinExist Slide ahk_class AutoHotkeyGUI ahk_exe AutoHotkey.exe
~LButton::
WinGetClass, class, A
If (class = "AutoHotkeyGUI")
 Return
SliderGuiEscape:
ToolTip
Gui, Slider:Hide
Return
#IfWinExist

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Giresharu, Google [Bot], inseption86, jomaweb, Rohwedder and 262 guests