4
« on: March 14, 2021, 12:56:52 pm »
;Code update and picture attached. Check.
;download autohotkey, install.
;copy code below to .txt file and save it to autologin.ahk.
;To start the script press CTRL+S, to pause CTRL+P
;OPENTTD AUTOLOGIN by constructor ver 1.2
#IfWinActive, ahk_class OTTD
^P::Pause
^S::
;take screen of your openttd n-ice client and make 3 cropped pictures (press Fn+TakeScreen buttons or can use snipping tool if windowed)
;some clicking coordinates might need to be changed due to screen resolution.
tx:=1250 ;message x coord
ty:=0 ;message y coord
c:=0 ;counter
add_1:="C:\Users\vlad\Desktop\autoc\serv5.png" ;change to address where you hold n-ice client server 5 button
add_2:="C:\Users\vlad\Desktop\autoc\save.png" ;change to address where you hold ingame cropped save button
add_3:="C:\Users\vlad\Desktop\autoc\login.png" ;in game press "N" then crop the login button and put address here
Server:
Loop,
{
imgname:="serv5.png"
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %add_1%
if (ErrorLevel = 2)
{
ToolTip, invalid search -> %imgname% counter=%c% ,%tx%,%ty%
c++
Sleep, 1000
}
else if (ErrorLevel = 1)
{
ToolTip, no found -> %imgname% counter=%c% ,%tx%,%ty%
c++
Sleep, 5000
}
else
{
ToolTip, %imgname% was found at %FoundX%x%FoundY% counter=%c% ,%tx%,%ty%
x:=FoundX+50
y:=FoundY+5
Sleep, 500
c=0
Sleep, 500
Click, %x%, %y%
Sleep, 3000
Goto, InGame
}
}
InGame:
Loop,
{
imgname:="save.png"
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %add_2%
if (ErrorLevel = 2)
{
if(c>10)
{
Goto, server
}
else
{
ToolTip, invalid search -> %imgname% counter=%c% ,%tx%,%ty%
c++
Sleep, 1000
}
}
else if (ErrorLevel = 1)
{
if(c>10)
{
Goto, server
}
else
{
ToolTip, searching... -> %imgname% counter=%c% ,%tx%,%ty%
c++
Sleep, 1000
}
}
else
{
ToolTip, %imgname% was found at %FoundX%x%FoundY% counter=%c% ,%tx%,%ty%
;MouseMove, %FoundX%, %FoundY%
Sleep, 500
c=0
Sleep, 500
Goto, Login
}
}
Login:
Loop,
{
imgname:="login.png"
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, %add_3%
if (ErrorLevel = 2)
{
if(c>10)
{
Goto, server
}
else
{
ToolTip, invalid search -> %imgname% counter=%c% ,%tx%,%ty%
c++
Sleep, 1000
}
}
else if (ErrorLevel = 1)
{
if(c>10)
{
Goto, server
}
else
{
ToolTip, searching... -> %imgname% counter=%c% ,%tx%,%ty%
Sleep, 500
c++
Sleep, 500
Send {N}
}
}
else
{
ToolTip, Login was found at %FoundX%x%FoundY% counter=%c% ,%tx%,%ty%
x:=FoundX+50
y:=FoundY+5
Click, %x%, %y%
Sleep, 3000
c=0
Goto, Server
}
}