forked from ChrisS85/CGUI_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScriptLauncher.ahk
50 lines (49 loc) · 1.23 KB
/
ScriptLauncher.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
This script demonstrates the usage of ListViews and CFolderDialog
*/
gui := new ScriptLauncher()
#include <CGUI>
Class ScriptLauncher Extends CGUI
{
listView1 := this.AddControl("ListView", "listView1", "x12 y40 w334 h217", "Files")
button1 := this.AddControl("Button", "button1", "x271 y12 w75 h23", "Browse")
textBox1 := this.AddControl("Edit", "textBox1", "x12 y14 w253 h20", "")
statusStrip1 := this.AddControl("StatusBar", "statusStrip1", "w356 h22", "Double-click a script to launch it!")
__New()
{
this.Title := "ScriptLauncher"
this.DestroyOnClose := true
this.CloseOnEscape := true
this.Show()
}
listView1_DoubleClick(RowNumber)
{
run, % this.textBox1.Text "\" this.listView1.SelectedItem[1]
}
button1_Click()
{
;Show a folder dialog to choose a directory
FolderDialog := new CFolderDialog()
FolderDialog.Folder := this.textBox1.Text
if(FolderDialog.Show())
{
this.textBox1.Text := FolderDialog.Folder
this.FolderChanged()
}
}
textBox1_TextChanged()
{
this.FolderChanged()
}
FolderChanged()
{
this.ListView1.Items.Clear()
Loop, % this.TextBox1.Text "\*.ahk", 0, 0
this.listView1.Items.Add("", A_LoopFileName)
}
PostDestroy()
{
if(!this.Instances.MaxIndex())
ExitApp
}
}