Jump to content

First Script Help


Recommended Posts

Hi People, This is my very first script, i read about this in APC and it seemed pretty cool. I am making a script that u open it and it launches defragmenter and then opens notepad and writes the time and date u started, then it waits for it to finish then it says the time it finish, then loops. But writes in the same document i dunno why it wont work.

While 1 = 1
Send("#r")
WinWaitActive("Run")
Send("dfrg.msc{Enter}")
WinWaitActive("Disk Defragmenter")
MouseClick("primary", 160, 370, 1)
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Defragmentation started at {F5}.")
sleep(500)
WinSetState ( "Untitled - Notepad", "Progress", @SW_MINIMIZE )
WinWaitActive("Disk Defragmeter")
send("{RIGHT}")
send("{ENTER}")
WinSetState ( "Untitled - Notepad", "Progress", @SW_MAXIMIZE )
Send("{ENTER}")
Send("Defragmentation Completed at {F5}")
Send("{ENTER 2}")
WEnd

Just tell me where i went wrong please, also if someone could tell me another way of clicking on the defragment button apart from "Mouseclick"

Link to comment
Share on other sites

how about run(dfrgui.exe)

to open it... and then go into your editor click on tools then on the one with macro in it someweare... run it... start recording.. then click on the buitton and stop recording.... then save script and run script and it should work.

You could also use defrag.exe :P Should work better than simulated mouse clicks. Google the usage of it thought. I'm not too sure. I think if you go run and type "defrag.exe C:" it will defrag C:... Think... :)
Link to comment
Share on other sites

Hi People, This is my very first script, i read about this in APC and it seemed pretty cool. I am making a script that u open it and it launches defragmenter and then opens notepad and writes the time and date u started, then it waits for it to finish then it says the time it finish, then loops. But writes in the same document i dunno why it wont work.

While 1 = 1
Send("#r")
WinWaitActive("Run")
Send("dfrg.msc{Enter}")
WinWaitActive("Disk Defragmenter")
MouseClick("primary", 160, 370, 1)
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Defragmentation started at {F5}.")
sleep(500)
WinSetState ( "Untitled - Notepad", "Progress", @SW_MINIMIZE )
WinWaitActive("Disk Defragmeter")
send("{RIGHT}")
send("{ENTER}")
WinSetState ( "Untitled - Notepad", "Progress", @SW_MAXIMIZE )
Send("{ENTER}")
Send("Defragmentation Completed at {F5}")
Send("{ENTER 2}")
WEnd

Just tell me where i went wrong please, also if someone could tell me another way of clicking on the defragment button apart from "Mouseclick"

Do you want it to loop? Do you want it to write in the same document the start and finish times? What exactly are you trying to do?

My understanding of what you want to do is open and run defrag, document start and stop times, end script. Why not just use task scheduler it does all this already.

Edited by schilbiz
Link to comment
Share on other sites

Do you want it to loop? Do you want it to write in the same document the start and finish times? What exactly are you trying to do?

My understanding of what you want to do is open and run defrag, document start and stop times, end script. Why not just use task scheduler it does all this already.

This is my first script so i wanted to learn some of the basic functions, and it woudlnt really work so i asked for some input and thanks for the help people i will try again using ur ideas.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...