Guest RigureIsAFoolishMortal Posted February 27, 2004 Share Posted February 27, 2004 Hi, iv never posted in this forum befor. With that said, im allso perty new to the autoit script. im looking on some help for a program that i wrote for finding a game ip address. What i need to know is how to make it detect the first instance of the target ip and compare it to the one i targeted. I got that part, the next one is what im having problems with. Let me explain. This program is witten for a game. The game has about 150 servers. Id like to be able to search for the same ip twice and not have it dectect the first instance of the targeted ip. Iv been trying to get it to work and i just cant seem to get the commands right. Heres a little piece of it. ;========== Get IP =================== GetIP: WinRestore, Command WinActivate, Command, , Sleep, 250 Send, netstat -n>C:\\ip.txt{ENTER} Sleep, 250 WinGetActiveTitle, Title WinSetTitle, %Title%, , Command WinMinimize, Command Return ;========== Compare West IP ========== CompareWestIP: SetEnv, A, 1 Repeat, 20 FileReadLine, CheckIP, C:\\ip.txt, %A% IfInString, CheckIP, %WestIP%%DCloneIP1%, Goto, Detected IfInString, CheckIP, %WestIP%%DCloneIP2%, Goto, Detected IfInString, CheckIP, %WestIP%%DCloneIP3%, Goto, Detected IfInString, CheckIP, %WestIP%%DCloneIP4%, Goto, Detected IfInString, CheckIP, %WestIP%%DCloneIP5%, Goto, Detected EnvAdd, A, 1 EndRepeat Return now in the .ini i can specify the ip i want to ignore but i want it to look at the second ip .... heres what netstat -n looks like Proto Local Address Foreign Address State TCP 24.119.12.117:1069 63.209.48.149:80 CLOSE_WAIT TCP 24.119.12.117:1073 216.152.67.221:6667 ESTABLISHED TCP 24.119.12.117:1096 64.71.165.194:6667 ESTABLISHED TCP 24.119.12.117:1097 63.241.83.112:6112 TIME_WAIT TCP 24.119.12.117:1098 63.241.83.112:6112 ESTABLISHED TCP 24.119.12.117:1099 63.241.83.18:6112 TIME_WAIT TCP 24.119.12.117:1100 63.241.83.112:6112 TIME_WAIT TCP 24.119.12.117:1101 63.241.83.23:4000 ESTABLISHED TCP 24.119.12.117:1101 63.241.83.187:4000 ESTABLISHED The two ip that end in .4000 are the ones i want it to look at. if the first one is right, i want to check the .ini file to see if its the one to ignore and then look at the SECOND one and compare it to whats in the ini file. Can anybody help me with this? Link to comment Share on other sites More sharing options...
Beastmaster Posted February 28, 2004 Share Posted February 28, 2004 A one liner: RunWait, %COMSPEC% /C netstat -n > C:\\ip.txt What's the real trigger ?ESTABLISHED ? Yes/No:4000 + ESTABLISHED? Yes/No:6667 ESTABLISHED Yes/No63.241.83. ? Matching part of the IP + ESTABLISHED? Yes/No.....TCP 24.119.12.117:1069 63.209.48.149:80 CLOSE_WAITTCP 24.119.12.117:1073 216.152.67.221:6667 ESTABLISHEDTCP 24.119.12.117:1096 64.71.165.194:6667 ESTABLISHEDTCP 24.119.12.117:1097 63.241.83.112:6112 TIME_WAITTCP 24.119.12.117:1098 63.241.83.112:6112 ESTABLISHEDTCP 24.119.12.117:1099 63.241.83.18:6112 TIME_WAITTCP 24.119.12.117:1100 63.241.83.112:6112 TIME_WAITTCP 24.119.12.117:1101 63.241.83.23:4000 ESTABLISHEDTCP 24.119.12.117:1101 63.241.83.187:4000 ESTABLISHED Link to comment Share on other sites More sharing options...
Guest RigureIsAFoolishMortal Posted February 28, 2004 Share Posted February 28, 2004 ahh i see i wasnt clear enough. the trigger is the maching ip address. in this case its the 63.241.83.23:4000. the 23 is what is looking for. here is the complet prog...SetBatchLines, 100SetEnv, Cmd, 0SetEnv, Command, 0IfEqual, A_OSVERSION, WIN_XP, SetEnv, Cmd, 1IfEqual, A_OSVERSION, WIN_2000, SetEnv, Cmd, 1IfEqual, A_OSVERSION, WIN_NT4, SetEnv, Cmd, 1IfEqual, A_OSVERSION, WIN_95, SetEnv, Command, 1IfEqual, A_OSVERSION, WIN_98, SetEnv, Command, 1IfEqual, A_OSVERSION, WIN_ME, SetEnv, Command, 1SetEnv, WestIP, 63.241.83.SetEnv, EastIP, 63.240.202.SetEnv, EuroIP, 213.248.106.SetEnv, GameCreateDelay, 0SetEnv, Name, 0SetEnv, Pass, 0SetEnv, SettingsFile, %A_SCRIPTDIR%\\Gheeds.iniIniRead, ActiveAccount, %SettingsFile%, Account, AccountNameIniRead, ActivePassword, %SettingsFile%, Account, PasswordIniRead, RealmSelection, %SettingsFile%, Account, RealmIniRead, CharLocation, %SettingsFile%, Account, CharacterLocationIniRead, LoadDelay, %SettingsFile%, Settings, D2LoadDelayIniRead, GameCreateDelay, %SettingsFile%, Settings, GameCreateDelayIniRead, Switches, %SettingsFile%, Account, D2ParameterIniRead, DCloneIP1, %SettingsFile%, Settings, DCloneIP1IniRead, DCloneIP2, %SettingsFile%, Settings, DCloneIP2IniRead, DCloneIP3, %SettingsFile%, Settings, DCloneIP3IniRead, DCloneIP4, %SettingsFile%, Settings, DCloneIP4IniRead, DCloneIP5, %SettingsFile%, Settings, DCloneIP5IniRead, D2Path, %SettingsFile%, Settings, D2PathIfEqual, D2Path, , RegRead, D2Path, REG_SZ, HKEY_CURRENT_USER, Software\\Blizzard Entertainment\\Diablo II, InstallPathIniRead, D2Executable, %SettingsFile%, Settings, D2ExecutableIfEqual, D2Executable, , SetEnv, D2Executable, Diablo II.exe;========== Vanity Window ============SplashTextOn, 200, 100, Gheeds CloneHunter, Gheeds CloneHunter by valvetSleep, 5000WinMove, Gheeds CloneHunter,, 824, 0, default, default;========== Main =====================GoSub, CommandGoSub, StartDiabloIfEqual, RealmSelection, West, Gosub, WestLogonIfEqual, RealmSelection, East, Gosub, EastLogonIfEqual, RealmSelection, Europe, Gosub, EuropeLogonGoSub, LogonAccountGoSub, CharacterSelectionStartAgain:GoSub, CreateGameGoSub, GetIPIfEqual, RealmSelection, West, Gosub, CompareWestIPIfEqual, RealmSelection, East, Gosub, CompareEastIPIfEqual, RealmSelection, Europe, Gosub, CompareEuroIPGoSub, ExitGameGoto, StartAgain;========== Run Command ==============Command:IfEqual, Cmd, 1, Run, cmd.exeIfEqual, Command, 1, Run, command.comsleep, 250WinGetActiveTitle, TitleSleep, 250WinSetTitle, %Title%, , CommandWinMinimize, CommandReturn;========== Start Diablo =============StartDiablo:Run, %D2Path%\\%D2Executable% %Switches%, %D2Path%Sleep, %LoadDelay%WinActivate, Diablo II,,Sleep, 500WinMove, Diablo II,, 0, 0, default, defaultSleep, 500Return;========= Realm Selection ===========WestLogon:;Sleep, 500Send, {ESCAPE}Sleep, 1500MouseMove, 408, 403LeftClick, 408, 403Sleep, 1500MouseMove, 296, 374LeftClick, 296, 374LeftClick, 296, 374Sleep, 1500MouseMove, 404, 374LeftClick, 404, 374Sleep, 5000ReturnEastLogon:;Sleep, 500Send, {ESCAPE}Sleep, 1500MouseMove, 408, 403LeftClick, 408, 403Sleep, 1500MouseMove, 300, 400LeftClick, 300, 400LeftClick, 300, 400Sleep, 1500MouseMove, 404, 374LeftClick, 404, 374Sleep, 5000ReturnEuropeLogon:;Sleep, 500Send, {ESCAPE}Sleep, 1500MouseMove, 408, 403LeftClick, 408, 403Sleep, 1500MouseMove, 295, 448LeftClick, 295, 448LeftClick, 295, 448Sleep, 1500MouseMove, 404, 374LeftClick, 404, 374Sleep, 5000Return;======== Enter Account Info =========LogonAccount:Send, {TAB}Sleep, 250Send, %ActiveAccount%Sleep, 250Send, {TAB}Sleep, 250Send, %ActivePassword%Sleep, 250Send, {ENTER}Sleep, 6000Return;======== Character Selection ========CharacterSelection:IfEqual, CharLocation, 1, Send, {ENTER}IfEqual, CharLocation, 2, Send, {RIGHT}{ENTER}IfEqual, CharLocation, 3, Send, {DOWN}{ENTER}IfEqual, CharLocation, 4, Send, {RIGHT}{DOWN}{ENTER}IfEqual, CharLocation, 5, Send, {DOWN}{DOWN}{ENTER}IfEqual, CharLocation, 6, Send, {RIGHT}{DOWN}{DOWN}{ENTER}IfEqual, CharLocation, 7, Send, {DOWN}{DOWN}{DOWN}{ENTER}IfEqual, CharLocation, 8, Send, {RIGHT}{DOWN}{DOWN}{DOWN}{ENTER}Sleep, 5000Return;========= Create Game ===============CreateGame:IfWinNotActive, Diablo II, , WinRestore, Diablo IIWinActivate, Diablo II,,LeftClick, 601,482Sleep, 1500Random, Name, 10000, 90000Random, Pass, 10000, 90000Send, Gheeds-%Name%{TAB}Sleep, 250;Send, %Pass%{ENTER}Send, 11{ENTER}sleep, %GameCreateDelay%WinMinimize, Diablo IIsleep, 250Return;========== Get IP ===================GetIP:WinRestore, CommandWinActivate, Command, ,Sleep, 250Send, netstat -n>C:\\ip.txt{ENTER}Sleep, 250WinGetActiveTitle, TitleWinSetTitle, %Title%, , CommandWinMinimize, CommandReturn;========== Compare West IP ==========CompareWestIP:SetEnv, A, 1Repeat, 20FileReadLine, CheckIP, C:\\ip.txt, %A%IfInString, CheckIP, %WestIP%%DCloneIP1%, Goto, DetectedIfInString, CheckIP, %WestIP%%DCloneIP2%, Goto, DetectedIfInString, CheckIP, %WestIP%%DCloneIP3%, Goto, DetectedIfInString, CheckIP, %WestIP%%DCloneIP4%, Goto, DetectedIfInString, CheckIP, %WestIP%%DCloneIP5%, Goto, DetectedEnvAdd, A, 1EndRepeatReturnDetected:MsgBox, 4, IP Detected, The proper IP for Diablo Clone has been detected. Would you like to exit?IfMsgBox, OK, Goto, ExitExit:ExitReturn;========== Compare East IP ==========CompareEastIP:SetEnv, A, 1Repeat, 20FileReadLine, CheckIP, C:\\ip.txt, %A%IfInString, CheckIP, %EastIP%%DCloneIP1%, Goto, DetectedIfInString, CheckIP, %EastIP%%DCloneIP2%, Goto, DetectedIfInString, CheckIP, %EastIP%%DCloneIP3%, Goto, DetectedIfInString, CheckIP, %EastIP%%DCloneIP4%, Goto, DetectedIfInString, CheckIP, %EastIP%%DCloneIP5%, Goto, DetectedEnvAdd, A, 1EndRepeatReturnDetected:MsgBox, 4, IP Detected, The proper IP for Diablo Clone has been detected. Would you like to exit?IfMsgBox, OK, Goto, ExitExit:ExitReturn;========== Compare Euro IP ==========CompareEuroIP:SetEnv, A, 1Repeat, 20FileReadLine, CheckIP, C:\\ip.txt, %A%IfInString, CheckIP, %EuroIP%%DCloneIP1%, Goto, DetectedIfInString, CheckIP, %EuroIP%%DCloneIP2%, Goto, DetectedIfInString, CheckIP, %EuroIP%%DCloneIP3%, Goto, DetectedIfInString, CheckIP, %EuroIP%%DCloneIP4%, Goto, DetectedIfInString, CheckIP, %EuroIP%%DCloneIP5%, Goto, DetectedEnvAdd, A, 1EndRepeatReturnDetected:MsgBox, 4, IP Detected, The proper IP for Diablo Clone has been detected. Would you like to exit?IfMsgBox, OK, Goto, ExitExit:ExitReturn;========== Exit Game ================ExitGame:WinRestore, Diablo IIWinActivate, Diablo II,,SetKeyDelay, 5Sleep, 250Send, {ENTER}Send, Gheeds Clone HunterSleep, 250Send, {ENTER}Sleep, 250Send, {ENTER}Send, The proper IP for Diablo Clone was not detected.Sleep, 250Send, {ENTER}Sleep, 250Send, {ESC}Sleep, 250Send, {UP}Sleep, 250Send, {ENTER}Sleep, 5000Return[ADLIB]the trigger is the matching part of the ip.also, i had ALOT of help writing this. this is the first one iv witten..i think i bit off more than i can chew..*chuckle*does this help? Link to comment Share on other sites More sharing options...
Beastmaster Posted March 1, 2004 Share Posted March 1, 2004 (edited) I've made some slight changes in the following section ...;========== Get IP ===================GetIP:RunWait, %COMSPEC% /C netstat -n > C:\\ip.txt, , HideReturn;========== Compare West IP ==========CompareWestIP:SetEnv, lc, 0IniRead, SPattern, C:\\ip.ini, SearchPattern, spStart:SetEnv, inilc, 0EnvAdd, lc, 1FileReadLine, IPLine, C:\\ip.txt, %lc%IfEqual, IPLine, ERROR, ExitIfInString, IPLine, %SPattern%, Goto, INICompareGoto, StartINICompare:EnvAdd, inilc, 1IfEqual, inilc, 3, Goto, StartIniRead, IP, C:\\ip.ini, ProperIPs, %inilc%;//MsgBox for testingMsgBox,0,B, Have to check: %IPLine%\nSearching for INI key: %inilc%=.%IP%:IfNotInString, IPLine, .%IP%:, Goto, INICompareMsgBox, 4, IP Detected, The proper IP [%IP%] for Diablo Clone has been detected. Would you like to exit?IfMsgBox, YES, Exit...The assigned INI file: C:\IP.ini[ProperIPs]1=1872=23[searchPattern]sp=:4000 ESTABLISHED-----The first match (in this case) has to be :4000 ESTABLISHEDTCP 24.119.12.117:1101 63.241.83.23:4000 ESTABLISHEDTCP 24.119.12.117:1101 63.241.83.187:4000 ESTABLISHEDFound two lines.The second check is to identify if the previous match contains one of the specified (proper) IPs from the IP.ini file. Delivers the first match.TCP 24.119.12.117:1101 63.241.83.23:4000 ESTABLISHEDTCP 24.119.12.117:1101 63.241.83.187:4000 ESTABLISHED Edited March 1, 2004 by Beastmaster Link to comment Share on other sites More sharing options...
Recommended Posts