sias Posted September 12, 2008 Share Posted September 12, 2008 I am fairly new to autoit, however, I have done basic scripts for simple functions. However, I recently have attempted one that has become much harder, and though it works without error. It does not do everything I need for it to do. A rundown of my situation is this; A log at work is open at all times (Microsoft Excel), everything that we do is recorded in this log, with the date and time preceding the entry. I simply wrote a program to enter the date and time automatically when a single key is pressed. The program has two main functions. 1) when I press the ` key, it sends Ctrl+; and Ctrl+Shift+; (This auto enters date and time in Microsoft Excel), this I have no problem with and it works without error. The second function, is that every 24 hours, I need for it to autosave the document that is open. This is where I run into trouble, though the program doesn't error, it also doesn't save. As you can see in the following code, I have what I thought would work in there for the date and time, but it isn't working as I expected. What I am requesting is a code, or a way to modify this so that once a day it will save the document automatically, (I have it set so everyday at midnight). Thanks for reading, and for any suggestions or help you may give. RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "ExcelHelper", "REG_SZ", "C:\ExcelHelper_v2.exe") HotKeySet ( "^!x", "ProgExit") winwaitactive ( "Microsoft Excel" ) HotKeySet ( "`", "DateTime") while 1 If @error Then MsgBox (0, "Error 08x002", "An error has occured causing this program to terminate." & @CRLF & 'All data has been saved, Please contact the System Admin for additional assistance.', 120000 ) Exit EndIf winwaitactive ( "Microsoft Excel" ) if @hour = 24 AND @min = 00 AND @sec = 00 Then send( "^s" ) Else sleep(500) EndIf wend Func DateTime() If @error Then MsgBox (0, "Error 08x001", "An error has occured causing this program to terminate." & @CRLF & 'All data has been saved, Please contact System Admin for additional assistance.', 120000 ) Exit EndIf If WinActive( "Microsoft Excel" ) = false Then sleep(2000) ElseIf WinActive( "Microsoft Excel" ) = True Then Send( "{CtrlDown}{;}" ) Send( "{Ctrlup}" ) Send( "{Tab}" ) Send( "{CtrlDown}{ShiftDown}{:}" ) Send( "{Ctrlup}{Shiftup}" ) Send( "{Tab}" ) EndIf EndFunc Func ProgExit() Exit EndFunc "The true measure of a man is how he treats someone who can do him absolutely no good." Link to comment Share on other sites More sharing options...
Alek Posted September 12, 2008 Share Posted September 12, 2008 (edited) edit: try @hour = 00 Edited September 12, 2008 by Alek [font="Impact"]Never fear, I is here.[/font] Link to comment Share on other sites More sharing options...
sias Posted September 12, 2008 Author Share Posted September 12, 2008 edit:try@hour = 00 >_<On the one hand I hope it is that easy....but on the other, it is such an easy fix, I'm going to feel stupid for not thinking of it Thanks for the help. "The true measure of a man is how he treats someone who can do him absolutely no good." Link to comment Share on other sites More sharing options...
sias Posted September 12, 2008 Author Share Posted September 12, 2008 Just as an update, it worked, thank you very much for your assistance Alek. "The true measure of a man is how he treats someone who can do him absolutely no good." 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