matrixnz Posted January 22, 2008 Share Posted January 22, 2008 Hi there I've created a small script that inserts a customised OUTLOOK.HOL file with all our companies Holidays for the next 3 years, it's based on the Microsoft Update KB924423. If the date is older then my version which I've touched to 01/01/2008 I want it to backup their old file and copy the new file on their system. Now the issue isn't a major and to be honest I could live without the fix but it's just bugging me, I'm unsure if it's the Tool Window I'm using or I haven't used the correct code within the while <...> statement below. I attempted to use <switch> etc.. but I don't have a full understanding of that function and well it didn't work anyway If anyone could help point me in the right direction, it would be much appreciated. Cheers CODE #NoTrayIcon #include <GUIConstants.au3> #include <IE.au3> #include <Date.au3> $OUTLOOK_ICON = "OUTLOOK.ico" $OUTLHOL_TDDT = StringSplit(_NowDate(), '/') ; Todays Date Split $OUTLHOL_OLDT = $OUTLHOL_TDDT[3] & '-' & $OUTLHOL_TDDT[2] & '-' & $OUTLHOL_TDDT[1] & '_' ; Todays Date Formated to YYYY-MM-DD $OUTLOOK_FLDR = @ProgramFilesDir & '\Microsoft Office\OFFICE11\' ; Path to OUTLOOK.EXE $OUTLOOK_FILE = 'OUTLOOK.EXE' ; OUTLOOK.EXE Filename $OUTLOOK_EXST = FileExists($OUTLOOK_FLDR & $OUTLOOK_FILE) ; Verify OUTLOOK.EXE Exists $OUTLHOL_FLDR = @ProgramFilesDir & '\Microsoft Office\OFFICE11\1033\' ; Path to OUTLOOK.HOL $OUTLHOL_FILE = 'OUTLOOK.HOL' ; OUTLOOK.HOL Filename $OUTLHOL_EXST = FileExists($OUTLHOL_FLDR & $OUTLHOL_FILE) ; Verify OUTLOOK.HOL Exists $FILEDATE = FileGetTime($OUTLHOL_FLDR & $OUTLHOL_FILE, -1, 1) ; Get OUTLOOK.HOL Modify Date and Time While 1 If Not $OUTLOOK_EXST Then Exit ; If OUTLOOK.EXE doesn't exist Exit Script ExitLoop ; OUTLOOK.EXE Exists Continue Script WEnd If $FILEDATE >= '20080101120000' Then ; If OUTLOOK.HOL Modify Date and Time less then or equal to 20080101120000 Then No Update is required _IECreate ("www.autoitscript.com", 0, 1, 1, 0) ; Open Browser with instructions on enabling Outlook Holiday Update. Exit Else FileMove($OUTLHOL_FLDR & $OUTLHOL_FILE, $OUTLHOL_FLDR & $OUTLHOL_OLDT & $OUTLHOL_FILE & '.OLD') ; Renames OUTLOOK.HOL to <Todays Date>_OUTLOOK.HOL.OLD GUICreate("Outlook 2003 Updates",300,100, -1,-1, $WS_THICKFRAME, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW) $LABEL_INSTALL = GUICtrlCreateLabel("Updating Outlook 2003 Calendar, please wait...", 40, 10, 300) GUICtrlCreateIcon ($OUTLOOK_ICON, 1, 3, 3) $PROGRESSBAR = GUICtrlCreateProgress (10, 40, 280, 5,$PBS_SMOOTH) GUISetState() FileCopy( @ScriptDir & '\OUTLOOK.HOL', $OUTLHOL_FLDR, 1) EndIf While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit For $i = 0 to 100 step 10 sleep(150) GUICtrlSetData ($PROGRESSBAR, $i) Next $OUTLHOL_DATE = FileGetTime($OUTLHOL_FLDR & $OUTLHOL_FILE, -1, 1) ; Get OUTLOOK.HOL Modify Date and Time If $OUTLHOL_DATE = '20080101120000' Then GUICtrlSetData ($LABEL_INSTALL, 'Update Complete!') If $OUTLHOL_DATE = '20080101120000' Then sleep(1000) If $OUTLHOL_DATE = '20080101120000' Then GUIDelete() If $OUTLHOL_DATE = '20080101120000' Then ExitLoop Wend _IECreate ("www.autoitscript.com", 0, 1, 1, 0) ; Open Browser with instructions on enabling Outlook Holiday Update. Link to comment Share on other sites More sharing options...
Swift Posted January 22, 2008 Share Posted January 22, 2008 (edited) Just Use While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd that should work...think thats what i used Edited January 22, 2008 by Swift Link to comment Share on other sites More sharing options...
matrixnz Posted January 22, 2008 Author Share Posted January 22, 2008 Hi Swift Thanks for the quick reply I tried the following but it still doesn't exit, for e.g. if I change "If $OUTLHOL_DATE = '20080101120000'" to "If $OUTLHOL_DATE = '20080101120001'" the window stays in the loop even if I press [x] (hope that makes sense) Cheers CODEWhile 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch For $i = 0 to 100 step 10 sleep(150) GUICtrlSetData ($PROGRESSBAR, $i) Next $OUTLHOL_DATE = FileGetTime($OUTLHOL_FLDR & $OUTLHOL_FILE, -1, 1) ; Get OUTLOOK.HOL Modify Date and Time If $OUTLHOL_DATE = '20080101120000' Then GUICtrlSetData ($LABEL_INSTALL, 'Update Complete!') If $OUTLHOL_DATE = '20080101120000' Then sleep(1000) If $OUTLHOL_DATE = '20080101120000' Then GUIDelete() If $OUTLHOL_DATE = '20080101120000' Then ExitLoop Wend 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