Sign in to follow this  
Followers 0
Chobyhy

Checking INI

13 posts in this topic

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

Share this post


Link to post
Share on other sites



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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

yes this is exactly what your script does :P

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Chobyhy

Share this post


Link to post
Share on other sites

ah its easy Run( 'Diablo II.exe -w -lq -ns -title "Diablo II"' )

Share this post


Link to post
Share on other sites

#7 ·  Posted (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
WEnd
Edit : forgot the Sleep(100)

Edited by Helge

Share this post


Link to post
Share on other sites

Wait. Longer the sleep time = less cpu usage right? But whats the downfall of long sleeptime?

Share this post


Link to post
Share on other sites

#9 ·  Posted (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.. :P Edited by Helge

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

No, sleep loop is good, because if you dont use the sleep loop it goes autoit uses default sleep which is extremely fast

Share this post


Link to post
Share on other sites

No, sleep loop is good, because if you dont use the sleep loop it goes autoit uses default sleep which is extremely fast

Thanks that explains a few 100% Cpu usage programs I've been trying to fix lately

Piano_Man


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0