API Basic Windows ko - LIHACHTETAN/ClassicUO-BadNewbie-BasicIDE GitHub Wiki

Windows.bas

ClassicUO โ€ข Basic

Windows.bas๋Š” ํ”„๋กœ์„ธ์Šค ์ •๋ณด, ์งง์€ ์‹œ๊ฐ„ ์ธก์ •, ๋ฐ์Šคํฌํ†ฑ ํฌ๊ธฐ๋ฅผ ์œ„ํ•œ ๊ณต๊ฐœ ํ•จ์ˆ˜ 6๊ฐœ๋ฅผ ์ œ๊ณตํ•˜๋Š” ํŽธ์ง‘ ๊ฐ€๋Šฅํ•œ Basic ๋ชจ๋“ˆ์ž…๋‹ˆ๋‹ค. ์ „์ฒด ์ฝ”๋“œ์™€ Private Declare๋ฅผ ์•„๋ž˜์— ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. Main๋งŒ ๋ณต์‚ฌํ•˜๋ฉด ์‹คํ–‰๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์ •ํ™•ํ•œ ๊ตฌ๋ฌธ

Include "Windows.bas"
Windows.ProcessId() As Integer
Windows.Milliseconds() As Double
Windows.ElapsedMilliseconds(ByVal startMilliseconds As Double) As Double
Windows.ScreenWidth() As Integer
Windows.ScreenHeight() As Integer
Windows.DesktopBounds() As Object

๋งค๊ฐœ๋ณ€์ˆ˜

  • Include / Windows.bas โ€” Include "Windows.bas"๋Š” Scripts/Include/Windows.bas๋ฅผ ์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹ค. ๋ณ„๋„ ์Šคํฌ๋ฆฝํŠธ ํด๋”์—์„œ๋Š” Include ํ•˜์œ„ ํด๋”์— ๋ณต์‚ฌํ•˜์„ธ์š”. ์˜ˆ์ œ์—๋Š” Main.bas์™€ Include/Windows.bas๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. Windows.๋กœ ํ˜ธ์ถœํ•˜๋ฉฐ UO.๋Š” ๋ถ™์ด์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
  • ProcessId() โ€” ProcessId()๋Š” ์ธ์ˆ˜ ์—†์ด ํ˜„์žฌ ํด๋ผ์ด์–ธํŠธ์˜ Windows ํ”„๋กœ์„ธ์Šค ID๋ฅผ Integer๋กœ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์บ๋ฆญํ„ฐยท์•„์ดํ…œ ์‹œ๋ฆฌ์–ผ์ด๋‚˜ ์„œ๋ฒ„ ์—ฐ๊ฒฐ ID๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.
  • Milliseconds() โ€” Milliseconds()๋Š” ์ธ์ˆ˜ ์—†์ด 0..4294967295์˜ Double์„ ๋ฐ˜ํ™˜ํ•˜๋ฉฐ ๋ถ€ํ˜ธ ์—†๋Š” 32๋น„ํŠธ GetTickCount๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. ์Œ์ˆ˜์ธ ๋„ค์ดํ‹ฐ๋ธŒ ๊ฒฐ๊ณผ์—๋Š” 4294967296.0์„ ๋”ํ•ฉ๋‹ˆ๋‹ค. ์•ฝ 49.7์ผ๋งˆ๋‹ค ์ˆœํ™˜ํ•˜๋ฉฐ ๋‹ฌ๋ ฅ ์‹œ๊ฐ„์ด๋‚˜ ๊ณ ์ •๋ฐ€ ํƒ€์ด๋จธ๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.
  • ElapsedMilliseconds(startMilliseconds) โ€” ElapsedMilliseconds(startMilliseconds)๋Š” ์ €์žฅํ•œ Milliseconds() ๊ฐ’์„ Double๋กœ ๋ฐ›์•„ ์ง€๋‚œ ๋ฐ€๋ฆฌ์ดˆ๋ฅผ Double๋กœ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. 0..4294967295 ๋ฐ–์ด๋ฉด ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค. ์Œ์ˆ˜ ์ฐจ์ด์— 4294967296.0์„ ๋”ํ•ด ํ•œ ๋ฒˆ์˜ ์ˆœํ™˜๋งŒ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ์ธก์ •์€ ํ•œ ์ฃผ๊ธฐ๋ณด๋‹ค ์งง์•„์•ผ ํ•˜๋ฉฐ ํ•จ์ˆ˜ ์ž์ฒด๋Š” ๊ธฐ๋‹ค๋ฆฌ์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
  • ScreenWidth() / ScreenHeight() โ€” ScreenWidth()/ScreenHeight()๋Š” ์ธ์ˆ˜ ์—†์ด ๋ฉ”ํŠธ๋ฆญ 0/1๋กœ ๊ธฐ๋ณธ ๋ชจ๋‹ˆํ„ฐ์˜ Integer ํฌ๊ธฐ๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ํ”„๋กœ์„ธ์Šค DPI ํ™˜๊ฒฝ์˜ Windows ์ขŒํ‘œ์ด๋ฉฐ UO ํƒ€์ผ์ด๋‚˜ ๊ฒŒ์ž„ ์ฐฝ ํฌ๊ธฐ๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.
  • DesktopBounds() โ€” DesktopBounds()๋Š” ๋ฌธ์ž์—ด ํ‚ค X, Y, Width, Height์™€ Integer ๊ฐ’์„ ๊ฐ€์ง„ ์ƒˆ Dictionary๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. Item("X") ๋“ฑ์œผ๋กœ ์ฝ์Šต๋‹ˆ๋‹ค. ๋ฉ”ํŠธ๋ฆญ 76~79๋Š” ๋ชจ๋“  ๋ชจ๋‹ˆํ„ฐ๋ฅผ ๋‘˜๋Ÿฌ์‹ผ ์‚ฌ๊ฐํ˜•์ด๋ฉฐ X/Y๋Š” ์Œ์ˆ˜์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์‚ฌ์ „ ์ˆ˜์ •์€ ์ฐฝ์„ ์ด๋™ํ•˜๊ฑฐ๋‚˜ ํฌ๊ธฐ๋ฅผ ๋ฐ”๊พธ์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

๋ฐ˜ํ™˜๊ฐ’

ID์™€ ํ™”๋ฉด ํฌ๊ธฐ๋Š” Integer ์ˆ˜๋Ÿ‰, ์‹œ๊ฐ„์€ Double ๋ฐ€๋ฆฌ์ดˆ๋กœ Boolean์ด ์•„๋‹™๋‹ˆ๋‹ค. DesktopBounds๋Š” Integer ๊ฐ’์„ ๊ฐ€์ง„ Object(Dictionary)์ž…๋‹ˆ๋‹ค. Include์™€ ์„ ์–ธ์—๋Š” ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ๊ฐ ์˜ˆ์ œ Main์€ ๋ฐ์ดํ„ฐ ๊ฒ€์‚ฌ ์„ฑ๊ณต ์‹œ 1/True, ์‹คํŒจ ์‹œ 0/False๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ฉฐ ๋ชจ๋“  ๋„ค์ดํ‹ฐ๋ธŒ ์ˆซ์ž๊ฐ€ ์„ฑ๊ณต ํ”Œ๋ž˜๊ทธ๋ผ๋Š” ๋œป์€ ์•„๋‹™๋‹ˆ๋‹ค.

๋™์ž‘

  • Windows x64๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. NativeTicks, NativeProcessId, NativeMetric์€ ์•„๋ž˜์˜ Private Declare 3๊ฐœ์ž…๋‹ˆ๋‹ค. DLL ๋™์ž‘์€ Basic.Declare๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”. ๊ฒŒ์ž„ ํŒจํ‚ท, ์„ค์ • ๋ณ€๊ฒฝ, ์บ๋ฆญํ„ฐ ์ด๋™์€ ์—†์Šต๋‹ˆ๋‹ค.
  • ๋งค๋ฒˆ ํ˜„์žฌ ๊ฐ’์„ ์ฝ์Šต๋‹ˆ๋‹ค. Milliseconds๋Š” ๋ณดํ†ต 10~16ms๋งˆ๋‹ค ๊ฐฑ์‹ ๋˜๋ฉฐ ์—ฌ๋Ÿฌ ์ˆœํ™˜์ด๋‚˜ ๋‹ค๋ฅธ Windows ์„ธ์…˜์˜ ๊ฐ’์€ ๊ตฌ๋ถ„ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ์งง์€ ์ž‘์—…์— ์‚ฌ์šฉํ•˜์„ธ์š”. Wait์˜ ์ •ํ™•ํ•œ ์‹œ๊ฐ„์€ ๋ณด์žฅํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
  • Main.bas์™€ Include/Windows.bas๋ฅผ ํ•จ๊ป˜ ๋ณต์‚ฌํ•˜๋ฉด IDE์—์„œ ํŽธ์ง‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. DesktopBounds๋Š” ๋งค๋ฒˆ ๋…๋ฆฝ๋œ ์Šค๋ƒ…์ƒท์ด๋ฉฐ ๋ชจ๋‹ˆํ„ฐ ๊ตฌ์„ฑ์ด๋‚˜ DPI ๋ณ€๊ฒฝ์€ ๋‹ค์Œ ๊ฒฐ๊ณผ์— ์˜ํ–ฅ์„ ์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์˜ˆ์ œ

1. ํ”„๋กœ์„ธ์Šค์™€ ์นด์šดํ„ฐ

# Main์€ Windows.bas๋ฅผ ์—ฐ๊ฒฐํ•˜๊ณ  ProcessId()๋ฅผ ์ฝ์œผ๋ฉฐ Milliseconds()๋ฅผ startedAt์— ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. AndAlso๋กœ ์–‘์ˆ˜ ID์™€ 0..4294967295 ๋ฒ”์œ„๋ฅผ ๊ฒ€์‚ฌํ•ด 1/True๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์‹ค์ œ ์ˆซ์ž๋Š” ์ปดํ“จํ„ฐ๋งˆ๋‹ค ๋‹ค๋ฆ…๋‹ˆ๋‹ค.
Option Explicit On
Include "Windows.bas"

Sub Main()
    Dim processId = Windows.ProcessId()
    Dim startedAt = Windows.Milliseconds()
    Return processId > 0 AndAlso startedAt >= 0 AndAlso startedAt <= 4294967295.0
End Sub

๋งค๊ฐœ๋ณ€์ˆ˜ ๋ฐ ์‹คํ–‰ ์„ค๋ช…:

Main์€ Windows.bas๋ฅผ ์—ฐ๊ฒฐํ•˜๊ณ  ProcessId()๋ฅผ ์ฝ์œผ๋ฉฐ Milliseconds()๋ฅผ startedAt์— ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. AndAlso๋กœ ์–‘์ˆ˜ ID์™€ 0..4294967295 ๋ฒ”์œ„๋ฅผ ๊ฒ€์‚ฌํ•ด 1/True๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์‹ค์ œ ์ˆซ์ž๋Š” ์ปดํ“จํ„ฐ๋งˆ๋‹ค ๋‹ค๋ฆ…๋‹ˆ๋‹ค.

Include/Windows.bas

Option Explicit On

' Windows x64 helpers. Include "Windows.bas" from the main script.
' These declarations use the Windows ABI, not VB6 Integer/Long widths.
Module Windows
    Private Declare Function NativeTicks Lib "kernel32.dll" Alias "GetTickCount"() As Integer
    Private Declare Function NativeProcessId Lib "kernel32.dll" Alias "GetCurrentProcessId"() As Integer
    Private Declare Function NativeMetric Lib "user32.dll" Alias "GetSystemMetrics"(ByVal index As Integer) As Integer

    ' Returns the current client process ID. This is not a character/item serial.
    Public Function ProcessId() As Integer
        Return NativeProcessId()
    End Function

    ' Unsigned 32-bit milliseconds since Windows started, represented as Double.
    ' Wraps every 4294967296 ms (about 49.7 days); this is not a calendar time.
    Public Function Milliseconds() As Double
        Dim value As Double = NativeTicks()
        If value < 0 Then
            value += 4294967296.0
        End If
        Return value
    End Function

    ' startMilliseconds must come from Milliseconds(). Handles one wrap only.
    ' Use for intervals shorter than 49.7 days; no waiting is performed here.
    Public Function ElapsedMilliseconds(ByVal startMilliseconds As Double) As Double
        If Not (startMilliseconds >= 0 AndAlso startMilliseconds <= 4294967295.0) Then
            Throw "Windows.ElapsedMilliseconds requires a tick value in 0..4294967295."
        End If
        Dim elapsed As Double = Milliseconds() - startMilliseconds
        If elapsed < 0 Then
            elapsed += 4294967296.0
        End If
        Return elapsed
    End Function

    ' Primary monitor dimensions in the process's Windows DPI coordinate space.
    ' These are desktop dimensions, not the UO game viewport size.
    Public Function ScreenWidth() As Integer
        Return NativeMetric(0)
    End Function

    Public Function ScreenHeight() As Integer
        Return NativeMetric(1)
    End Function

    ' Returns a new Dictionary: X, Y, Width, Height of the whole virtual desktop.
    ' X/Y may be negative when monitors are to the left/above the primary one.
    Public Function DesktopBounds() As Object
        Dim bounds = Dictionary()
        bounds.Set("X", NativeMetric(76))
        bounds.Set("Y", NativeMetric(77))
        bounds.Set("Width", NativeMetric(78))
        bounds.Set("Height", NativeMetric(79))
        Return bounds
    End Function
End Module

2. ๋Œ€๊ธฐ ์‹œ๊ฐ„ ์ธก์ •

# MeasureWait(delayMilliseconds)๋Š” ์Œ์ˆ˜๋ฅผ ๊ฑฐ๋ถ€ํ•˜๊ณ  ์นด์šดํ„ฐ๋ฅผ ์ €์žฅํ•œ ๋’ค Wait๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ElapsedMilliseconds(startMilliseconds:=startedAt)๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. Main์€ 15๋ฅผ ์ „๋‹ฌํ•˜๊ณ  elapsed >= 0์„ ๊ฒ€์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์‹ค์ œ ์‹œ๊ฐ„์€ 15ms๋ณด๋‹ค ๊ธธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ชจ๋“  ๋ณด์กฐ ํ•จ์ˆ˜์™€ ํ•œ ๋ฒˆ์˜ ์ˆœํ™˜ ์ฒ˜๋ฆฌ๋ฅผ ์•„๋ž˜์— ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.
Option Explicit On
Include "Windows.bas"

Function MeasureWait(ByVal delayMilliseconds As Integer) As Double
    If delayMilliseconds < 0 Then
        Throw "delayMilliseconds must be non-negative"
    End If
    Dim startedAt = Windows.Milliseconds()
    Wait(delayMilliseconds)
    Return Windows.ElapsedMilliseconds(startMilliseconds:=startedAt)
End Function

Sub Main()
    Dim elapsed = MeasureWait(15)
    Return elapsed >= 0
End Sub

๋งค๊ฐœ๋ณ€์ˆ˜ ๋ฐ ์‹คํ–‰ ์„ค๋ช…:

MeasureWait(delayMilliseconds)๋Š” ์Œ์ˆ˜๋ฅผ ๊ฑฐ๋ถ€ํ•˜๊ณ  ์นด์šดํ„ฐ๋ฅผ ์ €์žฅํ•œ ๋’ค Wait๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ElapsedMilliseconds(startMilliseconds:=startedAt)๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. Main์€ 15๋ฅผ ์ „๋‹ฌํ•˜๊ณ  elapsed >= 0์„ ๊ฒ€์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์‹ค์ œ ์‹œ๊ฐ„์€ 15ms๋ณด๋‹ค ๊ธธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ชจ๋“  ๋ณด์กฐ ํ•จ์ˆ˜์™€ ํ•œ ๋ฒˆ์˜ ์ˆœํ™˜ ์ฒ˜๋ฆฌ๋ฅผ ์•„๋ž˜์— ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

Include/Windows.bas

Option Explicit On

' Windows x64 helpers. Include "Windows.bas" from the main script.
' These declarations use the Windows ABI, not VB6 Integer/Long widths.
Module Windows
    Private Declare Function NativeTicks Lib "kernel32.dll" Alias "GetTickCount"() As Integer
    Private Declare Function NativeProcessId Lib "kernel32.dll" Alias "GetCurrentProcessId"() As Integer
    Private Declare Function NativeMetric Lib "user32.dll" Alias "GetSystemMetrics"(ByVal index As Integer) As Integer

    ' Returns the current client process ID. This is not a character/item serial.
    Public Function ProcessId() As Integer
        Return NativeProcessId()
    End Function

    ' Unsigned 32-bit milliseconds since Windows started, represented as Double.
    ' Wraps every 4294967296 ms (about 49.7 days); this is not a calendar time.
    Public Function Milliseconds() As Double
        Dim value As Double = NativeTicks()
        If value < 0 Then
            value += 4294967296.0
        End If
        Return value
    End Function

    ' startMilliseconds must come from Milliseconds(). Handles one wrap only.
    ' Use for intervals shorter than 49.7 days; no waiting is performed here.
    Public Function ElapsedMilliseconds(ByVal startMilliseconds As Double) As Double
        If Not (startMilliseconds >= 0 AndAlso startMilliseconds <= 4294967295.0) Then
            Throw "Windows.ElapsedMilliseconds requires a tick value in 0..4294967295."
        End If
        Dim elapsed As Double = Milliseconds() - startMilliseconds
        If elapsed < 0 Then
            elapsed += 4294967296.0
        End If
        Return elapsed
    End Function

    ' Primary monitor dimensions in the process's Windows DPI coordinate space.
    ' These are desktop dimensions, not the UO game viewport size.
    Public Function ScreenWidth() As Integer
        Return NativeMetric(0)
    End Function

    Public Function ScreenHeight() As Integer
        Return NativeMetric(1)
    End Function

    ' Returns a new Dictionary: X, Y, Width, Height of the whole virtual desktop.
    ' X/Y may be negative when monitors are to the left/above the primary one.
    Public Function DesktopBounds() As Object
        Dim bounds = Dictionary()
        bounds.Set("X", NativeMetric(76))
        bounds.Set("Y", NativeMetric(77))
        bounds.Set("Width", NativeMetric(78))
        bounds.Set("Height", NativeMetric(79))
        Return bounds
    End Function
End Module

3. ๋ฐ์Šคํฌํ†ฑ ํฌ๊ธฐ

# Main์€ ๋…๋ฆฝ๋œ Dictionary์—์„œ Item์œผ๋กœ X/Y/Width/Height๋ฅผ ์ฝ๊ณ  ๊ธฐ๋ณธ ๋ชจ๋‹ˆํ„ฐ์™€ ๋น„๊ตํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ ํฌ๊ธฐ๋Š” ์–‘์ˆ˜์ด๊ณ  ์ „์ฒด ๋ฐ์Šคํฌํ†ฑ์ด ๋” ์ž‘์ง€ ์•Š์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. left/top์€ ์Œ์ˆ˜์ผ ์ˆ˜ ์žˆ์œผ๋ฉฐ UO ์ด๋™ ๋ช…๋ น์œผ๋กœ ์ „๋‹ฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
Option Explicit On
Include "Windows.bas"

Sub Main()
    Dim desktop = Windows.DesktopBounds()
    Dim left = desktop.Item("X")
    Dim top = desktop.Item("Y")
    Dim width = desktop.Item("Width")
    Dim height = desktop.Item("Height")
    Dim primaryWidth = Windows.ScreenWidth()
    Dim primaryHeight = Windows.ScreenHeight()
    Return width >= primaryWidth AndAlso height >= primaryHeight AndAlso primaryWidth > 0 AndAlso primaryHeight > 0
End Sub

๋งค๊ฐœ๋ณ€์ˆ˜ ๋ฐ ์‹คํ–‰ ์„ค๋ช…:

Main์€ ๋…๋ฆฝ๋œ Dictionary์—์„œ Item์œผ๋กœ X/Y/Width/Height๋ฅผ ์ฝ๊ณ  ๊ธฐ๋ณธ ๋ชจ๋‹ˆํ„ฐ์™€ ๋น„๊ตํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ ํฌ๊ธฐ๋Š” ์–‘์ˆ˜์ด๊ณ  ์ „์ฒด ๋ฐ์Šคํฌํ†ฑ์ด ๋” ์ž‘์ง€ ์•Š์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. left/top์€ ์Œ์ˆ˜์ผ ์ˆ˜ ์žˆ์œผ๋ฉฐ UO ์ด๋™ ๋ช…๋ น์œผ๋กœ ์ „๋‹ฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

Include/Windows.bas

Option Explicit On

' Windows x64 helpers. Include "Windows.bas" from the main script.
' These declarations use the Windows ABI, not VB6 Integer/Long widths.
Module Windows
    Private Declare Function NativeTicks Lib "kernel32.dll" Alias "GetTickCount"() As Integer
    Private Declare Function NativeProcessId Lib "kernel32.dll" Alias "GetCurrentProcessId"() As Integer
    Private Declare Function NativeMetric Lib "user32.dll" Alias "GetSystemMetrics"(ByVal index As Integer) As Integer

    ' Returns the current client process ID. This is not a character/item serial.
    Public Function ProcessId() As Integer
        Return NativeProcessId()
    End Function

    ' Unsigned 32-bit milliseconds since Windows started, represented as Double.
    ' Wraps every 4294967296 ms (about 49.7 days); this is not a calendar time.
    Public Function Milliseconds() As Double
        Dim value As Double = NativeTicks()
        If value < 0 Then
            value += 4294967296.0
        End If
        Return value
    End Function

    ' startMilliseconds must come from Milliseconds(). Handles one wrap only.
    ' Use for intervals shorter than 49.7 days; no waiting is performed here.
    Public Function ElapsedMilliseconds(ByVal startMilliseconds As Double) As Double
        If Not (startMilliseconds >= 0 AndAlso startMilliseconds <= 4294967295.0) Then
            Throw "Windows.ElapsedMilliseconds requires a tick value in 0..4294967295."
        End If
        Dim elapsed As Double = Milliseconds() - startMilliseconds
        If elapsed < 0 Then
            elapsed += 4294967296.0
        End If
        Return elapsed
    End Function

    ' Primary monitor dimensions in the process's Windows DPI coordinate space.
    ' These are desktop dimensions, not the UO game viewport size.
    Public Function ScreenWidth() As Integer
        Return NativeMetric(0)
    End Function

    Public Function ScreenHeight() As Integer
        Return NativeMetric(1)
    End Function

    ' Returns a new Dictionary: X, Y, Width, Height of the whole virtual desktop.
    ' X/Y may be negative when monitors are to the left/above the primary one.
    Public Function DesktopBounds() As Object
        Dim bounds = Dictionary()
        bounds.Set("X", NativeMetric(76))
        bounds.Set("Y", NativeMetric(77))
        bounds.Set("Width", NativeMetric(78))
        bounds.Set("Height", NativeMetric(79))
        Return bounds
    End Function
End Module

๋‚ด๋ถ€ ํ•จ์ˆ˜: ํ˜ธ์ถœ๋ถ€ํ„ฐ ๊ฒฐ๊ณผ๊นŒ์ง€

Windows.bas๋Š” ํ”„๋กœ์„ธ์Šค ์ •๋ณด, ์งง์€ ์‹œ๊ฐ„ ์ธก์ •, ๋ฐ์Šคํฌํ†ฑ ํฌ๊ธฐ๋ฅผ ์œ„ํ•œ ๊ณต๊ฐœ ํ•จ์ˆ˜ 6๊ฐœ๋ฅผ ์ œ๊ณตํ•˜๋Š” ํŽธ์ง‘ ๊ฐ€๋Šฅํ•œ Basic ๋ชจ๋“ˆ์ž…๋‹ˆ๋‹ค. ์ „์ฒด ์ฝ”๋“œ์™€ Private Declare๋ฅผ ์•„๋ž˜์— ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. Main๋งŒ ๋ณต์‚ฌํ•˜๋ฉด ์‹คํ–‰๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

1. ProcessId / Milliseconds

Milliseconds()๋Š” ์ธ์ˆ˜ ์—†์ด 0..4294967295์˜ Double์„ ๋ฐ˜ํ™˜ํ•˜๋ฉฐ ๋ถ€ํ˜ธ ์—†๋Š” 32๋น„ํŠธ GetTickCount๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. ์Œ์ˆ˜์ธ ๋„ค์ดํ‹ฐ๋ธŒ ๊ฒฐ๊ณผ์—๋Š” 4294967296.0์„ ๋”ํ•ฉ๋‹ˆ๋‹ค. ์•ฝ 49.7์ผ๋งˆ๋‹ค ์ˆœํ™˜ํ•˜๋ฉฐ ๋‹ฌ๋ ฅ ์‹œ๊ฐ„์ด๋‚˜ ๊ณ ์ •๋ฐ€ ํƒ€์ด๋จธ๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.

GetTickCount -> signed Integer -> if negative add 4294967296.0 -> Double

ํ”„๋กœ์ ํŠธ ์†Œ์Šค: src/ClassicUO.Client/Scripts/Include/Windows.bas; ํ•จ์ˆ˜ ProcessId / Milliseconds.

2. ElapsedMilliseconds

ElapsedMilliseconds(startMilliseconds)๋Š” ์ €์žฅํ•œ Milliseconds() ๊ฐ’์„ Double๋กœ ๋ฐ›์•„ ์ง€๋‚œ ๋ฐ€๋ฆฌ์ดˆ๋ฅผ Double๋กœ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. 0..4294967295 ๋ฐ–์ด๋ฉด ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค. ์Œ์ˆ˜ ์ฐจ์ด์— 4294967296.0์„ ๋”ํ•ด ํ•œ ๋ฒˆ์˜ ์ˆœํ™˜๋งŒ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ์ธก์ •์€ ํ•œ ์ฃผ๊ธฐ๋ณด๋‹ค ์งง์•„์•ผ ํ•˜๋ฉฐ ํ•จ์ˆ˜ ์ž์ฒด๋Š” ๊ธฐ๋‹ค๋ฆฌ์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

validate start -> now - start -> if negative add one wrap -> Double

ํ”„๋กœ์ ํŠธ ์†Œ์Šค: src/ClassicUO.Client/Scripts/Include/Windows.bas; ํ•จ์ˆ˜ ElapsedMilliseconds.

3. ScreenWidth / ScreenHeight / DesktopBounds

DesktopBounds()๋Š” ๋ฌธ์ž์—ด ํ‚ค X, Y, Width, Height์™€ Integer ๊ฐ’์„ ๊ฐ€์ง„ ์ƒˆ Dictionary๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. Item("X") ๋“ฑ์œผ๋กœ ์ฝ์Šต๋‹ˆ๋‹ค. ๋ฉ”ํŠธ๋ฆญ 76~79๋Š” ๋ชจ๋“  ๋ชจ๋‹ˆํ„ฐ๋ฅผ ๋‘˜๋Ÿฌ์‹ผ ์‚ฌ๊ฐํ˜•์ด๋ฉฐ X/Y๋Š” ์Œ์ˆ˜์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์‚ฌ์ „ ์ˆ˜์ •์€ ์ฐฝ์„ ์ด๋™ํ•˜๊ฑฐ๋‚˜ ํฌ๊ธฐ๋ฅผ ๋ฐ”๊พธ์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

metrics 0, 1: primary; 76, 77, 78, 79: desktop X, Y, Width, Height

ํ”„๋กœ์ ํŠธ ์†Œ์Šค: src/ClassicUO.Client/Scripts/Include/Windows.bas; ํ•จ์ˆ˜ ScreenWidth / ScreenHeight / DesktopBounds.

ID์™€ ํ™”๋ฉด ํฌ๊ธฐ๋Š” Integer ์ˆ˜๋Ÿ‰, ์‹œ๊ฐ„์€ Double ๋ฐ€๋ฆฌ์ดˆ๋กœ Boolean์ด ์•„๋‹™๋‹ˆ๋‹ค. DesktopBounds๋Š” Integer ๊ฐ’์„ ๊ฐ€์ง„ Object(Dictionary)์ž…๋‹ˆ๋‹ค. Include์™€ ์„ ์–ธ์—๋Š” ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ๊ฐ ์˜ˆ์ œ Main์€ ๋ฐ์ดํ„ฐ ๊ฒ€์‚ฌ ์„ฑ๊ณต ์‹œ 1/True, ์‹คํŒจ ์‹œ 0/False๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ฉฐ ๋ชจ๋“  ๋„ค์ดํ‹ฐ๋ธŒ ์ˆซ์ž๊ฐ€ ์„ฑ๊ณต ํ”Œ๋ž˜๊ทธ๋ผ๋Š” ๋œป์€ ์•„๋‹™๋‹ˆ๋‹ค.


en ยท ru ยท uk ยท fr ยท de ยท it ยท es ยท zh-tw ยท ja ยท ko

Basic