Misc

The Misc class contains general purpose functions of common use.

Table of Contents

Methods

AllSharedValue

Syntax: Misc.AllSharedValue()
Returns: List[String]

AppendNotDupToFile

Syntax: Misc.AppendNotDupToFile(fileName, lineOfData)

Allows creation and append of a file within RE ValidLocations. For OSI/RE this is only the RE directory / sub-directories For CUO/RE this is only CUO or RE directory / sub-directories The filename MUST end in a limited file suffix list Checks to see if an identical line is already in the file, and does not add if it exists

Parameters:
  • fileName (String)
  • lineOfData (String)
Returns: Boolean

AppendToFile

Syntax: Misc.AppendToFile(fileName, lineOfData)

Allows creation and append of a file within RE ValidLocations. For OSI/RE this is only the RE directory / sub-directories For CUO/RE this is only CUO or RE directory / sub-directories The filename MUST end in a limited file suffix list

Parameters:
  • fileName (String)
  • lineOfData (String)
Returns: Boolean

Beep

Syntax: Misc.Beep()

Play Beep system sound.

Returns: Void

CancelPrompt

Syntax: Misc.CancelPrompt()

Cancel a prompt request.

Returns: Void

CaptureNow

Syntax: Misc.CaptureNow()

Creates a snapshot of the current UO window.

Returns: String

ChangeProfile

Syntax: Misc.ChangeProfile(profileName)

Allow the scripted loading of a profile

Parameters:
  • profileName (String): Name of profile to load
Returns: Void

CheckIgnoreObject

Syntax: Misc.CheckIgnoreObject(serial)

Check object from ignore list, return true if present. Can check Serial, Items or Mobiles

Parameters:
  • serial (Int32): Serial to check.
Returns: Boolean

CheckSharedValue

Syntax: Misc.CheckSharedValue(name)

Check if a shared value exists.

Parameters:
  • name (String): Name of the value.
Returns: Boolean

ClearIgnore

Syntax: Misc.ClearIgnore()

Clear ignore list from all object

Returns: Void

CloseBackpack

Syntax: Misc.CloseBackpack()

Close the backpack. (OSI client only, no ClassicUO)

Returns: Void

CloseMenu

Syntax: Misc.CloseMenu()

Close opened Old Menu.

Returns: Void

ConfigDirectory

Syntax: Misc.ConfigDirectory()

Get the full path to the Persistence Directory.

Returns: String

ContextReply

Syntax: Misc.ContextReply(serial, response_num)

Respond to a context menu on mobile or item. Menu ID is base zero, or can use string of menu text.

Parameters:
  • serial (Int32): Serial of the Entity
  • response_num (Int32): Position of the option in the menu. Starts from 0.
Returns: Void

DataDirectory

Syntax: Misc.DataDirectory()

Get the full path to the Persistence Directory.

Returns: String

DeleteFile

Syntax: Misc.DeleteFile(fileName)

Allows deletion of a file within RE ValidLocations. For OSI/RE this is only the RE directory / sub-directories For CUO/RE this is only CUO or RE directory / sub-directories The filename MUST end in a limited file suffix list

Parameters:
  • fileName (String)
Returns: Boolean

Disconnect

Syntax: Misc.Disconnect()

Force client to disconnect.

Returns: Void

Distance

Syntax: Misc.Distance(X1, Y1, X2, Y2)

Returns the UO distance between the 2 sets of co-ordinates.

Parameters:
  • X1 (Int32): X co-ordinate of first place.
  • Y1 (Int32): Y co-ordinate of first place.
  • X2 (Int32): X co-ordinate of second place.
  • Y2 (Int32): Y co-ordinate of second place.
Returns: Int32

DistanceSqrt

Syntax: Misc.DistanceSqrt(point_a, point_b)

Compute the distance between 2 Point3D using Pythagorean.

Parameters:
  • point_a (Point3D): First coordinates.
  • point_b (Point3D): Second coordinates.
Returns: Double

ExportPythonAPI

Syntax: Misc.ExportPythonAPI(path, pretty)

Return a string containing list RE Python API list in JSON format.

Parameters:
  • path (String): Name of the output file. (default: Persistence/AutoComplete.json )
  • pretty (Boolean): Print a readable JSON. (default: True )
Returns: Void

FilterSeason

Syntax: Misc.FilterSeason(enable, seasonFlag)

Enable or disable the Seasons filter forcing a specific season Season filter state will be saved on logout but not the season flag that will be recovered.

Parameters:
  • enable (Boolean): True: enable seasons filter
  • seasonFlag (UInt32): 0: Spring (default fallback) 1: Summer 2: Fall 3: Winter 4: Desolation
Returns: Void

FocusUOWindow

Syntax: Misc.FocusUOWindow()

Set UoClient window in focus or restore if minimized.

Returns: Void

GetContPosition

Syntax: Misc.GetContPosition()

Get the position of the currently active Gump/Container. (OSI client only, no ClassicUO)

Returns: Point

GetMapInfo

Syntax: Misc.GetMapInfo(serial)

Get MapInfo about a Mobile or Item using the serial

Parameters:
  • serial (UInt32): Serial of the object.
Returns: Misc.MapInfo

GetMenuTitle

Syntax: Misc.GetMenuTitle()

Get the title of title for open Old Menu.

Returns: String

GetWindowSize

Syntax: Misc.GetWindowSize()

Get a Rectangle representing the window size. See also: https://docs.microsoft.com/dotnet/api/system.drawing.rectangle

Returns: Rectangle

HasMenu

Syntax: Misc.HasMenu()

Check if an Old Menu is open.

Returns: Boolean

HasPrompt

Syntax: Misc.HasPrompt()

Check if have a prompt request.

Returns: Boolean

HasQueryString

Syntax: Misc.HasQueryString()

Check if a have a query string menu opened, return true or false.

Returns: Boolean

IgnoreObject

Syntax: Misc.IgnoreObject(serial)

Add an entity to the ignore list. Can ignore Serial, Items or Mobiles.

Parameters:
  • serial (Int32): Serial to ignore.
Returns: Void

Inspect

Syntax: Misc.Inspect()

Prompt the user with a Target. Open the inspector for the selected target.

Returns: Void

IsItem

Syntax: Misc.IsItem(serial)

Determine if the serial is an item

Parameters:
  • serial (UInt32): Serial number of object to test is Item
Returns: Boolean

IsMobile

Syntax: Misc.IsMobile(serial)

Determine if the serial is a mobile

Parameters:
  • serial (UInt32): Serial number of object to test is Mobile
Returns: Boolean

LastHotKey

Syntax: Misc.LastHotKey()

Returns the latest HotKey recorded by razor as HotKeyEvent object.

Returns: HotKeyEvent

LeftMouseClick

Syntax: Misc.LeftMouseClick(xpos, ypos, clientCoords)

Perform a physical left click on the window using Windows API. Is possible to use absolute Screen Coordinates by setting clientCoords=False.

Parameters:
  • xpos (Int32): X click coordinate.
  • ypos (Int32): Y click coordinate.
  • clientCoords (Boolean): True: Client coordinates.- False:Screen coordinates (default: True, client).
Returns: Void

MenuContain

Syntax: Misc.MenuContain(text)

Search in open Old Menu if contains a specific text.

Parameters:
  • text (String): Text to search.
Returns: Boolean

MenuResponse

Syntax: Misc.MenuResponse(text)

Perform a menu response by subitem name. If item not exist close menu.

Parameters:
  • text (String): Name of subitem to respond.
Returns: Void

MouseLocation

Syntax: Misc.MouseLocation()

Returns a point with the X and Y coordinates of the mouse relative to the UO Window

Returns: Point

MouseMove

Syntax: Misc.MouseMove(posX, posY)

Moves the mouse pointer to the position X,Y relative to the UO window

Parameters:
  • posX (Int32): X screen coordinate.
  • posY (Int32): Y screen coordinate.
Returns: Void

NextContPosition

Syntax: Misc.NextContPosition(x, y)

Return the X,Y of the next container, relative to the game window. (OSI client only, no ClassicUO)

Parameters:
  • x (Int32): X coordinate.
  • y (Int32): Y coordinate.
Returns: Void

NoOperation

Syntax: Misc.NoOperation()

Just do nothing and enjoy the present moment.

Returns: Void

OpenPaperdoll

Syntax: Misc.OpenPaperdoll()

Open the backpack. (OSI client only, no ClassicUO)

Returns: Void

Pause

Syntax: Misc.Pause(millisec)

Pause the script for a given amount of time.

Parameters:
  • millisec (Int32): Pause duration, in milliseconds.
Returns: Void

PetRename

Syntax: Misc.PetRename(serial, name)

Rename a specific pet.

Parameters:
  • serial (Int32): Serial of the pet.
  • name (String): New name to set.
Returns: Void

PlaySound

Syntax: Misc.PlaySound(sound, x, y, z)

Send a sound to the client.

Parameters:
  • sound (Int32): The sound to play.
  • x (Int32): The x point to send sound to.
  • y (Int32): The y point to send sound to.
  • z (Int32): The z point to send sound to.
Returns: Void

QueryStringResponse

Syntax: Misc.QueryStringResponse(okcancel, response)

Perform a query string response by ok or cancel button and specific response string.

Parameters:
  • okcancel (Boolean): OK Button
  • response (String): Cancel Button
Returns: Void

RazorDirectory

Syntax: Misc.RazorDirectory()

Get the full path to the main Razor Enhanced folder. This path maybe be different from the Python starting folder when RE is loaded as plugin (ex: ClassicUO)

Returns: String

ReadSharedValue

Syntax: Misc.ReadSharedValue(name)

Get a Shared Value, if value not exist return null. Shared values are accessible by every script. Get a Shared Value, if value not exist return null. Shared values are accessible by every script.

Parameters:
  • name (String): Name of the value.
Returns: Object, T

RemoveLineInFile

Syntax: Misc.RemoveLineInFile(fileName, lineOfData)

Allows removal of a line in a file within RE ValidLocations. For OSI/RE this is only the RE directory / sub-directories For CUO/RE this is only CUO or RE directory / sub-directories The filename MUST end in a limited file suffix list Checks to see if an identical line is in the file, and if it exists, it is removed and file written

Parameters:
  • fileName (String)
  • lineOfData (String)
Returns: Boolean

RemoveSharedValue

Syntax: Misc.RemoveSharedValue(name)

Remove a Shared Value.

Parameters:
  • name (String): Name of the value.
Returns: Void

ResetPrompt

Syntax: Misc.ResetPrompt()

Reset a prompt response.

Returns: Void

ResponsePrompt

Syntax: Misc.ResponsePrompt(text)

Response a prompt request. Often used to rename runes and similar.

Parameters:
  • text (String): Text of the response.
Returns: Void

Resync

Syntax: Misc.Resync()

Trigger a client ReSync.

Returns: Void

RightMouseClick

Syntax: Misc.RightMouseClick(xpos, ypos, clientCoords)

Perform a physical Right click on the window.

Parameters:
  • xpos (Int32): X click coordinate.
  • ypos (Int32): Y click coordinate.
  • clientCoords (Boolean): True: Client coordinates - False: Screen coordinates (default: True, client).
Returns: Void

ScriptCurrent

Syntax: Misc.ScriptCurrent(fullpath)

Returns the path of the current script.

Parameters:
  • fullpath (Boolean): True:Returns the full path. False: Returns the filename. (Default: true)
Returns: String

ScriptDirectory

Syntax: Misc.ScriptDirectory()

Get the full path to the Scripts Directory.

Returns: String

ScriptIsSuspended

Syntax: Misc.ScriptIsSuspended(scriptfile)

Get status of script if is suspended or not, Script must be present in script grid.

Parameters:
  • scriptfile (String)
Returns: Boolean

ScriptResume

Syntax: Misc.ScriptResume(scriptfile)

Resume a script by file name, Script must be present in script grid.

Parameters:
  • scriptfile (String): Name of the script.
Returns: Void

ScriptRun

Syntax: Misc.ScriptRun(scriptfile)

Run a script by file name, Script must be present in script grid.

Parameters:
  • scriptfile (String): Name of the script.
Returns: Void

ScriptStatus

Syntax: Misc.ScriptStatus(scriptfile)

Get status of script if running or not, Script must be present in script grid.

Parameters:
  • scriptfile (String)
Returns: Boolean

ScriptStop

Syntax: Misc.ScriptStop(scriptfile)

Stop a script by file name, Script must be present in script grid.

Parameters:
  • scriptfile (String): Name of the script.
Returns: Void

ScriptStopAll

Syntax: Misc.ScriptStopAll(skipCurrent)

Stop all script running.

Parameters:
  • skipCurrent (Boolean): True: Stop all scripts, but the current one - False: stop all scripts. (Default: false)
Returns: Void

ScriptSuspend

Syntax: Misc.ScriptSuspend(scriptfile)

Suspend a script by file name, Script must be present in script grid.

Parameters:
  • scriptfile (String): Name of the script.
Returns: Void

SendMessage

Syntax: Misc.SendMessage(msg, color, wait)

Send a message to the client.

Parameters:
  • msg (String): The object to print.
  • color (Int32): Color of the message.
  • wait (Boolean): True: Wait for confirmation. - False: Returns instantly.
Returns: Void

SendToClient

Syntax: Misc.SendToClient(keys)

Send to the client a list of keystrokes. Can contain control characters: - Send Control+Key: ctrl+u: ^u - Send ENTER: {Enter} Note: some keys don't work with ClassicUO (es: {Enter} )

Parameters:
  • keys (String): List of keys.
Returns: Void

SetSharedValue

Syntax: Misc.SetSharedValue(name, value)

Set a Shared Value by specific name, if value exist he replace value. Shared values are accessible by every script.

Parameters:
  • name (String): Name of the value.
  • value (Object): Value to set.
Returns: Void

ShardName

Syntax: Misc.ShardName()

Get the name of the shard.

Returns: String

UnIgnoreObject

Syntax: Misc.UnIgnoreObject(serial)

Remove object from ignore list. Can remove serial, items or mobiles

Parameters:
  • serial (Int32): Serial to unignore.
Returns: Void

UseContextMenu

Syntax: Misc.UseContextMenu(serial, choice, delay)

Open and click the option of Context menu, given the serial of Mobile or Item, via packets.

Parameters:
  • serial (Int32): Serial of the Item or Mobile.
  • choice (String): Option as Text or integer.
  • delay (Int32): Maximum wait for the action to complete.
Returns: Boolean

WaitForContext

Syntax: Misc.WaitForContext(serial, delay, showContext)

Return the List entry of a Context menu, of Mobile or Item objects. The function will ask the server for the List and wait for a maximum amount of time.

Parameters:
  • serial (Int32): Serial of the entity.
  • delay (Int32): Maximum wait.
  • showContext (Boolean): Show context menu in-game. (default: True)
Returns: List[Misc.Context]

WaitForMenu

Syntax: Misc.WaitForMenu(delay)

Pause script until server send an Old Menu, for a maximum amount of time.

Parameters:
  • delay (Int32): Maximum wait, in milliseconds.
Returns: Boolean

WaitForPrompt

Syntax: Misc.WaitForPrompt(delay)

Wait for a prompt for a maximum amount of time.

Parameters:
  • delay (Int32): Maximum wait time.
Returns: Boolean

WaitForQueryString

Syntax: Misc.WaitForQueryString(delay)

Pause script until server send query string request, for a maximum amount of time.

Parameters:
  • delay (Int32): Maximum wait, in milliseconds.
Returns: Boolean