Results 1 to 8 of 8

Thread: RESOLVED Get menu disabled status

Threaded View

  1. #8

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Re: RESOLVED Get menu disabled status

    If anyone needs a workaround for the menu update problem, that some apps may have, try this basic idea:
    Insert a process component named exeAppTitle.
    Use the API GetForegroundWindow, BlockInput, and SetForegroundWindow.
    Declare an integer data type for the current ForeGroundWindow.

    VB Code:
    1. Const MF_GRAYED = &H1
    2. Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Integer) As Integer    
    3. Private Declare Function GetForegroundWindow Lib "user32" () As Integer  
    4. Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Integer) As Integer
    5. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer  
    6. Public Declare Function GetMenu Lib "user32" Alias "GetMenu" (ByVal hwnd As Integer) As Integer
    7. Public Declare Function GetSubMenu Lib "user32" Alias "GetSubMenu" (ByVal hMenu As Integer, ByVal nPos As Integer) As Integer
    8. Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Integer, ByVal nPos As Integer) As Integer
    9. Public Declare Function GetMenuState Lib "user32" Alias "GetMenuState" (ByVal hMenu As Integer, ByVal wID As Integer, ByVal wFlags As Integer) As Integer

    VB Code:
    1. On Error Resume Next
    2.         Dim count as integer = 0
    3.         Dim SomeLimit as integer = [COLOR=Lime]YourLimit[/COLOR]
    4.         exeAppTitle.PriorityClass = ProcessPriorityClass.Normal
    5.         ForeGroundWindow = GetForegroundWindow
    6.         BlockInput(True)
    7.         Do
    8.             SetForegroundWindow(FindWindow(Nothing, "[COLOR=Lime]AppTitle[/COLOR]"))
    9.             If GetForegroundWindow = FindWindow(Nothing, "[COLOR=Lime]AppTitle[/COLOR]") Then
    10.                 SendKeys.Send("{F10}f")
    11.                 Exit Do
    12.             End If
    13.             count += 1
    14.             If count > [COLOR=Orange]Some Limit[/COLOR] then
    15.                Exit Do
    16.             End if
    17.         Loop
    18.         BlockInput(False)
    19.         SetForegroundWindow(ForeGroundWindow)
    20.  
    21.  
    22.         Dim hWnd As Integer = FindWindow(Nothing, "[COLOR=Lime]AppTitle[/COLOR]")
    23.         Dim hMenu As Integer = GetMenu(hWnd)
    24.         Dim hSubMenu As Integer = GetSubMenu(hMenu, [COLOR=Lime]0[/COLOR])
    25.         Dim hId As Integer = GetMenuItemID(hSubMenu, [COLOR=Lime]2[/COLOR])
    26.         exeAppTitle.PriorityClass = ProcessPriorityClass.Idle
    27.  
    28.  
    29.         If GetMenuState(hMenu, hId, MF_GRAYED Then
    30.             MessageBox.Show("menu disabled")
    31.         Else
    32.             MessageBox.Show("menu enabled")
    33.         End If
    Last edited by TTn; Sep 7th, 2006 at 06:23 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width