I've almost finished a screen jiggling app, to prevent managers from having their laptops lock when they're waffling for too long in a presentation, but have been thrown a spanner by the guy writing the app's spec.
Currently, I grab the active processes, and check against a list of apps which can ignore the lock out period in our group policy, e.g. WebEx and PowerPoint, and identify if they're the active window, but I can't work out how to tell if they're maximised.
(We're being as specific as we can to stop people working out certain apps will stop their laptops from locking if running in the background)
This app will primarily be used on Windows XP machines, but will need to run in Windows 7 eventually.
The code I'm using to pick up the window details is attached, and taken from
Is there a simple way to check if the active window is maximised, rather than just normal?
(I've tried isiconic but that didn't differentiate between normal and maxismised)
Private Function checkAppInFocus(ByVal curproc As String)
Dim activeExempt As Boolean = False
Dim hWnd As IntPtr = GetForegroundWindow()
If hWnd <> IntPtr.Zero Then
'—– Find the Length of the Window’s Title —–
Dim TitleLength As Integer
TitleLength = GetWindowTextLength(hWnd)
'—– Find the Window’s Title —–
Dim WindowTitle As String = StrDup(TitleLength + 1, "*")
GetWindowText(hWnd, WindowTitle, TitleLength + 1)
'—– Find the PID of the Application that Owns the Window —–
Dim pid As Integer = 0
If pid = 0 Then Exit Function
'—– Get the actual PROCESS from the process ID —–
Dim proc As Process = Process.GetProcessById(pid)
If proc Is Nothing Then Exit Function
If curproc = proc.ProcessName Then activeExempt = True