- This topic has 0 replies, 1 voice, and was last updated 18 years ago by method.
-
AuthorPosts
-
May 24, 2006 at 8:00 pm #188849methodMember
Hi i am using this code to try to load first fav room item from fav window outside the room but it does not work. could any one help me fix this .Thanks
Private Declare Function GetMenu Lib “user32” (ByVal hwnd As Long) As Long
Private Declare Function GetSubMenu Lib “user32” (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function FindWindow Lib “user32” Alias “FindWindowA” (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetMenuItemID& Lib “user32” (ByVal hMenu As Long, ByVal nPos _
As Long)
Private Declare Function FindWindowEx Lib “user32” Alias “FindWindowExA” _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal _
lpsz2 As String) As Long
Private Declare Function GetWindowText Lib “user32” Alias “GetWindowTextA” (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function SendMessage Lib “user32” Alias “SendMessageA” (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function PostMessage Lib “user32” Alias “PostMessageA” (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const WM_COMMAND = &H111
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Const WM_SETTEXT = &HCPrivate Sub Command1_Click()
Dim hMenu As Long, hSubMenu As Long
‘get the handle of the current menu
Dim ptwnd As Long
ptwnd = FindWindow(“SEINFELD_SUPERMAN”, vbNullString)
hMenu = GetMenu(ptwnd)
‘get the handle of the first submenu
hSubMenu = GetSubMenu(hMenu, 3)
‘initialize the structure
ItemID = GetMenuItemID(hSubMenu, 1)
PostMessage ptwnd, WM_COMMAND, ItemID, 0End Sub
Public Function WindowText(window_hwnd As Long) As String
Dim txtlen As Long
Dim txt As StringWindowText = “”
If window_hwnd = 0 Then Exit Functiontxtlen = SendMessage(window_hwnd, WM_GETTEXTLENGTH, 0, 0)
If txtlen = 0 Then Exit Functiontxtlen = txtlen + 1
txt = Space$(txtlen)
txtlen = SendMessage(window_hwnd, WM_GETTEXT, txtlen, ByVal txt)
WindowText = Left$(txt, txtlen)
End Function -
AuthorPosts
Related
- You must be logged in to reply to this topic.