Chobyhy Posted September 5, 2006 Share Posted September 5, 2006 I'm trying to make a script where it will do bunch of stuff and one of them requires checking the Ini. Example: [Testing] Basic=Yes ;Type Yes to work or No to disable the function $Chobyhy = IniRead("C:\Program Files\AutoIt3\beta\Config.ini", "Basic", "Testing", "Error") While 1 If _IsPressed("11") And $Chobyhy = "Yes" Then Send("Working") Sleep(100) Else Sleep(10) EndIf WEnd Thats what i have so far. But it doesnt give much option if you dont type "yes". I want it to be able to take a different action if someone typed No. How will i be able to do this Second question: For the script above, i put Else Sleep(10). How would i make it so that it takes No action like nothing. Null action if it does not match Yes? Would Sleep(10) do the work? or is there a simpler way? Thanks in advance Link to comment Share on other sites More sharing options...
ramadash Posted September 5, 2006 Share Posted September 5, 2006 with the current script you have, if the key is not pressed and chub = something else than yes, it will do nothing. or i am not getting what you are trying to do? Link to comment Share on other sites More sharing options...
Chobyhy Posted September 5, 2006 Author Share Posted September 5, 2006 If Ctrl is pressed and the config has set Yes then it will do the action If ctrl is pressed and config has set no it wont do anything Link to comment Share on other sites More sharing options...
ramadash Posted September 5, 2006 Share Posted September 5, 2006 yes this is exactly what your script does Link to comment Share on other sites More sharing options...
Chobyhy Posted September 5, 2006 Author Share Posted September 5, 2006 (edited) lol thats good. well should i leave the Sleep thing in? or can i remove it Edit: One more question for you ramadash. How do you run Diablo in window mode? I know if you put Run("Diablo.exe") it will run full window but how can u make it so it goes window'd? Edited September 5, 2006 by Chobyhy Link to comment Share on other sites More sharing options...
ramadash Posted September 5, 2006 Share Posted September 5, 2006 ah its easy Run( 'Diablo II.exe -w -lq -ns -title "Diablo II"' ) Link to comment Share on other sites More sharing options...
Helge Posted September 5, 2006 Share Posted September 5, 2006 (edited) Having a Sleep in a loop is good since it lowers CPU-usage.$Chobyhy = IniRead("C:\Program Files\AutoIt3\beta\Config.ini", "Basic", "Testing", "Error") While 1 Sleep(10) If _IsPressed ("11") And $Chobyhy = "Yes" Then Send("Working") Sleep(100) EndIf WEndEdit : forgot the Sleep(100) Edited September 5, 2006 by Helge Link to comment Share on other sites More sharing options...
Chobyhy Posted September 5, 2006 Author Share Posted September 5, 2006 Wait. Longer the sleep time = less cpu usage right? But whats the downfall of long sleeptime? Link to comment Share on other sites More sharing options...
Helge Posted September 5, 2006 Share Posted September 5, 2006 (edited) Wait. Longer the sleep time = less cpu usage right? But whats the downfall of long sleeptime?Naah, 10 will be good enough ! The downfall can be slower response.. Edited September 5, 2006 by Helge Link to comment Share on other sites More sharing options...
ramadash Posted September 5, 2006 Share Posted September 5, 2006 there aint really any downfall if you dont set the sleep too high, Sleep( 10 ) will sleep for 1/100th of a second, you could even do Sleep( 100 ) and you wont notice any difference. Link to comment Share on other sites More sharing options...
Achilles Posted September 5, 2006 Share Posted September 5, 2006 there aint really any downfall if you dont set the sleep too high, Sleep( 10 ) will sleep for 1/100th of a second, you could even do Sleep( 100 ) and you wont notice any difference. Ok, wait a sec... For a thing like this While 1 ;Should there be a sleep here??? If $button then Msgbox(0, "", "WHATEVER") If $button1 then Msgbox(0, "", "WHATEVER1") If $button2 then Msgbox(0, "", "WHATEVER2") If $button3 then Msgbox(0, "", "WHATEVER2") Wend Would that not go 100% CPU usage if there was a sleep in it? I always thought sleeps in loops were bad... Sincerely confused, Piano_Man My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Chobyhy Posted September 5, 2006 Author Share Posted September 5, 2006 No, sleep loop is good, because if you dont use the sleep loop it goes autoit uses default sleep which is extremely fast Link to comment Share on other sites More sharing options...
Achilles Posted September 5, 2006 Share Posted September 5, 2006 No, sleep loop is good, because if you dont use the sleep loop it goes autoit uses default sleep which is extremely fastThanks that explains a few 100% Cpu usage programs I've been trying to fix latelyPiano_Man My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] 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