Auto-It3 script to auto-start Razor and a macro

Auto-It3 script to auto-start Razor and a macro

Postby Batlin on Fri Mar 12, 2010 4:09 pm

The following is an AutoIt3 (au3) script I wrote that will:
1) check if the connection to your shard is alive (using netstat)
2) if the client is still connected than the script exists without doing anthing
3) otherwise, the client is forcefully closed
4) Razor is started
5) using a preconfigured password (in the script) the client will auto-connect
6) and the last played character is activated again
7) then the hotkey (Ctrl-T) is send, assign your razor script here or modify the au3 script to use another hotkey

Limitation of this script:
1) it requires AutoIt3, to schedule this script at certain intervals you still need a seperate utility
2) the script does not function well with multiple clients/razors in one windows session
3) a screensaver will most likely block the correct function of the script

Code: Select all
#include <File.au3>
#include <Constants.au3>

; Shard/Language Configuration
Local $ServerIP = "64.34.176.148" ; must be an IP address!
Local $ServerPort = "2593"
Local $Password = "uo@demo"
Local $ForceRazorPath = "" ; type a full path here if you have a custom razor installation
Local $ClientName = "client.exe"
Local $EstablishedWord = "established"

; Detect Razor!
if $ForceRazorPath = "" Then
   $RazorPath = _PathMake("", RegRead("HKLM\SOFTWARE\Razor", "InstallDir"), "razor", "exe")
Else
   $RazorPath = $ForceRazorPath
EndIf
If Not FileExists($RazorPath) Then
   MsgBox(0, "Error, Razor not found!", $RazorPath)
   Exit
EndIf

;
Local $IsConnected = False 

; Use cmd.exe + netstat to detect if we are connected we our beloved shard
Local $foo = Run(@ComSpec & " /C netstat -n -p tcp | FINDSTR /L " & $ServerIP & ":" & $ServerPort & " | FINDSTR /I "  & $EstablishedWord &  """", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line
While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
   If $line <> '' Then
      ;MsgBox(0, "STDOUT read:", $line)
     $IsConnected = True
    EndIf
Wend

; If we are connected then do nothing and exit
If $IsConnected Then Exit

; Close the client & wait 5 seconds
If ProcessExists($ClientName) Then
  ProcessClose($ClientName)
  Sleep(5000)
EndIf

; Run Razor
Run($RazorPath)
Sleep(5000)

; If we have a Welcome to Razor! screen we close it
If WinExists("Welcome to Razor!") Then
   WinActivate("Welcome to Razor!")
   Sleep(1000)
   Send("!o")
EndIf

; Wait for the client to be ready
WinWait("Ultima Online")
Sleep(10000)
WinActivate("Ultima Online")

; Logon to the last character
Sleep(5000)
Send($password & "{ENTER}")
Sleep(5000)
Send("{ENTER}")
Sleep(5000)
Send("{ENTER}")
Sleep(5000)

; Activate Razor and go to the Help & Status tab
WinActivate("Razor")
Sleep(1000)
If WinActive("Razor") Then
   Send("{END}")
EndIf

; Reactivate the client and send our HotKey
; Ctrl-T
WinActivate("Ultima Online")
Sleep(1000)
Send("^t")

; Done
MsgBox(0, "Auto Connection Script", "Done")


To use this script, download AutoIt3 and copy/paste the above copy to a au3 file. -- http://www.autoitscript.com/autoit3/
<Derrick> RunUO AI is kind of a functional prototype, which i have hacked into something resembling OSI behavior, but only by complitcating everything
Batlin
Site Admin
 
Posts: 306
Joined: Wed Apr 08, 2009 6:35 am


Return to UO Client

Who is online

Users browsing this forum: No registered users and 1 guest