Diablo2 Posted October 14, 2009 Share Posted October 14, 2009 (edited) Hi, I have run into a problem with my program that I am making for Diablo II Lord of Destruction. The problem is I want my script to enter an account name + password from a .ini file and the "IniRead"s that I have tried have so far not worked. Do I just need to put the .ini read in my script or would there be somewhere else to put it aswell...? $Account = IniRead("Config.ini", "Settings", "Account", "NotFound") Send("{TAB}") $Password = IniRead("Config.ini", "Settings", "Password", "NotFound") is what my current part in the script is to read the account + password from a .ini, but it seems to just skip[ that part of the script and move onto the next (It sends the tab, but skips the IniRead both times) Let me know if I am unclear.. I'm sure I am.. but I just started doing this 2 nights ago. Thanks My config looks like this [settings] Username=AccNamehere Password=Pass Here Edited October 14, 2009 by Diablo2 Link to comment Share on other sites More sharing options...
somdcomputerguy Posted October 14, 2009 Share Posted October 14, 2009 IniRead just reads, and puts the value into the variable. You have to Send the variable. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Diablo2 Posted October 15, 2009 Author Share Posted October 15, 2009 IniRead just reads, and puts the value into the variable. You have to Send the variable.Hmm could you give me an example on how to do this? Once again I'm new. I am definitely not asking you to write my script for me, but just enlighten me on how to do this ... Link to comment Share on other sites More sharing options...
Pandemic Posted October 15, 2009 Share Posted October 15, 2009 Basically, what you're doing is setting that variable equal to the key in your ini file. However, you're not really doing anything with it . $myVar = IniRead("filename.ini", "mySection", "myKey", "myDefualtValue") MsgBox(0, "", "$myVar = " & $myVar) This reads the variable, then displays it to the screen. Basically, to fix your code... $Account = IniRead("Config.ini", "Settings", "Account", "NotFound") $Password = IniRead("Config.ini", "Settings", "Password", "NotFound") send("" & $Account) Send("{TAB}") send("" & $Password) send("{ENTER}") If that still doesn't make sense, do say so -Pandemic Link to comment Share on other sites More sharing options...
Diablo2 Posted October 15, 2009 Author Share Posted October 15, 2009 Basically, what you're doing is setting that variable equal to the key in your ini file. However, you're not really doing anything with it . $myVar = IniRead("filename.ini", "mySection", "myKey", "myDefualtValue") MsgBox(0, "", "$myVar = " & $myVar) This reads the variable, then displays it to the screen. Basically, to fix your code... $Account = IniRead("Config.ini", "Settings", "Account", "NotFound") $Password = IniRead("Config.ini", "Settings", "Password", "NotFound") send("" & $Account) Send("{TAB}") send("" & $Password) send("{ENTER}") If that still doesn't make sense, do say so -Pandemic Yes! Thanks a lot this works, now I will try to use other functions from my config. I will post here if I have trouble, but thanks I will try to learn off what you posted for me. Link to comment Share on other sites More sharing options...
Diablo2 Posted October 15, 2009 Author Share Posted October 15, 2009 yea I pretty much do understand it, I added it to join a channel that you can chose & edit in the .ini file, along with changeable game name + passwords I have a new problem with getting a counter to add +1 to Send("" & $GameName) that line, I want it to be able to join games that are continuing with just a changing number (Baalrun1, then after Baalrun2, then Baalrun3, etc) $GameName = IniRead("config.ini", "settings", "GameName", "") Send("" & $GameName) Send("{TAB}") $GamePass = IniRead("Config.ini", "Settings", "Gamepass", "") Send("" & $GamePass) send("{ENTER}") How would I add a counter to the "GameName" and let it go up from whatever number I start at... Thanks for your help and I am learning with it. Another thing, I tried to add in the ini file a line where you can chose where your path to Diablo II folder & game.exe is because for everyone it is not the same.. $D2Path = IniRead("Config.ini", "Settings", "D2Path", "") $D2Exe = IniRead("Config.ini", "Settings", "D2exe", "game.exe & -w -skiptobnet -ns") Run("$D2Path") Run("$D2Exe") (This is my config file with the lines) D2Path=C:\Program Files (x86)\Diablo II\ D2Exe=game.exeThis did not work, it just skipped the part to open diablo II and went alone clicking on the screen and typing in what it is supposed to have typed in Diablo II window XD Link to comment Share on other sites More sharing options...
dantay9 Posted October 15, 2009 Share Posted October 15, 2009 (edited) First off, to increment a counter, you use $Counter += 1. For the run command, it should be like this: Run($D2Path) Run($D2EXE) Edited October 15, 2009 by dantay9 Link to comment Share on other sites More sharing options...
jebus495 Posted October 15, 2009 Share Posted October 15, 2009 yea I pretty much do understand it, I added it to join a channel that you can chose & edit in the .ini file, along with changeable game name + passwords I have a new problem with getting a counter to add +1 to Send("" & $GameName) that line, I want it to be able to join games that are continuing with just a changing number (Baalrun1, then after Baalrun2, then Baalrun3, etc) $GameName = IniRead("config.ini", "settings", "GameName", "") Send("" & $GameName) Send("{TAB}") $GamePass = IniRead("Config.ini", "Settings", "Gamepass", "") Send("" & $GamePass) send("{ENTER}") How would I add a counter to the "GameName" and let it go up from whatever number I start at... Thanks for your help and I am learning with it. Another thing, I tried to add in the ini file a line where you can chose where your path to Diablo II folder & game.exe is because for everyone it is not the same.. $D2Path = IniRead("Config.ini", "Settings", "D2Path", "") $D2Exe = IniRead("Config.ini", "Settings", "D2exe", "game.exe & -w -skiptobnet -ns") Run("$D2Path") Run("$D2Exe") This did not work, it just skipped the part to open diablo II and went alone clicking on the screen and typing in what it is supposed to have typed in Diablo II window XD Run($D2Path & $D2Exe) Don't put variables in quotations. Link to comment Share on other sites More sharing options...
Diablo2 Posted October 15, 2009 Author Share Posted October 15, 2009 (edited) First off, to increment a counter, you use $Counter += 1. For the run command, it should be like this: Run($D2Path) Run($D2EXE) Ok I got it to open my game from the path in config file, but how would I go about adding a perimeter like "-w" to the game.exe ($D2Exe) so my game runs in a windowed mode, I am clueless as to go about doing that, and keep in mind I do try doing these things before I post here and ask for advice and help, so I'm trying not to just leech off of you, but learn. Also about the counter, it says that I have to define the variable, would I put that somewhere in my config? That's also got me stumped. Run($D2Path & $D2Exe) Don't put variables in quotations. Thanks. Edited October 15, 2009 by Diablo2 Link to comment Share on other sites More sharing options...
jebus495 Posted October 15, 2009 Share Posted October 15, 2009 (edited) Ok I got it to open my game from the path in config file, but how would I go about adding a perimeter like "-w" to the game.exe ($D2Exe) so my game runs in a windowed mode, I am clueless as to go about doing that, and keep in mind I do try doing these things before I post here and ask for advice and help, so I'm trying not to just leech off of you, but learn. Also about the counter, it says that I have to define the variable, would I put that somewhere in my config? That's also got me stumped. Thanks. To do that I believe you would need to run the game from a shortcut. (adding -w to the target) Edit: Perhaps you would benefit from a script I wrote to install a mod for D2. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <String.au3> Global $Input1, $nMsg, $Checkbox3, $d2_dir, $wmode, $Checkbox2, $reald2_dir _GUI() Func _GUI() $Form1_1 = GUICreate("CrapHack Installation", 319, 203, 234, 195, -1, 0) $Input1 = GUICtrlCreateInput("C:\Program Files\Diablo II\Game.exe", 8, 31, 217, 21) $Label1 = GUICtrlCreateLabel("Please find Game.exe", 41, 10, 230, 17, $SS_CENTER) $Checkbox1 = GUICtrlCreateCheckbox("See monsters on map", 88, 64, 129, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Checkbox2 = GUICtrlCreateCheckbox("See healthbars and immunities", 88, 96, 185, 17) $Checkbox3 = GUICtrlCreateCheckbox("Load in window mode", 88, 128, 137, 17) $Button1 = GUICtrlCreateButton("Install", 104, 168, 75, 25, 0, $WS_EX_CLIENTEDGE) $Button2 = GUICtrlCreateButton("Browse...", 232, 30, 75, 21, 0, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then GUICtrlSetState($Checkbox2, $GUI_UNCHECKED) If GUICtrlRead($Checkbox1) = $GUI_UNCHECKED And GUICtrlRead($Checkbox2) = $GUI_UNCHECKED Then GUICtrlSetState($Checkbox1, $GUI_CHECKED) Case $Checkbox2 If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then GUICtrlSetState ($Checkbox1, $GUI_UNCHECKED) If GUICtrlRead($Checkbox2) = $GUI_UNCHECKED And GUICtrlRead($Checkbox1) = $GUI_UNCHECKED Then GUICtrlSetState($Checkbox2, $GUI_CHECKED) Case $Button1 GUISetState(@SW_HIDE) _installcheck() Case $Button2 $customdir = FileOpenDialog("Find Game.exe", @DesktopDir, "(*.exe)", 1, "", $Form1_1) If Not @error Then GUICtrlSetData($Input1, $customdir) EndSwitch WEnd EndFunc Func _installcheck() If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then $wmode = " -w" Else $wmode = "" EndIf $d2_dir = GUICtrlRead($Input1) $split = StringSplit ($d2_dir, "\") $reald2_dir = StringReplace ($d2_dir, "\" & $split[$split[0]], "") $existcase = FileExists($reald2_dir & "\Game.exe") If $existcase = 0 Then Switch MsgBox(21, "Path incorrect", "Enter correct path or cancel.") Case 4 GUISetState(@SW_SHOW) Return Case 2 Exit EndSwitch Else Switch MsgBox(36, "WARNING", "All files in " & @CRLF & $reald2_dir & "\data" & @CRLF & "Will be overwritten. Do you wish to continue?") Case 7 Exit Case 6 _install() EndSwitch EndIf EndFunc Func _install() $dircheck = DirCopy(@ScriptDir & "\data", $reald2_dir & "\data", 1) If $dircheck = 0 Then MsgBox(20, "ERROR", "Can not copy directory" & @CRLF & "Closing installation") Exit EndIf If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then FileDelete($reald2_dir & "\data\global\excel\monstats2.txt") FileDelete($reald2_dir & "\data\global\excel\monstats.txt") FileCopy(@ScriptDir & "\data\souls invisibility hak\Monstats.txt", $reald2_dir & "\data\global\excel", 1) DirRemove($reald2_dir & "\data\souls invisibility hak", 1) EndIf FileCreateShortcut($reald2_dir & "\Diablo II.exe", @DesktopDir & "\Diablo II (Craphack).lnk", $reald2_dir, "-direct -txt" & $wmode) MsgBox("", "CrapHack Installed", "Run D2 from the new shortcut on your desktop to use the mod!") Exit EndFunc I does a few of what you're asking but instead of getting info from an INI it gets it from a GUI. Edited October 15, 2009 by jebus495 Link to comment Share on other sites More sharing options...
ScriptingNewb Posted October 15, 2009 Share Posted October 15, 2009 For the counter you can just say $Counter = 0 in some part of your script, typically the beginning. Then, $counter +=1 will actually increment. It states you have to declare it first because $counter +=1 is shorthand for $counter = $counter +1. If you have no initial value for $counter, it doesn't know what to do with itself. Link to comment Share on other sites More sharing options...
Diablo2 Posted October 15, 2009 Author Share Posted October 15, 2009 To do that I believe you would need to run the game from a shortcut. (adding -w to the target) Edit: Perhaps you would benefit from a script I wrote to install a mod for D2. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <String.au3> Global $Input1, $nMsg, $Checkbox3, $d2_dir, $wmode, $Checkbox2, $reald2_dir _GUI() Func _GUI() $Form1_1 = GUICreate("CrapHack Installation", 319, 203, 234, 195, -1, 0) $Input1 = GUICtrlCreateInput("C:\Program Files\Diablo II\Game.exe", 8, 31, 217, 21) $Label1 = GUICtrlCreateLabel("Please find Game.exe", 41, 10, 230, 17, $SS_CENTER) $Checkbox1 = GUICtrlCreateCheckbox("See monsters on map", 88, 64, 129, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Checkbox2 = GUICtrlCreateCheckbox("See healthbars and immunities", 88, 96, 185, 17) $Checkbox3 = GUICtrlCreateCheckbox("Load in window mode", 88, 128, 137, 17) $Button1 = GUICtrlCreateButton("Install", 104, 168, 75, 25, 0, $WS_EX_CLIENTEDGE) $Button2 = GUICtrlCreateButton("Browse...", 232, 30, 75, 21, 0, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then GUICtrlSetState($Checkbox2, $GUI_UNCHECKED) If GUICtrlRead($Checkbox1) = $GUI_UNCHECKED And GUICtrlRead($Checkbox2) = $GUI_UNCHECKED Then GUICtrlSetState($Checkbox1, $GUI_CHECKED) Case $Checkbox2 If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then GUICtrlSetState ($Checkbox1, $GUI_UNCHECKED) If GUICtrlRead($Checkbox2) = $GUI_UNCHECKED And GUICtrlRead($Checkbox1) = $GUI_UNCHECKED Then GUICtrlSetState($Checkbox2, $GUI_CHECKED) Case $Button1 GUISetState(@SW_HIDE) _installcheck() Case $Button2 $customdir = FileOpenDialog("Find Game.exe", @DesktopDir, "(*.exe)", 1, "", $Form1_1) If Not @error Then GUICtrlSetData($Input1, $customdir) EndSwitch WEnd EndFunc Func _installcheck() If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then $wmode = " -w" Else $wmode = "" EndIf $d2_dir = GUICtrlRead($Input1) $split = StringSplit ($d2_dir, "\") $reald2_dir = StringReplace ($d2_dir, "\" & $split[$split[0]], "") $existcase = FileExists($reald2_dir & "\Game.exe") If $existcase = 0 Then Switch MsgBox(21, "Path incorrect", "Enter correct path or cancel.") Case 4 GUISetState(@SW_SHOW) Return Case 2 Exit EndSwitch Else Switch MsgBox(36, "WARNING", "All files in " & @CRLF & $reald2_dir & "\data" & @CRLF & "Will be overwritten. Do you wish to continue?") Case 7 Exit Case 6 _install() EndSwitch EndIf EndFunc Func _install() $dircheck = DirCopy(@ScriptDir & "\data", $reald2_dir & "\data", 1) If $dircheck = 0 Then MsgBox(20, "ERROR", "Can not copy directory" & @CRLF & "Closing installation") Exit EndIf If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then FileDelete($reald2_dir & "\data\global\excel\monstats2.txt") FileDelete($reald2_dir & "\data\global\excel\monstats.txt") FileCopy(@ScriptDir & "\data\souls invisibility hak\Monstats.txt", $reald2_dir & "\data\global\excel", 1) DirRemove($reald2_dir & "\data\souls invisibility hak", 1) EndIf FileCreateShortcut($reald2_dir & "\Diablo II.exe", @DesktopDir & "\Diablo II (Craphack).lnk", $reald2_dir, "-direct -txt" & $wmode) MsgBox("", "CrapHack Installed", "Run D2 from the new shortcut on your desktop to use the mod!") Exit EndFunc I does a few of what you're asking but instead of getting info from an INI it gets it from a GUI. I tried running it from a shortcut with the perimeters (-w, etc) and it just starts the script without opening d2, meaning (I assume) that it is not recognizing my $D2Exe Also how can I make this run in just the Diablo II window, because right now I am using all on screen co ordinates for clicking, and not just clicking with co ordinates from in the "Diablo II" window. I'm quite sure that if I want to send this program it will not work right because I use a different (widescreen) resolution then a lot of people do. Link to comment Share on other sites More sharing options...
jebus495 Posted October 16, 2009 Share Posted October 16, 2009 I tried running it from a shortcut with the perimeters (-w, etc) and it just starts the script without opening d2, meaning (I assume) that it is not recognizing my $D2Exe Also how can I make this run in just the Diablo II window, because right now I am using all on screen co ordinates for clicking, and not just clicking with co ordinates from in the "Diablo II" window. I'm quite sure that if I want to send this program it will not work right because I use a different (widescreen) resolution then a lot of people do. Disable the widescreen and do something like this. $Winpos = WinGetPos("Diablo II") $isfull1 = PixelSearch(341 + $Winpos[0], 278 + $Winpos[1], 368 + $Winpos[0], 305 + $Winpos[1], 0x0C0C28) Make sure you get your original coordinates when the d2 window is at (0, 0) X and Y. Then add the X and Y coords of the actual D2 window location and then all of a sudden you can use on screen coords to accurately click the d2 window. Link to comment Share on other sites More sharing options...
Diablo2 Posted October 16, 2009 Author Share Posted October 16, 2009 (edited) Disable the widescreen and do something like this. $Winpos = WinGetPos("Diablo II") $isfull1 = PixelSearch(341 + $Winpos[0], 278 + $Winpos[1], 368 + $Winpos[0], 305 + $Winpos[1], 0x0C0C28) Make sure you get your original coordinates when the d2 window is at (0, 0) X and Y. Then add the X and Y coords of the actual D2 window location and then all of a sudden you can use on screen coords to accurately click the d2 window. Okay, I've switched into 1280x1024 resolution, but I don't understand what you mean by adding the X and Y coords of the d2 window. Edit: do you mean these? Edited October 16, 2009 by Diablo2 Link to comment Share on other sites More sharing options...
jebus495 Posted October 16, 2009 Share Posted October 16, 2009 Okay, I've switched into 1280x1024 resolution, but I don't understand what you mean by adding the X and Y coords of the d2 window. Oh it isn't your d2 window that's widescreened it's your resolution. That's fine you can swap it back lol. Say you have MouseClick("Left", 300, 300) If you move the D2 window it will obviously click the wrong place right? To fix it so that it clicks the right spot on the d2 window regardless of its location you would do this. $offset = WinGetPos("Diablo II") This will return an array. $offset[0] is the X location of the window and $offset[1] is the Y position. MouseClick("Left", 300 + $offset[0], 300 + $offset[1]) ^ See how it adds to the coordinates an amount exact to that of which the window is moved? You can do this to everything that relies on a specific location on the screen. I don't really know a better way of explaining this. I guess you've kinda gotta see it. Link to comment Share on other sites More sharing options...
Diablo2 Posted October 16, 2009 Author Share Posted October 16, 2009 Oh it isn't your d2 window that's widescreened it's your resolution. That's fine you can swap it back lol. Say you have MouseClick("Left", 300, 300) If you move the D2 window it will obviously click the wrong place right? To fix it so that it clicks the right spot on the d2 window regardless of its location you would do this. $offset = WinGetPos("Diablo II") This will return an array. $offset[0] is the X location of the window and $offset[1] is the Y position. MouseClick("Left", 300 + $offset[0], 300 + $offset[1]) ^ See how it adds to the coordinates an amount exact to that of which the window is moved? You can do this to everything that relies on a specific location on the screen. I don't really know a better way of explaining this. I guess you've kinda gotta see it. Ok thanks a lot for all of the help, I think I got this part working out now. The counter is still troubling me, do you have experience with Diablo II? Do you know what a leech bot does, and what it's meant to do? That is what I am scripting, a Leechbot. Link to comment Share on other sites More sharing options...
jebus495 Posted October 16, 2009 Share Posted October 16, 2009 Ok thanks a lot for all of the help, I think I got this part working out now. The counter is still troubling me, do you have experience with Diablo II? Do you know what a leech bot does, and what it's meant to do?That is what I am scripting, a Leechbot.Yes I am aware. I'm sure there are plenty already available that do such things.I'm not sure how to explain the counter because sometimes games go like this:Baal-01 / 02 / 03 / 04... / 09 / 10 / 11And other times they go like this:Baal-1 / 2 / 3... 9 / 10 / 11Difficult to account for that. Link to comment Share on other sites More sharing options...
Diablo2 Posted October 16, 2009 Author Share Posted October 16, 2009 (edited) Yes I am aware. I'm sure there are plenty already available that do such things.I'm not sure how to explain the counter because sometimes games go like this:Baal-01 / 02 / 03 / 04... / 09 / 10 / 11And other times they go like this:Baal-1 / 2 / 3... 9 / 10 / 11Difficult to account for that.Yeah this is set to follow my friends' baal games with a static password, and the games are in this format "56xbaal1, 56xbaal2, then after game number 9, 56xbaal10, etc" Edited October 16, 2009 by Diablo2 Link to comment Share on other sites More sharing options...
Diablo2 Posted October 16, 2009 Author Share Posted October 16, 2009 What's up? Link to comment Share on other sites More sharing options...
Diablo2 Posted October 17, 2009 Author Share Posted October 17, 2009 Working with the counter still 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