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:
Const MF_GRAYED = &H1 Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Integer) As Integer Private Declare Function GetForegroundWindow Lib "user32" () As Integer Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Integer) As Integer Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Public Declare Function GetMenu Lib "user32" Alias "GetMenu" (ByVal hwnd As Integer) As Integer Public Declare Function GetSubMenu Lib "user32" Alias "GetSubMenu" (ByVal hMenu As Integer, ByVal nPos As Integer) As Integer Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Integer, ByVal nPos As Integer) As Integer Public Declare Function GetMenuState Lib "user32" Alias "GetMenuState" (ByVal hMenu As Integer, ByVal wID As Integer, ByVal wFlags As Integer) As Integer
VB Code:
On Error Resume Next Dim count as integer = 0 Dim SomeLimit as integer = [COLOR=Lime]YourLimit[/COLOR] exeAppTitle.PriorityClass = ProcessPriorityClass.Normal ForeGroundWindow = GetForegroundWindow BlockInput(True) Do SetForegroundWindow(FindWindow(Nothing, "[COLOR=Lime]AppTitle[/COLOR]")) If GetForegroundWindow = FindWindow(Nothing, "[COLOR=Lime]AppTitle[/COLOR]") Then SendKeys.Send("{F10}f") Exit Do End If count += 1 If count > [COLOR=Orange]Some Limit[/COLOR] then Exit Do End if Loop BlockInput(False) SetForegroundWindow(ForeGroundWindow) Dim hWnd As Integer = FindWindow(Nothing, "[COLOR=Lime]AppTitle[/COLOR]") Dim hMenu As Integer = GetMenu(hWnd) Dim hSubMenu As Integer = GetSubMenu(hMenu, [COLOR=Lime]0[/COLOR]) Dim hId As Integer = GetMenuItemID(hSubMenu, [COLOR=Lime]2[/COLOR]) exeAppTitle.PriorityClass = ProcessPriorityClass.Idle If GetMenuState(hMenu, hId, MF_GRAYED Then MessageBox.Show("menu disabled") Else MessageBox.Show("menu enabled") End If




Reply With Quote