Floooooo24 Posted April 5, 2022 Share Posted April 5, 2022 Guten Tag, Ich habe folgen des problem, ich möchte zwei skript teile unterschiedlich schnell ablaufen lassen. Local $Input1 = Irgend_ein_Trigger_von_außen() Local $sWait = IniRead("Nullpunkte_Sichern.ini", "Messprogramm minimieren", "Wait", "10") ;Ist die Zeit, die gewartet wird, um die CPU zu schonen While 1 If $Input1 Then ;Skriptteil 1 EndIf For Local $i = 0 To 500 / $sWait Step 1 ;Skripteil 2 Sleep($sWait) Next Wend Das ist das wie ich es bis her gelöst habe, aber umso kleiner "$sWait" wird, umso länger dauert es bis der Skriptteil 1 bearbeitet wird. Ich vermute mal, dass das daran liegt, das die For schleife und alle anderen opterationen auch Zeit brauchen, um bearbeitet zu werden. wie rechne ich diese denn am besten raus? Oder noch besser gibt es einen besseren Weg, mit dem ich die beiden Skriptteile unterschiedlich schnell aufrufen lassen kann ohne die Skripte zu teilen? Link to comment Share on other sites More sharing options...
Developers Jos Posted April 5, 2022 Developers Share Posted April 5, 2022 Did you forget this is an English forum since you post "auf deutsch" ? There is also a German forum when you prefer to ask question in your own language: https://autoit.de/ SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Floooooo24 Posted April 5, 2022 Author Share Posted April 5, 2022 Sorry yes i forget it😅 here ist the englisch one: Hello, I have a problem, I need two skripts, which run at diffrent speed. Local $Input1 = Irgend_ein_Trigger_von_außen() Local $sWait = IniRead("Nullpunkte_Sichern.ini", "Messprogramm minimieren", "Wait", "10") ;is the Time to wait to save the CPU While 1 If $Input1 Then ;Skript part 1 EndIf For Local $i = 0 To 500 / $sWait Step 1 ;Skrip part 2 Sleep($sWait) Next Wend That's how I've solved it so far, but the smaller "$sWait" becomes, the longer it takes for script part 1 to be processed. I assume that this is because the "For" loop and all other optations also need time to be processed. what is the best way to calculate this time and cancel it out? Or even better, is there a better way that I can have the two script parts called at different speeds without splitting the scripts? Link to comment Share on other sites More sharing options...
Developers Solution Jos Posted April 5, 2022 Developers Solution Share Posted April 5, 2022 Would AdlibRegister() be an option? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Floooooo24 Posted April 5, 2022 Author Share Posted April 5, 2022 Thank you this is the funktion I have looking for. but one thing what is better for the performing? AdlibRegister("Skript1") AdlibRegister("Skript2") While 1 WEnd or AdlibRegister("Skript1") While 1 ;Skript2 WEnd Thank you Link to comment Share on other sites More sharing options...
Developers Jos Posted April 5, 2022 Developers Share Posted April 5, 2022 16 minutes ago, Floooooo24 said: but one thing what is better for the performing? AdlibRegister("Skript1") AdlibRegister("Skript2") While 1 WEnd or Never do it like this as the closed-loop (While-Wend) will cause a CPU core to Max out. Always add a minimal Sleep(10). Other than that there is no preference and you choose what you like best. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Floooooo24 Posted April 5, 2022 Author Share Posted April 5, 2022 Ok, fun fakt: While 1 WEnd creates on my Pc and others I tested only max 10%-15% of CPU use. I think maybe there is a maximum of Cpu use coded by autoit or scite? 2: When both "if"s are false the skript need up to 2%, but if the skript1 true, the usage is by 0,2 or less. Why? AdlibRegister("Skript1") AdlibRegister("Skript2") While 1 WEnd Func Skript1() If $input1 then ;Do some thing Endif EndFunc Func Skript2() If $input1 then ;Do some thing Endif EndFunc My Skript1 ;Minimize the Programm Func Minimizer() ;when the proseccsname is avilable If ProcessExists($sProzessname) Then ;Minimize the Program WinSetState($sProgrammname,"",@SW_MINIMIZE) EndIf Sleep (1) EndFunc ;==> Minimizer() Link to comment Share on other sites More sharing options...
Developers Jos Posted April 5, 2022 Developers Share Posted April 5, 2022 (edited) 7 minutes ago, Floooooo24 said: creates on my Pc and others I tested only max 10%-15% of CPU use. I think maybe there is a maximum of Cpu use coded by autoit or scite? How many cores do you have? 6? 7 minutes ago, Floooooo24 said: When both "if"s are false the skript need up to 2%, but if the skript1 true, the usage is by 0,2 or less. Why? That depends on the things you do when the If's are true. Edited April 5, 2022 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Floooooo24 Posted April 5, 2022 Author Share Posted April 5, 2022 30 minutes ago, Jos said: How many cores do you have? 6? I've 16 I think 31 minutes ago, Jos said: That depends on the things you do when the If's are true. ok, this: 39 minutes ago, Floooooo24 said: My Skript1 ;Minimize the Programm Func Minimizer() ;when the proseccsname is avilable If ProcessExists($sProzessname) Then ;Minimize the Program WinSetState($sProgrammname,"",@SW_MINIMIZE) EndIf Sleep (1) EndFunc ;==> Minimizer() Link to comment Share on other sites More sharing options...
Developers Jos Posted April 5, 2022 Developers Share Posted April 5, 2022 58 minutes ago, Floooooo24 said: I've 16 I think That would mean that AutoIt CPU % will never be higher than 100/16 = 6.2% as it is single threaded. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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