#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.0 Author: kcvinu Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include #include #include #include #include #include #include #include Opt("GUIOnEventMode", 1) Const $CLICKED = 0 #Region ### START Koda GUI section ### Form=F:\ISN AutoIt Folder\Projects\AstroHelper\Forms\INI CreatorGUI.kxf Local $Form1_1 = GUICreate("INI Creator", 782, 482, 275, 102) GUISetFont(10, 400, 0, "Segoe UI") GUISetOnEvent($GUI_EVENT_CLOSE, "Form1_1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1_1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1_1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1_1Restore") Local $tb_SecName = GUICtrlCreateInput("", 112, 63, 225, 28) GUICtrlSetOnEvent(-1, "tb_SecNameChange") Local $Label1 = GUICtrlCreateLabel("Section Name", 8, 63, 97, 24) GUICtrlSetOnEvent(-1, "Label1Click") Local $tb_KeyName = GUICtrlCreateInput("", 112, 111, 225, 28) GUICtrlSetOnEvent(-1, "tb_KeyNameChange") Local $Label2 = GUICtrlCreateLabel("Key Name", 29, 113, 72, 24) GUICtrlSetOnEvent(-1, "Label2Click") Local $tb_Values = GUICtrlCreateInput("", 112, 155, 225, 28) GUICtrlSetOnEvent(-1, "tb_ValuesChange") Local $Label3 = GUICtrlCreateLabel("Values", 53, 157, 47, 24) GUICtrlSetOnEvent(-1, "Label3Click") Local $btn_EnterSecName = GUICtrlCreateButton("Enter", 352, 62, 81, 33) GUICtrlSetOnEvent(-1, "btn_EnterSecNameClick") Local $btn_EnterKey = GUICtrlCreateButton("Enter", 352, 110, 81, 33) GUICtrlSetOnEvent(-1, "btn_EnterKeyClick") Local $btn_EnterValue = GUICtrlCreateButton("Enter", 352, 156, 81, 30) GUICtrlSetOnEvent(-1, "btn_EnterValueClick") Local $btn_CreatINI = GUICtrlCreateButton("Creat INI File", 112, 303, 321, 49) GUICtrlSetFont(-1, 14, 800, 0, "Segoe UI") GUICtrlSetOnEvent(-1, "btn_CreatINIClick") Local $tb_Fname = GUICtrlCreateInput("", 112, 23, 225, 28) GUICtrlSetOnEvent(-1, "tb_FnameChange") Local $Label4 = GUICtrlCreateLabel("File Name", 30, 25, 71, 24) GUICtrlSetOnEvent(-1, "Label4Click") Local $btn_ChoosePath = GUICtrlCreateButton("Path", 352, 22, 81, 33) GUICtrlSetOnEvent(-1, "btn_ChoosePathClick") Local $Edit_DispPath = GUICtrlCreateEdit("", 112, 208, 321, 81, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetData(-1, "") GUICtrlSetOnEvent(-1, "Edit_DispPathChange") Local $tv1 = GUICtrlCreateTreeView(456, 16, 313, 457, BitOR($GUI_SS_DEFAULT_TREEVIEW,$TVS_EDITLABELS,$TVS_TRACKSELECT,$WS_VSCROLL)) GUICtrlSetBkColor($tv1, 0xBFCDDB) GUICtrlSetOnEvent($tv1, "tv1Click") Local $Pic1 = GUICtrlCreatePic("H:\AstroHelper\Wallpaper 1080p (55).jpg", 9, 360, 433, 113) GUICtrlSetOnEvent(-1, "Pic1Click") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region Form load Code GUICtrlSetState($tb_Fname,$GUI_FOCUS ) GUIRegisterMsg($WM_NOTIFY, "TreeView_WM_NOTIFY") #EndRegion While 1 Sleep(100) WEnd Func btn_ChoosePathClick() Local $fName = GUICtrlRead($tb_Fname) Global $FullPath If $fName <> "" Then $fName = $fName & ".ini" Local $Path = FileSelectFolder("Choose a Path for INI File", "", 1) If $Path <> "" Then $FullPath = $Path & "\" & $fName Else $FullPath = @DesktopDir & "\" & $fName EndIf GUICtrlSetData($Edit_DispPath, $FullPath) Else MsgBox(0,"Ini Creator","Please type a file name first") EndIf GUICtrlSetState($tb_SecName,$GUI_FOCUS ) EndFunc ;==>btn_ChoosePathClick Func btn_CreatINIClick() Local $Ihwnd = _GUICtrlTreeView_GetSelection($tv1) Local $SelItem = _GUICtrlTreeView_GetText($tv1, $Ihwnd) ConsoleWrite($SelItem & @CRLF) EndFunc ;==>btn_CreatINIClick Func btn_EnterKeyClick() Local $Ihwnd = _GUICtrlTreeView_GetSelection($tv1) Local $SelItem = _GUICtrlTreeView_GetText($tv1, $Ihwnd) Local $KeyName = GUICtrlRead($tb_KeyName) If $KeyName <> "" And $Ihwnd <> 0 Then _GUICtrlTreeView_BeginUpdate($tv1) _GUICtrlTreeView_AddChild($tv1,$Ihwnd,$KeyName) _GUICtrlTreeView_Expand($tv1,$Ihwnd) _GUICtrlTreeView_EndUpdate($tv1) ElseIf $Ihwnd = 0 Then MsgBox(0,"Ini Creator","Please an item from tree view") ElseIf $KeyName = "" Then MsgBox(0,"Ini Creator","Please type a key name first") EndIf GUICtrlSetData($tb_KeyName,"") EndFunc ;==>btn_EnterKeyClick Func btn_EnterSecNameClick() Global $SecName = GUICtrlRead($tb_SecName) If $SecName <> "" Then _GUICtrlTreeView_Add($tv1,"",$SecName) Else MsgBox(0,"Ini Creator","Please type a section name first") EndIf GUICtrlSetData($tb_SecName,"") EndFunc ;==>btn_EnterSecNameClick Func btn_EnterValueClick() Local $Value = GUICtrlRead($tb_Values) Local $Ihwnd = _GUICtrlTreeView_GetSelection($tv1) Local $SelItem = _GUICtrlTreeView_GetText($tv1, $Ihwnd) If $Value <> "" And $Ihwnd <> 0 Then _GUICtrlTreeView_BeginUpdate($tv1) _GUICtrlTreeView_AddChild($tv1,$Ihwnd,$Value) _GUICtrlTreeView_Expand($tv1,$Ihwnd) _GUICtrlTreeView_EndUpdate($tv1) Else MsgBox(0,"Ini Creator","Please type a file name first") EndIf GUICtrlSetData($tb_Values,"") EndFunc ;==>btn_EnterValueClick Func Edit_DispPathChange() EndFunc ;==>Edit_DispPathChange Func Form1_1Close() Exit EndFunc ;==>Form1Close Func Form1_1Maximize() EndFunc ;==>Form1Maximize Func Form1_1Minimize() EndFunc ;==>Form1Minimize Func Form1_1Restore() EndFunc ;==>Form1Restore #Region Unnecessary funcs Func Label1Click() EndFunc ;==>Label1Click Func Label2Click() EndFunc ;==>Label2Click Func Label3Click() EndFunc ;==>Label3Click Func Label4Click() EndFunc ;==>Label4Click Func Label5Click() EndFunc ;==>Label5Click Func Label6Click() EndFunc ;==>Label6Click Func Label7Click() EndFunc ;==>Label7Click #EndRegion Unnecessary funcs Func List_SectionClick() EndFunc ;==>List_SectionClick Func List_ValuesClick() EndFunc ;==>List_ValuesClick Func tb_FnameChange() EndFunc ;==>tb_FnameChange Func tb_KeyNameChange() EndFunc ;==>tb_KeyNameChange Func tb_SecNameChange() ;btn_EnterSecNameClick() EndFunc ;==>tb_SecNameChange Func tb_ValuesChange() EndFunc ;==>tb_ValuesChange Func tv1Click() EndFunc Func Pic1Click() EndFunc Func TreeView_WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview $hWndTreeview = $tv1 If Not IsHWnd($tv1) Then $hWndTreeview = GUICtrlGetHandle($tv1) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Local $cntr = 0 Switch $hWndFrom Case $hWndTreeview Switch $iCode Case $TVN_SELCHANGINGW ; Insert your code here ;ConsoleWrite("Clicked" & $cntr + 1 & @CRLF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY