What bone-head thing did I miss this time?
#8
Thumbs Up 
(10-29-2022, 01:28 AM)Spriggsy Wrote: This is a very dirty way of doing this but here, @Pete :

Code: (Select All)
Declare Dynamic Library "user32"
    Sub ShowWindow (ByVal hWnd As _Offset, Byval nCmdShow As Long)
End Declare

title$ = "Set Window Active Test"
_Title title$
_Delay .1

Do
    hwnd%& = _WindowHandle
Loop Until hwnd%&


Do
    _Limit 10
    If _WindowHasFocus = 0 Then
        _ScreenIcon
        ShowWindow hwnd%&, 1
    End If
    Print hwnd%&
    Sleep 4
    If Len(InKey$) Then End
Loop

Basically, I'm checking if the window has focus. If it doesn't, I'm forcing the focus back to the window by minimizing it with ScreenIcon and then maximizing it with ShowWindow. The stuff like SetActiveWindow, SetForegroundWindow, etc are all buggy as hell and don't work half the time and no one ever has a good explanation why. Hope this helps you at least a little, Pete.

This is pretty cool. I remember somewhere, sometime we discussed how to keep a Window on top but danged if I could find the code.

This works, is it the same thing?
b = b + ...
Reply


Messages In This Thread
RE: What bone-head thing did I miss this time? - by bplus - 10-29-2022, 01:56 AM



Users browsing this thread: 9 Guest(s)