I am working to my GUI CSV STATISTICS, but i am bad at chart in gui and nice design. (I wanna keep all the code in one ahk file)
I need professional help, if someone want to join project?
it will be really nice to have possibility to change the graph design by right click or add a customization menu.
I need export menu to excel, export all 13 file in one. To export graphs.
Or is better to make a menu to go to graph gui and display them there?
Open to ideas!
Code: Select all
;=========================================================================================================================================;
;REV//GLOBAL//MENU
;=========================================================================================================================================;
;12-Jul-23/r00:Creating the script.
;19-Jul-23/r00:Change the order of events;add 2nd srch bar;add grid MLV2.
;21-Jul-23/r00:Change background;addICO;addLogo;add MLV3;FillMLV2;FillMLV3;remove Fill;
;24-Jul-23/r00:Add splashtxt FillMLV2;add timer+gui FillMLV2;
PassedCount := 0
OpenCount := 0
ArcCount := 0
ShortCount := 0
Menu, tray, icon, %A_ScriptDir%\Pictures\TQT8.png
Menu, tray, NoStandard ;[revent Open, pause script, Suspend Hotkey, Exit menu]
Menu, tray, add, Exit, Closeall ;[In case i wanna put Exit to Tray meniu]
Menu, Tray, Tip , TQT-Interface`nRev:00`nAuthor:Valcon`nUpdate:24.07.23
;=========================================================================================================================================;
;AutoHotKey Environment Settings/ Auto-Execute
;=========================================================================================================================================;
;#Include Win10_Gui.ahk ;[GUI change design, not tested]
;#Include gdip_all.ahk ;[This hellps with GIF inside GUI]
;#SingleInstance, Force ;[Allow only one running instance of script]
;#Persistent ;[Keep the script permanently running until terminated]
;#NoEnv ;[Avoid checking empty variables for environment variables]
;#Warn ;[Enable warnings to assist with detecting common errors]
;#NoTrayIcon ;[Disable the tray icon of the script]
SendMode Input ;[Recommended for new script due to its superior speed and reliability]
SetWorkingDir, %A_ScriptDir% ;[Set the working directory of the script]
SetBatchLines, -1 ;[The speed at which the lines of the script are executed]
;SetTitleMatchMode, 2 ;[Set the title match mode to match any window title containing the specified text]
;SetWinDelay,-1 ;[The delay to occur after modifying a window]
;SetControlDelay,-1 ;[The delay to occur after modifying a control]
;OnExit("OnUnload") ;[Run a subroutine or function when exiting the script]
;=========================================================================================================================================;
;AutoHotKey Start/Reload/Exit
;=========================================================================================================================================;
{
^+x::exitapp
^+Q::suspend
Return
^+R:: reload
SoundBeep, 750, 400
}
Return
^+S:: ;[Start script command]
;=========================================================================================================================================;
;Initialise & Graphical user interface (GUI)
;=========================================================================================================================================;
;+DPIScale=GUI elements in your script will automatically scale according to the DPI settings of the user's display.
;-Resize=Disables the ability to resize the GUI window by dragging its edges or corners.
;+OwnDialogs=Allows you to define your custom GUI to handle file selection or message box display.
;-AlwaysOnTop=GUI window that does not stay on top of other windows by default.
;-Disabled=Gui command to create a graphical user interface (GUI) window with its controls initially disabled.
;-SysMenu=Exit X, miximize, put in bar.
;+Owner=minimize nice.
Gui,1: -DPIScale -Resize +MaximizeBox -AlwaysOnTop -Disabled +SysMenu +Owner +Caption +Border
LVArray := {}
wa:=A_screenwidth,ha:=A_screenHeight,xx:=120 ;[Screen size]
;Gui, Add, Picture, Background, %A_ScriptDir%\Pictures\TQT8.png ;[Replace with the path to your image]
Gui,1:Color,Teal,White ;[Teal, Lime]
Gui,1:Font,s13 cBlack,Calibri ;[Text inside the windows]
;------------------------------------------------------------------------------------------------------------------------
TreeRoot = \\10.67.1.22\Testing\Ploiesti\00-ECI\01-ECB-TRANSABILITY\
treerootx:=treeroot
;------------------------------------------------------------------------------------------------------------------------
x:=(wa*1)/xx,y:=(ha*1)/xx,y2:=(ha*30)/xx,w:=(wa*20)/xx,h:=(ha*5)/xx
Gui, Add, TreeView, vMyTreeView x%x% y%y% w%w% h%h% w%w% backgroundWhite gMyTreeView ImageList%ImageListID%
;------------------------------------------------------------------------------------------------------------------------
;Search box xy/ wh/ disply text/
x:=(wa*1)/xx,y:=(ha*7)/xx
x:=(wa*1)/xx,y:=(ha*7)/xx,w:=(wa*20)/xx,h:=(ha*2.9)/xx
Gui, Add, Edit,x%x% y%y% w%w% h%h% -hscroll hWndHED1 vSRCH gSearch
SendMessage 0x1501, 10, "SEARCH",, ahk_id %hed1% ;msg to the search bar.
;------------------------------------------------------------------------------------------------------------------------
; Second search box xy/ wh/ display text/
x:=(wa*1)/xx,y:=(ha*11)/xx
x:=(wa*1)/xx,y:=(ha*11)/xx,w:=(wa*20)/xx,h:=(ha*2.9)/xx
Gui, Add, Edit, x%x% y%y% w%w% h%h% -hscroll hWndHED2 vSRCH2 gSearchInFile
SendMessage 0x1501, 10, "SEARCH IN FILE",, ahk_id %hed2% ;msg to the second search bar.
;------------------------------------------------------------------------------------------------------------------------
;MENU MLV1
x:=(wa*1)/xx,y:=(ha*15)/xx,w:=(wa*20)/xx,h:=(ha*45)/xx
Gui, Add, ListView, vMLV1 x%x% y%y% w%w% h%h% backgroundSilver gMLV1 AltSubmit +Grid, ECB|FILE MODIFIED
T1:=(wa*7)/xx,T2:=(wa*12)/xx
LV_ModifyCol(1, "Center " . T1)
LV_ModifyCol(2, "Center " . T2)
;------------------------------------------------------------------------------------------------------------------------
;MENU MLV2
x:=(wa*22)/xx,y:=(ha*1)/xx,w:=(wa*70)/xx,h:=(ha*59)/xx
Gui, Add, ListView, vMLV2 x%x% y%y% w%w% h%h% backgroundSilver gMLV2 AltSubmit +Grid, ECB| ANTENNA| TEST NO| STATE| NAME| PIN1| PIN2| VALUE| TEST END
Gui, Add, Picture, x500 y625 Background, %A_ScriptDir%\Pictures\Yazaki.png
T1:=(wa*5)/xx,T2:=(wa*16)/xx,T3:=(wa*5)/xx,T4:=(wa*5)/xx,T5:=(wa*4)/xx,T6:=(wa*8)/xx,T7:=(wa*8)/xx,T8:=(wa*7)/xx,T9:=(wa*10)/xx
LV_ModifyCol(1, "Center " . T1)
LV_ModifyCol(2, "Center " . T2)
LV_ModifyCol(3, "Center " . T3)
LV_ModifyCol(4, "Center " . T4)
LV_ModifyCol(5, "Center " . T5)
LV_ModifyCol(6, "Center " . T6)
LV_ModifyCol(7, "Center " . T7)
LV_ModifyCol(8, "Center " . T8)
LV_ModifyCol(9, "Center " . T9)
;------------------------------------------------------------------------------------------------------------------------
;MENU MLV3
x:=(wa*1)/xx,y:=(ha*62)/xx,w:=(wa*20)/xx,h:=(ha*14.5)/xx
Gui, Add, ListView, vMLV3 x%x% y%y% w%w% h%h% backgroundSilver gMLV3 AltSubmit +Grid, STATE|NO
T1:=(wa*7)/xx,T2:=(wa*12)/xx
LV_ModifyCol(1, "Center " . T1)
LV_ModifyCol(2, "Center " . T2)
;------------------------------------------------------------------------------------------------------------------------
Gui, Add, StatusBar
w1:=(wa*6)/xx,w2:=(wa*9)/xx
SB_SetParts(w1,w2) ;Create three parts in the bar (the third part fills the remaining width).
;=========================================================================================================================================;
;Script
;=========================================================================================================================================;
; Add folders and their subfolders to the tree. Display the status in case loading takes a long time:
SplashTextOn, 250, 25,, LOADING THE FILES...
TreeRoot := RTrim(TreeRoot, "\") ;- Remove trailing backslashes, if any.
SplitPath, TreeRoot, TreeRootName, TreeRootDir ;- Split TreeRoot into TreeRootName and TreeRootDir.
If (TreeRootName) ;- If TreeRootName is not empty
TreeRootID := TV_Add(TreeRootName, 0, "Expand Icon4") ;- add it to the TreeView
Else ;- Else
TreeRootID := 0 ;- set TreeRootId to zero.
AddSubFoldersToTree(TreeRoot, TreeRootID) ;- Call AddSubFolders() passing TreeRoot and TreeRootID
TreeRoot := TreeRootDir ;- Set TreeRoot to TreeRootDir.
SplashTextOff
;x:=(wa*.1)/xx,y:=(ha*.1)/xx,GUIw:=(wa*98)/xx,h:=(ha*94)/xx ;Windows in left top corner.
x:=(wa*10)/xx,y:=(ha*10)/xx,GUIw:=(wa*98)/xx,h:=(ha*94)/xx ;Windows middle screen.
Gui, Show,x%x% y%y% w%GUIw% h%h%, TQT-Interface
Guicontrol,focus,srch
return
;------------------------------------------------------------------------------------------------------------------------
;This function adds to the TreeView all subfolders in the specified folder.
AddSubFoldersToTree(Folder, ParentItemID = 0)
{
;- It also calls itself recursively to gather nested folders to any depth.
Loop %Folder%\*.*, 2 ;- Retrieve all of Folder's sub-folders.
AddSubFoldersToTree(A_LoopFileFullPath, TV_Add(A_LoopFileName, ParentItemID, "Icon4 Sort"))
;Sort so that underscores and numbers are sorted to top of tree
}
;------------------------------------------------------------------------------------------------------------------------
MyTreeView:
if A_GuiEvent <> S ;If event other than "select new tree item".
return ;Do nothing.
;Otherwise, populate the ListView with the contents of the selected folder.
;First determine the full path of the selected folder:
TV_GetText(SelectedItemText, A_EventInfo)
ParentID := A_EventInfo
Loop ;- Build the full path to the selected folder.
{
ParentID := TV_GetParent(ParentID)
if not ParentID ; No more ancestors.
break
TV_GetText(ParentText, ParentID)
SelectedItemText = %ParentText%\%SelectedItemText%
}
SelectedFullPath = %TreeRoot%\%SelectedItemText%
;________________________________________________________________________________________________________________________
Gui,1:ListView,MLV1
LV_Delete()
GuiControl, -Redraw, MLV1
FileCount:= 0,TotalSize:= 0
Loop, %SelectedFullPath%\*.* ; For simplicity, this omits folders so that only files are shown in the ListView.
{
;If A_LoopFileExt in bmp,png,jpg ; show only these extensions
If A_LoopFileExt in csv
{
LV_Add("", A_LoopFileName, A_LoopFileTimeModified,A_LoopFileSize) ;A_LoopFileTimeModified, A_LoopFileTimeCreated
LVArray.Push({1:A_LoopFileName,2:A_LoopFileTimeModified,3:A_LoopFileSize})
FileCount += 1
TotalSize += A_LoopFileSize
}
}
GuiControl, +Redraw, MLV1
LV_ModifyCol(1, "Logical SortAsc")
;- Populate status bar to show info about the currently selected folder:
SB_SetText(FileCount . " files", 1)
SB_SetText(Round(TotalSize / 1024, 1) . " KB", 2)
SB_SetText(SelectedFullPath, 3)
return
;------------------------------------------------------------------------------------------------------------------------
MLV1:
global StartTime ; Define a global variable to store the start time
Gui,1:ListView,MLV1
RN:=LV_GetNext("C")
if (rn=0)
return
if (A_GuiEvent = "Normal")
{
LV_GetText(C1,a_eventinfo,1)
StartTime := A_TickCount ; Store the start time before processing
xxc=%SelectedFullPath%\%C1%
SplashTextOn, 600, 20,, LOADING THE TABLE...
; Display the data inside the selected file in MLV2
Gui,1:ListView,MLV2
Gosub, FillMLV2
; Count the occurrences of "Arc" and "Short" and update MLV3
Gui,1:ListView,MLV3
Gosub, FillMLV3
SplashTextOff
; Calculate the time taken in minutes and seconds
ElapsedTime := A_TickCount - StartTime
ElapsedSeconds := ElapsedTime / 1000
ElapsedMinutes := Floor(ElapsedSeconds / 60)
ElapsedSecondsRemain := Round(Mod(ElapsedSeconds, 60))
; Show the elapsed time in minutes and seconds in a message box
MsgBox, Time taken: %ElapsedMinutes% minutes and %ElapsedSecondsRemain% seconds
}
;------------------------------------------------------------------------------------------------------------------------
MLV2:
Gui,1:default
Gui,1:ListView,MLV2
RN:=LV_GetNext("C")
if (rn=0)
return
if A_GuiEvent = Normal
{
LV_GetText(C1,a_eventinfo,1)
C1=%c1%
;try
;run,notepad "%SelectedFullPath%\%C1%"
}
return
;------------------------------------------------------------------------------------------------------------------------
MLV3:
Gui,1:default
Gui,1:ListView,MLV3
RN:=LV_GetNext("C")
if (RN=0)
return
if A_GuiEvent = Normal
{
LV_GetText(C1, A_EventInfo, 1)
C1 = %C1%
try
; Create a string with the extracted data
FormatTime, currentDateTime, %A_Now%, dddd, MMMM d, yyyy, HH:mm:ss
DataString =
(
Export Date: %currentDateTime%
-----------------------------------------------------
Passed Count: %PassedCount%
Open Count: %OpenCount%
Arc Count: %ArcCount%
Short Count: %ShortCount%
-----------------------------------------------------
)
Run, notepad.exe
Sleep 100 ;[Wait for Notepad to open before sending data]
WinWaitActive, ahk_class Notepad ;[Use ControlSetText to set the text in Notepad]
ControlGet, hEdit, Hwnd, , Edit1, ahk_class Notepad
ControlSetText, %hEdit%, %DataString%, ahk_class Notepad
}
return
;________________________________________________________________________________________________________________________
FillMLV2:
LV_Delete()
F1 := xxc
SplitPath, F1, name, dir, ext, name_no_ext, drive
Obj := FileOpen(F1, "r", "UTF-8")
e := Obj.Read()
Obj.Close()
Loop, Parse, e, `n, `r
{
if (A_Index = 1)
continue ; Skip the first row
x := a_loopfield
if x =
break
C := StrSplit(x, ";")
C1 := C[1], C2 := C[2], C3 := C[3], C4 := C[4], C5 := C[5], C6 := C[6], C7 := C[7], C8 := C[8], C9 := C[9]
LV_Add("", name, C1, C2, C3, C4, C5, C6, C7, C8, C9)
}
e =
return
;------------------------------------------------------------------------------------------------------------------------
FillMLV3:
; Count the occurrences of "Arc" and "Short" and update MLV3
PassedCount := 0
OpenCount := 0
ArcCount := 0
ShortCount := 0
FileRead, fileContent, %xxc%
Loop, Parse, fileContent, `n
{
x := a_loopfield
C := StrSplit(x, ";")
C1 := C[1], C2 := C[2], C3 := C[3], C4 := C[4], C5 := C[5], C6 := C[6], C7 := C[7], C8 := C[8], C9 := C[9]
; Count the occurrences of "Arc" and "Short" in each line
if (InStr(x, "Passed"))
PassedCount++
if (InStr(x, "Open"))
OpenCount++
if (InStr(x, "Arc"))
ArcCount++
if (InStr(x, "Short"))
ShortCount++
}
LV_Delete()
LV_Add("", "Passed", PassedCount)
LV_Add("", "Open", OpenCount)
LV_Add("", "Arc", ArcCount)
LV_Add("", "Short", ShortCount)
return
;________________________________________________________________________________________________________________________
Search:
GuiControlGet,srch
GuiControlGet,srch2
Gui,1:ListView,MLV1
GuiControl, -Redraw, MLV1
LV_Delete()
For Each, CS In LVArray
{
If (srch != "")
{
If (InStr(CS.1,srch) or InStr(CS.2,srch)) ;[search in column-1 and column-2]
;If InStr(CS.2,srch)
LV_Add("", CS.1,CS.2,CS.3)
}
Else
LV_Add("", CS.1,CS.2,CS.3)
}
GuiControl, +Redraw, MLV1
Return
;------------------------------------------------------------------------------------------------------------------------
SearchInFile:
GuiControlGet,srch2
Gui,1:ListView,MLV2
GuiControl, -Redraw, MLV2
LV_Delete()
F1 := xxc
SplitPath, F1, name, dir, ext, name_no_ext, drive
Obj := FileOpen(F1, "r", "UTF-8")
e := Obj.Read()
Obj.Close()
Loop, Parse, e, `n, `r
{
if (A_Index = 1)
continue ;[Skip the first row]
x := a_loopfield
if x =
break
C := StrSplit(x, ";")
C1 := C[1], C2 := C[2], C3 := C[3], C4 := C[4], C5 := C[5], C6 := C[6], C7 := C[7], C8 := C[8], C9 := C[9]
If (srch2 != "")
{
If (InStr(x, srch2))
LV_Add("", name, C1, C2, C3, C4, C5, C6, C7, C8, C9)
}
Else
LV_Add("", name, C1, C2, C3, C4, C5, C6, C7, C8, C9)
}
e =
GuiControl, +Redraw, MLV2
Return
;________________________________________________________________________________________________________________________
GuiClose:
reload
return
Closeall:
Exitapp
return
@Hellbent is good to bitmap designer. This are what graphs i love: