polara Posted July 5, 2006 Share Posted July 5, 2006 I am new to AutoIt and need help for a script that runs a Robocopy backup. 1.) I need the script to check if Outlook.exe is open before it starts the backup. It looks like the ProcessClose command would do this. But I also need the script to pop open a dialog box if it finds outlook.exe is open and ask the user to close Outlook, then click Ok. The clicking Ok would then re-check for outlook.exe, then resume the rest of the script commands if no instance of outlook.exe is found, or re-open the dialog box asking that outlook be closed if it is still open. Can anyone show me what these commands would look like? 2.) I would also like to know how to open a dialog box that says "Backup has finished" with a "Click OK" to close button that doesn't open until after the robocopy process has completed. Thanks. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 5, 2006 Moderators Share Posted July 5, 2006 1. If ProcessExists('Outlook.exe') Then 2. MsgBox() Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 5, 2006 Share Posted July 5, 2006 (edited) HI, here is something to start with : $exe = 'outlook.exe' If ProcessExists($exe) Then $answer = MsgBox(33, "Question", "Want to close outlook?", 5) If $answer = 1 Then ProcessClose($exe) EndIf EndIf If ProcessExists($exe) = 0 Then ; rest of script EndIf So long, Mega Edited July 5, 2006 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Paulie Posted July 5, 2006 Share Posted July 5, 2006 (edited) To complete smoke's code: Do If ProcessExists("Outlook.exe") then Msgbox(0, "Close", "Close Outlook Before Continuing.") Until Not ProcessExists('Outlook.exe') ;Do backup Code Here Msgbox(0, "Done", "Backup complete") Edit Got Beat Smoke and th's code Edited July 5, 2006 by Paulie Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 5, 2006 Moderators Share Posted July 5, 2006 HI, here is something to start with : $exe = 'outlook.exe' If ProcessExists($exe) Then $answer = MsgBox(33, "Question", "Want to close outlook?", 5) If $answer = 1 Then ProcessClose($exe) EndIf EndIf If ProcessExists($exe) = 0 Then ; rest of script EndIf So long, MegaWouldn't $answer always = 1? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
seandisanti Posted July 5, 2006 Share Posted July 5, 2006 I am new to AutoIt and need help for a script that runs a Robocopy backup. 1.) I need the script to check if Outlook.exe is open before it starts the backup. It looks like the ProcessClose command would do this. But I also need the script to pop open a dialog box if it finds outlook.exe is open and ask the user to close Outlook, then click Ok. The clicking Ok would then re-check for outlook.exe, then resume the rest of the script commands if no instance of outlook.exe is found, or re-open the dialog box asking that outlook be closed if it is still open. Can anyone show me what these commands would look like? 2.) I would also like to know how to open a dialog box that says "Backup has finished" with a "Click OK" to close button that doesn't open until after the robocopy process has completed. Thanks.$ol = ObjGet("","outlook.Application") If Not @error Then $ol.quit MsgBox(0,"Outlook Closed","The active instance of outlook has been sucessfully closed") Else MsgBox(0,"No outlook","Script failed to get an open outlook object") EndIf Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 5, 2006 Share Posted July 5, 2006 Wouldn't $answer always = 1?HI,no! If you press abort it will be 2. There is Msgbox 33 not 32So long,Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
seandisanti Posted July 5, 2006 Share Posted July 5, 2006 HI,no! If you press abort it will be 2. There is Msgbox 33 not 32So long,Megai say don't even give them the option to say no. use COM to close outlook on them like in my example. then you know it's done. they may get a popup from the application saying 'are you sure you want to empty deleted items folder" or whatever, but as soon as they say yes or no (there is no cancel) then the application closes. Link to comment Share on other sites More sharing options...
polara Posted July 5, 2006 Author Share Posted July 5, 2006 HI, here is something to start with : $exe = 'outlook.exe' If ProcessExists($exe) Then $answer = MsgBox(33, "Question", "Want to close outlook?", 5) If $answer = 1 Then ProcessClose($exe) EndIf EndIf If ProcessExists($exe) = 0 Then ; rest of script EndIf So long, Mega This is a good start but: This kills outlook.exe as if I had killed it in Task Manager. I need it to close as if I had clicked on File>Exit in Outlook so that Outlook can do closing tasks such as sending messages and offline syncing. Any way to do this kind of close? Also, in the message box, clicking Cancel runs the rest of the script anyway, with Outlook still open. I need to halt the entire script and open a message like "Backup cannot run until Outlook is closed" if Outlook is still open. Thanks. Link to comment Share on other sites More sharing options...
seandisanti Posted July 5, 2006 Share Posted July 5, 2006 This is a good start but:This kills outlook.exe as if I had killed it in Task Manager. I need it to close as if I had clicked on File>Exit in Outlook so that Outlook can do closing tasks such as sending messages and offline syncing. Any way to do this kind of close? Also, in the message box, clicking Cancel runs the rest of the script anyway, with Outlook still open. I need to halt the entire script and open a message like "Backup cannot run until Outlook is closed" if Outlook is still open. Thanks.did you see the code that i posted? beta is required Link to comment Share on other sites More sharing options...
polara Posted July 5, 2006 Author Share Posted July 5, 2006 did you see the code that i posted? beta is required I have the beta installed and I did try the code: $ol = ObjGet("","outlook.Application") If Not @error Then $ol.quit MsgBox(0,"Outlook Closed","The active instance of outlook has been sucessfully closed") Else MsgBox(0,"No outlook","Script failed to get an open outlook object") EndIf And got this error message: Link to comment Share on other sites More sharing options...
polara Posted July 5, 2006 Author Share Posted July 5, 2006 I have the beta installed and I did try the code: $ol = ObjGet("","outlook.Application") If Not @error Then $ol.quit MsgBox(0,"Outlook Closed","The active instance of outlook has been sucessfully closed") Else MsgBox(0,"No outlook","Script failed to get an open outlook object") EndIf And got this error message: Ok, I did it again and it worked. Thanks. So, can I assume that, once compiled to an.exe, this will run just like the old versions? Link to comment Share on other sites More sharing options...
seandisanti Posted July 5, 2006 Share Posted July 5, 2006 Ok, I did it again and it worked. Thanks. So, can I assume that, once compiled to an.exe, this will run just like the old versions?you have to make sure you compile with beta, alt+f7 from scite. Link to comment Share on other sites More sharing options...
polara Posted July 5, 2006 Author Share Posted July 5, 2006 (edited) you have to make sure you compile with beta, alt+f7 from scite.Will do. One last question: I really need to open a message box to warn users that Outlook is going to be closed, "Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel." If cancel is clicked, then script is halted and second message that says "Please close Outlook, then run backup again." Edited July 5, 2006 by polara Link to comment Share on other sites More sharing options...
seandisanti Posted July 5, 2006 Share Posted July 5, 2006 Will do. One last question: I really need to open a message box to warn users that Outlook is going to be closed, "Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel." If cancel is clicked, then script is halted and second message that says "Please close Outlook, then run backup again."$ol = ObjGet("","outlook.Application") If @error Then ;no outlook to grab onto EndIf $update = MsgBox(1,"Update","Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel.",5) If $update = 2 Then MsgBox(0,"Update Canceled", "Please close Outlook, then run backup again") Exit EndIf $ol.quit like that? Link to comment Share on other sites More sharing options...
polara Posted July 5, 2006 Author Share Posted July 5, 2006 $ol = ObjGet("","outlook.Application") If @error Then ;no outlook to grab onto EndIf $update = MsgBox(1,"Update","Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel.",5) If $update = 2 Then MsgBox(0,"Update Canceled", "Please close Outlook, then run backup again") Exit EndIf $ol.quit like that? Exactly! I've learned a lot today. Thanks all. Link to comment Share on other sites More sharing options...
seandisanti Posted July 5, 2006 Share Posted July 5, 2006 Exactly! I've learned a lot today. Thanks all.no problem, always glad to help Link to comment Share on other sites More sharing options...
polara Posted July 5, 2006 Author Share Posted July 5, 2006 (edited) $ol = ObjGet("","outlook.Application") If @error Then ;no outlook to grab onto EndIf $update = MsgBox(1,"Update","Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel.",5) If $update = 2 Then MsgBox(0,"Update Canceled", "Please close Outlook, then run backup again") Exit EndIf $ol.quit like that? Oops, found another problem. This works great if Outlook is open. If Outlook is already closed I get this error: What needs to be changed to allow for if Outlook is already closed? Edited July 5, 2006 by polara Link to comment Share on other sites More sharing options...
herewasplato Posted July 6, 2006 Share Posted July 6, 2006 (edited) $ol = ObjGet("", "outlook.Application") If @error Then ;no outlook to grab onto $update = MsgBox(1, "Update", "Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel.", 5) If $update = 2 Then MsgBox(0, "Update Canceled", "Please close Outlook, then run backup again") Exit EndIf $ol.quit EndIfoÝ÷ ØGbµÆ¦zº'±ÖßÛ(®("©¡×°ØfÉÊ&éí±«¢+ØÀÌØí½°ô=©Ð ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí½Õѱ½½¬¹ÁÁ±¥Ñ¥½¸ÅÕ½Ðì¤)%ÉɽÈQ¡¸(í¹¼½Õѱ½½¬Ñ¼É½¹Ñ¼(()¹%ì±Ðì±Ðì±ÐìQ¡¥Ì¥ÌÑ¡¹%Ñ¡Ð$µ½ÙѼѡÙÉä½Ñѽ´½Ñ¡Í¹¥ÁÁбÐì±Ðì±Ðì±Ðì(((ÀÌØíÕÁÑô5Í ½à Ä°ÅÕ½ÐíUÁÑÅÕ½Ðì°ÅÕ½Ðí ÕÀ¹ÌѼ±½Í=Õѱ½½¬½É¥Ð¸ÉÕ¸¸ ±¥¬=¬Ñ¼±½Í=Õѱ½½¬½È ¹°¸ÅÕ½Ðì°Ô¤)%ÀÌØíÕÁÑôÈQ¡¸(5Í ½à À°ÅÕ½ÐíUÁÑ ¹±ÅÕ½Ðì°ÅÕ½ÐíA±Í±½Í=Õѱ½½¬°Ñ¡¸ÉÕ¸ÕÀ¥¸ÅÕ½Ðì¤(á¥Ð)¹%(ÀÌØí½°¹ÅÕ¥Ð( Edited July 6, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
polara Posted July 6, 2006 Author Share Posted July 6, 2006 $ol = ObjGet("", "outlook.Application") If @error Then ;no outlook to grab onto $update = MsgBox(1, "Update", "Backup needs to close Outlook before it can run. Click Ok to close Outlook or Cancel.", 5) If $update = 2 Then MsgBox(0, "Update Canceled", "Please close Outlook, then run backup again") Exit EndIf $ol.quit EndIf Adding in this EndIf at the end gets me this error: EndIf Error: "EndIf" statement with no matching "If" statement. 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