This is extreme beta, as there are many things I would want to implement, but am finding it difficult to proceed as currently listviews are too weak.
Supports drag and drop for folders and files. Will allow randomly generated
secure passwords based on findings from Thalon.
Useful for large projects as constant recompiling can be quickened and passwords automated.
Thanks to Thalon for giving me the information on passwords necessary for this and majkinetor for icon dialogue.
Update:
1.01 - Trailing quoatation removed when password specified. added ability to move up and down to choose order of compilation. Finds ahk2exe.exe for registry.
Code:
;#############################################################################################################
;#############################################################################################################
;AHKompile v1.01 by Tariq Porter
;#############################################################################################################
;#############################################################################################################
#Persistent
#SingleInstance, Force
DetectHiddenWindows, On
SetTitleMatchMode, Regex
SetTitleMatchMode, Slow
SetWinDelay, 0
Process, Priority,, High
SetBatchLines, 0
AppName := "AHKompile"
VersionNumber := "1.01"
Space := " "
RegRead, Compiler, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Ahk2Exe.exe
1RString := "#$'()*+,-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|}~"
OddBall := "ß§°´²³äöü"
StringSplit, 1RStringArray, 1RString
StringSplit, OddBallArray, OddBall
;#############################################################################################################
Gui, 1: Add, ListView, x10 y10 w680 h300 vMyListView gMyListView NoSort -LV0x10 NoSortHdr +AltSubmit Count10 Checked, Compile | Icon | AHK%Space% | Password%Space%
LV_ModifyCol(3, "AutoHdr Left")
Gui, 1: Add, Button, x10 y330 w75 r1 -Multi -Wrap gClear, &Clear
Gui, 1: Add, Button, xp+0 y+20 w75 r1 -Multi -Wrap gDelete, &Delete
Gui, 1: Add, Button, x+10 y330 w75 r1 -Multi -Wrap gGenerate, &Generate
Gui, 1: Add, Button, xp+0 y+20 w75 r1 -Multi -Wrap gIcon, &Icon...
Gui, 1: Add, Button, x+40 y330 w75 r1 -Multi -Wrap gMoveUp, &MoveUp
Gui, 1: Add, Button, xp+0 y+20 w75 r1 -Multi -Wrap gMoveDown, &MoveDown
Gui, 1: Add, Button, x+245 y330 w75 r1 -Multi -Wrap gCompile, &Compile
Gui, 1: Add, Button, x+10 yp+0 w75 r1 -Multi -Wrap gExit, &Exit
Gui, 1: Show, w700 h405, %AppName% settings - %VersionNumber%
Return
;#############################################################################################################
MoveUp:
RowHighlighted := LV_GetNext(0,"Focused")
If RowHighlighted = 1
Return
Direction := RowHighlighted - 1
GoSub, Move
Return
;#############################################################################################################
MoveDown:
RowHighlighted := LV_GetNext(0,"Focused")
Direction := RowHighlighted + 1
GoSub, Move
Return
;#############################################################################################################
Move:
If RowHighlighted <= 0
Return
NumberRows := LV_GetCount()
If NumberRows = 1
Return
NextChecked := LV_GetNext(RowHighlighted-1, "Checked")
If NextChecked = %RowHighlighted%
NextChecked = 1
Else
NextChecked = 0
LV_GetText(AHK, RowHighlighted, 3)
LV_GetText(Password, RowHighlighted, 4)
LV_Delete(RowHighlighted)
If NextChecked = 1
LV_Insert(Direction, "Check Focus Select Vis Col3", AHK, Password)
Else
LV_Insert(Direction, "Focus Select Vis Col3", AHK, Password)
Return
;#############################################################################################################
Delete:
Gui, 1: Submit, NoHide
NumberRows := LV_GetCount()
RowNumber =
Loop
{
RowNumber := LV_GetNext(0)
If !RowNumber
Break
LV_Delete(RowNumber)
}
Return
;#############################################################################################################
Clear:
LV_Delete()
Return
;#############################################################################################################
Compile:
CheckFocus = Checked
GoSub, CheckEnable
BatContents =
Loop, %ActiveNum%
{
LV_GetText(Source, CheckedBox%A_Index%, 3) ; Source
LV_GetText(Password, CheckedBox%A_Index%, 4) ; Password
If Password
FullPassword := " /pass " . """" . Password . """"
BatContents .= """" . Compiler . """" . " /in " . """" . Source """" . FullPassword . " /nodecompile`n"
}
BatContents .= "del " . """" . A_ScriptDir . "\compile.bat" . """"
;MsgBox, %BatContents%
FileDelete, %A_ScriptDir%\compile.bat
FileAppend, %BatContents%, %A_ScriptDir%\compile.bat
Run, %COMSPEC% /c "%A_ScriptDir%\compile.bat" ; ,,Hide can be added when script finished
Return
;#############################################################################################################
CheckEnable:
Gui, 99: Submit, NoHide
NumberRows := LV_GetCount()
ActiveNum =
RowNumber = 0
Loop
{
If CheckFocus = Checked
CheckedBox%A_Index% := LV_GetNext(RowNumber, "Checked")
If CheckFocus = Selected
CheckedBox%A_Index% := LV_GetNext(RowNumber)
RowNumber := CheckedBox%A_Index%
If !CheckedBox%A_Index%
Break
ActiveNum++
}
Return
;#############################################################################################################
Exit:
ExitApp
Return
;#############################################################################################################
MyListView:
Return
;#############################################################################################################
Icon:
NumRows := LV_GetCount()
RowHighlighted := LV_GetNext(0,"Focused")
hwndA := DllCall("GetActiveWindow")
CmnDlg_ChooseIcon(icon, idx, hwndA)
ImageListID := IL_Create(10, 10)
;LV_SetImageList(ImageListID) ; Not implemented until icon can be moved to 3rd column
;IL_Add(ImageListID, icon, idx)
;LV_Modify(RowHighlighted, "Col3 Icon1")
Return
;#############################################################################################################
Generate:
CheckFocus = Selected
GoSub, CheckEnable
Loop, %ActiveNum%
{
Loop, %OddBallArray0%
Random, 1ON%A_Index%, 1, 30
2RString =
Loop
{
If A_Index in %ON1%,%1ON2%,%1ON3%,%1ON4%,%1ON5%,%1ON6%,%1ON7%,%1ON8%,%1ON9%
{
Random, 2ON, 1, %OddBallArray0%
2RString .= OddBallArray%2ON%
}
Else
{
Random, RNum, 1, %1RStringArray0%
2RString .= 1RStringArray%RNum%
}
If StrLen(2RString) >= 30
Break
}
LV_Modify(CheckedBox%A_index%, "Col4", 2RString)
}
Return
;#############################################################################################################
GuiDropFiles:
Gui, 1: -Redraw
Loop, Parse, A_GuiEvent, `n
{
Loop, %A_LoopField%\*.ahk, 0, 1
LV_ADD("Col3 Check", A_LoopFileFullPath)
SplitPath, A_LoopField,,, Extension
If Extension = ahk
LV_ADD("Col3 Check", A_LoopField)
}
LV_ModifyCol(3, "AutoHdr")
LV_ModifyCol(4, "AutoHdr")
Gui, 1: +Redraw
Return
;#############################################################################################################
CmnDlg_ChooseIcon(ByRef sIcon, ByRef idx, hGui=0)
{
global
idx--
VarSetCapacity(wIcon, 1025, 0)
If sIcon
{
r := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "Str", sIcon, "Int", StrLen(sIcon), "UInt", &wIcon, "Int", 1025)
If !r
Return false
}
r := DllCall(DllCall("GetProcAddress", "Uint", DllCall("LoadLibrary", "str", "shell32.dll"), "Uint", 62), "uint", hGui, "uint", &wIcon, "uint", 1025, "intp", idx)
If !r
Return false
len := DllCall("lstrlenW", "UInt", &wIcon)
VarSetCapacity(sIcon, len, 0)
r := DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", &wIcon, "Int", len, "Str", sIcon, "Int", len, "UInt", 0, "UInt", 0)
If !r
Return false
idx++
Return true
}