I used GetWindowLong window api to get current window state of a window in c#.
[DllImport("user32.dll")]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);
Process[] processList = Process.GetProcesses();
foreach (Process theprocess in processList)
{
long windowState = GetWindowLong(theprocess.MainWindowHandle, GWL_STYLE);
MessageBox.Show(windowState.ToString());
}
I expected to get numbers on http://www.autohotkey.com/docs/misc/Styles.htm, but I get numbers like -482344960, -1803550644, and 382554704.
Do I need to convert windowState variable?? if so, to what?
What is weird about those values? For example, 482344960
is equivalent to 0x1CC00000
which looks like something you might expect to see as a window style. Looking at the styles reference you linked to, that is WS_VISIBLE | WS_CAPTION | 0xC000000
.
If you wanted to test for WS_VISIBLE
, for example, you would do something like:
int result = GetWindowLong(theprocess.MainWindowHandle, GWL_STYLE);
bool isVisible = ((result & WS_VISIBLE) != 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With