'Pete's_Translucent_window_test-005.bas
'injected code from Pete_Ctrl+-008.bas NotePad example
z&=z&:hwnd%&=hwnd%&:title$=""
CONST HWND_TOPMOST%&
= -1 CONST SWP_SHOWWINDOW%&
= &H40
FUNCTION GetForegroundWindow&
'find currently focused process handle
' Needed for acquiring the hWnd of the window
'_TITLE "Translucent window test"
_TITLE "F1/F2 +/- opacity" ' alt 241 does not give CP437 +/-
dth = 355: hght = 20 ' was 300x400
' Set screen
' Main loop
Level = 40' was 175
SetWindowOpacity Myhwnd, Level 'when Level = bAlpha is 0 the window is completely transparent =255 opaque
'************************************************************88
'gosub MouseAround:
NotePad:
title$= "START NotePad.exe G:\a.txt" '*******************
system '*************************************************END OF PROGRAM
PRINT "_SCREENCLICK "; logger$
(i
);
", "; logger2$
(i
)
'====================================================================\
Ctrl_Plus:
SENDKEYS VK_CTRL, 0, 0, 0 ' Ctrl
'SENDKEYS &H2B, 0, 0, 0 ' + ' &hBB Virtual
'SENDKEYS &H2B, 0, KEYEVENTF_KEYUP, 0 ' Release + ' &hBB Virtual
SENDKEYS &HbB, 0, 0, 0 ' + ' &hBB Virtual
SENDKEYS &HbB, 0, KEYEVENTF_KEYUP, 0 ' Release + ' &hBB Virtual
SENDKEYS VK_CTRL, 0, KEYEVENTF_KEYUP, 0 ' Release Ctrl
_delay .2 '********************
MouseAround:
'DIM logger$(100), logger2$(100)
msg = GetCursorPos(Hold)
cnt = cnt + 1
'''logger$(cnt) = LTRIM$(STR$(Hold.X_Pos))
'''logger2$(cnt) = LTRIM$(STR$(Hold.Y_Pos))
flag = -1
IF GetAsyncKeyState
(&H1B) THEN EXIT DO 'ESC key exits loop and prints logged key presses oldimage& = s&
IF hght
<= 100 THEN hght
= 100 IF wdth
<= 150 THEN wdth
= 150 oldimage& = s&
IF b$
= CHR$(0) + CHR$(59) AND Level
< 255 THEN Level
= Level
+ 1: SetWindowOpacity Myhwnd
, Level
IF b$
= CHR$(0) + CHR$(60) AND Level
> 0 THEN Level
= Level
- 1: SetWindowOpacity Myhwnd
, Level
mystring$ = mystring$ + b$
CONST LWA_ALPHA
= &H2' use bAlpha to determine the opacity of the layered window CONST WS_EX_LAYERED
= &H80000 Msg = GetWindowLong(hwnd, G)
Msg
= Msg
OR WS_EX_LAYERED
action = SetWindowLong(hwnd, G, Msg)
action = SetLayeredWindowAttributes(hwnd, 0, Level, LWA_ALPHA)'(hwnd,colorref crkey,BYTE bAlpha,DWORD dwflags
'https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setlayeredwindowattributes
'when bAlpha is 0 , the window is completely transparent
'when bAlpha is 255, the window is opaque