arion
arion
CC#
Created by arion on 7/9/2023 in #help
❔ TrayIcon Context Menu
Regarding the System Tray Overflow Menu, what determines if the menu stays open or closes shortly after? I have checked to see if its Window Focus, for all actions the focus is shifted to the window of the tray icon. Window Messages? In the example video 2/3 examples use a custom window to render their context menu, one works, the other doesn't (Riot Client works, Battle.net doesn't) I couldn't find if anyone else has had this problem or looked into it before but I would like to know how to keep that overflow menu open while your window is rendered to prevent the Steam window from the example closing the overflow menu prematurely (while the window is still active) tl;dr I would like to know what (low level or high level) causes the Riot Client window to keep the overflow menu active and not the Steam window
2 replies
CC#
Created by arion on 11/20/2022 in #help
❔ How can I get the Visual Tree root of a Xaml process?
Visual Studio has a "Live Visual Tree" feature that allows you to see the visual tree of a process (native or managed) Examples of this working is Windows Terminal (C# mainly) and Windows Explorer https://cdn.discordapp.com/attachments/883435300880261120/1043756088677371975/81041c55-7889-48d1-ac78-bf130172f7a8_20-11-2022.png Can I get some pointers on where to start on manipulating other processes' xaml objects?
2 replies
CC#
Created by arion on 10/28/2022 in #help
FindWindow by lpClassName. Is there an event based alternative to polling?
The code summarises the issue pretty well:
private static async Task InitializePollingLoop()
{
while (true)
{
await Task.Delay(100);

var hWnd = User32.FindWindow("Xaml_WindowedPopupClass", null);

if (hWnd == IntPtr.Zero) continue;

Console.WriteLine("Found a window at {0}", hWnd);

var style = User32.GetWindowLong(hWnd, User32.WindowLongIndexFlags.GWL_EXSTYLE);
style |= (int)User32.SetWindowLongFlags.WS_EX_TRANSPARENT | (int)User32.SetWindowLongFlags.WS_EX_LAYERED;
var retVal = User32.SetWindowLong(hWnd, User32.WindowLongIndexFlags.GWL_EXSTYLE, (User32.SetWindowLongFlags)style);
if (retVal == 0)
{
var error = Marshal.GetLastWin32Error();
Console.WriteLine("Error setting window style: {0}", new Win32Exception(error));
}

}
}
private static async Task InitializePollingLoop()
{
while (true)
{
await Task.Delay(100);

var hWnd = User32.FindWindow("Xaml_WindowedPopupClass", null);

if (hWnd == IntPtr.Zero) continue;

Console.WriteLine("Found a window at {0}", hWnd);

var style = User32.GetWindowLong(hWnd, User32.WindowLongIndexFlags.GWL_EXSTYLE);
style |= (int)User32.SetWindowLongFlags.WS_EX_TRANSPARENT | (int)User32.SetWindowLongFlags.WS_EX_LAYERED;
var retVal = User32.SetWindowLong(hWnd, User32.WindowLongIndexFlags.GWL_EXSTYLE, (User32.SetWindowLongFlags)style);
if (retVal == 0)
{
var error = Marshal.GetLastWin32Error();
Console.WriteLine("Error setting window style: {0}", new Win32Exception(error));
}

}
}
User32 comes from the Nuget package "PInvoke.User32" Setting the window requires administrator or you will get a Win32Error on 'retVal', the code addresses an issue on Windows11 My question is, is there some sort of Event based alternative to polling to find that window handle? The main focus of the question is the first 3 lines of actual code:
await Task.Delay(100);

var hWnd = User32.FindWindow("Xaml_WindowedPopupClass", null);

if (hWnd == IntPtr.Zero) continue;
await Task.Delay(100);

var hWnd = User32.FindWindow("Xaml_WindowedPopupClass", null);

if (hWnd == IntPtr.Zero) continue;
2 replies