StickyChopstix Posted November 24, 2009 Share Posted November 24, 2009 #include <String.au3> If FileExists("settings.ini") Then Call("wmccheck") Else $user = InputBox("Security Check", "Enter your username.", "") $user2 = _StringEncrypt(1, $user, "123", 1) ;IniWrite("settings.ini", "login", "Username", $user2) $pass = InputBox("Security Check", "Enter your password.", "", "*") $pass2 = _StringEncrypt(1, $pass, "456", 1) ;IniWrite("settings.ini", "login", "Password", $pass2) $wmc = FileOpenDialog("Choose File...", @MyDocumentsDir, "Windows Mouse Capture (*.exe)", 1) If @error Then Exit ;Else ; IniWrite("settings.ini", "files", "WMC", $wmc) EndIf $ace = FileOpenDialog("Choose File...", @ProgramFilesDir, "ACE Online (ACEonline.exe)", 1) If @error Then Exit ;Else ; IniWrite("settings.ini", "files", "ACE", $ace) EndIf Call("writeini") Call("wmccheck") EndIf Func writeini() IniWrite("settings.ini", "login", "Username", $user2) IniWrite("settings.ini", "login", "Password", $pass2) IniWrite("settings.ini", "files", "WMC", $wmc) IniWrite("settings.ini", "files", "ACE", $ace) EndFunc The only thing I want it to do here is write the settings.ini files into the same directory as the exe. But it always write into the $ace directory. Why does this happen? Link to comment Share on other sites More sharing options...
enaiman Posted November 24, 2009 Share Posted November 24, 2009 (edited) It looks like you haven't specified a location for your ini file. However your post is not clear enough to help me understand what you want. This script works: #include <String.au3> If FileExists(@ScriptDir&"\settings.ini") Then Call("wmccheck") Else $user = InputBox("Security Check", "Enter your username.", "") $user2 = _StringEncrypt(1, $user, "123", 1) ;IniWrite("settings.ini", "login", "Username", $user2) $pass = InputBox("Security Check", "Enter your password.", "", "*") $pass2 = _StringEncrypt(1, $pass, "456", 1) ;IniWrite("settings.ini", "login", "Password", $pass2) $wmc = FileOpenDialog("Choose File...", @MyDocumentsDir, "Windows Mouse Capture (*.exe)", 1) If @error Then Exit ;Else ; IniWrite("settings.ini", "files", "WMC", $wmc) EndIf $ace = FileOpenDialog("Choose File...", @ProgramFilesDir, "ACE Online (ACEonline.exe)", 1) If @error Then Exit ;Else ; IniWrite("settings.ini", "files", "ACE", $ace) EndIf Call("writeini") Call("wmccheck") EndIf Func writeini() IniWrite(@ScriptDir&"\settings.ini", "login", "Username", $user2) IniWrite(@ScriptDir&"\settings.ini", "login", "Password", $pass2) IniWrite(@ScriptDir&"\settings.ini", "files", "WMC", $wmc) IniWrite(@ScriptDir&"\settings.ini", "files", "ACE", $ace) EndFunc Take note how the ini file's location needs to be specified (@ScriptDir&"\settings.ini"). Also - if the ini file does not exist yet - you need to create it bofore any reading/writing. Edited November 25, 2009 by enaiman SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Bowmore Posted November 25, 2009 Share Posted November 25, 2009 #include <String.au3> If FileExists("settings.ini") Then Call("wmccheck") Else $user = InputBox("Security Check", "Enter your username.", "") $user2 = _StringEncrypt(1, $user, "123", 1) ;IniWrite("settings.ini", "login", "Username", $user2) $pass = InputBox("Security Check", "Enter your password.", "", "*") $pass2 = _StringEncrypt(1, $pass, "456", 1) ;IniWrite("settings.ini", "login", "Password", $pass2) $wmc = FileOpenDialog("Choose File...", @MyDocumentsDir, "Windows Mouse Capture (*.exe)", 1) If @error Then Exit ;Else ; IniWrite("settings.ini", "files", "WMC", $wmc) EndIf $ace = FileOpenDialog("Choose File...", @ProgramFilesDir, "ACE Online (ACEonline.exe)", 1) If @error Then Exit ;Else ; IniWrite("settings.ini", "files", "ACE", $ace) EndIf Call("writeini") Call("wmccheck") EndIf Func writeini() IniWrite("settings.ini", "login", "Username", $user2) IniWrite("settings.ini", "login", "Password", $pass2) IniWrite("settings.ini", "files", "WMC", $wmc) IniWrite("settings.ini", "files", "ACE", $ace) EndFunc The only thing I want it to do here is write the settings.ini files into the same directory as the exe. But it always write into the $ace directory. Why does this happen? FileOpenDialog changes the current directory You need to specify the directory of the ini file. Try this. #include <String.au3> If FileExists(@scriptdir & "\settings.ini") Then Call("wmccheck") Else $user = InputBox("Security Check", "Enter your username.", "") $user2 = _StringEncrypt(1, $user, "123", 1) ;IniWrite(@scriptdir & "\settings.ini", "login", "Username", $user2) $pass = InputBox("Security Check", "Enter your password.", "", "*") $pass2 = _StringEncrypt(1, $pass, "456", 1) ;IniWrite(@scriptdir & "\settings.ini", "login", "Password", $pass2) $wmc = FileOpenDialog("Choose File...", @MyDocumentsDir, "Windows Mouse Capture (*.exe)", 1) If @error Then Exit ;Else ; IniWrite(@scriptdir & "\settings.ini", "files", "WMC", $wmc) EndIf $ace = FileOpenDialog("Choose File...", @ProgramFilesDir, "ACE Online (ACEonline.exe)", 1) If @error Then Exit ;Else ; IniWrite(@scriptdir & "\settings.ini", "files", "ACE", $ace) EndIf Call("writeini") Call("wmccheck") EndIf Func writeini() IniWrite(@scriptdir & "\settings.ini", "login", "Username", $user2) IniWrite(@scriptdir & "\settings.ini", "login", "Password", $pass2) IniWrite(@scriptdir & "\settings.ini", "files", "WMC", $wmc) IniWrite(@scriptdir & "\settings.ini", "files", "ACE", $ace) EndFunc "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
StickyChopstix Posted November 25, 2009 Author Share Posted November 25, 2009 Ah thanks a lot. @scriptdir was EXACTLY what I was looking for. It couldn't find it in the directory macros so I gave up looking for those. 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