ahmed9100 Posted May 13, 2010 Posted May 13, 2010 Hello every body whats wrong with my code !! when i write any thing with my hand and press add it create the "ini" file in data folder but when i choose the file and the 2 folders it wouldn't make anything !! expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> #include <GuiImageList.au3> #Include <Array.au3> If FileExists("data") Then Else DirCreate("data") EndIf #Region ### START Koda GUI section ### Form=c:\users\el-zaeem\desktop\backup\bacckup form.kxf $Form1_1 = GUICreate("Z - Backup", 607, 560, 230, 132) $Group1 = GUICtrlCreateGroup("", 8, 8, 585, 201) $path_source = GUICtrlCreateInput("", 72, 43, 497, 21) $browes_source = GUICtrlCreateButton("Browse", 16, 40, 49, 25, $WS_GROUP) $Browes_b_dir = GUICtrlCreateButton("Browse", 17, 131, 49, 25, $WS_GROUP) $path_b_dir = GUICtrlCreateInput("", 73, 134, 497, 21) $icon = GUICtrlCreateButton("", 17, 160, 49, 41, $WS_GROUP) $add = GUICtrlCreateButton("Add", 496, 168, 73, 25, $WS_GROUP) $folder_to_b = GUICtrlCreateButton("Browse", 17, 86, 49, 25, $WS_GROUP) $F2p_path = GUICtrlCreateInput("", 73, 89, 497, 21) $Label3 = GUICtrlCreateLabel("Application dire", 17, 24, 76, 17) $Label4 = GUICtrlCreateLabel("Folder to backup", 17, 69, 84, 17) $Label5 = GUICtrlCreateLabel("Backup dir", 16, 114, 55, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup(" Options ", 8, 216, 585, 57) $Checkbox1 = GUICtrlCreateCheckbox("Start lancher on computer startup", 24, 240, 177, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $List1 = GUICtrlCreateList("", 8, 304, 585, 201) $Label1 = GUICtrlCreateLabel("Application List", 9, 280, 95, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $ok = GUICtrlCreateButton("ok", 500, 518, 81, 25, $WS_GROUP) $Delete = GUICtrlCreateButton("Delete", 400, 518, 81, 25, $WS_GROUP) $list_icon = GUICtrlCreateButton("", 8, 510, 49, 41, $WS_GROUP) $restore = GUICtrlCreateButton("Restore", 100, 518, 81, 25, $WS_GROUP) $edit = GUICtrlCreateButton("Edit", 300, 518, 81, 25, $WS_GROUP) $backup = GUICtrlCreateButton("backup", 200, 518, 81, 25, $WS_GROUP) $Label2 = GUICtrlCreateLabel("Made by Elzaem", 512, 280, 82, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg case $browes_source $file = FileOpenDialog("Select file", @ProgramFilesDir & "", "Application (*.exe)", 1 + 4 ) If @error Then GUICtrlSetData($path_source,"") Else $iconfile_to_use = $file $array = StringSplit($iconfile_to_use, '\', 1) $name = $array[$array[0]] $newname = StringReplace($name,".exe","") $hImage = _GUIImageList_Create(32, 32, 5, 3, 6) _GUIImageList_AddIcon($hImage, $iconfile_to_use, 0, True) _GUICtrlButton_SetImageList($icon, $hImage,4) GUICtrlSetData($path_source,$file) EndIf case $folder_to_b $var = FileSelectFolder("Choose a folder.", "") if $var = "" Then GUICtrlSetData($F2p_path,"") EndIf GUICtrlSetData($F2p_path,$var) case $Browes_b_dir $var2 = FileSelectFolder("Choose a folder.", "") if $var2 = "" Then GUICtrlSetData($path_b_dir,"") EndIf GUICtrlSetData($path_b_dir,$var2) case $add if GUICtrlRead($path_source) = "" or GUICtrlRead($F2p_path) = "" or GUICtrlRead($path_b_dir) = "" Then MsgBox("Error","Notic","Please choose backup and restore folders") Else $array = StringSplit(GUICtrlRead($path_source), '\', 1) $name = $array[$array[0]] $newname = StringReplace($name,".exe","") IniWrite("data\" & $newname & ".ini","info","name",$name) IniWrite("data\" & $newname & ".ini","info","source",GUICtrlRead($path_source)) IniWrite("data\" & $newname & ".ini","info","surcedir",GUICtrlRead($F2p_path)) IniWrite("data\" & $newname & ".ini","info","backupdir",GUICtrlRead($path_b_dir)) MsgBox("","","done") EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
taietel Posted May 13, 2010 Posted May 13, 2010 (edited) Try this: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiButton.au3> #include <GuiImageList.au3> #Include <Array.au3> If FileExists(@ScriptDir & "\data") Then Else DirCreate(@ScriptDir & "\data") EndIf #Region ### START Koda GUI section ### Form=c:\users\el-zaeem\desktop\backup\bacckup form.kxf $Form1_1 = GUICreate("Z - Backup", 607, 560, 230, 132) $Group1 = GUICtrlCreateGroup("", 8, 8, 585, 201) $path_source = GUICtrlCreateInput("", 72, 43, 497, 21) $browes_source = GUICtrlCreateButton("Browse", 16, 40, 49, 25, $WS_GROUP) $Browes_b_dir = GUICtrlCreateButton("Browse", 17, 131, 49, 25, $WS_GROUP) $path_b_dir = GUICtrlCreateInput("", 73, 134, 497, 21) $icon = GUICtrlCreateButton("", 17, 160, 49, 41, $WS_GROUP) $add = GUICtrlCreateButton("Add", 496, 168, 73, 25, $WS_GROUP) $folder_to_b = GUICtrlCreateButton("Browse", 17, 86, 49, 25, $WS_GROUP) $F2p_path = GUICtrlCreateInput("", 73, 89, 497, 21) $Label3 = GUICtrlCreateLabel("Application dire", 17, 24, 76, 17) $Label4 = GUICtrlCreateLabel("Folder to backup", 17, 69, 84, 17) $Label5 = GUICtrlCreateLabel("Backup dir", 16, 114, 55, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup(" Options ", 8, 216, 585, 57) $Checkbox1 = GUICtrlCreateCheckbox("Start lancher on computer startup", 24, 240, 177, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $List1 = GUICtrlCreateList("", 8, 304, 585, 201) $Label1 = GUICtrlCreateLabel("Application List", 9, 280, 95, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $ok = GUICtrlCreateButton("ok", 500, 518, 81, 25, $WS_GROUP) $Delete = GUICtrlCreateButton("Delete", 400, 518, 81, 25, $WS_GROUP) $list_icon = GUICtrlCreateButton("", 8, 510, 49, 41, $WS_GROUP) $restore = GUICtrlCreateButton("Restore", 100, 518, 81, 25, $WS_GROUP) $edit = GUICtrlCreateButton("Edit", 300, 518, 81, 25, $WS_GROUP) $backup = GUICtrlCreateButton("backup", 200, 518, 81, 25, $WS_GROUP) $Label2 = GUICtrlCreateLabel("Made by Elzaem", 512, 280, 82, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg case $browes_source $file = FileOpenDialog("Select file", @ProgramFilesDir & "", "Application (*.exe)", 1 + 4 ) If @error Then GUICtrlSetData($path_source,"") Else $iconfile_to_use = $file $array = StringSplit($iconfile_to_use, '\', 1) $name = $array[$array[0]] $newname = StringReplace($name,".exe","") $hImage = _GUIImageList_Create(32, 32, 5, 3, 6) _GUIImageList_AddIcon($hImage, $iconfile_to_use, 0, True) _GUICtrlButton_SetImageList($icon, $hImage,4) GUICtrlSetData($path_source,$file) EndIf case $folder_to_b $var = FileSelectFolder("Choose a folder.", "") if $var = "" Then GUICtrlSetData($F2p_path,"") EndIf GUICtrlSetData($F2p_path,$var) case $Browes_b_dir $var2 = FileSelectFolder("Choose a folder.", "") if $var2 = "" Then GUICtrlSetData($path_b_dir,"") EndIf GUICtrlSetData($path_b_dir,$var2) case $add if GUICtrlRead($path_source) = "" or GUICtrlRead($F2p_path) = "" or GUICtrlRead($path_b_dir) = "" Then MsgBox("Error","Notic","Please choose backup and restore folders") Else $array = StringSplit(GUICtrlRead($path_source), '\', 1) $name = $array[$array[0]] $newname = StringReplace($name,".exe","") IniWrite(@ScriptDir & "\data\" & $newname & ".ini","info","name",$name) IniWrite(@ScriptDir & "\data\" & $newname & ".ini","info","source",GUICtrlRead($path_source)) IniWrite(@ScriptDir & "\data\" & $newname & ".ini","info","surcedir",GUICtrlRead($F2p_path)) IniWrite(@ScriptDir & "\data\" & $newname & ".ini","info","backupdir",GUICtrlRead($path_b_dir)) MsgBox(64,"Z - Backup","All done!") EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited May 13, 2010 by taietel Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text
Marlo Posted May 13, 2010 Posted May 13, 2010 Not had a proper look at your code as im just quickly passing but the line that says: If FileExists("data") Then Else DirCreate("data") EndIf should be If Not FileExists("data") Then DirCreate("data") EndIf Click here for the best AutoIt help possible.Currently Working on: Autoit RAT
ahmed9100 Posted May 13, 2010 Author Posted May 13, 2010 thx guys it works but it's a weird thing right !
ResNullius Posted May 13, 2010 Posted May 13, 2010 Hello every body whats wrong with my code !!when i write any thing with my hand and press add it create the "ini" file in data folder butwhen i choose the file and the 2 folders it wouldn't make anything !! Frome the Remarks in the help file for FileOpenDialog():@WorkingDir is changed on successful return.You can prove that to yourself by checking the value of @WorkingDir before and after the FileOpenDialog().So, you're trying to save the ini in the (probably) non-existant "data" folder in the folder where you selected your exe.That probably gives you enough info to solve your problem, right?
Mungo Posted June 11, 2010 Posted June 11, 2010 Frome the Remarks in the help file for FileOpenDialog():You can prove that to yourself by checking the value of @WorkingDir before and after the FileOpenDialog().So, you're trying to save the ini in the (probably) non-existant "data" folder in the folder where you selected your exe.That probably gives you enough info to solve your problem, right?I ran into then same problem - luckily found the post - however, is there a way to reset the @WorkingDir value again after the FileOpenDialog() e.g. through @ScriptDir value ? Thanks
Moderators Melba23 Posted June 11, 2010 Moderators Posted June 11, 2010 Mungo, is there a way to reset the @WorkingDir valueFrom the Help file: FileChangeDir - Changes the current working directory. So you would need to use: FileChangeDir(@ScriptDir)) And you are back in the script folder again. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
ResNullius Posted June 12, 2010 Posted June 12, 2010 Mungo,You could also make it so that you always uses @Scriptdir when referencing your inifile, as in IniWrite(@ScriptDir & "\myIniFile.ini",.....That way you never have to worry about whether you've changed the working dir or not.
Mungo Posted June 13, 2010 Posted June 13, 2010 Mungo,You could also make it so that you always uses @Scriptdir when referencing your inifile, as in IniWrite(@ScriptDir & "\myIniFile.ini",.....That way you never have to worry about whether you've changed the working dir or not.M23 and ResNullius,Thanks, and done exactly as you said. Wasn't aware that the @workingdir value actually changes ... well, learned something new again . I had also quite a few icon and gif files included in my script and they didn't show as well ... It works now, thanks. Mungo
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now