hitechoutlaw Posted March 27, 2003 Posted March 27, 2003 is there a way to run through the processes every so often and check to see if a program has been minimized and if it is then maximize it? if so, how? i was thinking along the lines of: Dim processes(), p As Process processes = Process.GetProcesses() For Each p In processes If Not (p.MainModule Is Nothing) Then If System.IO.Path.GetFileName(p.MainModule.FileName).ToLower() = "game.exe" Then [i](sumthang)[/i] End If End If Next Quote
*Gurus* Derek Stone Posted March 28, 2003 *Gurus* Posted March 28, 2003 The window's style will have WS_MINIMIZE style applied to it if the window is minimized. Use the Win32 API function [api]GetWindowLong[/api] to determine if this style is present. Const GWL_STYLE As Integer = (-16) Const WS_MINIMIZE As Integer = &H20000000 Dim pStyle As IntPtr = GetWindowLong(p.MainWindowHandle, GWL_STYLE) If (pStyle And WS_MINIMIZE) <> False Then 'Window is minimized End If You'll need to declare GetWindowLong of course. Quote Posting Guidelines
hitechoutlaw Posted March 28, 2003 Author Posted March 28, 2003 if i'm not mastaken (which i might be) that will only work on the app its run in, i want it to check to see if an app is being run and if it is, then if it is minimized or not. thats why i was looking through the processes for "game.exe" what do u or anyone else think? Quote
*Gurus* Derek Stone Posted March 28, 2003 *Gurus* Posted March 28, 2003 I think that code works. Try it. *nudge* Quote Posting Guidelines
hitechoutlaw Posted March 28, 2003 Author Posted March 28, 2003 i get two error messages and have no clue where to take it from here Name 'p' is not declared & Operator 'And' is not defined for types 'System.IntPtr' and 'Integer'. Quote
*Gurus* Derek Stone Posted March 28, 2003 *Gurus* Posted March 28, 2003 You declared "p" in your code... which is why I used it. :rolleyes: Change the IntPtr to an Integer, for sake of simplicity. Quote Posting Guidelines
hitechoutlaw Posted March 28, 2003 Author Posted March 28, 2003 thanks for ur help now if gives me an error: Value of 'System.IntPtr' cannot be converted into long. i know some people on the internet would give up after the first answer, this form has the nicest people u can find on the net, i'm glad i found it. thanks Quote
*Gurus* Derek Stone Posted March 28, 2003 *Gurus* Posted March 28, 2003 Change the "Long" value types in the GetWindowLong declaration to "Integer". Long's in Visual Basic .NET are 64-bit, while in Visual Basic 6 they were 32-bit. This makes a huge difference when calling a Win32 API function. Quote Posting Guidelines
hitechoutlaw Posted March 28, 2003 Author Posted March 28, 2003 my program brings up an exception that has never come up before: --------------------------------------------- An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in system.dll Additional information: Access is denied --------------------------------------------- at this line: If Not (p.MainModule Is Nothing) Then it has always worked before in other programs but now it wont work in any of my programs. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.