Jump to content

Open text file wirh Notepad and wait until text file is saved


kneze
 Share

Recommended Posts

Hi

i start with new script to ad computer names to empty text file. The steps to do this are: Press Button "New CP Name List". Script check if cpnamelist.txt exist and delete it. Script create a new one. Now Script open cpnamelist.txt with notepad and i paste computer names in to this file and save file. How can i stop script until content is saved. I have tried Miscellaneous (winwait etc.) but somthing was wrong.

 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("CP Name List", 615, 438, 522, 356)
$ListCPNameList = GUICtrlCreateList("", 25, 25, 96, 383)
$ButtonNewCPNameList = GUICtrlCreateButton("New CP Name List", 130, 120, 105, 25)
$ButtonAddCPName = GUICtrlCreateButton("Add CP Name", 130, 30, 105, 25)
$ButtonRemoveCPName = GUICtrlCreateButton("Remove CP Name", 130, 60, 105, 25)
$InputCPName = GUICtrlCreateInput("", 245, 30, 121, 21)
GUISetState(@SW_SHOW)

 While 1
    $msg = GUIGetMsg()
    Select
        ;Case $GUI_EVENT_CLOSE
             Case $msg = $GUI_EVENT_CLOSE
            Exitloop

            Case $msg = $ButtonNewCPNameList
            MsgBox(0, "Note", "$ButtonNewCPNameList")

            $CPnameList="D:\AutoIT_Scripts\writefile\temp\temp\cpnamelist.txt"

            If FileExists($CPnameList) Then FileDelete($CPnameList) ; CPNameList if exist.

            $hFile = FileOpen("D:\AutoIT_Scripts\writefile\temp\cpnamelist.txt", 1)
            FileClose($hFile)

            $sText = FileRead("D:\AutoIT_Scripts\writefile\temp\cpnamelist.txt", 1)
            $sText = StringReplace($sText, @CRLF, '|')
            $sText = StringReplace($sText, '||', '|')
            GUICtrlSetData($ListCPNameList, $sText)




            Case $msg = $ButtonAddCPName
            MsgBox(0, "Note", "$ButtonAddCPName")


            Case $msg = $ButtonRemoveCPName
            MsgBox(0, "Note", "$ButtonRemoveCPName")




    EndSelect
 WEnd

 func terminate()                                                                     ;exit
    Exit 0
EndFunc

 

Link to comment
Share on other sites

Your script doesn't use Notepad in it.

You need to add a FileWrite to write the data to the file, which is also missing in your script.

Don't use Notepad to do this, it just adds complexity to a simple process.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...