Skip to content

problem selecting fav menu room item

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #188849
    method
    Member

    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 = &HC

    Private 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, 0

    End Sub
    Public Function WindowText(window_hwnd As Long) As String
    Dim txtlen As Long
    Dim txt As String

    WindowText = “”
    If window_hwnd = 0 Then Exit Function

    txtlen = SendMessage(window_hwnd, WM_GETTEXTLENGTH, 0, 0)
    If txtlen = 0 Then Exit Function

    txtlen = txtlen + 1
    txt = Space$(txtlen)
    txtlen = SendMessage(window_hwnd, WM_GETTEXT, txtlen, ByVal txt)
    WindowText = Left$(txt, txtlen)
    End Function

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.