I'm trying to use Class_Scrollgui to add the scrollbar, it is working great when I tested the example but I'm having no luck trying to add it to the gui I want. Source for Class_ScrollGUI (https://www.autohotkey.com/boards/viewtopic.php?f=6&t=6316)
I'm open to any suggestion anyone might have it doesn't have to be Class_SCrollGUI. Any help would be greatly appreciated.
Here is the modified code of my current gui that I would like to add a scrollbar to:
Code: Select all
#SingleInstance force
#Persistent
SetBatchLines -1
SysGet, Size, MonitorWorkArea
GuiRight := SizeRight - 147
Button_Right := SizeRight - 147
Button_Bottom := SizeBottom - 31
Gui, 1: Color, cFFFFFF
Loop, *
{
If (A_LoopFileName <> "AfterLemonScriptLauncher.ahk")
{
A_IndexCount := A_Index
If A_IndexCountMinus
A_IndexCount -= A_IndexCountMinus
YPos := A_IndexCount * 25 - 20
StringTrimRight, FileName%A_IndexCount%, A_LoopFileName, 4
RunPath%A_IndexCount% := A_LoopFileFullPath
Gui, 1: Add, Button, w110 h20 x5 y%YPos% gRun, % FileName%A_IndexCount%
Gui, 1: Add, Button, w20 h20 x120 Disabled y%YPos% vFileName2%A_IndexCount%, K
YPos%A_IndexCount% := YPos . "," . FileName%A_IndexCount%
}
else
{
A_IndexCountMinus++
continue
}
}
YPos += 50
GuiBottom := SizeBottom - YPos - 1
TitlePos := YPos - 21
ButtonPos := YPos - 25
Gui, 1: Font, w700 c000000
Gui, 1: Add, Text, w90 h20 x30 y%TitlePos% Center gDrag, Utilities
Gui, 1: Font, c000000
Gui, 1: Add, Button, w20 h20 x5 y%ButtonPos%, &-
Gui, 1: Add, Button, w20 h20 x120 y%ButtonPos%, &X
Gui, 1: +AlwaysOnTop +E0x08000000 -Caption +ToolWindow +Border
Gui, 1: Show, NoActivate w145 h%YPos% x%GuiRight% y%GuiBottom%, Main Window
return
Drag:
PostMessage, 0xA1, 2,,, A
return
Run:
Loop
{
If (A_GuiControl = FileName%A_Index%)
{
RunPath := RunPath%A_Index%
Run, "%RunPath%",,, ProgRun%A_Index%
ProcessRun := A_Index
break
}
}
GuiControl, Enable, FileName2%ProcessRun%
Gui, 1: Show, NoActivate w145 h%YPos% x%GuiRight% y%GuiBottom%, Main Window
return
ButtonK:
StringTrimLeft, RunningName, A_GuiControl,9
FileNameKill := ProgRun%RunningName%
Process, Close, % FileNameKill
GuiControl, Disable, FileName2%RunningName%
return
Button-:
Gui, 1: Cancel
Gui, 2: Color, cFFFFFF
Gui, 2: Font, w700 c000000
Gui, 2: Add, Text, w90 h20 x30 y9 Center gDrag, Utilities
Gui, 2: Font, c000000
Gui, 2: Add, Button, w20 h20 x5 y5, &+
Gui, 2: Add, Button, w20 h20 x120 y5, &X
Gui, 2: -Caption +AlwaysOnTop +E0x08000000 +Border
Gui, 2: Show, NoActivate w145 h30 x%Button_Right% y%Button_Bottom%, Minimized
return
2Button+:
Gui, 2: Destroy
Gui, 1: Show, NoActivate w145 h%YPos% x%GuiRight% y%GuiBottom%, Main Window
return
ButtonX:
2ButtonX:
ExitApp
Description from AfterLemon: Place this small script into a directory with other .ahk scripts and it will enumerate a list with links to run, and killswitches.
I love this script because I can drop it in any folder containing ahk's and it automatically collects all ahk's in the folder. Super useful for whenever I create new ahk scripts without having to manually create a button for each one and I don't have to remember a bunch of hotkeys assigned to launch different scripts. I also modified the script to not take focus away from any active window so that each button can be clicked to run a script to act on the active window if desired (NoActivate parameter). I'm not sure if that functionality can remain intact with the scrollbar added.
AfterLemon's script adds more buttons automatically starting from the bottom the more ahk files it finds in a directory. The problem I have is I have created too many ahk scripts to fit nicely within the gui and the buttons overflow over the top of the screen and are inaccessible, see example below. This is what I have so far and having no luck:
Code: Select all
#NoEnv
#SingleInstance force
#Persistent
#Include Class_ScrollGUI.ahk
SetBatchLines, -1
; ----------------------------------------------------------------------------------------------------------------------
; ChildGUI 1
Gui, new, +hwndHGUI +Resize
SetBatchLines -1
SysGet, Size, MonitorWorkArea
GuiRight := SizeRight - 147
Button_Right := SizeRight - 147
Button_Bottom := SizeBottom - 31
Gui, 1: Color, cFFFFFF
Loop, *
{
If (A_LoopFileName <> "AfterLemonScriptLauncher.ahk")
{
A_IndexCount := A_Index
If A_IndexCountMinus
A_IndexCount -= A_IndexCountMinus
YPos := A_IndexCount * 25 - 20
StringTrimRight, FileName%A_IndexCount%, A_LoopFileName, 4
RunPath%A_IndexCount% := A_LoopFileFullPath
Gui, 1: Add, Button, w110 h20 x5 y%YPos% gRun, % FileName%A_IndexCount%
Gui, 1: Add, Button, w20 h20 x120 Disabled y%YPos% vFileName2%A_IndexCount%, K
YPos%A_IndexCount% := YPos . "," . FileName%A_IndexCount%
}
else
{
A_IndexCountMinus++
continue
}
}
YPos += 50
GuiBottom := SizeBottom - YPos - 1
TitlePos := YPos - 21
ButtonPos := YPos - 25
Gui, 1: Font, w700 c000000
Gui, 1: Add, Text, w90 h20 x30 y%TitlePos% Center gDrag, Utilities
Gui, 1: Font, c000000
Gui, 1: Add, Button, w20 h20 x5 y%ButtonPos%, &-
Gui, 1: Add, Button, w20 h20 x120 y%ButtonPos%, &X
Gui, 1: +AlwaysOnTop +E0x08000000 -Caption +ToolWindow +Border
Gui, 1: Show, NoActivate w145 h%YPos% x%GuiRight% y%GuiBottom%, Main Window
return
Drag:
PostMessage, 0xA1, 2,,, A
return
Run:
Loop
{
If (A_GuiControl = FileName%A_Index%)
{
RunPath := RunPath%A_Index%
Run, "%RunPath%",,, ProgRun%A_Index%
ProcessRun := A_Index
break
}
}
GuiControl, Enable, FileName2%ProcessRun%
Gui, 1: Show, NoActivate w145 h%YPos% x%GuiRight% y%GuiBottom%, Main Window
return
ButtonK:
StringTrimLeft, RunningName, A_GuiControl,9
FileNameKill := ProgRun%RunningName%
Process, Close, % FileNameKill
GuiControl, Disable, FileName2%RunningName%
return
Button-:
Gui, 1: Cancel
Gui, 2: Color, cFFFFFF
Gui, 2: Font, w700 c000000
Gui, 2: Add, Text, w90 h20 x30 y9 Center gDrag, Utilities
Gui, 2: Font, c000000
Gui, 2: Add, Button, w20 h20 x5 y5, &+
Gui, 2: Add, Button, w20 h20 x120 y5, &X
Gui, 2: -Caption +AlwaysOnTop +E0x08000000 +Border
Gui, 2: Show, NoActivate w145 h30 x%Button_Right% y%Button_Bottom%, Minimized
return
2Button+:
Gui, 2: Destroy
Gui, 1: Show, NoActivate w145 h%YPos% x%GuiRight% y%GuiBottom%, Main Window
return
ButtonX:
2ButtonX:
ExitApp
; Create ScrollGUI1 with both horizontal and vertical scrollbars and scrolling by mouse wheel
Global SG1 := New ScrollGUI(HGUI, 400, 400, "+Resize +LabelGui1", 3, 4)
; Show ScrollGUI1
SG1.Show("ScrollGUI1", "y0 xcenter")
; ----------------------------------------------------------------------------------------------------------------------
; ChildGUI 2
Gui, New, +hwndHGUI2
Gui, Margin, 20, 20
Gui, Font, s32
Gui, Add, Text, xm Border Hidden vTX1, Test
Gui, Add, Text, x+m yp w460 h300 Center 0x200 Border Section, GUI number 2
Gui, Font
Gui, Add, Button, xs wp gShowHide, Show/Hide additional controls.
Gui, Font, s32
Gui, Add, Text, ys wp h300 Center 0x200 Border Hidden vTX2, Hidden Text 1
Gui, Add, Text, xs wp h300 Center 0x200 Border Hidden vTX3, Hidden Text 2
Gui, Add, Text, xs wp h300 Center 0x200 Border Hidden vTX4, Hidden Text 3
; Create ScrollGUI2 with both horizontal and vertical scrollbars
SG2 := New ScrollGUI(HGUI2, 600, 200, "+Resize +LabelGui2")
; Show ScrollGUI2
SG2.Show("ScrollGUI2", "x0 yCenter")
Return
; ----------------------------------------------------------------------------------------------------------------------
ShowHide:
GuiControlGet, V, %HGUI2%:Visible, TX1
GuiControl, %HGUI2%:Hide%V%, TX1
GuiControl, %HGUI2%:Hide%V%, TX2
GuiControl, %HGUI2%:Hide%V%, TX3
GuiControl, %HGUI2%:Hide%V%, TX4
SG2.AdjustToChild()
Return
; ----------------------------------------------------------------------------------------------------------------------
Gui1Close:
Gui1Escape:
ExitApp
; ----------------------------------------------------------------------------------------------------------------------
Gui1Size:
Return
Gui2Size:
Return
; ----------------------------------------------------------------------------------------------------------------------
Gui2Close:
Gui2Escape:
SG2 := ""
Return