Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
setting program to display always on top of other windows without having the focus?
#19
Maybe you can do something with these programs.
The first always keeps the window in the foreground and also gives it focus.
With the second you can make the window invisible.
You just have to think about how you can shoot it again if you can't see it.

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
    Cls
    Print hwnd%&
    Sleep 1
    If Len(InKey$) Then End
Loop


Code: (Select All)
Declare Dynamic Library "user32"
    Function SetLayeredWindowAttributes& (ByVal hwnd As Long, Byval crKey As Long, Byval bAlpha As _Unsigned _Byte, Byval dwFlags As Long)
    Function GetWindowLong& Alias "GetWindowLongA" (ByVal hwnd As Long, Byval nIndex As Long)
    Function SetWindowLong& Alias "SetWindowLongA" (ByVal hwnd As Long, Byval nIndex As Long, Byval dwNewLong As Long)
End Declare

' Needed for acquiring the hWnd of the window
Declare Library
    Function FindWindow& (ByVal ClassName As _Offset, WindowName$) ' To get hWnd handle
End Declare

MyHwnd = _WindowHandle 'FindWindow(0, "Translucent window test" + CHR$(0))
Level = 150 '0 TO 255
SetWindowOpacity MyHwnd, Level

Sub SetWindowOpacity (hWnd As Long, Level)
    Dim Msg As Long
    Const G = -20
    Const LWA_ALPHA = &H2
    Const WS_EX_LAYERED = &H80000

    Msg = GetWindowLong(hWnd, G)
    Msg = Msg Or WS_EX_LAYERED
    Crap = SetWindowLong(hWnd, G, Msg)
    Crap = SetLayeredWindowAttributes(hWnd, 0, Level, LWA_ALPHA)

End Sub

Reply


Messages In This Thread
RE: setting program to display always on top of other windows without having the focus? - by Steffan-68 - 05-21-2024, 06:54 PM



Users browsing this thread: 1 Guest(s)