DarkAnel Posted April 13, 2012 Share Posted April 13, 2012 Hi!! I got a small problem i want to exit the loop when i click on the $cancelbutton the loop continuei want the $okbutton to start my loop and $cancelbutton to exit the scriptCAN YOU HELP ME PLEASE#include <GUIConstantsEx.au3>_Main()Func _Main() Local $filemenu, $fileitem, $recentfilesmenu Local $exititem, $helpmenu, $aboutitem, $okbutton, $cancelbutton Local $msg, $file GUICreate("AntiSleep Script", 300, 150) $filemenu = GUICtrlCreateMenu("File") $exititem = GUICtrlCreateMenuItem("Exit", $filemenu) $helpmenu = GUICtrlCreateMenu("?") $aboutitem = GUICtrlCreateMenuItem("About", $helpmenu) $okbutton = GUICtrlCreateButton("Start the AntiSleep Script", 50, 10, 200, 40) $cancelbutton = GUICtrlCreateButton("Stop", 50, 60, 200, 40) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton ExitLoop Case $msg = $exititem ExitLoop Case $msg = $okbutton ; this is where my problem startdo MouseMove(800, 900) Sleep (4000) MouseMove(600, 800) Sleep (4000) until $msg = $cancelbutton ExitLoop Case $msg = $aboutitem MsgBox(0, "About", "This Script was created by Eric Boudreau") EndSelect WEnd GUIDelete() ExitEndFunc ;==>_Main Link to comment Share on other sites More sharing options...
kylomas Posted April 13, 2012 Share Posted April 13, 2012 Darkanel, Use "EXIT", not "EXITLOOP" when you want to exit the script. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Skitty Posted April 13, 2012 Share Posted April 13, 2012 (edited) You're not allowing the guigetmsg function to set the massage to the variable... Also, since you seem to be starting at this, try to avoid using while loops and make your learning experience involve more "on event" functions, you'll thank me later. Edited April 13, 2012 by ApudAngelorum Link to comment Share on other sites More sharing options...
EndFunc Posted April 13, 2012 Share Posted April 13, 2012 (edited) Darkanel,Use "EXIT", not "EXITLOOP" when you want to exit the script.kylomasI don't think he wants to exit the script. If he uses Exit, it will close his Gui. I see it as him wanting to go back to Ready or Idle status.Edit: NM, I misread his request. I thought he wanted to just go back to the interface.. Edited April 13, 2012 by EndFunc EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
Reg2Post Posted April 13, 2012 Share Posted April 13, 2012 To OP, What is this for? Your button title leads me to believe you want people to believe this is to prevent a screen saver to kick in. Link to comment Share on other sites More sharing options...
Skitty Posted April 13, 2012 Share Posted April 13, 2012 To OP,What is this for?Your button title leads me to believe you want people to believe this is to prevent a screen saver to kick in.jaja, i just noticed that, wtf? it would be weird to create a script to disable a sccreen saver when you casn do that by the right click contect menu and editing screen saver options in the display properties..; Link to comment Share on other sites More sharing options...
kylomas Posted April 13, 2012 Share Posted April 13, 2012 @EndFunc, Your right, I mis-read the deal...ApudAngelorum got it...$msg does not get set kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 13, 2012 Moderators Share Posted April 13, 2012 DarkAnel,try to avoid using while loops and make your learning experience involve more "on event" functionsNot altogether of the same opinion. Choose whichever best suits whatever you are trying to do - which means you need to understand both Event Modes (MessageLoop and OnEvent). M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
DarkAnel Posted April 13, 2012 Author Share Posted April 13, 2012 (edited) this script is to prevent the computer to go sleep, i do alot of computer update and i open a RDP on the user session and sometime the update take alot of time and the session lock because no activity was done on the computer when you are on a domain you cant do what you want, and where i work we got a GPO if the computer is in idle for 10 minute the session lock and we can't play in the display option to disable the screen saver and its why i want to generate some activity on the computer with this script Edited April 13, 2012 by DarkAnel Link to comment Share on other sites More sharing options...
Reg2Post Posted April 13, 2012 Share Posted April 13, 2012 jaja, i just noticed that, wtf? it would be weird to create a script to disable a sccreen saver when you casn do that by the right click contect menu and editing screen saver options in the display properties..;Actually, my subtle point was that clicking a button would already disable a screen saver. Link to comment Share on other sites More sharing options...
Skitty Posted April 13, 2012 Share Posted April 13, 2012 Actually, my subtle point was that clicking a button would already disable a screen saver.Well, I know that...Point is that I think we can both agree that this is not the corrrect way of going about this. Link to comment Share on other sites More sharing options...
Reg2Post Posted April 13, 2012 Share Posted April 13, 2012 this script is to prevent the computer to go sleep, i do alot of computer update and i open a RDP on the user session and sometime the update take alot of time and the session lock because no activity was done on the computerwhen you are on a domain you cant do what you want, and where i work we got a GPO if the computer is in idle for 10 minute the session lockSure. And what GPO would this be that you can't just log right back in? Link to comment Share on other sites More sharing options...
EndFunc Posted April 13, 2012 Share Posted April 13, 2012 Sure. And what GPO would this be that you can't just log right back in?Probably just the hassle of having to log back in IMO. We have similar polcies, but it shouldn't hurt what your running in the session though. EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
DarkAnel Posted April 13, 2012 Author Share Posted April 13, 2012 Sure. And what GPO would this be that you can't just log right back in?tell me how you can have the user password? Link to comment Share on other sites More sharing options...
kaotkbliss Posted April 13, 2012 Share Posted April 13, 2012 this is one of the early scripts I made and still use today I have a machine I don't want to lock (and can't change the setting) so I have this script running 24/7 and works wonderfully. Since the mouse only moves just enough to keep the pc from locking, it doesn't interfere with other stuff you are doing. While 1 $pos = MouseGetPos() $x = $pos[0] $y = $pos[1] If $x<1023/2 And $y<767/2 Then MouseMove($x + 5,$y + 5) If $x>1023/2 And $y>767/2 Then MouseMove($x - 5,$y - 5) If $x<1023/2 And $y>767/2 Then MouseMove($x + 5,$y - 5) If $x>1023/2 And $y<767/2 Then MouseMove($x - 5,$y + 5) Sleep(300000) WEnd 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Reg2Post Posted April 13, 2012 Share Posted April 13, 2012 This thread stinks of a big pile. @EndFunc: Yes, logging in would be inconvenient but pressing a button every 10 mins to prevent the screen saver kicking in wouldn't? Why not focus the mouse on the remote host and move the mouse? @OP: Your job responsibilities are perplexing. You have RDP rights but are asking me you need a user password to log back into your session? No offence (sincerely) but I am not believing your reason you need help with this script. Link to comment Share on other sites More sharing options...
DarkAnel Posted April 13, 2012 Author Share Posted April 13, 2012 (edited) this is one of the early scripts I made and still use today I have a machine I don't want to lock (and can't change the setting) so I have this script running 24/7 and works wonderfully. Since the mouse only moves just enough to keep the pc from locking, it doesn't interfere with other stuff you are doing. [autoit]While 1 $pos = MouseGetPos() $x = $pos[0] $y = $pos[1] If $x<1023/2 And $y<767/2 Then MouseMove($x + 5,$y + 5) If $x>1023/2 And $y>767/2 Then MouseMove($x - 5,$y - 5) If $x<1023/2 And $y>767/2 Then MouseMove($x + 5,$y - 5) If $x>1023/2 And $y<767/2 Then MouseMove($x - 5,$y + 5) Sleep(300000) WEnd[/autoit ] thank you tho share you script it will work, but i will not the only one to use this script and its why i want a GUI to start and stop the script i have do a script with a loop of mousemove with a exit hotkey but if someone start the script and dont know the hotkey, the user need to kill the process its not really good but anyway i pretty sure someone will have a small modification on my script (sorry for my bad english) Edited April 13, 2012 by DarkAnel Link to comment Share on other sites More sharing options...
BrewManNH Posted April 13, 2012 Share Posted April 13, 2012 Reg2Post, do you even work on computers in a domain? If not, you really shouldn't say anything because you're starting to look silly. When I'm logged into a computer on any of the domains I work on, they will all lock if the idle time kicks in, and then I HAVE to log back onto the Windows environment because the screensaver password screen is showing. If I don't have the user's password, I'm stuck until I can get in touch with that user. If I RDP into that computer, I'm logged in as myself, but if I use LanDesk, I'm logged into their session, same with Dameware. If this prevents having that happen, then it's useful. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
DarkAnel Posted April 13, 2012 Author Share Posted April 13, 2012 (edited) This thread stinks of a big pile.@EndFunc: Yes, logging in would be inconvenient but pressing a button every 10 mins to prevent the screen saver kicking in wouldn't? Why not focus the mouse on the remote host and move the mouse?@OP: Your job responsibilities are perplexing. You have RDP rights but are asking me you need a user password to log back into your session?No offence (sincerely) but I am not believing your reason you need help with this script.OK I HAVE SAID RDP but its to easy understand i use DAMEWARE to do a remote control on a computer and i jump directly in the user session, AND I GOT A GPO, and this gpo lock the computer after 10 minutes, i have try alot of thing but nothing work the mouse need to move..You should know the only way to have the user password on a domain is to do a password reset, and the user will not loving it...Oh yeah, i need to tell also i can not mouve the mouse of 20 pc in sametime to generate activity... i just can pray to return on the computer before the end of 10 minutes Edited April 13, 2012 by DarkAnel Link to comment Share on other sites More sharing options...
EndFunc Posted April 13, 2012 Share Posted April 13, 2012 (edited) Reg2Post, do you even work on computers in a domain? If not, you really shouldn't say anything because you're starting to look silly.When I'm logged into a computer on any of the domains I work on, they will all lock if the idle time kicks in, and then I HAVE to log back onto the Windows environment because the screensaver password screen is showing. If I don't have the user's password, I'm stuck until I can get in touch with that user. If I RDP into that computer, I'm logged in as myself, but if I use LanDesk, I'm logged into their session, same with Dameware. If this prevents having that happen, then it's useful.AgreedThis thread stinks of a big pile.@EndFunc: Yes, logging in would be inconvenient but pressing a button every 10 mins to prevent the screen saver kicking in wouldn't? Why not focus the mouse on the remote host and move the mouse?@OP: Your job responsibilities are perplexing. You have RDP rights but are asking me you need a user password to log back into your session?No offence (sincerely) but I am not believing your reason you need help with this script.If you are RDP'd to a server or computer, it will still lock if you are idle. Its just a window. so in order to keep it from locking it must be maximized and activity occurring, e.g. moving the mouse. Also, when you do desktop support often the user leaves you with the PC so that you can do work on it. If you didn't get their password and the computer locks if you step away, then you have to track them down to get it. What if they left for the day? Then you have to wait to finish.So there are many reasons why someone would like to keep the screensaver from coming on in a domain environment.Edit:The same principle applies to Dameware as well. You are still controlling the users local session so you will need to send mouse movements to the Dameware window to keep their computer from locking locally which you are viewing. Edited April 13, 2012 by EndFunc EndFuncAutoIt is the shiznit. I love it. 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