twp Posted February 19, 2014 Posted February 19, 2014 Hi! I'm pretty new when it comes to AutoIt. Would need a Function that prevents your computer from entering into any hibernate or screensaver during an installation. I have a script to install a complicated application but have run into problems with some computers locks the desktop before installation is complete. I've found something that I think would fit perfectly but from what I can see, the reset function resets the settings to the windows default. I want the settings to be reset to the previous value. Someone who can help me solve this? The script needs to work on win7 x86 and Win7 x64. Here's the function I'm talking about: '?do=embed' frameborder='0' data-embedContent>>
FireFox Posted February 19, 2014 Posted February 19, 2014 Hi, Welcome to the autoit forum If you want to avoid screen lock you can simply move the mouse every X seconds or if the user is idle more than X seconds. Local $aMgp = MouseGetPos() MouseMove($aMgp[0], $aMgp[1] + 1, 1) MouseMove($aMgp[0], $aMgp[1] - 1, 1) Br, FireFox.
water Posted February 19, 2014 Posted February 19, 2014 You could use AdLibRegister to move the mouse every x seconds (every 60 seconds in the example): AdlibRegister(_MouseMove, 1000*60) While 1 ; Replace While/Wend with your code WEnd Func _MouseMove() Local $aMgp = MouseGetPos() MouseMove($aMgp[0], $aMgp[1] + 1, 1) MouseMove($aMgp[0], $aMgp[1] - 1, 1) EndFunc My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Moderators JLogan3o13 Posted February 19, 2014 Moderators Posted February 19, 2014 (edited) If you are doing this while you're installing software, you could also set it up so it moves the mouse only while the process is active: While ProcessExists("setup.exe") Local $aMgp = MouseGetPos() MouseMove($aMgp[0], $aMgp[1] + 1, 1) MouseMove($aMgp[0], $aMgp[1] - 1, 1) Sleep(1000 * 30) WEnd Edited February 19, 2014 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
BrewManNH Posted February 19, 2014 Posted February 19, 2014 #include <APIProcConstants.au3> DllCall('kernel32.dll','long', 'SetThreadExecutionState', 'long', BitOr($ES_CONTINUOUS, $ES_DISPLAY_REQUIRED, $ES_SYSTEM_REQUIRED)) While Sleep(100) WEnd This will disable the screensaver and the computer won't go into sleep mode. 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
twp Posted February 19, 2014 Author Posted February 19, 2014 (edited) Hi, Welcome to the autoit forum If you want to avoid screen lock you can simply move the mouse every X seconds or if the user is idle more than X seconds. Local $aMgp = MouseGetPos() MouseMove($aMgp[0], $aMgp[1] + 1, 1) MouseMove($aMgp[0], $aMgp[1] - 1, 1) Br, FireFox. You could use AdLibRegister to move the mouse every x seconds (every 60 seconds in the example): AdlibRegister(_MouseMove, 1000*60) While 1 ; Replace While/Wend with your code WEnd Func _MouseMove() Local $aMgp = MouseGetPos() MouseMove($aMgp[0], $aMgp[1] + 1, 1) MouseMove($aMgp[0], $aMgp[1] - 1, 1) EndFunc If you are doing this while you're installing software, you could also set it up so it moves the mouse only while the process is active: While ProcessExists("setup.exe") Local $aMgp = MouseGetPos() MouseMove($aMgp[0], $aMgp[1] + 1, 1) MouseMove($aMgp[0], $aMgp[1] - 1, 1) Sleep(1000 * 30) WEnd I have tried to use the method that moves the mouse but do not really understand how I can implement it in my script. My script installs an application and during the installation, a few keystrokes are made. The script waits for boxes that are popping up in order to close them. It is a recording of keystrokes which I've modified a bit afterwards and added a few features that closes processes and so on. Have no idea how I implement a mouse move every minute in such a script, as in several minutes standing and waiting to perform a few keystrokes. Suggestions are appreciated. Edited February 19, 2014 by twp
Moderators JLogan3o13 Posted February 19, 2014 Moderators Posted February 19, 2014 Post your code. We've gone about as far as we can stumbling about in the dark, trying to divine just what you're trying to accomplish. Help us help you "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
twp Posted February 19, 2014 Author Posted February 19, 2014 #include <APIProcConstants.au3> DllCall('kernel32.dll','long', 'SetThreadExecutionState', 'long', BitOr($ES_CONTINUOUS, $ES_DISPLAY_REQUIRED, $ES_SYSTEM_REQUIRED)) While Sleep(100) WEnd This will disable the screensaver and the computer won't go into sleep mode. This is similar to what I mentioned in the beginning and I like that: But how do I reset the settings to what they were before I changed them? You mention just how I shut down functions. Not how I restore them again. Really like this solution and would appreciate some help.
BrewManNH Posted February 19, 2014 Posted February 19, 2014 With the code I posted, use the DLLCall line at the start of your script. Then as long as your script is running that will keep it from going into sleep/hibernate. The While loop was just for a demonstration, you don't need it in your script. It will self enable sleep/hibernate after it closes. 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
twp Posted February 19, 2014 Author Posted February 19, 2014 (edited) Post your code. We've gone about as far as we can stumbling about in the dark, trying to divine just what you're trying to accomplish. Help us help you Do not have my code right now but it's basically like the example below: ;Run the Office 2010 installer Run ("setup.exe") ;Wait for the setup window to be active WinWaitActive ("Microsoft Office Professional Plus 2010", "setup") ;Accept the license agreement Send (!a) ;Proceed to the next screen Send (!c) ;Install Office with default options WinWaitActive ("Microsoft Office Professional Plus 2010", "Choose the installation you want") Send (!i) ;Close the setup when office is installed WinWaitActive ("Microsoft Office Professional Plus 2010", "Setup Complete") Send (!c) Above this code, there are also some auto-generated function for WinWaitActive. It takes just under an hour to install, and the wait can be quite long between inputs. Edited February 19, 2014 by twp
water Posted February 19, 2014 Posted February 19, 2014 Why do you automate the installation GUI? Did you have a look at silent installation? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
twp Posted February 19, 2014 Author Posted February 19, 2014 If I run a function to move the mouse between all these WinWaitActive step, then it will prevent these steps from executing. What should I do? Ideally, I'd turn off the computers/users ability to lock, shut down or go into sleep mode functions at the beginning of the script, and then restore everything if something goes wrong or when everything is ready. That is my goal! But if the mouse movement seems to be a better solution then let's go for that.
twp Posted February 19, 2014 Author Posted February 19, 2014 Why do you automate the installation GUI? Did you have a look at silent installation? We have tested all that is possible to test when it comes to silent installation but it is unfortunately quite impossible in this unique case. It's an impossible application installation to silence.
water Posted February 19, 2014 Posted February 19, 2014 How do you think does the Microsoft SCCM tool roll out Office 2010? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
TXTechie Posted February 19, 2014 Posted February 19, 2014 (edited) Microsoft Office installations are definitely very customizable and they can be installed quietly (with a limited GUI) or completely silently (no GUI or user-interaction). You need to download and use Microsoft's free Office Customization Tool in order to customize the Office installation to your needs. Here's the link for the Office Customization Tool for Office 2010. Edited February 19, 2014 by TXTechie
water Posted February 19, 2014 Posted February 19, 2014 The Office Customization Tool (OCT) is used to create a Setup customization file (.msp file). Setup applies this file when Office is installed on the computers. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
twp Posted February 19, 2014 Author Posted February 19, 2014 How do you think does the Microsoft SCCM tool roll out Office 2010? Microsoft Office installations are definitely very customizable and they can be installed quietly (with a limited GUI) or completely silently (no GUI or user-interaction). You need to download and use Microsoft's free Office Customization Tool in order to customize the Office installation to your needs. Here's the link for the Office Customization Tool for Office 2010. The Office Customization Tool (OCT) is used to create a Setup customization file (.msp file). Setup applies this file when Office is installed on the computers. I'm sorry for the misunderstanding but it is not the office I'm trying to install. The script above is only an example! I'm trying to automate the installation of an old application for medical devices. Please and try not to focus on what I am trying to automate but how. I need to find a good way to prevent the computer from being locked or go into sleep mode/screen saver during installation.
mrider Posted February 19, 2014 Posted February 19, 2014 (edited) According to Microsoft's kernel32 documentation, you clear the flags by calling kernel32 again using only the ES_CONTINUOUS flag. I've personally never done it - but if I'm reading the documentation correctly, the the code below should work. (EDIT - here's a link to the API http://msdn.microsoft.com/en-us/library/aa373208%28VS.85%29.aspx ) #include <APIProcConstants.au3> ; Turn off screensaver, sleep, and etcetera DllCall('kernel32.dll','long', 'SetThreadExecutionState', 'long', BitOr($ES_CONTINUOUS, $ES_DISPLAY_REQUIRED, $ES_SYSTEM_REQUIRED)) ;Run the Office 2010 installer Run ("setup.exe") ;Wait for the setup window to be active WinWaitActive ("Microsoft Office Professional Plus 2010", "setup") ;Accept the license agreement Send (!a) ;Proceed to the next screen Send (!c) ;Install Office with default options WinWaitActive ("Microsoft Office Professional Plus 2010", "Choose the installation you want") Send (!i) ;Close the setup when office is installed WinWaitActive ("Microsoft Office Professional Plus 2010", "Setup Complete") Send (!c) ; Reset to normal mode DllCall('kernel32.dll','long', 'SetThreadExecutionState', 'long', $ES_CONTINUOUS) Edited February 20, 2014 by mrider How's my riding? Dial 1-800-Wait-There Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.
BrewManNH Posted February 20, 2014 Posted February 20, 2014 As I said above, the code I posted will only affect Windows not going to sleep as long as that program is running. As soon as the program ends, so does the bypass of sleep and hibernate. Sometimes, it will allow the screensaver to kick in, but when you're automating the GUI that shouldn't matter because any sends or mouseclicks will just cause the screensaver to go away, and a screensaver shouldn't affect the script. mrider's suggestion to explicitly turn it off is probably good practice just to make sure things get cleaned up after it's done. 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
twp Posted February 20, 2014 Author Posted February 20, 2014 According to Microsoft's kernel32 documentation, you clear the flags by calling kernel32 again using only the ES_CONTINUOUS flag. I've personally never done it - but if I'm reading the documentation correctly, the the code below should work. (EDIT - here's a link to the API http://msdn.microsoft.com/en-us/library/aa373208%28VS.85%29.aspx ) #include <APIProcConstants.au3> ; Turn off screensaver, sleep, and etcetera DllCall('kernel32.dll','long', 'SetThreadExecutionState', 'long', BitOr($ES_CONTINUOUS, $ES_DISPLAY_REQUIRED, $ES_SYSTEM_REQUIRED)) ;Run the Office 2010 installer Run ("setup.exe") ;Wait for the setup window to be active WinWaitActive ("Microsoft Office Professional Plus 2010", "setup") ;Accept the license agreement Send (!a) ;Proceed to the next screen Send (!c) ;Install Office with default options WinWaitActive ("Microsoft Office Professional Plus 2010", "Choose the installation you want") Send (!i) ;Close the setup when office is installed WinWaitActive ("Microsoft Office Professional Plus 2010", "Setup Complete") Send (!c) ; Reset to normal mode DllCall('kernel32.dll','long', 'SetThreadExecutionState', 'long', $ES_CONTINUOUS) As I said above, the code I posted will only affect Windows not going to sleep as long as that program is running. As soon as the program ends, so does the bypass of sleep and hibernate. Sometimes, it will allow the screensaver to kick in, but when you're automating the GUI that shouldn't matter because any sends or mouseclicks will just cause the screensaver to go away, and a screensaver shouldn't affect the script. mrider's suggestion to explicitly turn it off is probably good practice just to make sure things get cleaned up after it's done. I will give it a try and see if it works. Thanks!
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