PDA

Показать полную графическую версию : [решено] скрипт для автоподключения CS:Source


Страниц : [1] 2

rustsss
24-03-2010, 16:43
Писал в раздел про командную строку,посоветовали обратится в этот раздел, суть проблемы описана здесь:
суть проблемы (http://forum.oszone.net/thread-171050.html)
так как AutoIt не дружу совсем, прошу помочь тех кто в этом деле знаток.

madmasles
24-03-2010, 19:42
rustsss,
1. Порт у Вас всегда 27016?
2. Проверку наличия интернета надо делать?

rustsss
24-03-2010, 23:25
madmasles, вообще сервера два у одного порт 27016 у другого 1800, желательно для обоих, проверку можно не делать

madmasles
25-03-2010, 08:24
rustsss,
У меня так получилось #include <WinAPIEx.au3>
#include <Misc.au3>

Opt (http://www.autoitscript.com/autoit3/docs/functions/Opt.htm)("TrayMenuMode", 1)
TraySetState (http://www.autoitscript.com/autoit3/docs/functions/TraySetState.htm)(4)
$port = "27016"
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) _Singleton(@ScriptName (http://www.autoitscript.com/autoit3/docs/macros.htm#@ScriptName), 1) = 0 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
TrayTip (http://www.autoitscript.com/autoit3/docs/functions/TrayTip.htm)("Подключение порт " & $port, "Уже работаем!", 0, 1)
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(3000)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)

If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) _WinAPI_IsNetworkAlive() = 0 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
TrayTip (http://www.autoitscript.com/autoit3/docs/functions/TrayTip.htm)("Подключение порт " & $port, "Отсутствует подключение к интернету", 0, 1)
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(3000)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)

If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) Not (http://www.autoitscript.com/autoit3/docs/keywords.htm#Not) FileExists (http://www.autoitscript.com/autoit3/docs/functions/FileExists.htm)(@ScriptDir (http://www.autoitscript.com/autoit3/docs/macros.htm#@ScriptDir) & "\Launcher_CSS.exe") Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
TrayTip (http://www.autoitscript.com/autoit3/docs/functions/TrayTip.htm)("Подключение порт " & $port, "В этой папке отсутствует файл Launcher_CSS.exe", 0, 1)
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(3000)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
TCPStartup (http://www.autoitscript.com/autoit3/docs/functions/TCPStartup.htm)()
$IP = TCPNameToIP (http://www.autoitscript.com/autoit3/docs/functions/TCPNameToIP.htm)("316774-local.dyn.ufanet.ru")
RunWait (http://www.autoitscript.com/autoit3/docs/functions/RunWait.htm)(@ComSpec (http://www.autoitscript.com/autoit3/docs/macros.htm#@ComSpec) & " /c start Launcher_CSS.exe -console +connect " & $IP & ":" & $port, "", @SW_HIDE (http://www.autoitscript.com/autoit3/docs/macros.htm#@SW_HIDE))
$socket = TCPConnect (http://www.autoitscript.com/autoit3/docs/functions/TCPConnect.htm)($IP, $port)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $socket <> -1 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
TrayTip (http://www.autoitscript.com/autoit3/docs/functions/TrayTip.htm)("Подключение порт " & $port, "Подключение установлено.", 0, 1)
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(3000)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
Else (http://www.autoitscript.com/autoit3/docs/keywords.htm#Else)
TrayTip (http://www.autoitscript.com/autoit3/docs/functions/TrayTip.htm)("Подключение порт " & $port, "Произошла ошибка подключения. Попробуйте еще раз.", 0, 1)
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(3000)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
#include <WinAPIEx.au3>
#include <Misc.au3>

Opt (http://www.autoitscript.com/autoit3/docs/functions/Opt.htm)("TrayMenuMode", 1)
TraySetState (http://www.autoitscript.com/autoit3/docs/functions/TraySetState.htm)(4)
$port = "1800"
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) _Singleton(@ScriptName (http://www.autoitscript.com/autoit3/docs/macros.htm#@ScriptName), 1) = 0 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
TrayTip (http://www.autoitscript.com/autoit3/docs/functions/TrayTip.htm)("Подключение порт " & $port, "Уже работаем!", 0, 1)
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(3000)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)

If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) _WinAPI_IsNetworkAlive() = 0 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
TrayTip (http://www.autoitscript.com/autoit3/docs/functions/TrayTip.htm)("Подключение порт " & $port, "Отсутствует подключение к интернету", 0, 1)
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(3000)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)

If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) Not (http://www.autoitscript.com/autoit3/docs/keywords.htm#Not) FileExists (http://www.autoitscript.com/autoit3/docs/functions/FileExists.htm)(@ScriptDir (http://www.autoitscript.com/autoit3/docs/macros.htm#@ScriptDir) & "\Launcher_CSS.exe") Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
TrayTip (http://www.autoitscript.com/autoit3/docs/functions/TrayTip.htm)("Подключение порт " & $port, "В этой папке отсутствует файл Launcher_CSS.exe", 0, 1)
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(3000)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
TCPStartup (http://www.autoitscript.com/autoit3/docs/functions/TCPStartup.htm)()
$IP = TCPNameToIP (http://www.autoitscript.com/autoit3/docs/functions/TCPNameToIP.htm)("316774-local.dyn.ufanet.ru")
RunWait (http://www.autoitscript.com/autoit3/docs/functions/RunWait.htm)(@ComSpec (http://www.autoitscript.com/autoit3/docs/macros.htm#@ComSpec) & " /c start Launcher_CSS.exe -console +connect " & $IP & ":" & $port, "", @SW_HIDE (http://www.autoitscript.com/autoit3/docs/macros.htm#@SW_HIDE))
$socket = TCPConnect (http://www.autoitscript.com/autoit3/docs/functions/TCPConnect.htm)($IP, $port)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $socket <> -1 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
TrayTip (http://www.autoitscript.com/autoit3/docs/functions/TrayTip.htm)("Подключение порт " & $port, "Подключение установлено.", 0, 1)
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(3000)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
Else (http://www.autoitscript.com/autoit3/docs/keywords.htm#Else)
TrayTip (http://www.autoitscript.com/autoit3/docs/functions/TrayTip.htm)("Подключение порт " & $port, "Произошла ошибка подключения. Попробуйте еще раз.", 0, 1)
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(3000)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
В прикрепленном архиве скомпилированные скрипты. Их надо положить в ту папку, в которой лежит Launcher_CSS.exe.

PS
По идее надо как-то проверку соединения организовать, но так как у меня всего этого нет, то не знаю как.

PPS
Может быть проверить вот так?$socket = TCPConnect (http://www.autoitscript.com/autoit3/docs/functions/TCPConnect.htm)($IP, $port)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $socket <> -1 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
TrayTip (http://www.autoitscript.com/autoit3/docs/functions/TrayTip.htm)("Подключение", "Подключение установлено.", 0, 1)
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(3000)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
Else (http://www.autoitscript.com/autoit3/docs/keywords.htm#Else)
TrayTip (http://www.autoitscript.com/autoit3/docs/functions/TrayTip.htm)("Подключение", "Произошла ошибка подключения. Попробуйте еще раз.", 0, 1)
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(3000)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)

rustsss
25-03-2010, 14:52
madmasles, Попробовал , сама CS:Source запускается но вот соединения с этим адресом и портом в игре не происходит, все проходит без ошибок. Спасибо что пытаетесь помочь!
А нельзя сделать по такой схеме 1) сначала узнается Ip 2) к нему прибавляется порт-получается готовая строка для консоли connect ip:port все это копируется в буфер 3) запускается CS с консолью и в эту консоль вставляется connect ip:port и эмулируется нажатие клавиши Энтер. Вот как то так или это из области научной фантастики? :)

madmasles
25-03-2010, 15:08
rustsss,
То есть Вам надо, чтобы в командной строке было выполнено следующее:start Launcher_CSS.exe connect ip:portЯ правильно понял?

И еще, для того, чтобы сделать проверку соединения, прикрепите, пожалуйста, скриншот окна ком.строки.

rustsss
25-03-2010, 15:43
madmasles,
Даже не знаю как объяснить, скажем если создать такой батник:

set commandline=-console +connect 172.27.21.85:1800
set execute=Launcher_CSS.exe
start %execute% %commandline%

то запустится CS с консолью и сразу же пойдет подключение к этому ip но поскольку ip динамический, а наш провайдер раз в сутки делает дисконнект то ip меняется, поэтому и нужно брать ip с DNS вставлять его между connect и:1800 и запускать игру с авто подключением.

а что именно должно быть отображено на скриншоте?

madmasles
25-03-2010, 15:56
rustsss,
То есть должно быть так? start Launcher_CSS.exe -console +connect 172.27.21.85:1800Или нет? Вы сделайте батник, который точно подключает. Последней строкой напишите pause? запустите его и, не нажимая любую кнопку, сделайте скриншот окна.

rustsss
25-03-2010, 16:08
madmasles, Да должно быть так тока ip из должен браться от 316774-local.dyn.ufanet.ru

скриншот батника
http://imagepost.ru/images/84/batnik.jpg
если его запустить то CS запускается и происходит подключение к серверу по данному ip

madmasles
25-03-2010, 16:56
rustsss,
Я в 4-ом посте код и вложения поменял. Попробуйте. А скриншот мне был нужен, так как я думал, что в консоли какой-то ответ будет, а его нет.

rustsss
25-03-2010, 17:08
madmasles, Огромное Вам Спасибо :Beer: ! Теперь всё работает и прекрасно соединяется!

madmasles
25-03-2010, 17:15
rustsss,
Может окно сделать с возможностью выбора порта?

rustsss
25-03-2010, 17:21
madmasles, Если Вам не сложно, то сделайте пожалуйста, буду очень благодарен!

madmasles
26-03-2010, 09:17
rustsss,
Вот что у меня получилось. Попробуйте, должно работать. Скомпилированный лежит здесь: Connect_Launcher_CSS (http://www.multiupload.com/TZNGM1J4WB). Сам скрипт в прикрепленном архиве. Отпишитесь работает или нет.

rustsss
26-03-2010, 13:39
madmasles, Спасибо! Всё работает! Единственное,когда CS закрываешь в трее и в процессах висит процесс Connect_Launcher_CSS.exe и выгрузить можно только через диспетчер задач, нельзя ли приделать кнопку выход?

madmasles
26-03-2010, 14:27
rustsss,
Не понимаю, почему Connect_Launcher_CSS.exe висит в процессах. После того, как Вы выбрали порт и нажали кнопку Подключиться, какое в трее сообщение появляется?

rustsss
26-03-2010, 14:49
madmasles, Сообщений никаких нет просто значок в трее, когда из CS выходишь, значок продолжает висеть в трее и в процессах, сообщений никаких нет.

madmasles
26-03-2010, 15:03
rustsss,
А cmd.exe вместе с Connect_Launcher_CSS.exe не висит в процессах?

PS
Вроде нашел ошибку. Попробуйте этот вариант 1-Connect_Launcher_CSS.7z (http://www.multiupload.com/GXALXTSCLL).

rustsss
26-03-2010, 15:27
madmasles, а можно попросить выложить сам скрипт?

madmasles
26-03-2010, 15:40
rustsss,
Держите.




© OSzone.net 2001-2012