Hi teadrinker,
Thank you heaps for the help, can you tell me what is different between the 1st and 2nd approaches? I have very little programming experience, but have a solid understanding of technology. What I am trying to do is piece together bits of code and learn as I go.
To give you context on my project I am trying to increase my functionality of my Microsoft Surface Dial. Below is how I plan on doing this.
- On single press of the dial a gui will come up showing a list that of slider you can select using Up/down scroll events.
- Once you have landed on the slider you want, single press of the dial will select the line, close the gui and match a corresponding slider control within lightroom.
I have gotten a separate working which I can control a slider using the dial, the script here forms part of how I select the slider I want to control. There is a a bit of work still to do, but I need to slowly piece it all together.
Below is what I have done to date on the gui, I have tried to put your script as a subroutine but it is not working, will need to tinker more
Code: Select all
y := 31
Width := 500
Gui, +LastFound
WinSet, Transparent, 240
Gui, Color, cD0D0D0
Gui, Margin, 0, 0
Gui, Font, s11 808080 Bold
;Gosub Scrollbar
Gui, Add, Progress, % "x-0 y0 w" (Width+2) " h30 Background404040 Disabled hwndHPROG"
Gui, Add, Text, % "x0 y0 w" Width-400 " h30 BackgroundTrans Center 0x200 gGuiMove vCaption", Select Slider
Gui, Font, s8
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 BackgroundTrans vTX1 gS1", Slider 1
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 BackgroundTrans vTX2 gS2", Slider 2
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 BackgroundTrans vTX3 gs3", Slider 3
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 BackgroundTrans vTX4 gs4", Slider 4
Gui, Add, Text, % "x7 y+10 w" (Width-14) "r1 +0x4000 BackgroundTrans vTX5 gClose", Close
Gui, Add, Text, % "x7 y+10 w" (Width-14) "h5 vP"
GuiControlGet, P, Pos
H := PY + PH
Gui, -Caption
WinSet, Region, 0-0 w%Width% h%H% r6-6
Gui, Show, % "w" Width " NA" " x" 500 " y200"
WinSet AlwaysOnTop
return
GuiMove:
PostMessage, 0xA1, 2
return
S1:
MsgBox, You clicked Slider 1 (%A_GuiControl%).
return
S2:
MsgBox, You clicked Slider 2 (%A_GuiControl%).
return
S3:
MsgBox, You clicked Slider 3 (%A_GuiControl%).
return
S4:
MsgBox, You clicked Slider 4 (%A_GuiControl%).
return
Scrollbar:
H := PY + PH
Size := H
number_of_steps := 6
Height := Size / number_of_steps
Gui, New, ToolWindow -Caption HWNDhBack AlwaysOnTop
Gui, +0x02000000 ; WS_CLIPCHILDREN
Gui, Color, cD0D0D0
Gui, New, -Caption HWNDhThumb Parent%hBack%
Gui, Color, 404040
Gui, Show, NA x0 y0 w500 h%Height%
Gui, %hBack%: Show, w500 h%Size%
fn := Func("WM_LBUTTONDOWN").Bind(hThumb)
OnMessage(0x201, fn) ; WM_LBUTTONDOWN
return
Esc:: ExitApp
F5:: Reload
;-------------------------------------------------------------------------------
#If WinActive("ahk_id " hBack)
;-------------------------------------------------------------------------------
WheelUp:: Wheel("Up")
WheelDown:: Wheel("Dn")
#If ; end
;-------------------------------------------------------------------------------
WM_LBUTTONDOWN(hThumb, wp, lp, msg, hWnd) { ; event handler
;-------------------------------------------------------------------------------
static pos := 0, maxPos, dpi := A_ScreenDPI / 96
global Height, Size
if (maxPos = "")
maxPos := (Size-Height) * dpi
if (hThumb = hWnd) {
MouseGetPos,, prevY
while GetKeyState("LButton", "P") {
MouseGetPos,, Y
newPos := pos + Y - prevY
newPos := clamp(newPos, 0, maxPos)
Gui, %hThumb%: Show, NA x0 w500 y%newPos% h%H%
ToolTip, % Round(newPos * 100 / maxPos)
Sleep, 10
}
}
if newPos
pos := newPos
ToolTip ; off
}
;-------------------------------------------------------------------------------
Wheel(Direction) { ; callled by hotkeys
;-------------------------------------------------------------------------------
static pos := 0, dpi := A_ScreenDPI / 96
global hThumb, Height, Size, number_of_steps
pos += (Direction = "Up") ? -1 : 1
pos := clamp(pos, 0, number_of_steps - 1)
newY := pos * Size / number_of_steps
Gui, %hThumb%: Show, NA x0 w500 y%newY% h%Height%
}
;-------------------------------------------------------------------------------
clamp(Variable, min, max) { ; limit variable range to [min..max]
;-------------------------------------------------------------------------------
Return, (Variable < min) ? min
: (Variable > max) ? max : Variable
}
Return
Escape::
ExitApp
return
Close:
ExitApp