Bert Posted November 29, 2005 Share Posted November 29, 2005 I have a text file that I use to create a list. (using GUICtrlCreateCombo). Does anyone knowa way that will remove a item from the file so when the list is refreshed, the item is no longer listed? I like it so the GUI would have a remove button, and a second GUI would open that lets me choose what I want to remove. Any thoughts? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Valuater Posted November 29, 2005 Share Posted November 29, 2005 show your script on how you populate the combobox from the list then i can show you how to place a delete button in your script 8) Link to comment Share on other sites More sharing options...
kpu Posted November 29, 2005 Share Posted November 29, 2005 Check out _ReplaceStringInFile(). You should be able to do it with this. http://www.kpunderground.com Link to comment Share on other sites More sharing options...
Bert Posted November 29, 2005 Author Share Posted November 29, 2005 Here is what I got so far. I'm still designing it, so the code is quite crude, and the formatting is a mess, but you will get the idea of what I'm doing. expandcollapse popup;#NoTrayIcon Break(0) #include <GuiConstants.au3> ;----------------------------- $Shandle = fileopen ("quicktext.ini", 0) $note1 = FileReadLine ("quicktext.ini") GUICreate("QuickText", 600, 65) $Combo_2 = GuiCtrlCreateCombo("", 20, 5, 500, 80) GuiCtrlSetData($combo_2, $note1) fileclose($Shandle) $button1 = GuiCtrlCreateButton("Paste", 530, 5, 60, 20) $button2 = GuiCtrlCreateButton("Cancel", 530, 32, 60, 20) $button3 = GuiCtrlCreateButton("Add", 20, 32, 60, 20) $button4 = GuiCtrlCreateButton("Remove", 100, 32, 60, 20) $button5 = GuiCtrlCreateButton("About", 180, 32, 60, 20) ; Run the GUI until it is closed GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop ;When button1 is pressed, label text is copied to the clipboard Case $msg = $button1 $data = GUICtrlRead($Combo_2) ClipPut($data) sleep(200) exit ;When button2 is pressed, it will open a add text box. Case $msg = $button2 exit ;--------------------------------------- ;this will open a sub GUI window to allow for adding or removing data Case $msg = $button3 GUiDelete() GUICreate("Add data to QuickText", 520,65, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES $file = GUICtrlCreateInput ( "", 10, 5, 500, 20) GUICtrlSetState(-1,$GUI_ACCEPTFILES) $button6 = GUICtrlCreateButton ("Ok", 10,30,60,20) $button7 = GUICtrlCreateButton ("Cancel", 90,30,60,20) GUISetState () $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $button6; this will add data to the quicktest.ini file. It will make the file if it is missing $adddata = GUICtrlRead($file) $file1 = FileOpen("quicktext.ini", 1) filewrite($file1, $adddata) filewrite($file1, "|") GUiDelete() exitloop Case $msg = $button7 GUiDelete() exitloop EndSelect Wend EndSelect WEnd Exit The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted November 29, 2005 Author Share Posted November 29, 2005 (edited) I also have a second problem. When I open the "add data to quicktext" window, I have the main window close. My thinking is I need for it to be refreshed after I make my change to the ini file. The problem is the window won't reopen, no matter what I do. I know I can't do a goto statement, but in this case it would be a easy fix. What do I do? I tried to make a loop, but it doesn't work. Edited November 29, 2005 by vollyman The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
GaryFrost Posted November 29, 2005 Share Posted November 29, 2005 I also have a second problem. When I open the "add data to quicktext" window, I have the main window close. My thinking is I need for it to be refreshed after I make my change to the ini file. The problem is the window won't reopen, no matter what I do. I know I can't do a goto statement, but in this case it would be a easy fix. What do I do? I tried to make a loop, but it doesn't work. Instead of GuiDelete, try GuiSetState(@SW_HIDE,$main_gui), then when done, just do GuiSetState(@SW_SHOW,$main_gui)you need to set $main_gui when you do the initial GuiCreate. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Bert Posted November 29, 2005 Author Share Posted November 29, 2005 If I do that, then how do I refresh the list on the main GUI? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
GaryFrost Posted November 29, 2005 Share Posted November 29, 2005 (edited) just before you show it again just do $Shandle = fileopen ("quicktext.ini", 0) $note1 = FileReadLine ($Shandle) fileclose($Shandle) GuiCtrlSetData($combo_2, "|" & $note1) Edited November 29, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Bert Posted November 29, 2005 Author Share Posted November 29, 2005 I'm not following you. What you are saying then is to do this:? $adddata = GUICtrlRead($file) $file1 = FileOpen("quicktext.ini", 1) filewrite($file1, $adddata) filewrite($file1, "|") $Shandle = fileopen ("quicktext.ini", 0) $note1 = FileReadLine ($Shandle) fileclose($Shandle) GuiCtrlSetData($combo_2, "|" & $note1) this doesn't make sense. The file is already open. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
GaryFrost Posted November 29, 2005 Share Posted November 29, 2005 I'm not following you. What you are saying then is to do this:? $adddata = GUICtrlRead($file) $file1 = FileOpen("quicktext.ini", 1) filewrite($file1, $adddata) filewrite($file1, "|") $Shandle = fileopen ("quicktext.ini", 0) $note1 = FileReadLine ($Shandle) fileclose($Shandle) GuiCtrlSetData($combo_2, "|" & $note1) this doesn't make sense. The file is already open. it does make sense, being you have it open in write mode, you'll need to close it first $adddata = GUICtrlRead($file) $file1 = FileOpen($file, 1) filewrite($file1, $adddata & "|") FileClose($file1) $Shandle = fileopen ("quicktext.ini", 0) $note1 = FileReadLine ($Shandle) fileclose($Shandle) GuiCtrlSetData($combo_2, "|" & $note1) SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Bert Posted November 29, 2005 Author Share Posted November 29, 2005 Tried it, and it didn't work. The sub window won't close. It loses focus, and the only way I can close it is to kill the script The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
GaryFrost Posted November 29, 2005 Share Posted November 29, 2005 (edited) expandcollapse popup;#NoTrayIcon Break(0) #include <GuiConstants.au3> ;----------------------------- $main_gui = GUICreate("QuickText", 600, 65) $Combo_2 = GUICtrlCreateCombo("", 20, 5, 500, 80) _LoadData(@ScriptDir & "\quicktext.ini", $Combo_2) $button1 = GUICtrlCreateButton("Paste", 530, 5, 60, 20) $button2 = GUICtrlCreateButton("Cancel", 530, 32, 60, 20) $button3 = GUICtrlCreateButton("Add", 20, 32, 60, 20) $button4 = GUICtrlCreateButton("Remove", 100, 32, 60, 20) $button5 = GUICtrlCreateButton("About", 180, 32, 60, 20) ; Run the GUI until it is closed GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop ;When button1 is pressed, label text is copied to the clipboard Case $msg = $button1 $data = GUICtrlRead($Combo_2) ClipPut($data) Sleep(200) Exit ;When button2 is pressed, it will open a add text box. Case $msg = $button2 Exit ;--------------------------------------- ;this will open a sub GUI window to allow for adding or removing data Case $msg = $button3 GUISetState(@SW_HIDE, $main_gui) $add_gui = GUICreate("Add data to QuickText", 520, 65, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES $file = GUICtrlCreateInput("", 10, 5, 500, 20) GUICtrlSetState(-1, $GUI_ACCEPTFILES) $button6 = GUICtrlCreateButton("Ok", 10, 30, 60, 20) $button7 = GUICtrlCreateButton("Cancel", 90, 30, 60, 20) GUISetState(@SW_SHOW, $add_gui) $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $button6; this will add data to the quicktest.ini file. It will make the file if it is missing $adddata = GUICtrlRead($file) $file1 = FileOpen("quicktext.ini", 1) FileWrite($file1, $adddata & "|") FileClose($file1) GUIDelete($add_gui) ExitLoop Case $msg = $button7 GUIDelete($add_gui) ExitLoop EndSelect WEnd _LoadData(@ScriptDir & "\quicktext.ini", $Combo_2) GUISetState(@SW_SHOW, $main_gui) EndSelect WEnd Exit Func _LoadData($s_file, ByRef $h_Combo) $Shandle = FileOpen($s_file, 0) $note1 = FileReadLine($Shandle) FileClose($Shandle) GUICtrlSetData($h_Combo, "|" & $note1) EndFunc ;==>_LoadData Edited November 29, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Bert Posted November 29, 2005 Author Share Posted November 29, 2005 YOU ROCK!!! thanks for fixing my window problem! I still need to fix my original problem. I need to be able to remove a entry from the INI file. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
kpu Posted November 29, 2005 Share Posted November 29, 2005 This should do it. #include <File.au3> Func _RemoveData() $xData = GUICtrlRead($Combo_2) MsgBox(32,"removing","Remove " & $xData & " from quicktext.ini") _ReplaceStringInFile("quicktext.ini",$xData & "|","") _LoadData(@ScriptDir & "\quicktext.ini", $Combo_2) EndFunc http://www.kpunderground.com Link to comment Share on other sites More sharing options...
Bert Posted November 29, 2005 Author Share Posted November 29, 2005 where do I drop it in? I tried to put it in as a Case, but I get a wend error. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
kpu Posted November 29, 2005 Share Posted November 29, 2005 (edited) where do I drop it in? I tried to put it in as a Case, but I get a wend error. This is what I did using the code in this forum. expandcollapse popup;#NoTrayIcon #include <GuiConstants.au3> #include <File.au3> ;----------------------------- $main_gui = GUICreate("QuickText", 600, 65) $Combo_2 = GUICtrlCreateCombo("", 20, 5, 500, 80) _LoadData(@ScriptDir & "\quicktext.ini", $Combo_2) $button1 = GUICtrlCreateButton("Paste", 530, 5, 60, 20) $button2 = GUICtrlCreateButton("Cancel", 530, 32, 60, 20) $button3 = GUICtrlCreateButton("Add", 20, 32, 60, 20) $button4 = GUICtrlCreateButton("Remove", 100, 32, 60, 20) $button5 = GUICtrlCreateButton("About", 180, 32, 60, 20) ; Run the GUI until it is closed GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop ;When button1 is pressed, label text is copied to the clipboard Case $msg = $button1 $data = GUICtrlRead($Combo_2) ClipPut($data) Sleep(200) Exit ;When button2 is pressed, it will open a add text box. Case $msg = $button2 Exit ;--------------------------------------- ;this will open a sub GUI window to allow for adding or removing data Case $msg = $button3 GUISetState(@SW_HIDE, $main_gui) $add_gui = GUICreate("Add data to QuickText", 520, 65, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES $file = GUICtrlCreateInput("", 10, 5, 500, 20) GUICtrlSetState(-1, $GUI_ACCEPTFILES) $button6 = GUICtrlCreateButton("Ok", 10, 30, 60, 20) $button7 = GUICtrlCreateButton("Cancel", 90, 30, 60, 20) GUISetState(@SW_SHOW, $add_gui) $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $button6; this will add data to the quicktest.ini file. It will make the file if it is missing $adddata = GUICtrlRead($file) $file1 = FileOpen("quicktext.ini", 1) FileWrite($file1, $adddata & "|") FileClose($file1) GUIDelete($add_gui) ExitLoop Case $msg = $button7 GUIDelete($add_gui) ExitLoop EndSelect WEnd _LoadData(@ScriptDir & "\quicktext.ini", $Combo_2) GUISetState(@SW_SHOW, $main_gui) [b];---------put it here------> Case $msg = $button4 _RemoveData() ;---------put it here------>[/b] EndSelect WEnd Exit Func _LoadData($s_file, ByRef $h_Combo) $Shandle = FileOpen($s_file, 0) $note1 = FileReadLine($Shandle) FileClose($Shandle) GUICtrlSetData($h_Combo, "|" & $note1) EndFunc;==>_LoadData Func _RemoveData() $xData = GUICtrlRead($Combo_2) MsgBox(32,"removing","Remove " & $xData & " from quicktext.ini") _ReplaceStringInFile("quicktext.ini",$xData & "|","") _LoadData(@ScriptDir & "\quicktext.ini", $Combo_2) EndFunc Edited November 29, 2005 by kpu http://www.kpunderground.com Link to comment Share on other sites More sharing options...
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