jbsoccerbrit Posted November 19, 2013 Posted November 19, 2013 (edited) Could anyone please tell me how I get this application to write its information out to a notepad file? Thank you in advance. I had tried changing the code to reference "Untitled - Notepad" instead of the Product 2009 and I would think the send commands and references to buttons and specific pages would need to be removed also. For example I would like to set the $amount to say 100 and then have it write 000-00-0001, 000-00-0002 etc etc until the end of the count into the notepad file. expandcollapse popup#include <GUIConstants.au3> #include <IE.au3> $me = GUICreate("Desktop Generator", 450, 200) GUISetBkColor(0xFFFFFF) ; background color $textbox1 = GUICtrlCreateEdit("", 10, 90, 430, 100) $Pic1 = GUICtrlCreatePic("image.jpg", 300, 1, 141, 42) $Labelnumberstart = GUICtrlCreateLabel("number Start", 10, 1, 60, 20) $Estart = GUICtrlCreateInput("000-00-", 75, 1, 45, 20) $Eend = (GUICtrlCreateInput("0000", 125, 1, 40, 20)) $LabelAnount = GUICtrlCreateLabel("# ", 10, 25, 60, 20) $amount = GUICtrlCreateInput("000", 75, 25, 30, 20) $newReturn = GUICtrlCreateButton("Create ", 10, 47, 151, 20) $helpButton = GUICtrlCreateButton("Help", 10, 67, 151, 20) fRunGui() Func fRunGui() GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ; closes when red x is pressed ExitLoop Case $msg = $newReturn GUICtrlSetData($textbox1, "");deletes the text openRetrun() Case Else ;;; EndSelect WEnd EndFunc ;==>fRunGui Func openRetrun() $iCount = 0 For $count = 0 To GUICtrlRead($amount) - 1 Step 1 $numberEnd = GUICtrlRead($Eend) + $count While StringLen($numberEnd) < 4 $numberEnd = "0" & $numberEnd WEnd $number = GUICtrlRead($Estart) & $numberEnd fThrowError(@ScriptLineNumber, WinActivate("product 2009 :", "")) Send("^n") fThrowError(@ScriptLineNumber, WinWaitActive("Enter number", "", 10)) fThrowError(@ScriptLineNumber, ControlSetText("Enter number", "", "TMaskEdit3", $number)) fThrowError(@ScriptLineNumber, ControlSetText("Enter number", "", "TMaskEdit1", $number)) Send("{TAB}") If (WinExists("Confirm", "&Yes")) Then fThrowError(@ScriptLineNumber, WinActivate("Confirm", "&Yes")) fThrowError(@ScriptLineNumber, ControlClick("Confirm", "", "TButton1", "left", 1)) fThrowError(@ScriptLineNumber, WinWaitActive("Enter number", "", 10)) fThrowError(@ScriptLineNumber, ControlClick("Enter number", "", "TButton3", "left", 1)) GUICtrlSetData($textbox1, "- - - - The return " & $number & " already exists" & @CRLF, 1) Else fThrowError(@ScriptLineNumber, ControlClick("Enter number", "", "TButton4", "left", 1)) fThrowError(@ScriptLineNumber, WinWaitActive("product 2009 :", "pnlNavigation", 10)) Send("!f") Send("c") fThrowError(@ScriptLineNumber, WinWaitActive("product 2009 :", "homepage.htm", 10)) GUICtrlSetData($textbox1, "- - - - The return " & $number & " Created" & @CRLF, 1) $iCount = $iCount + 1 EndIf Next; end of for statement GUICtrlSetData($textbox1, "A total of " & $iCount & " returns were created" & @CRLF, 1) EndFunc ;==>openRetrun Func fThrowError($sMessage, $iZero) If ($iZero = 0) Then MsgBox(1, "Error", "Please restart tool" & $sMessage) fRunGui() Exit EndIf EndFunc ;==>fThrowError Exit Edited November 19, 2013 by jbsoccerbrit
Moderators JLogan3o13 Posted November 19, 2013 Moderators Posted November 19, 2013 You are correct, if you want to change where it writes to, you will need to activate the notepad window instead of the "Product 2009" window, and change all the references used to write to that window to write to Notepad instead. Have you attempted to do this already? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
jbsoccerbrit Posted November 19, 2013 Author Posted November 19, 2013 I've tried changing it to the below, it sets the focus on the Notepad application but nothing is ever written to it and then it just displays the error message at the end of the code. expandcollapse popup#include <GUIConstants.au3> #include <IE.au3> $me = GUICreate("Desktop Generator", 450, 200) GUISetBkColor(0xFFFFFF) ; background color $textbox1 = GUICtrlCreateEdit("", 10, 90, 430, 100) $Pic1 = GUICtrlCreatePic("image.jpg", 300, 1, 141, 42) $Labelnumberstart = GUICtrlCreateLabel("number Start", 10, 1, 60, 20) $Estart = GUICtrlCreateInput("000-00-", 75, 1, 45, 20) $Eend = (GUICtrlCreateInput("0000", 125, 1, 40, 20)) $LabelAnount = GUICtrlCreateLabel("# ", 10, 25, 60, 20) $amount = GUICtrlCreateInput("000", 75, 25, 30, 20) $newReturn = GUICtrlCreateButton("Create ", 10, 47, 151, 20) $helpButton = GUICtrlCreateButton("Help", 10, 67, 151, 20) fRunGui() Func fRunGui() GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ; closes when red x is pressed ExitLoop Case $msg = $newReturn GUICtrlSetData($textbox1, "");deletes the text openRetrun() Case Else ;;; EndSelect WEnd EndFunc ;==>fRunGui Func openRetrun() $iCount = 0 For $count = 0 To GUICtrlRead($amount) - 1 Step 1 $numberEnd = GUICtrlRead($Eend) + $count While StringLen($numberEnd) < 4 $numberEnd = "0" & $numberEnd WEnd $number = GUICtrlRead($Estart) & $numberEnd fThrowError(@ScriptLineNumber, WinActivate("Untitled - Notepad", "")) fThrowError(@ScriptLineNumber, WinWaitActive("Enter number", "", 10)) fThrowError(@ScriptLineNumber, ControlSetText("Enter number", "", "TMaskEdit3", $number)) fThrowError(@ScriptLineNumber, ControlSetText("Enter number", "", "TMaskEdit1", $number)) If (WinExists("Confirm", "&Yes")) Then fThrowError(@ScriptLineNumber, WinActivate("Confirm", "&Yes")) fThrowError(@ScriptLineNumber, WinWaitActive("Enter number", "", 10)) GUICtrlSetData($textbox1, "- - - - The return " & $number & " already exists" & @CRLF, 1) Else fThrowError(@ScriptLineNumber, WinWaitActive("Untitled - Notepad", "", 10)) Send("!f") Send("c") fThrowError(@ScriptLineNumber, WinWaitActive("Untitled - Notepad", "", 10)) GUICtrlSetData($textbox1, "- - - - The return " & $number & " Created" & @CRLF, 1) $iCount = $iCount + 1 EndIf Next; end of for statement GUICtrlSetData($textbox1, "A total of " & $iCount & " returns were created" & @CRLF, 1) EndFunc ;==>openRetrun Func fThrowError($sMessage, $iZero) If ($iZero = 0) Then MsgBox(1, "Error", "Please restart tool" & $sMessage) fRunGui() Exit EndIf EndFunc ;==>fThrowError Exit
l3ill Posted November 19, 2013 Posted November 19, 2013 Using FileWriteLine would probably work better to write text to a notepad. And the count up to 100 can be done with a For Next loop. My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
jbsoccerbrit Posted November 19, 2013 Author Posted November 19, 2013 Billo do you mean something like this: fThrowError(@ScriptLineNumber, WinWaitActive("Enter number", "", 10)) FileWriteLine(@ScriptLineNumber, ControlSetText("Enter number", "", "TMaskEdit3", $number)) FileWriteLine(@ScriptLineNumber, ControlSetText("Enter number", "", "TMaskEdit1", $number))
l3ill Posted November 19, 2013 Posted November 19, 2013 Not really. Didn't work did it? For FileWriteLine you will need to OPEN & CLOSE a text file. Get the example and play with it, it is pretty straightforward. I am still mulling through your script and trying to make some sense of it. Why does your loop include the fthrowerror function? My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
l3ill Posted November 19, 2013 Posted November 19, 2013 Hi again, I cant figure what its supposed to be doing so I changed it around a bit to test. Have a look. It is counting and writing to your GUI and to the text file. Maybe you can change it around to do what you want now. expandcollapse popup#include <GUIConstants.au3> #include <IE.au3> #include <File.au3> Local $file = FileOpen("test.txt", 2) ;file to write to $me = GUICreate("Desktop Generator", 450, 200) GUISetBkColor(0xFFFFFF) ; background color $textbox1 = GUICtrlCreateEdit("", 10, 90, 430, 100) $Pic1 = GUICtrlCreatePic("image.jpg", 300, 1, 141, 42) $Labelnumberstart = GUICtrlCreateLabel("number Start", 10, 1, 60, 20) $Estart = GUICtrlCreateInput("000-00-", 75, 1, 45, 20) $Eend = (GUICtrlCreateInput("0000", 125, 1, 40, 20)) $LabelAnount = GUICtrlCreateLabel("# ", 10, 25, 60, 20) $amount = GUICtrlCreateInput("000", 75, 25, 30, 20) $newReturn = GUICtrlCreateButton("Create ", 10, 47, 151, 20) $helpButton = GUICtrlCreateButton("Help", 10, 67, 151, 20) fRunGui() Func fRunGui() GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ; closes when red x is pressed ExitLoop Case $msg = $newReturn GUICtrlSetData($textbox1, "");deletes the text openRetrun() Case Else EndSelect WEnd EndFunc ;==>fRunGui Func openRetrun() ;$iCount = 0 For $count = 0 To GUICtrlRead($amount) - 1 Step 1 FileWriteLine($file, $count & @ScriptLineNumber & "Some Other Stuff") ;;;--------------------- ;$numberEnd = GUICtrlRead($Eend) + $count ;While StringLen($numberEnd) < 4 ;$numberEnd = "0" & $numberEnd ;WEnd ;$number = GUICtrlRead($Estart) & $numberEnd ;~ fThrowError(@ScriptLineNumber, WinActivate("product 2009 :", "")) ;~ Send("^n") ;~ fThrowError(@ScriptLineNumber, WinWaitActive("Enter number", "", 10)) ;~ fThrowError(@ScriptLineNumber, ControlSetText("Enter number", "", "TMaskEdit3", $number)) ;~ fThrowError(@ScriptLineNumber, ControlSetText("Enter number", "", "TMaskEdit1", $number)) ;~ Send("{TAB}") ;~ If (WinExists("Confirm", "&Yes")) Then ;~ fThrowError(@ScriptLineNumber, WinActivate("Confirm", "&Yes")) ;~ fThrowError(@ScriptLineNumber, ControlClick("Confirm", "", "TButton1", "left", 1)) ;~ fThrowError(@ScriptLineNumber, WinWaitActive("Enter number", "", 10)) ;~ fThrowError(@ScriptLineNumber, ControlClick("Enter number", "", "TButton3", "left", 1)) ;~ GUICtrlSetData($textbox1, "- - - - The return " & $number & " already exists" & @CRLF, 1) ;~ Else ;~ fThrowError(@ScriptLineNumber, ControlClick("Enter number", "", "TButton4", "left", 1)) ;~ fThrowError(@ScriptLineNumber, WinWaitActive("product 2009 :", "pnlNavigation", 10)) ;~ Send("!f") ;~ Send("c") ;~ fThrowError(@ScriptLineNumber, WinWaitActive("product 2009 :", "homepage.htm", 10)) ;~ GUICtrlSetData($textbox1, "- - - - The return " & $number & " Created" & @CRLF, 1) ;~ $iCount = $iCount + 1 ;~ EndIf ;Next; end of for statement GUICtrlSetData($textbox1, "A total of " & $amount & " returns were created" & @CRLF, 1) Next FileClose($file) EndFunc ;==>openRetrun Func fThrowError($sMessage, $iZero) If ($iZero = 0) Then MsgBox(1, "Error", "Please restart tool" & $sMessage) fRunGui() Exit EndIf EndFunc ;==>fThrowError Exit Good luck! Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
jbsoccerbrit Posted November 19, 2013 Author Posted November 19, 2013 Thank you sir, I will check it out for sure .
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