Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

List All AHK Scripts in Directory in GUI


  • Please log in to reply
7 replies to this topic
AfterLemon
  • Moderators
  • 237 posts
  • Connoisseur of Boobs
  • Last active: Jan 04 2016 11:12 PM
  • Joined: 09 Oct 2012
Just throwing this out there as it is my first public script.
 
Place this small script into a directory with other .ahk scripts and it will enumerate a list with links to run, and killswitches.
Also incorporates a "minimize" feature and can be dragged.
 
Let me know what you think and if you can offer improvement ideas.
 
#Persistent
SetBatchLines -1
SysGet, Size, MonitorWorkArea
GuiRight := SizeRight - 147
Button_Right := SizeRight - 147
Button_Bottom := SizeBottom - 31
Gui, 1: Color, cFFFFFF
Loop, *.ahk
{
   If (A_LoopFileName <> "Main Window.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 -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, Autohotkey.exe "%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 +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


AfterLemon
  • Moderators
  • 237 posts
  • Connoisseur of Boobs
  • Last active: Jan 04 2016 11:12 PM
  • Joined: 09 Oct 2012

Depending on how this works, it may be used to enumerate a gui with .lnk items (e.g. in a Favourites folder).

Only issue is that the killswitches might not gather the processID.

 

Will test.



AfterLemon
  • Moderators
  • 237 posts
  • Connoisseur of Boobs
  • Last active: Jan 04 2016 11:12 PM
  • Joined: 09 Oct 2012

With a combination of WinWait and WinClose, this can be accomplished with .lnk items for windows folders.

 

For other executables (in this case Access Databases), it can be done simply with this...

 

I've removed the specification of using the autohotkey.exe from the Run GLabel. I've also changed the initial Loop parameters to search through .accdb rather than .ahk.

 

#Persistent
SetBatchLines -1
SysGet, Size, MonitorWorkArea
GuiRight := SizeRight - 147
Button_Right := SizeRight - 147
Button_Bottom := SizeBottom - 31
Gui, 1: Color, cFFFFFF
Loop, *.accdb
{
If (A_LoopFileName <> "Main Window.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 -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 +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


ozzii
  • Members
  • 167 posts
  • Last active: Oct 30 2015 04:54 PM
  • Joined: 23 Mar 2011

you have to change this:

Loop, *.accdb

Also I have to change w110 to w150 the button are too small for the names of the scripts.

Maybe to add an automatic way to have the right width for the buttons.

 

Also I can't see all my script because I have a lot. Maybe putting your buttons on a gui with a scroll.  



AfterLemon
  • Moderators
  • 237 posts
  • Connoisseur of Boobs
  • Last active: Jan 04 2016 11:12 PM
  • Joined: 09 Oct 2012

Fair enough. This worked for me for about 18 or so scripts. It was meant as a quick-launch for my specific system. You're welcome to customize it. I'm not sure how I'd make a scroll of buttons.



mozillan
  • Members
  • 2 posts
  • Last active: Sep 09 2013 10:09 AM
  • Joined: 18 Jul 2013

Fair enough. This worked for me for about 18 or so scripts. It was meant as a quick-launch for my specific system. You're welcome to customize it. I'm not sure how I'd make a scroll of buttons.

Great script. However, since it occupies the scrollbar, I find it difficult to scroll through the active window. I couldn't figure out how to move it slightly to the left, so the scrollbar is visible. Minimising is one alternative, but the main purpose of AHK is to make life simpler, isn't it?

 

P.S.

Hey, I didn't pay much attention to the fact that it can be dragged out of the way. This makes it all the more better. Thanks!!


Edited by mozillan, 09 September 2013 - 09:38 AM.


Abrin
  • Members
  • 50 posts
  • Last active: Aug 16 2016 03:24 AM
  • Joined: 19 Jan 2014

Sorry for such a newbie question, but the font on the button is so big that I can't see what is written on it.

 

I tried fixing it here where it says: Gui, 2: Add, Text, w90 h20 x30 y9 Center gDrag, Utilities

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 +Border
Gui, 2: Show, NoActivate w145 h30 x%Button_Right% y%Button_Bottom%, Minimized
return

But it didn't work for me and I am confused to what to try next. :S

 

Other than that I adore the program! It is nice having a sidebar of my common scripts up. :D

 

(Edited to clarify what line I have tried.)



Abrin
  • Members
  • 50 posts
  • Last active: Aug 16 2016 03:24 AM
  • Joined: 19 Jan 2014

The more I keep playing with this script the more I fall in love with it.

 

Thanks again. :D