Rex Posted November 29, 2007 Share Posted November 29, 2007 Hi i have crated a simpel script to keep track of a window. The script is running on/thru a citrix server, but it uses to many resurces ~8 mb ram and 1-2 % cpu. Can any of u help me so the script dont uses so much. $Count = 0 While 1 _check() Sleep(100) WEnd Func _check() If WinActive("Navision XAL", "Udskriftsmuligheder") then $Count = $Count + 1 ;GUICtrlSetData($counter, $Count) Sleep(1000) WinWaitNotActive("Navision XAL", "Udskriftsmuligheder") EndIf If $count = 37 Then MsgBox(16, "Warning", "Om ca. 2 følgeseddler kommer følgeseddels fejlen") ; $Count = 0 EndIf EndFunc /Rex Link to comment Share on other sites More sharing options...
Iklim Posted November 29, 2007 Share Posted November 29, 2007 Hi,To reduce CPU usage, you can increase the sleep delay.$Count = 0While 1_check()Sleep(100)WEndI dont know if you need to have exactly 100 ms of sleep but if not you should increase itand choose a value that fit your needs (by testing for instance with 200,300,...,800, etc ). Iklim Link to comment Share on other sites More sharing options...
zfisherdrums Posted November 29, 2007 Share Posted November 29, 2007 Hello Rex, Would it be correct assume that the memory usage is more problematic for your environment than CPU usage? How are you running the script? When I run the script "compiled" on my old laptop, the memory usage is @ 3,784 K with CPU usage of 1-2%. Running it from the "Run Script" link in Start->Programs, the memory usage is @ 6,924 K with CPU usage of 1-2%. Zach... Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog... Link to comment Share on other sites More sharing options...
Rex Posted November 29, 2007 Author Share Posted November 29, 2007 Hello Rex,Would it be correct assume that the memory usage is more problematic for your environment than CPU usage?How are you running the script?When I run the script "compiled" on my old laptop, the memory usage is @ 3,784 K with CPU usage of 1-2%.Running it from the "Run Script" link in Start->Programs, the memory usage is @ 6,924 K with CPU usage of 1-2%.Zach...My script is compiled, and to be true then i'm not sure if it's the cpu usage or the mem usage that's the prob.becurce the script is running on a citrix server, all i know is that when i start the script the sys works slower But hey maby it's not my script alt all, maby it's system thats slow ???I have to come back on that.but thx for responding/Rex Link to comment Share on other sites More sharing options...
Rex Posted November 29, 2007 Author Share Posted November 29, 2007 Hi,To reduce CPU usage, you can increase the sleep delay.$Count = 0While 1_check()Sleep(100)WEndI dont know if you need to have exactly 100 ms of sleep but if not you should increase itand choose a value that fit your needs (by testing for instance with 200,300,...,800, etc ).Hmm that i could try/Rex Link to comment Share on other sites More sharing options...
Iklim Posted November 29, 2007 Share Posted November 29, 2007 you can also try some different compile option. The Aut2Exe.exe program can be run from the command line as follows: Aut2exe.exe /in <infile.au3> [/out <outfile.exe>] [/icon <iconfile.ico>] [/nodecompile] [/comp 0-4] [/pass <passphrase>] [/nopack] [/ansi] [/unicode] like playing with /comp, /nodecompile and /nopack. Iklim Link to comment Share on other sites More sharing options...
OldCoder Posted November 29, 2007 Share Posted November 29, 2007 What you may want to try is taking out your Sleep commands and replacing the first one with the GUIGetMsg() function. This gives other applications a chance to use processing time. (Check out the REMARKS section of this command). While 1 _check() GUIGetMsg() WEnd Func _check() If WinActive("Navision XAL", "Udskriftsmuligheder") then $Count = $Count + 1 ;GUICtrlSetData($counter, $Count) WinWaitNotActive("Navision XAL", "Udskriftsmuligheder") EndIf If $count = 37 Then MsgBox(16, "Warning", "Om ca. 2 følgeseddler kommer følgeseddels fejlen") ; $Count = 0 EndIf EndFunc Hope this is helpful. Cheers! "Intelligence is the ability to adapt to change." - Stephen Hawking "...not the ability to exploit others." - OldCoder Link to comment Share on other sites More sharing options...
Rex Posted January 28, 2008 Author Share Posted January 28, 2008 What you may want to try is taking out your Sleep commands and replacing the first one with the GUIGetMsg() function. This gives other applications a chance to use processing time. (Check out the REMARKS section of this command). While 1 _check() GUIGetMsg() WEnd Func _check() If WinActive("Navision XAL", "Udskriftsmuligheder") then $Count = $Count + 1 ;GUICtrlSetData($counter, $Count) WinWaitNotActive("Navision XAL", "Udskriftsmuligheder") EndIf If $count = 37 Then MsgBox(16, "Warning", "Om ca. 2 følgeseddler kommer følgeseddels fejlen") ; $Count = 0 EndIf EndFunc Hope this is helpful. Cheers! Sorry sorry for this extreem late reply I forgot this tropic - i dumbed the script, the server coulden handel it But thx for alle the sugg's.. /Rex 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