dlaso

Script List GUI

Jun 11th, 2015
2,892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Taken and modified from AfterLemon's Script here:
  2. ; http://www.autohotkey.com/board/topic/93997-list-all-ahk-scripts-in-directory-in-gui/
  3.  
  4. #Persistent
  5. #SingleInstance Force
  6. SetBatchLines -1
  7. SysGet, Size, MonitorWorkArea
  8. SetTitleMatchMode, 2
  9.  
  10.  
  11.  
  12.  
  13. ;
  14. ButtonWidth := 160                      ; Can change these values
  15. IndentFromRight := 30
  16. ;
  17. XButtonXCoord := ButtonWidth + 10       ; Don't change these
  18. TitleWidth := ButtonWidth - 20
  19. SceneWidth := ButtonWidth + 35
  20. ;
  21. GuiRight := SizeRight - IndentFromRight - SceneWidth
  22. Button_Right := SizeRight - IndentFromRight - SceneWidth
  23. Button_Bottom := SizeBottom - 39
  24. ;
  25. Gui, 1: Color, cFFFFFF
  26. Loop, %A_ScriptDir%\*.ahk
  27. {
  28.    If (A_LoopFileName <> "Main Window.ahk")
  29.    {
  30.       A_IndexCount := A_Index
  31.       If A_IndexCountMinus
  32.          A_IndexCount -= A_IndexCountMinus
  33.       YPos := A_IndexCount * 25 - 20
  34.       StringTrimRight, FileName%A_IndexCount%, A_LoopFileName, 4
  35.       RunPath%A_IndexCount% := A_LoopFileFullPath
  36.       Gui, 1: Add, Button, w%ButtonWidth% h20 x5 y%YPos% gRun, % FileName%A_IndexCount%
  37.       Gui, 1: Add, Button, w20 h20 x%XButtonXCoord% Disabled y%YPos% vFileName2%A_IndexCount%, K
  38.       YPos%A_IndexCount% := YPos . "," . FileName%A_IndexCount%
  39.    }
  40.    else
  41.    {
  42.       A_IndexCountMinus++
  43.       continue
  44.    }
  45. }
  46. YPos += 50
  47. GuiBottom := SizeBottom - YPos
  48. TitlePos := YPos - 21
  49. ButtonPos := YPos - 25
  50. Gui, 1: Font, w700 c000000
  51. Gui, 1: Add, Text, w%TitleWidth% h20 x30 y%TitlePos% Center gDrag, AHK Scripts
  52. Gui, 1: Font, c000000
  53. Gui, 1: Add, Button, w20 h20 x5 y%ButtonPos%, &-
  54. Gui, 1: Add, Button, w20 h20 x%XButtonXCoord% y%ButtonPos%, &X
  55. Gui, 1: +AlwaysOnTop -Caption +ToolWindow +Border
  56. Gui, 1: Show, NoActivate w%SceneWidth% h%YPos% x%GuiRight% y%GuiBottom%, Main Window
  57. ;
  58. WinGetPos X, Y, Width, Height, Main Window
  59. MaxY := SizeBottom - Height
  60. MaxX := SizeRight - Width - IndentFromRight
  61. WinMove Main Window, , %MaxX%, %MaxY%
  62. return
  63.  
  64.  
  65. !#x::
  66. IfWinExist Minimized ahk_class AutoHotkeyGUI, AHK Scripts
  67. {
  68.    gosub 2Button+
  69.    return
  70. }
  71. else IfWinExist Main Window ahk_class AutoHotkeyGUI, AHK Scripts
  72. {
  73.    gosub Button-
  74.    return
  75. }
  76.  
  77.  
  78. Drag:
  79.   PostMessage, 0xA1, 2,,, A
  80. return
  81.  
  82. Run:
  83.    Loop
  84.    {
  85.    If (A_GuiControl = FileName%A_Index%)
  86.    {
  87.       RunPath := RunPath%A_Index%
  88.       Run, Autohotkey.exe "%RunPath%",,, ProgRun%A_Index%
  89.       ProcessRun := A_Index
  90.       break
  91.    }
  92.    }
  93.    GuiControl, Enable, FileName2%ProcessRun%
  94.    Gui, 1: Show, NoActivate w%SceneWidth% h%YPos% x%GuiRight% y%GuiBottom%, Main Window
  95.    ;
  96.    WinGetPos X, Y, Width, Height, Main Window
  97.    MaxY := SizeBottom - Height
  98.    MaxX := SizeRight - Width - IndentFromRight
  99.    WinMove Main Window, , %MaxX%, %MaxY%
  100. return
  101.  
  102.  
  103. ButtonK:
  104.   StringTrimLeft, RunningName, A_GuiControl,9
  105.    FileNameKill := ProgRun%RunningName%
  106.    Process, Close, % FileNameKill
  107.    GuiControl, Disable, FileName2%RunningName%
  108. return
  109.  
  110. Button-:
  111.    Gui, 1: Cancel
  112.    Gui, 2: Color, cFFFFFF
  113.    Gui, 2: Font, w700 c000000
  114.    Gui, 2: Add, Text, w%TitleWidth% h20 x30 y9 Center gDrag, AHK Scripts
  115.    Gui, 2: Font, c000000
  116.    Gui, 2: Add, Button, w20 h20 x5 y5, &+
  117.    Gui, 2: Add, Button, w20 h20 x%XButtonXCoord% y5, &X
  118.    Gui, 2: -Caption +AlwaysOnTop +Border
  119.    Gui, 2: Show, NoActivate w%SceneWidth% h30 x%Button_Right% y%Button_Bottom%, Minimized
  120.    WinGetPos X, Y, Width, Height, Minimized
  121.    MaxY := SizeBottom - Height
  122.    MaxX := SizeRight - Width - IndentFromRight
  123.    WinMove Minimized, , %MaxX%, %MaxY%
  124. return
  125.  
  126. 2Button+:
  127.    Gui, 2: Destroy
  128.    Gui, 1: Show, NoActivate w%SceneWidth% h%YPos% x%GuiRight% y%GuiBottom%, Main Window
  129.    WinGetPos X, Y, Width, Height, Main Window
  130.    MaxY := SizeBottom - Height
  131.    MaxX := SizeRight - Width - IndentFromRight
  132.    WinMove Main Window, , %MaxX%, %MaxY%
  133. return
  134.  
  135.  
  136. ButtonX:
  137. 2ButtonX:
  138. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment