May 14, 2024, 03:18:49 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


AlphaXWin.. Alphablending windows you do not own.

Started by WayneA, July 10, 2010, 11:30:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

WayneA

/* Requires Windows 2000 or later; Win9x/ME: Not supported
Select a window you want to alphablend, click okay and use the slider to set the opaque-ness-ity...
If its at -1 then itll remove the alphablend. Remember that even alphablended windows fully opaque (255)
will draw slower and use more processing power, so if you are done dilly dallying with this useless app, turn it off! (set to -1)
This is actually just to show that you can alphablend windows you don't own without any special tricks.
*/
$Include "windows.inc"
$Define WS_EX_LAYERED 0x80000
Declare Import,SetLayeredWindowAttributes(hWnd As UInt,crKey As Int,bAlpha As Char,dwFlags As UInt),Int
AutoDefine "Off"
Dim wndMain As Window
Dim dlgOpenWindow As Dialog
Dim hWnd As UInt
OpenWindow wndMain,0,0,300,90,@MinBox,0,"AlphaXWin",&wndMainProc
SetWindowColor wndMain,_GetSysColor(15)
CreateDialog dlgOpenWindow,0,0,400,450,@SysMenu|@Caption,0,"Open Window",&dlgOpenWndProc
Control dlgOpenWindow,@ListView,"",10,10,375,400,@LVSReport|@LVSSingleSel|@Border|@TabStop,1
Control dlgOpenWindow,@Button,"Okay!",175,415,50,30,@CTLBTNDefault|@TabStop,2
hWnd=DoModal(dlgOpenWindow,wndMain)
If hWnd=@IDCancel Then CloseWindow wndMain
SetFocus wndMain,1
WaitUntil IsWindowClosed wndMain
End

Sub wndMainProc
Dim l,t,w,h As Int
Dim AlphaVal As Int
Select @Message
Case @IDCreate
CenterWindow wndMain
GetClientSize wndMain,l,t,w,h
TrackBarControl wndMain,10,10,w-20,h-20,@TBS_Both|@TBS_ToolTips,0,1
SetTrackBarRange wndMain,1,-1,255
SetTrackBarPosition wndMain,1,-1
SetControlColor wndMain,1,0,_GetSysColor(15)
Case @IDControl
If @ControlID=1 And hWnd Then
AlphaVal=GetTrackBarPosition(wndMain,1)
If AlphaVal>=0 Then
_SetWindowLong(hWnd,GWL_EXSTYLE,_GetWindowLong(hWnd,GWL_EXSTYLE)|WS_EX_LAYERED)
SetLayeredWindowAttributes(hWnd,0,AlphaVal,2)
Else
_SetWindowLong(hWnd,GWL_EXSTYLE,_GetWindowLong(hWnd,GWL_EXSTYLE)&Not(WS_EX_LAYERED))
EndIf
EndIf
Case @IDCloseWindow
CloseWindow wndMain
EndSelect
EndSub

Sub dlgOpenWndProc
Dim hWnd As String
Dim i,count As Int
Select @Message
Case @IDInitDialog
lvListWindows(dlgOpenWindow,1)
CenterWindow dlgOpenWindow
Case @IDControl
If @ControlID=2 And @NotifyCode=0 And ControlCMD(dlgOpenWindow,1,@LVGetSelCount) Then
count=ControlCMD(dlgOpenWindow,1,@LVGetCount)
For i=0 to count
If ControlCMD(dlgOpenWindow,1,@LVGetSelected,i) Then BreakFor
Next i
ControlCMD(dlgOpenWindow,1,@LVGetText,i,2,hWnd)
SetCaption wndMain,"hWnd: "+Hex$(Val(hWnd))
CloseDialog dlgOpenWindow,Val(hWnd)
EndIf
Case @IDCloseWindow
CloseDialog dlgOpenWindow,@IDCancel
EndSelect
EndSub

Sub lvListWindows(parent As Window,cid As Int)
Dim hWnd As UInt
Dim handle,title="" As String
Dim l,t,w,h As Int
GetSize parent,l,t,w,h,cid
ControlCMD parent,cid,@LVInsertColumn,0,"Title"
ControlCMD parent,cid,@LVInsertColumn,1,"Handle"
ControlCMD parent,cid,@LVInsertColumn,2,""
ControlCMD parent,cid,@LVSetColWidth,0,w-w/4-_GetSystemMetrics(SM_CXBORDER)*4 'This is  just a tweaked number. I think its like
ControlCMD parent,cid,@LVSetColWidth,1,w/4-_GetSystemMetrics(SM_CXVSCROLL) 'The border of the control,scrollbar and 2 of the
ControlCMD parent,cid,@LVSetColWidth,2,0 'header bars borders as well. It should work reliably
hWnd=_GetWindow(_GetForegroundWindow(),GW_HWNDFIRST) 'Even if I can't exactly explain it ;)
While hWnd
_GetWindowText(hWnd,title,254)
If title<>"" Then
handle=Hex$(hWnd):handle=String$(8-Len(handle),"0")+handle
ControlCMD parent,cid,@LVInsertItem,0,title
ControlCMD parent,cid,@LVSetText,0,1,handle 'This is the pretty hex hwnd
ControlCMD parent,cid,@LVSetText,0,2,Str$(hWnd) 'This is a secret field storing a usable decimal version of the hwnd
EndIf
hWnd=_GetWindow(hWnd,GW_HWNDNEXT)
WEnd
EndSub
99 little bugs in the code,
99 bugs in the code,
Fix one bug,
Compile again,
104 little bugs in the code...

All code I post is in the public domain.

ZeroDog

World's Greatest Secrets Exposed!

QuoteThis is a secret field storing a usable decimal version of the hwnd

With the magic of Ctrl + Shift + NumpadPlus the secret field is revealed!  ;D



Fun bit of code, thanks for sharing  :)