satanttin Posted March 27, 2013 Share Posted March 27, 2013 (edited) Hello, I want to make it so an inputbox popup but just the first time it opens. this is because i would let it save as a variable in a .ini file and load when i start it a second time. i was thinking about a if settings.ini exists then return else inputbox ... do you think that will work? Edited March 27, 2013 by satanttin Link to comment Share on other sites More sharing options...
JohnOne Posted March 27, 2013 Share Posted March 27, 2013 Yes, that will work. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
satanttin Posted March 27, 2013 Author Share Posted March 27, 2013 just don't know how to see if a file exists or not :') i tried : if "settings.ini" Then return Else $PassWord = InputBox ("Enter password...", "Please set password to unlock your screens...", "", "*") EndIf Link to comment Share on other sites More sharing options...
James Posted March 27, 2013 Share Posted March 27, 2013 (edited) It sure will and there are a couple of ways you could go about using the native functions.Use RegRead and RegWrite to store the returned variable in the registry. Alternatively you could just store a "hasShownInput" or whatever, with a boolean value.Use IniRead and IniWrite to do the same thing as above but in an INI file.To help not frighten you, the script you're looking to write is just a little bit more than an if..then...else... condition just don't know how to see if a file exists or not :') i tried : if "settings.ini" Then return Else $PassWord = InputBox ("Enter password...", "Please set password to unlock your screens...", "", "*") EndIf That won't work as it's checking if a string value is a boolean. To check if the file exists, then you can use FileExists. Edited March 27, 2013 by James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
satanttin Posted March 27, 2013 Author Share Posted March 27, 2013 It sure will and there are a couple of ways you could go about using the native functions.Use RegRead and RegWrite to store the returned variable in the registry. Alternatively you could just store a "hasShownInput" or whatever, with a boolean value.Use IniRead and IniWrite to do the same thing as above but in an INI file.To help not frighten you, the script you're looking to write is just a little bit more than an if..then...else... condition That won't work as it's checking if a string value is a boolean. To check if the file exists, then you can use FileExists.yeah i would use iniread and iniwrite but first i want to figure out how to show the inputbox just once but ill go check the forums in order to do that:)and i am not frighten to do more:P just thought it would be quite easy to do:P Link to comment Share on other sites More sharing options...
James Posted March 27, 2013 Share Posted March 27, 2013 (edited) just thought it would be quite easy to do:P It is with a little effort. If Not FileExists("myfile.ini") Then InputBox("Hey", "Enter your name please son.") Else $hINI = FileOpen("myfile.ini", 2) ; This will create the file FileClose($hINI) EndIf Edited March 27, 2013 by James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
satanttin Posted March 27, 2013 Author Share Posted March 27, 2013 It is with a little effort. If Not FileExists("myfile.ini") Then InputBox("Hey", "Enter your name please son.") Else $hINI = FileOpen("myfile.ini", 2) ; This will create the file FileClose($hINI) EndIf but that will make a inputbox when the file does exist? i want to to show when it doesn't exist because when i start up the first time i want to enter a password which get saves in a .ini and the other times i run it (When .ini file exists) it will load the password and so don't need the inputbox anymore. so it will need to be something like if fileexists ("settings.ini") then guimain() else $Var = inputbox (stuff here) and then the iniwrite to save it into an ini file endif what i got so far is if FileExists("settings.ini") Then guimain() Else $PassWord = InputBox ("Enter password...", "Please set password to unlock your screens...", "", "*") EndIf just doesn't show up with anything just run the gui:( Link to comment Share on other sites More sharing options...
satanttin Posted March 27, 2013 Author Share Posted March 27, 2013 solved code was if FileExists(@ScriptDir & "\" & "settings.ini") Then $PassWord = IniRead (@scriptdir & "\" & "settings.ini", "instellingen", "Password", "error") Else $PassWord = InputBox ("Enter password...", "Please set password to unlock your screens...", "", "*") IniWrite (@scriptdir & "\" & "settings.ini", "instellingen", "Password", $PassWord) EndIf Link to comment Share on other sites More sharing options...
James Posted March 27, 2013 Share Posted March 27, 2013 (edited) but that will make a inputbox when the file does exist? i want to to show when it doesn't exist because when i start up the first time i want to enter a password which get saves in a .ini and the other times i run it (When .ini file exists) it will load the password and so don't need the inputbox anymore. So reverse the conditions? If Not FileExists("myfile.ini") Then $sPass = InputBox("Hey", "Enter your password.", "", "*") If $sPass == "" Then MsgBox(0, "Um", "Please give me a password!") Else IniWrite("myfile.ini", "settings", "name", $sPass) MsgBox(0, "So.", "We're cool!") ; Replace with guimain() or whatever. EndIf Else MsgBox(0, "So.", "We're cool!") ; Replace with guimain() or whatever. EndIf solved code was if FileExists(@ScriptDir & "\" & "settings.ini") Then $PassWord = IniRead (@scriptdir & "\" & "settings.ini", "instellingen", "Password", "error") Else $PassWord = InputBox ("Enter password...", "Please set password to unlock your screens...", "", "*") IniWrite (@scriptdir & "\" & "settings.ini", "instellingen", "Password", $PassWord) EndIf Ah good. Well done Edited March 27, 2013 by James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
satanttin Posted March 27, 2013 Author Share Posted March 27, 2013 the problem was that i already had a settings.ini on my desktop x'D 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