VB.NETダウンロードしてみた・・・

ソフトウェア開発ツールが無料な時代・・・

M$ソフトも無料にした模様だ

で、Microsoft Visual Basic 2005 Express Editionなるものをダウンロードして

インストールしてみたが、ヽ(`Д´)ノウワーン

よくわかんねぇ。

おまけに動作が重いヨ

まぁ、ちょっと昔Delphiで書いたコード移植してみた

仮想世界であるUltimaOnlineのツールでも誰か作ってくださいw(って、おれか!!)

UOHelperクラス
[vbnet]
Module Win32API
Public Const WM_IME_CHAR = &H286
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_USER = &H400
Public Const VK_RETURN = 13
Public Const VK_SHIFT = 16
Public Const VK_CONTROL = 17
Public Const VK_MENU = 18
Public Const KEYEVENTF_KEYUP = 2
Public Const HWND_NOTOPMOST = -2
Public Const HWND_TOPMOST = -1
Public Const HWND_TOP = 0
Public Const HWND_BOTTOM = 1
Public Const SWP_ASYNCWINDOWPOS = &H4000
Public Const SWP_DEFERERASE = &H2000
Public Const SWP_DRAWFRAME = &H20
Public Const SWP_FRAMECHANGED = SWP_DRAWFRAME
Public Const SWP_HIDEWINDOW = &H80
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_NOCOPYBITS = &H100
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOOWNERZORDER = &H200
Public Const SWP_NOREDRAW = &H8
Public Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
Public Const SWP_NOSENDCHANGING = &H400
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOZODER = &H4
Public Const SWP_SHOWWINDOW = &H40
_
Public Function FindWindow( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) As Integer
End Function
_
Public Function PostMessage( _
ByVal hwd As Integer, _
ByVal Msg As Integer, _
ByVal wpara As Integer, _
ByVal lpara As Integer _
) As Integer
End Function
_
Public Sub keybd_event( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Integer, _
ByVal dwExtraInfo As Integer _
)
End Sub
_
Public Function SetForegroundWindow( _
ByVal hWnd As Integer _
) As Integer
End Function
_
Public Function SetWindowPos( _
ByVal hWnd As Integer, _
ByVal hWndInertAfter As Integer, _
ByVal x As Integer, _
ByVal y As Integer, _
ByVal cx As Integer, _
ByVal cy As Integer, _
ByVal uFlags As Integer _
) As Integer
End Function
_
Public Function GlobalGetAtomName( _
ByVal nAtom As Short, _
ByVal lpBuffer As String, _
ByVal nSize As Integer _
) As Short
End Function
_
Public Function GlobalDeleteAtom( _
ByVal nAtom As Short _
) As Short
End Function
_
Public Function SendMessage( _
ByVal hWnd As Integer, _
ByVal MSG As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer _
) As Integer
End Function
End Module
Public Class UOHelper
Private sSayMode() As String = New String() {“”, “! “, “; “, “: “, “\”, “/”}
Private bStayOnTop As Boolean = False
Private hWndOwn As Integer = 0
Private Sub doStayOnTop()
If hWndOwn <> 0 Then
SetWindowPos(hWndOwn, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE)
End If
End Sub
Private Sub dontStayOnTop()
If hWndOwn <> 0 Then
SetWindowPos(hWndOwn, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE)
End If
End Sub
Public Enum UOSayTypeConstants As Integer
NORMAL = 0
YELL = 1
WHISPER = 2
EMOTE = 3
GUILD = 4
PARTY = 5
End Enum
Public Property StayOnTop() As Boolean
Get
Return StayOnTop
End Get
Set(ByVal value As Boolean)
bStayOnTop = value
If bStayOnTop Then
doStayOnTop()
Else
dontStayOnTop()
End If
End Set
End Property
Public Function Say(ByVal prmsMessage As String, Optional ByVal prmnMode As UOSayTypeConstants = UOSayTypeConstants.GUILD) As Boolean
Say = False
Dim sMessageString As String = prmsMessage
sMessageString = sSayMode(prmnMode) + sMessageString
Dim saMessageBuffer() As Char
saMessageBuffer = sMessageString.ToCharArray
Dim hWndUO As Integer = FindWindow(“Ultima Online”, vbNullString)
If hWndUO <> 0 Then
Dim nLoop As Integer
For nLoop = 0 To sMessageString.Length – 1
PostMessage(hWndUO, WM_IME_CHAR, Asc(saMessageBuffer(nLoop)), 1)
Next
PostMessage(hWndUO, WM_KEYDOWN, VK_RETURN, 1)
PostMessage(hWndUO, WM_KEYUP, VK_RETURN, 1 Or &HC0000000)
Say = True
End If
If bStayOnTop Then
doStayOnTop()
Else
dontStayOnTop()
End If
End Function
Public Sub New(Optional ByVal hWnd As Integer = 0)
hWndOwn = hWnd
End Sub
Public Sub New(ByVal clsForm As System.Windows.Forms.Form)
hWndOwn = clsForm.Handle
End Sub
Public Function SendKey(ByVal ctrl As Integer, ByVal shift As Integer, ByVal alt As Integer, ByVal key As Byte) As Boolean
Dim hWndUO As Integer = FindWindow(“Ultima Online”, vbNullString)
SetForegroundWindow(hWndUO)
If ctrl = 1 Then
keybd_event(VK_CONTROL, 0, 0, 0)
End If
If shift = 1 Then
keybd_event(VK_SHIFT, 0, 0, 0)
End If
If alt = 1 Then
keybd_event(VK_MENU, 0, 0, 0)
End If
keybd_event(key, 0, 0, 0)
keybd_event(key, 0, KEYEVENTF_KEYUP, 0)
If ctrl = 1 Then
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)
End If
If shift = 1 Then
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0)
End If
If alt = 1 Then
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0)
End If
If bStayOnTop Then
doStayOnTop()
Else
dontStayOnTop()
End If
End Function
End Class
[/vbnet]

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です