spikyoneuk Posted August 3, 2009 Share Posted August 3, 2009 Hi, I'm writing an app to log off of Sametime (chat app) after a certain amount of time and then shut down the machine. That part works fine however if the screensaver comes on the machine gets locked and the script doesn't work. What would be the cleanest way to have random mouse movements every few minutes during the countdown of the time entered to log off? The screensaver comes on after 15mins. The amount of time for the log off is currently entered in milliseconds, I also wanted to change that so it could be entered in minutes. Code attached for you to giggle at. expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.1.1 (beta) Author: myName Script Function: Logs off of Sametime and can shutdown the machine after. #ce ---------------------------------------------------------------------------- #Include <ScreenCapture.au3> If FileExists(@TempDir & "screen.jpg") Then FileDelete(@TempDir & "screen.jpg") $shutdown = MsgBox (4,"Shut Down?", "Do you want to shut down the machine after logging off of S/T?");Yes or No to shutting down the machine. If $shutdown=6 Then ; If it's a Yes $logofftime = InputBox("Log Off", "How long until you want S/T to log off? Enter amount of time in milliseconds");Prompt to enter in the countdown in milliseconds until logoff. The number entered ;will be stored as variable $logofftime. ;$logofftime/60*1000 MsgBox (0, "Notice", "Before logging off a screen capture will be taken and saved to the same location as the .exe file") Sleep ($logofftime);Take the figure entered from the previous message and delay for that long. While $logofftime < 120000 $x=Random(475,569,1) $y=Random(239,249,1) MouseMove($x,$y) Sleep(60000) WEnd WinActivate ("IBM Lotus Sametime Connect");Make the Sametime client active. _ScreenCapture_Capture(@ScriptDir & "\screen.jpg", 0, 0, @DesktopWidth, @DesktopHeight) Sleep (500);Wait half a second. Send ("!f");Type Alt+f to bring up the File menu. Send ("{DOWN 4})");Move down the menu 4 places. Sleep (500);Wait half a second. Send ("{ENTER}");Press Enter on Log Out Shutdown (8);Shutdown the machine. Else ;If it's a No $logofftime = InputBox("Log Off", "How long until you want S/T to log off? Enter amount of time in milliseconds");Prompt to enter in the countdown in milliseconds until logoff. The number entered ;will be stored as variable $logofftime. MsgBox (0, "Notice", "Before logging off a screen capture will be taken and saved to the same location as the .exe file") Sleep ($logofftime) ;Take the figure entered from the previous message and delay for that long. While $logofftime < 120000 $x=Random(475,569,1) $y=Random(239,249,1) MouseMove($x,$y) Sleep(60000) WEnd WinActivate ("IBM Lotus Sametime Connect") ;Make the Sametime client active. _ScreenCapture_Capture(@ScriptDir & "\screen.jpg", 0, 0, @DesktopWidth, @DesktopHeight) Sleep (500);Wait half a second. Send ("!f") ;Type Alt+f to bring up the File menu. Send ("{DOWN 4})");Move down the menu 4 places. Sleep (500);Wait half a second. Send ("{ENTER}") ;Press Enter on Log Out EndIf Link to comment Share on other sites More sharing options...
Info Posted August 3, 2009 Share Posted August 3, 2009 (edited) Take a look at the timer functions - TimerInit() and TimerDiff().Also,Mouse movements during a delay/sleepIsn't possible.The Sleep() function pauses your script so you cannot perform any actions while the whole script is paused.Edit:http://www.autoitscript.com/forum/index.php?showtopic=99348 Edited August 3, 2009 by Info Link to comment Share on other sites More sharing options...
zorphnog Posted August 3, 2009 Share Posted August 3, 2009 If you want to designate an action to happen every x amount of time, then look at AdlibEnable. A screensaver has nothing to do with why your script is not working correctly, though. You have an endless while loop if your logofftime is less than 120000. Try something like this: #Include <ScreenCapture.au3> If FileExists(@TempDir & "screen.jpg") Then FileDelete(@TempDir & "screen.jpg") $shutdown = MsgBox (4,"Shut Down?", "Do you want to shut down the machine after logging off of S/T?");Yes or No to shutting down the machine. $logofftime = InputBox("Log Off", "How long until you want S/T to log off? Enter amount of time in minutes");Prompt to enter in the countdown in minutes until logoff. The number entered $logofftime *= 60000 ;convert to milliseconds MsgBox (0, "Notice", "Before logging off a screen capture will be taken and saved to the same location as the .exe file") Sleep($logofftime) ;delay WinActivate ("IBM Lotus Sametime Connect");Make the Sametime client active. _ScreenCapture_Capture(@ScriptDir & "\screen.jpg", 0, 0, @DesktopWidth, @DesktopHeight) Sleep (500);Wait half a second. Send ("!f");Type Alt+f to bring up the File menu. Send ("{DOWN 4})");Move down the menu 4 places. Sleep (500);Wait half a second. Send ("{ENTER}");Press Enter on Log Out If $shutdown=6 Then Shutdown (8) ; If it's a Yes Link to comment Share on other sites More sharing options...
spikyoneuk Posted August 4, 2009 Author Share Posted August 4, 2009 If you want to designate an action to happen every x amount of time, then look at AdlibEnable. A screensaver has nothing to do with why your script is not working correctly, though. You have an endless while loop if your logofftime is less than 120000. Try something like this: #Include <ScreenCapture.au3> If FileExists(@TempDir & "screen.jpg") Then FileDelete(@TempDir & "screen.jpg") $shutdown = MsgBox (4,"Shut Down?", "Do you want to shut down the machine after logging off of S/T?");Yes or No to shutting down the machine. $logofftime = InputBox("Log Off", "How long until you want S/T to log off? Enter amount of time in minutes");Prompt to enter in the countdown in minutes until logoff. The number entered $logofftime *= 60000 ;convert to milliseconds MsgBox (0, "Notice", "Before logging off a screen capture will be taken and saved to the same location as the .exe file") Sleep($logofftime) ;delay WinActivate ("IBM Lotus Sametime Connect");Make the Sametime client active. _ScreenCapture_Capture(@ScriptDir & "\screen.jpg", 0, 0, @DesktopWidth, @DesktopHeight) Sleep (500);Wait half a second. Send ("!f");Type Alt+f to bring up the File menu. Send ("{DOWN 4})");Move down the menu 4 places. Sleep (500);Wait half a second. Send ("{ENTER}");Press Enter on Log Out If $shutdown=6 Then Shutdown (8) ; If it's a Yes Sorry, I should have clarified, it was working (except for when the screensaver comes on) before I started looking at trying to get the mouse movements. I'll have a look at AdlibEnable, thanks. Link to comment Share on other sites More sharing options...
spikyoneuk Posted August 4, 2009 Author Share Posted August 4, 2009 Take a look at the timer functions - TimerInit() and TimerDiff().Also,Isn't possible.The Sleep() function pauses your script so you cannot perform any actions while the whole script is paused.Edit:http://www.autoitscript.com/forum/index.php?showtopic=99348Cool, I'll have a look, thanks. 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