Sign in to follow this  
Followers 0
OliverA

Trasparency Problems

16 posts in this topic

Hi to all the member of Autoit Community :D

I have searched around the forum but i don't have found a solution

I want to add to every active windows a trasparency, but not to all the windows but only a specific region

For now i have make this:

#include <GuiconstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
 
HotKeySet("{ESC}", "On_Exit")
 
;~ Local $GUI = WinGetHandle("[ACTIVE]", "")
Local $GUI = GUICreate("trans", 300, 400, -1, -1, -1, $WS_EX_LAYERED)
_WinAPI_SetLayeredWindowAttributes($GUI, 0x010101, 150)
GUISetState()
 
While 1
 Switch GUIGetMsg()
  Case $GUI_EVENT_CLOSE
   ExitLoop
 EndSwitch
WEnd
 
Func On_Exit()
 Exit
EndFunc   ;==>On_Exit

work for the GUI but not for the active external windows.

Some help?

Thanks


I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites



Do you mean something like that here? http://www.autoitscript.com/forum/index.php?showtopic=93706

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

I can't test that script, i see only strange character.

As i have say before i want to edit the trasparency of a window (ex. a folder ) but with a zone not-trasparent.

Thanks


I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

Indeed, the code box is broken!

Here the code from that link:

;http://www.autoitscript.com/forum/index.php?showtopic=93706
;===============================================================================
;
; Function Name:
;                  _DrawTransparentEllipse
; Description::    Let you draw a transparent Ellipse
; Parameter(s):
;                  $hwnd - Handle of GUI to work on
;                  $x - Postion x of the Ellipse
;                  $y - Postion y of the Ellipse
;                  $w - Width of the Ellipse
;                  $h - Height of the Ellipse, If w=h it will be a circle.
;                  $Transparency - Set Transparancy of GUI ( optional )
;                  $EllipseBorderColor - A Border Color if you want =) ( optional )
; Requirement(s):  Layered Windows
; Return Value(s): ControlID of the Form
; Author(s):       Greek, martin
; Example :        Yes
;===============================================================================

;===============================================================================
;
; Function Name:   
;                  _DrawTransparentRect
; Description::    Let you draw a transparent Rect
; Parameter(s):
;                  $hwnd - Handle of GUI to work on
;                  $x - Postion x of the Rect
;                  $y - Postion y of the Rect
;                  $w - Width of the Rect
;                  $h - Height of the Rect, If w=h it will be a square.
;                  $Transparency - Set Transparancy of GUI ( optional )
;                  $RectBorderColor - A Border Color if you want =) ( optional )
; Requirement(s):  Layered Windows
; Return Value(s): ControlID of the Form
; Author(s):       Greek, martin
; Example :        Yes
;===============================================================================

;===============================================================================
;
; Function Name:   _DrawTransparentLine
; Description::    Let you draw a transparent Line
; Parameter(s):
;                  $hwnd - Handle of GUI to work on
;                  $x - Postion x of the Line
;                  $y - Postion x of the Line
;                  $length - Postion x of the Line
;                  $course - Postion x of the Line
;                  $pensize - The pensize, default is 2 ( optional )
;                  $Transparency - Set Transparancy of GUI ( optional )
; Requirement(s):  Layered Windows
; Return Value(s): ControlID of the Form
; Author(s):       Greek, martin
; Example :        Yes
;===============================================================================

;===============================================================================
;
; Function Name:   _DeletTransparentForm
; Description::    Delet the Form
; Parameter(s):
;                  $Form - controlID of the Form
; Return Value(s): Success: Returns 1.
;                  Failure: Returns 0.
; Author(s):       Greek, martin
;===============================================================================

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$gui=GUICreate ( "Transparent Ellipse and Rect", 420, 500, @DesktopWidth/2-300, @DesktopHeight/2-300, $WS_POPUP, $WS_EX_LAYERED )
GUISetBkColor ( 0x000000 )
GUICtrlCreateLabel("", 0, 0, 420, 500, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState ()

_DrawTransparentLine ( $gui, 50, 400, 300, 0)
_DrawTransparentEllipse ( $gui, 20, 20, 150, 100 )
_DrawTransparentEllipse ( $gui, 250, 20, 150, 100, 255, 0xFF0000 )
_DrawTransparentRect ( $gui, 20, 200, 150, 150 )
_DrawTransparentRect ( $gui, 250, 200, 150, 150, 255, 0x0000FF )


While 1
    $msg=GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd


Func _DeletTransparentForm ( $Form )
    $a=GUICtrlDelete ( $Form )
    Return $a
EndFunc

Func _DrawTransparentLine($hwnd, $X,$Y,$length,$course,$pensize=2,$Transparency=255)
     _WinAPI_SetLayeredWindowAttributes($hwnd, 0xABCDEF, $Transparency)
    $g1=GUICtrlCreateGraphic($X,$Y,0,0)
    GUICtrlSetGraphic($g1, $GUI_GR_PENSIZE, $pensize )
    GUICtrlSetGraphic($g1, $GUI_GR_COLOR,0xABCDEF, 0xABCDEF)
    GUICtrlSetGraphic($g1, $GUI_GR_LINE, $length, $course)
    GUICtrlSetGraphic($g1, $GUI_GR_REFRESH)
    GUICtrlSetGraphic($g1, $GUI_GR_LINE, 1, 1)
    Return $g1
EndFunc

Func _DrawTransparentRect($hwnd, $x,$y,$w,$h,$Transparency=255, $RectBorderColor=0xABCDEF)
     _WinAPI_SetLayeredWindowAttributes($hwnd, 0xABCDEF, $Transparency)
    $g1=GUICtrlCreateGraphic(0,0,0,0)
    GUICtrlSetGraphic($g1, $GUI_GR_COLOR,$RectBorderColor, 0xABCDEF)
    GUICtrlSetGraphic($g1, $GUI_GR_RECT, $x, $y, $w, $h)
    GUICtrlSetGraphic($g1, $GUI_GR_REFRESH)
    GUICtrlSetGraphic($g1, $GUI_GR_LINE, 1, 1)
    Return $g1
EndFunc

Func _DrawTransparentEllipse($hwnd, $x,$y,$w,$h,$Transparency=255,$EllipseBorderColor=0xABCDEF)
     _WinAPI_SetLayeredWindowAttributes($hwnd, 0xABCDEF, $Transparency)
    $g1=GUICtrlCreateGraphic(0,0,0,0)
    GUICtrlSetGraphic($g1, $GUI_GR_COLOR,$EllipseBorderColor, 0xABCDEF)
    GUICtrlSetGraphic($g1, $GUI_GR_ELLIPSE, $x, $y, $w, $h)
    GUICtrlSetGraphic($g1, $GUI_GR_REFRESH)
    GUICtrlSetGraphic($g1, $GUI_GR_LINE, 1, 1)
    Return $g1
EndFunc

Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
  ; progandy
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03
    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, _WinAPI_GetLastError(), 0)
        Case Else
            Return 1
    EndSelect
EndFunc ;==>_WinAPI_SetLayeredWindowAttributes

Func _WinAPI_GetLastError()
    Local $aResult

    $aResult = DllCall("Kernel32.dll", "int", "GetLastError")
    If @error Then Return SetError(@error, 0, 0)
    Return $aResult[0]
EndFunc   ;==>_WinAPI_GetLastError

Br,

UEZ

2 people like this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Yeah, a sort of.

Maybe it's better to post an image of the result i want to do:

Posted Image

I don't know if the image is clear:

The center of the notepad is visible to 100%

The border of the notepad has a trasparency

So how to apply the trasparency to a notepad, but not total, only the border?

Thanks for your help UEZ ;)


I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

bump, still unsolved.

Thanks for any type of help


I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

Bump again, noone knows how to do

With WinSetTrans i can add trasparency to a window, but i can't define a region. I'm sure it is possible with _WinAPI_ but my script always fail

Please some help :D


I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

Post what code you have until now


I feel nothing.It feels great.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

You can see on first post. _WinAPI work with the autoit GUI, but if i load the handle of the external window not work

From _WinAPI help i can load handle:

$hwnd = Handle of GUI to work on

I have try other method but is useless to post it, noone work so i'll make only confusion

Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

work for the GUI but not for the active external windows.

Some help?

For working of the external windows the exstyle should have $WS_EX_LAYERED which is not mandatory

you are only setting your GUI's exstyle..!


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

If i add the $WS_EX_LAYERED to the external windows with WinAPI or DLLCall i see the windows without the file bar ( i don't know what is the exatcly name of it ) and isn't trasparent, try by yourself

Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

Does this help

;The Following code was written by KaFu here - http://www.autoitscript.com/forum/topic/147185-windows-desktop-dimmer-shade/#entry1043453
; Modified by PhoenixXL

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Array.au3>

Global $bHKPressed = False
Local $hWin

While Not ProcessExists('notepad.exe')
Run('notepad.exe')
WEnd

WinWait('[CLASS:Notepad]')

$hWin = WinGetHandle("[CLASS:Notepad]")
If Not IsHWnd($hWin) Then Exit -1
$aPos = WinGetPos($hWin)

$hGUI = GUICreate("Test", $aPos[2], $aPos[3], $aPos[0], $aPos[1], $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TRANSPARENT))
WinSetTrans($hGUI, "", 210)
WinSetOnTop($hGUI, "", 1)
GUISetBkColor(0x808080)
If @error Then Exit -2
_MakeClientHole($hGUI, $hWin)
WinSetState($hGUI, "", @SW_SHOWNOACTIVATE)

HotKeySet("!q", "_HotKeyPressed")

Local $msg, $hLastActiveWin, $aPos, $aLastPos

While 1
$msg = GUIGetMsg()
If ($msg = -3 Or $bHKPressed) Then
ExitLoop
EndIf
Sleep(10)
WEnd

Func _GuiHole($h_win, $i_x, $i_y, $i_sizew, $i_sizeh)
Dim $pos, $outer_rgn, $inner_rgn, $wh, $combined_rgn
$pos = WinGetPos($h_win)
$outer_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", $pos[2], "long", $pos[3])
$inner_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $i_x, "long", $i_y, "long", $i_x + $i_sizew, "long", $i_y + $i_sizeh)
$combined_rgn = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
DllCall("gdi32.dll", "long", "CombineRgn", "long", $combined_rgn[0], "long", $outer_rgn[0], "long", $inner_rgn[0], "int", $RGN_DIFF)
DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $combined_rgn[0], "int", 1)
EndFunc   ;==>_GuiHole

Func _HotKeyPressed()
$bHKPressed = True
EndFunc   ;==>_HotKeyPressed

Func _MakeClientHole($hMain, $hExtWin)
;===Get the Screen coordinates of the External Window==========================
Local $tRect = _WinAPI_GetClientRect($hExtWin)
Local $cPos[4]
For $i = 0 To 1
$cPos[$i] = DllStructGetData($tRect, $i + 1)
Next
Local $tPoint = DllStructCreate($tagPoint)
;~  For $i = 0 To 2 Step 2
DllStructSetData($tPoint, 1, $cPos[ 0 ])
DllStructSetData($tPoint, 2, $cPos[ 1 ])
$tPoint =  _WinAPI_ClientToScreen($hExtWin, $tPoint)
_WinAPI_ScreenToClient( $hMain, $tPoint )
$cPos[ 0  ] = DllStructGetData($tPoint, 1)
$cPos[ 1  ] = DllStructGetData($tPoint, 2)
;~  _ArrayDisplay($cPos)
;~  Next
;==============================================================================
Return _GuiHole($hMain, $cPos[0], $cPos[1], DllStructGetData($tRect, 3), DllStructGetData($tRect, 4))
EndFunc   ;==>_MakeClientHole


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Simultaneously you cannot set the transparency of any Child control ( win) using SetLayeredWindowsAttributes

the window has to be a Top-Level window. The following script sets windowslayeredattributes if you replace the $hWin with $hCtl you will get a Invalid parameter (87) error code

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Constants.au3>
#include <Array.au3>

Global $bHKPressed = False
Local $hWin

While Not ProcessExists('notepad.exe')
Run('notepad.exe')
WEnd

WinWait('[CLASS:Notepad]')

$hWin = WinGetHandle("[CLASS:Notepad]")
If Not IsHWnd($hWin) Then Exit -1
$aPos = WinGetPos($hWin)
$hCtl = ControlGetHandle( $hWin, '', '[CLASS:Edit; INSTANCE:1]')

_WinAPI_SetWindowLong( $hWin, $GWL_EXSTYLE,BitOR( $WS_EX_LAYERED, _WinAPI_GetWindowLong( $hWin, $GWL_EXSTYLE ) ) )
If @error Then Exit -1

If Not _WinAPI_SetLayeredWindowAttributes( $hWin, 0x0, 150 ) Then Exit MsgBox( 0, @extended & '-' & @error, _WinAPI_GetLastError() ) <> 0

HotKeySet("!q", "_HotKeyPressed")

While Not $bHKPressed
Sleep(20)
WEnd

Func _HotKeyPressed()
$bHKPressed = True
EndFunc   ;==>_HotKeyPressed
Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

In the second script i can see finally a trasparency to an external window, thanks :D

About the child control, it's not essential if I can choose a portion to apply the transparency, or isn't possible?


I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

you cannot set the transparency of a part of the window,

it has to be the full top-level window


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

I mean something like _GuiHole, but if you say isn't possible...isn't possible :D


I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0