-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvGUI.ahk
107 lines (98 loc) · 2.84 KB
/
convGUI.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
; Generated by AutoGUI 2.5.7
#SingleInstance Force
#NoEnv
#Include d:\util\AutoGUI\convertFile.ahk
SetWorkingDir %A_ScriptDir%
SetBatchLines -1
global aFiles, sInputFolder
aFiles := []
;----- Start of GUI
Gui +Resize
Gui Font, s12, 微軟正黑體
Gui Color, 0xCFFEF7
Gui Font
Gui Font, s14 Bold Underline c0xFF0000
Gui Add, Text, x168 y8 w270 h23 +0x200, 檔案格式轉換工具 v1.0
Gui Font
Gui Font, s12, 微軟正黑體
Gui Add, Text, hWndhTxt2 x16 y72 w242 h23 +0x200, 選擇要轉換的檔案(多選)
Gui Add, Text, x-3 y42 w631 h2 +0x10
Gui Font
Gui Font, s10
Gui Add, Edit, hWndhEdtValue vEdtFiles x264 y56 w221 h60
Gui Font
Gui Font, s12, 微軟正黑體
Gui Font
Gui Font, s10, 細明體
Gui Add, Button, gBtnSelectFiles x496 y56 w110 h60, 選擇檔案...
Gui Font
Gui Font, s12, 微軟正黑體
Gui Add, Text, x16 y144 w242 h23 +0x200, 輸出資料夾
Gui Add, Edit, vEdtOutput x264 y136 w221 h36
Gui Font
Gui Font, s10, 細明體
Gui Add, Button, gBtnSelectOutput x496 y128 w110 h60, 選擇檔案...
Gui Font
Gui Font, s12, 微軟正黑體
Gui Add, Text, x16 y208 w242 h23 +0x200, 輸出格式
Gui Add, ListBox, vLbFormat x264 y208 w222 h129, PDF|DOCX|TXT|HTML|ODF
Gui Add, Button, gExecute x176 y376 w111 h47, &Y 開始轉檔
Gui Add, Button, x336 y376 w111 h47 gClose, &N 關閉
Gui Show, w620 h463, 檔案格式轉換工具 v1.0
;----- End of GUI
Return
BtnSelectFiles:
FileSelectFile, files, M3 ; M3 = Multiselect existing files.
if (files = "") {
;MsgBox, The user pressed cancel.
return
}
sInputFolder := ""
_sSelected := ""
_iCount := 0
Loop, parse, files, `n
{
if (A_Index = 1) {
;MsgBox, The selected files are all contained in %A_LoopField%.
sInputFolder = %A_LoopField%
} else {
_iCount++
;MsgBox, 4, , The next file is %A_LoopField%. Continue?
_sFilename := sInputFolder . "\" . A_LoopField
aFiles.push(_sFilename)
_sSelected := _sSelected . _sFilename . "`n"
IfMsgBox, No, break
}
}
;MsgBox count=%_iCount%
GuiControl,, edtFiles, %_iCount%個檔案: %_sSelected%
Return
BtnSelectOutput:
FileSelectFolder, folder, *C:\Users\%A_UserName%\Documents, 3, 選擇輸出資料夾
if (folder = "") {
;MsgBox, The user pressed cancel.
return
}
GuiControl,, EdtOutput, %folder%
Return
EdtFiles:
Return
Execute:
Gui, Submit
;MsgBox output folder=%EdtOutput%, format=%LbFormat%
; filename含有路徑
for index, filename in aFiles
{
;MsgBox 第[%index%]個檔=%filename%
_iPos := InStr(filename, ".")
_sFilenameWithoutExt := Substr(filename, 1, _iPos)
_sFilenameWithoutExt := StrReplace(_sFilenameWithoutExt, sInputFolder, EdtOutput)
_sOutputFilename := _sFilenameWithoutExt . LbFormat
;MsgBox output filename=%_sOutputFilename%
convertFile(filename, _sOutputFilename)
}
Return
Close:
GuiEscape:
GuiClose:
ExitApp