aphesia Posted July 14, 2009 Posted July 14, 2009 (edited) Hello guys. I made a little script which should run from the autostart and sets up some stuff for me all the time: #include <Timers.au3>;same as Timers.au3 #include <reducemem.au3> #include <Constants.au3> #NoTrayIcon _ReduceMemory() sleep(5000) run("C:\Program Files (x86)\Rainmeter\Rainmeter.exe") sleep(1000) run(@ScriptDir & "\wallpaperchanger\wallpaper.exe") sleep(2000) while 1 If _Timer_GetIdleTime() > "600000" Then if WinActive("dvd") = 0 And WinActive("firefox") = 0 And WinActive("player") = 0 And ProcessExists("lock.exe") = 0 and WinActive("vmware") = 0 and WinActive("foobar") = 0 and ProcessExists("ET.exe") = 0 Then run(@scriptdir & "\lock\lock.exe") EndIf EndIf ;If ProcessExists("ET.exe") Then sleep(5000) WEnd Exit So it starts from the autostarter folder (useing viat sp2 x64 btw) and waits some seconds so the other programms can load first.. well that was my idea. dont know if the sleep function will really stop the programm from loading. After some seconds it runs a programm called Rainmeter.. it had some widgeds on the desktop and doesnt use ressource at all. Then it start a little programm to change my wallpaper and after that the wallpaperchanger.exe quits. So the while starts: The programm lock.exe is a replacement for screensaver + turning display off. When there is no dvd player,browser,music player,etc active, lock.exe will start. It requires a pw to get acces to windows again (if u enter wrong pw it makes a screen with the webcam in my laptop ). And after 10 secs of innactivity lock.exe turns off. I have never checked how many ressources lock.exe uses cause taskmanager is also disabled and the only way to get acces to windows again is to torn off the power of the notebook. How ever here is my problem: I booted my laptop, did some stuff and went to gym. When i came back i entered my password and lock.exe turned off. I was back on my desktop and reconized my cpu is at 60%.. i checked the ressource momnitor and mainscript.exe (the on in the quote) took 40% of my cpu. Why is that and is there any way to solve this? btw reducemem.au3 includes this stuff: Func _ReduceMemory($i_PID = -1) If $i_PID <> -1 Then Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID) Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0]) Else Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] EndFunc;==> _ReduceMemory() thanks bb Edited July 17, 2010 by aphesia
AdmiralAlkex Posted July 14, 2009 Posted July 14, 2009 There are many things wrong with both scripts, but start by adding a Sleep() to the mainloop of both to reduce cpu-usage and get rid of that _ReduceMemory(), it won't help if you call it that often. Use it once when the script start or remove it completely. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
DYONISII Posted July 14, 2009 Posted July 14, 2009 hi, how about inserting a sleep(500) inside the while...wend? by using 500, the loop will run every half a second. or you can even use sleep(5000) so that the loop executes every 5 seconds instead. it may drop the cpu resource lower. hope this helps. http://dev.dyonisii.com/
aphesia Posted July 14, 2009 Author Posted July 14, 2009 (edited) ah great idea thanks.. i will use sleep(5000) in the while loop at the mainscript.exe then and the redeucemem only when starting the script. any other ideas? for the lock.exe i cannot really add a sleep into the mainloop cause then he could start the taskmanager and use it aslong as i have the script sleeping. @edit: hmm now every 5 secs my cpu jumps up to 30-40%.. its lower than before but still not a nice solution.. is it the timer_getidletime which takes so much cpu ressources? Edited July 14, 2009 by aphesia
GEOSoft Posted July 14, 2009 Posted July 14, 2009 ah great idea thanks.. i will use sleep(5000) in the while loop at the mainscript.exe then and the redeucemem only when starting the script. any other ideas? for the lock.exe i cannot really add a sleep into the mainloop cause then he could start the taskmanager and use it aslong as i have the script sleeping. I cleaned up that Monitor() function a bit. You were checking things that didn't have to be checked. Func Monitor($io_control = "on") Local $WM_SYSCommand = 274 Local $SC_MonitorPower = 61808 Local $iState = 2 Local $HWND = WinGetHandle("Program Manager") If $io_control = "on" Then $iState = -1 DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND, "int", _ $WM_SYSCommand, "int", $SC_MonitorPower, "int", $iState) EndFunc ;<==> Monitor() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
trung0407 Posted July 14, 2009 Posted July 14, 2009 Holy... Can't you put the whole things in CODE tag instead of QUOTE tag?
aphesia Posted July 14, 2009 Author Posted July 14, 2009 (edited) thanks alot Geosoft trung0407: if i would knew that exists... but u just told me in a nice way @edited the first post Edited July 14, 2009 by aphesia
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