iHonda Posted March 12, 2006 Share Posted March 12, 2006 Ok i so i wrote this script that is supposed to run the disk clean up program and stuff and write the instructions to a notepad document but everytime i run the script it launches it self like 8 times its really irratating to close all of the windows and end all of the scipts can you guys help me?? i dont know how to post that Code thing like everyone else does so ill attach it. A great place to start Autoit 1-2-3 Link to comment Share on other sites More sharing options...
Bokkie Posted March 12, 2006 Share Posted March 12, 2006 (edited) Ok i so i wrote this script that is supposed to run the disk clean up program and stuff and write the instructions to a notepad document but everytime i run the script it launches it self like 8 times its really irratating to close all of the windows and end all of the scipts can you guys help me?? i dont know how to post that Code thing like everyone else does so ill attach it.To post code is easy. Above the reply text window, notice the button roughly in the middle, looks like a # in a box? Paste in your code and select it, then click the # button and it'll add the code tags around it. Of course this does not help you with your problem but at least now you know how to do the "code thing". Edited March 12, 2006 by Peter Hamilton-Scott Link to comment Share on other sites More sharing options...
nfwu Posted March 12, 2006 Share Posted March 12, 2006 (edited) EDIT: For the sake of others, i'll repost the code in a code "quote". expandcollapse popup; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.0 ; Author: A.N.Other <myemail@nowhere.com> ; ; Script Function: ; Template AutoIt script. ; ; ---------------------------------------------------------------------------- ; Script Start ;Displays tip from tray icon TrayTip("Initiating DisKlean", "Now Starting DisKlean Please refer to the notepad that is being opened for instructions.", 30, 1) ;Launchs notepad, & writes info to notepad document Run("notepad.exe") Send("~~DisKlean By: Zmaster)atF(~~{ENTER}") Send("{ENTER}DO NOT CLOSE THIS WINDOW IT WILL CLOSE IT SELF LATER{ENTER}") Send("{ENTER}Thank you for using my program, I promise that it is 100% safe to use.This window will automaticaly close itself when the wizard is done running. Please follow all instructions on this page once the text has idled or you will freeze the script if that happens restart the script or the wizard will not work.{ENTER}") ;Launchs Disk Clean Up Sleep(800) Run("cleanmgr.exe") WinWaitActive("Disk Cleanup for (C:)") Sleep(800) ;Writes the Disk Clean Up instructions to Notepad WinActivate("Untitled - Notepad") Send("{ENTER}1. Make sure that the following Files to Delete are selected in the Disk Clean up for (C:) window") Send("{ENTER}Downloaded Program Files{ENTER}") Send("{ENTER}Temporary Internet Files{ENTER}") Send("{ENTER}Recycle Bing{ENTER}") Send("{ENTER}Temporary file{ENTER}") Send("{ENTER}WebClient/Publisher Temporary Files{ENTER}") Send("{ENTER}Compress old files{ENTER}") Send("{ENTER}After all of those boxes are selected click OK.{ENTER}") Sleep(50000) Send("{ENTER}Thank you for using DisKlean By:Zmaster)atF( if you have any comments or questions send them to <ihonda1@gmail.com>. I strongly recommend that you run this program at least twice a month so that it does not take too long, a good schedule would be to run the program on the first of the month and then again on either the sixteenth or seventeenth. The more often you run the program the better it will work.") #) Edited March 12, 2006 by nfwu TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
MHz Posted March 12, 2006 Share Posted March 12, 2006 Your Send() would triggering the 2nd instance of the script as you do not use WinWaitActive to wait for the Notepad window, so it send to the item which has focus, your script. FAQ 14 will help to prevent uncontrolled 2 instances of your script. My additions are commented with ;ADDED in the line. expandcollapse popup; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.0 ; Author: A.N.Other <myemail@nowhere.com> ; ; Script Function: ; Template AutoIt script. ; ; ---------------------------------------------------------------------------- ; Script Start ; Place at the top of your script;ADDED $g_szVersion = "My Script 1.1";ADDED If WinExists($g_szVersion) Then Exit; It's already running;ADDED AutoItWinSetTitle($g_szVersion);ADDED ; Rest of your script goes here;ADDED ;Displays tip from tray icon TrayTip("Initiating DisKlean", "Now Starting DisKlean Please refer to the notepad that is being opened for instructions.", 30, 1) ;Launchs notepad, & writes info to notepad document Run("notepad.exe") WinWaitActive('Untitled');ADDED Send("~~DisKlean By: Zmaster)atF(~~{ENTER}") Send("{ENTER}DO NOT CLOSE THIS WINDOW IT WILL CLOSE IT SELF LATER{ENTER}") Send("{ENTER}Thank you for using my program, I promise that it is 100% safe to use.This window will automaticaly close itself when the wizard is done running. Please follow all instructions on this page once the text has idled or you will freeze the script if that happens restart the script or the wizard will not work.{ENTER}") ;Launchs Disk Clean Up Sleep(800) Run("cleanmgr.exe") WinWaitActive("Disk Cleanup for (C:)") Sleep(800) ;Writes the Disk Clean Up instructions to Notepad WinActivate("Untitled - Notepad") Send("{ENTER}1. Make sure that the following Files to Delete are selected in the Disk Clean up for (C:) window") Send("{ENTER}Downloaded Program Files{ENTER}") Send("{ENTER}Temporary Internet Files{ENTER}") Send("{ENTER}Recycle Bing{ENTER}") Send("{ENTER}Temporary file{ENTER}") Send("{ENTER}WebClient/Publisher Temporary Files{ENTER}") Send("{ENTER}Compress old files{ENTER}") Send("{ENTER}After all of those boxes are selected click OK.{ENTER}") Sleep(50000) Send("{ENTER}Thank you for using DisKlean By:Zmaster)atF( if you have any comments or questions send them to <ihonda1@gmail.com>. I strongly recommend that you run this program at least twice a month so that it does not take too long, a good schedule would be to run the program on the first of the month and then again on either the sixteenth or seventeenth. The more often you run the program the better it will work.") Link to comment Share on other sites More sharing options...
BigDod Posted March 12, 2006 Share Posted March 12, 2006 If you run your script from SciTe it writes all over the script so it appears there is something wrong with the activation of notepad. I am assuming that you are running it from a compiled exe, Change the name of the exe to something else and try it again, I would suggest test.exe to begin with. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
iHonda Posted March 12, 2006 Author Share Posted March 12, 2006 (edited) thanx Mhz wut u changed fixed the problem. but now i have another problem i dont remember how to close the notepad window :"> Edited March 12, 2006 by Zmaster A great place to start Autoit 1-2-3 Link to comment Share on other sites More sharing options...
greenmachine Posted March 12, 2006 Share Posted March 12, 2006 Look at the notepad demo in the helpfile. Link to comment Share on other sites More sharing options...
slightly_abnormal Posted March 12, 2006 Share Posted March 12, 2006 (edited) Look at the notepad demo in the helpfile. expandcollapse popup; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.0 ; Author: A.N.Other <myemail@nowhere.com> ; ; Script Function: ; Template AutoIt script. ; ; ---------------------------------------------------------------------------- ; Script Start ; Place at the top of your script;ADDED $g_szVersion = "My Script 1.1";ADDED If WinExists($g_szVersion) Then Exit; It's already running;ADDED AutoItWinSetTitle($g_szVersion);ADDED ; Rest of your script goes here;ADDED ;Displays tip from tray icon TrayTip("Initiating DisKlean", "Now Starting DisKlean Please refer to the notepad that is being opened for instructions.", 30, 1) ;Launchs notepad, & writes info to notepad document Run("notepad.exe") WinWaitActive('Untitled');ADDED Send("~~DisKlean By: Zmaster)atF(~~{ENTER}") Send("{ENTER}DO NOT CLOSE THIS WINDOW IT WILL CLOSE IT SELF LATER{ENTER}") Send("{ENTER}Thank you for using my program, I promise that it is 100% safe to use.This window will automaticaly close itself when the wizard is done running. Please follow all instructions on this page once the text has idled or you will freeze the script if that happens restart the script or the wizard will not work.{ENTER}") ;Launchs Disk Clean Up Sleep(800) Run("cleanmgr.exe") WinWaitActive("Disk Cleanup for (C:)") Sleep(800) ;Writes the Disk Clean Up instructions to Notepad WinActivate("Untitled - Notepad") Send("{ENTER}1. Make sure that the following Files to Delete are selected in the Disk Clean up for (C:) window") Send("{ENTER}Downloaded Program Files{ENTER}") Send("{ENTER}Temporary Internet Files{ENTER}") Send("{ENTER}Recycle Bing{ENTER}") Send("{ENTER}Temporary file{ENTER}") Send("{ENTER}WebClient/Publisher Temporary Files{ENTER}") Send("{ENTER}Compress old files{ENTER}") Send("{ENTER}After all of those boxes are selected click OK.{ENTER}") Sleep(50000) WinClose("Untitled - Notepad") WinWaitActive("Notepad", "The text in the Untitled file has changed") Send("!n"); !y= yes !n= no hope this helps.. Sleep(50000) thats quite along wait Edited March 12, 2006 by slightly_abnormal Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted March 12, 2006 Share Posted March 12, 2006 (edited) If ProcessExists("notepad.exe") Then ProcessClose("notepad.exe") endif Edited March 12, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
iHonda Posted March 12, 2006 Author Share Posted March 12, 2006 lol ya but some times the disc clean takes a long time so i had to make it long to acomadate that unless there is a way to detect when its done. A great place to start Autoit 1-2-3 Link to comment Share on other sites More sharing options...
greenmachine Posted March 12, 2006 Share Posted March 12, 2006 lol ya but some times the disc clean takes a long time so i had to make it long to acomadate that unless there is a way to detect when its done.Like maybe.. RunWait instead of just Run... or ProcessWaitClose...? Link to comment Share on other sites More sharing options...
iHonda Posted March 12, 2006 Author Share Posted March 12, 2006 (edited) i didnt think of that thanx, but how do i get it to write the note pad stuff?? since the runwait thing pauses the script for the cleaner?? Edited March 12, 2006 by Zmaster A great place to start Autoit 1-2-3 Link to comment Share on other sites More sharing options...
FreeFry Posted March 13, 2006 Share Posted March 13, 2006 i didnt think of that thanx, but how do i get it to write the note pad stuff?? since the runwait thing pauses the script for the cleaner?? I Think this might work better for you: Opt("WinTitleMatchMode", 4) $g_szVersion = "My Script 1.1" If WinExists($g_szVersion) Then Exit AutoItWinSetTitle($g_szVersion) TrayTip("Initiating DisKlean", "Now Starting DisKlean Please refer to the notepad that is being opened for instructions.", 30, 1) Run("notepad.exe") WinWaitActive("classname=Notepad") WinSetTitle("classname=Notepad", "", "Instructions") ControlSend("classname=Notepad", "", "Edit1", _ "~~DisKlean By: Zmaster)atF(~~" & @CRLF & @CRLF _ & "DO NOT CLOSE THIS WINDOW IT WILL CLOSE IT SELF LATER" & @CRLF & @CRLF _ & "Thank you for using my program, I promise that it is 100% safe to use." & @CRLF _ & "This window will automaticaly close itself when the wizard is done running." & @CRLF _ & "Please follow all instructions on this page for optimal script operation." & @CRLF & @CRLF _ & "1. Make sure that the following Files to Delete are selected in the Disk Clean up for (C:) window" & @CRLF _ & "Downloaded Program Files" & @CRLF _ & "Temporary Internet Files" & @CRLF _ & "Recycle Bing" & @CRLF _ & "Temporary file" & @CRLF _ & "WebClient/Publisher Temporary Files" & @CRLF _ & "Compress old files" & @CRLF _ & "After all of those boxes are selected click OK." & @CRLF) Run("cleanmgr.exe") ProcessWaitClose("cleanmgr.exe") ProcessClose("notepad.exe") Link to comment Share on other sites More sharing options...
iHonda Posted March 13, 2006 Author Share Posted March 13, 2006 (edited) cool thank you, would u guys happen to know if there is a way that i can eliminate the need for a user to select the differnt things and just have the script do it on its own?? Edited March 13, 2006 by Zmaster A great place to start Autoit 1-2-3 Link to comment Share on other sites More sharing options...
FreeFry Posted March 13, 2006 Share Posted March 13, 2006 (edited) No problem mate, hope you learn something from it. Edit: Yes there is a way, actually there are a couple of ways you could try, one is Sending {up} or {down} and {space} to select the item(s) that are to be cleaned, OR you could look into the command "ControlListView" (which i dont have any knowledge about, but you could try it) thats my best shot if i where you. Edit2(doh): Ok, i looked into this a little, and i found out that the easiest way to do it was to use ControlSend, ill post my version of it here, but you need to change the text it searches for, ie. the "diskutrymme" to whatever text you can find in the DiscCleaning window(remember the CaSeInG). Edit3(....): Doh! Forgot to upload my version ... to little sleep last night i guess... ah well, here it is Edited March 13, 2006 by FreeFry 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