Sign in to follow this  
Followers 0
Guest DragonFire

Question

7 posts in this topic

Hello everyone. I am new to AutoIT scripting and I find it a very nice program indeed. There has been one thing I couldn't figure out and it's starting to bug me a little bit. Anyways I was wondering if someone could direct me in the AutoIT help files on where to find my problem. I have seen AutoIT scripts where if you were to enter something into a configuration file the script would input it into where it was typing.

For example: In the configuration file it asks me to type my name. After I do and save the config, I run the script and a notepad opens up saying "Hello {myname}" replacing {myname} with the name I placed into the configuration.

I was hoping that I could learn how to do something like this, having {myname} replaced with what I inputted into the configuration file. Also I was wondering if this could be done by using input boxes. Thanks for your help.

Share this post


Link to post
Share on other sites



Although you could use any external text or registry file, an ini file makes for easy access because of the ini read and write functions. See this example:

$name = IniRead(@ScriptDir & "\user-name.ini", "user", "name", "New User")
$newname = InputBox("User display", "Welcome " & $name & "!" & @LF & _
 "If this is not your name, please correct it and press OK to save changes")
If @error Then Exit
IniWrite(@ScriptDIr & "\user-name.ini", "user", "name", $newname)

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hello everyone. I am new to AutoIT scripting and I find it a very nice program indeed. There has been one thing I couldn't figure out and it's starting to bug me a little bit. Anyways I was wondering if someone could direct me in the AutoIT help files on where to find my problem. I have seen AutoIT scripts where if you were to enter something into a configuration file the script would input it into where it was typing.

For example: In the configuration file it asks me to type my name. After I do and save the config, I run the script and a notepad opens up saying "Hello {myname}" replacing {myname} with the name I placed into the configuration.

I was hoping that I could learn how to do something like this, having {myname} replaced with what I inputted into the configuration file. Also I was wondering if this could be done by using input boxes. Thanks for your help.

<{POST_SNAPBACK}>

You don't need the configuration file but you can use it. Look up Function References - Input Box. If you look at the help file in Index mode you'll see IniWrite and IniRead directly above InputBox. Click on those and read them.

Those three things will answer your questions.

Good luck.

Edit: Pekster beat me. But I didn't give the answer - just the lpace to find it.

Edited by randd

Raoul S. Duke: Few people understand the psychology of dealing with a highway traffic cop. Your normal speeder will panic and immediately pull over to the side. This is wrong. It arouses contempt in the cop-heart. Make the bastard chase you. He will follow.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thank you everyone for all of your help. So far it has come to work but I got a question. If I was to have the script open notepad.exe and type the $var how would I do that? When I try that it either gives me "$" or "$var" (without quotes) but that isn't what I put as my entry in the .ini so how can i make it so the $var turns into my entry? Thanks.

Edited by DragonFire

Share this post


Link to post
Share on other sites

If I was to have the script open notepad.exe and type the $var how would I do that? When I try that it either gives me "$" or "$var" (without quotes) but that isn't what I put as my entry in the .ini so how can i make it so the $var turns into my entry? Thanks.

<{POST_SNAPBACK}>

See FAQ #9.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Thank you for your help I greatly appreciate it. I have 1 more question that I once again can't seem to find the answer and that is how can I make it so the script will not start untill the Home or another key is pressed. Thanks for your help I greatly appreciate it.

Share this post


Link to post
Share on other sites

... how can I make it so the script will not start untill the Home or another key is pressed.

<{POST_SNAPBACK}>

Use a hotkey to start the main portion of the script. Until the hotkey is pressed, just to a loop of a short sleep. And after it starts, remove the hotkey. Like this:

HotKeySet("{HOME}", "main")
While 1
  Sleep(100)
WEnd

Func main()
  HotKeySet("{HOME}") ;remove the hotkey
 ;your code goes here
EndFunc

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

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