Who Posted July 31, 2007 Share Posted July 31, 2007 Nice AutoIT, I have done my auto-work with it and everything works fine . But the only trouble is the compiled program needs too much memory on my computer that it takes more than 75% of my Mem Usage ( 30Mb x 13 ) in Task Manager when my total memory is 512 MB although my program is very simple ( you can see below ). Can anyone please give me a suggestion please . If ProcessExists("pc.exe") Then ProcessClose("pc.exe") BlockInput(1) Run("C:\pc.exe","",@SW_MAXIMIZE) WinActivate("Program Box") sleep(3000) Send("{ENTER}") sleep(3000) $size = WinGetClientSize("Program") WinActivate("Program") WinSetState("Program", "", @SW_MAXIMIZE) MouseClick("left", 195, 55, 1) While 1 If WinExists(WinGetTitle("Program Box","Successfully.")) Then sleep(120000) Send("{ENTER}") ExitLoop EndIf WEnd WinActivate("Program") WinSetState("Program", "", @SW_MAXIMIZE) MouseClick("left", 195, 55, 1) While 2 If WinExists(WinGetTitle("Program Box","Done")) Then sleep(120000) Send("{ENTER}") ExitLoop EndIf WEnd Link to comment Share on other sites More sharing options...
qazwsx Posted July 31, 2007 Share Posted July 31, 2007 you could try lowering the priority of you script. Link to comment Share on other sites More sharing options...
enaiman Posted July 31, 2007 Share Posted July 31, 2007 It looks to me like a matter of processor usage not memory - I can't see how the memory can be "eaten" by your script. Why I said it looks like a matter of CPU usage? because if the specific tilte - "Program Box","Successfully." or the other one doesn't exist then it will continue to loop endlessly without any sleep. It would be a good idea to put a Sleep(200) or Sleep(100) or whatever value you might consider appropriate in each of the While loops - this way you will give the CPU some sleep time. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Who Posted July 31, 2007 Author Share Posted July 31, 2007 enaiman, I have put the sleep(120000) into my while but nothing change Link to comment Share on other sites More sharing options...
ChrisL Posted July 31, 2007 Share Posted July 31, 2007 (edited) This seems a bit extreeem for something that shouldn't use hardly any ramexpandcollapse popupReduceMemory(@autoitpid) If ProcessExists("pc.exe") Then ProcessClose("pc.exe") BlockInput(1) Run("C:\pc.exe","",@SW_MAXIMIZE) WinActivate("Program Box") sleep(3000) Send("{ENTER}") sleep(3000) ;$size = WinGetClientSize("Program");This never gets used so why is it here? WinActivate("Program") WinSetState("Program", "", @SW_MAXIMIZE) MouseClick("left", 195, 55, 1) While 1 If WinExists(WinGetTitle("Program Box","Successfully.")) Then sleep(120000) Send("{ENTER}") ExitLoop EndIf sleep(100) WEnd WinActivate("Program") WinSetState("Program", "", @SW_MAXIMIZE) MouseClick("left", 195, 55, 1) While 2 If WinExists(WinGetTitle("Program Box","Done")) Then sleep(120000) Send("{ENTER}") ExitLoop EndIf Sleep(100) WEnd 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] EndFuncI can't remember who wrote the ReduceMemory function but it wansn't me!It was a Zedna w0uter combo by the looks of it! Edited July 31, 2007 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
enaiman Posted July 31, 2007 Share Posted July 31, 2007 enaiman, I have put the sleep(120000) into my while but nothing change Indeed - but ... that sleep will be used only in case the specific window exists (If condition = True) Put another Sleep (100) outside - like ChrisL showed in his example. While 1 If WinExists(WinGetTitle("Program Box","Successfully.")) Then sleep(120000) Send("{ENTER}") ExitLoop EndIf sleep(100) ;<---- this Sleep I'm talking about WEnd SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Who Posted July 31, 2007 Author Share Posted July 31, 2007 Thank you very much for your answers. Now the program runs 10x faster than before and I will keep this in mind for later use . Link to comment Share on other sites More sharing options...
Fabry Posted July 31, 2007 Share Posted July 31, 2007 (edited) reducememory functionFunc _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 ;==>_ReduceMemoryFor other autoit snippets here Edited July 31, 2007 by Fabry A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza รจ il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center] 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