Jump to content

Window Transparency


Green_Lantern
 Share

Recommended Posts

I just wanted to share an app I wrote. It allows you to adjust the transparency of visible windows.

#include <GUIConstants.au3>

GUICreate("iWindow", 220, 135, 0, 0, -1, $WS_EX_TOPMOST)
$repop = GUICtrlCreateButton("Repopulate List", 10, 10, 200, 20)
$winLabel = GUICtrlCreateLabel("Window:", 10, 40)
$win = GUICtrlCreateCombo("Select a Window Title", 10, 55, 200, 20)
$transLabel = GUICtrlCreateLabel("Visibility:", 10, 90)
$trans = GUICtrlCreateCombo("Select Visibility", 10, 105, 200, 20)
GUICtrlSetData(-1, "0%|5%|10%|15%|20%|25%|30%|35%|40%|45%|50%|55%|60%|65%|70%|75%|80%|85%|90%|95%|100%")
GUISetState()
repopList()

Func repopList()
      GUICtrlSetData($win, "|")
      $winList = WinList()
      For $i = 1 To $WinList[0][0]
    If $WinList[$i][0] <> "" And $WinList[$i][0] <> "Program Manager" And BitAND(WinGetState($WinList[$i][0]), 2) Then
          GUICtrlSetData($win, $WinList[$i][0])
    EndIf
      Next
      GUICtrlSetData($win, "Select a Window Title", "Select a Window Title")
EndFunc

Func setTrans()
      $perc = StringTrimRight($perc, 1)
      $transNum = $perc * 2.55
      WinSetTrans($winName,"",$transNum)
EndFunc

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
      $msg = GUIGetMsg()

      Select
    Case $msg = $repop
          GUICtrlSetData($trans, "Select Visibility")
          repopList()
    Case $msg = $trans
          $winName = GUICtrlRead($win)
          $perc = GUICtrlRead($trans)
          If $winName <> "Select a Window Title" Then
        setTrans()
          EndIf
      EndSelect
Wend
Edited by Green_Lantern
DreamHost: great web hosting for as little as $7.95 a month.
Link to comment
Share on other sites

modded to fix visibility back to 100% upon exit of the app.

#include <GUIConstants.au3>
If (Not IsDeclared('CB_GETCOUNT')) Then Global Const $CB_GETCOUNT = 0x146
If (Not IsDeclared('CB_SETCURSEL')) Then Global Const $CB_SETCURSEL = 0x14E
$perc = "100%" 
$winName = ""

GUICreate("iWindow", 220, 135, 0, 0, -1, $WS_EX_TOPMOST)
$repop = GUICtrlCreateButton("Repopulate List", 10, 10, 200, 20)
$winLabel = GUICtrlCreateLabel("Window:", 10, 40)
$win = GUICtrlCreateCombo("Select a Window Title", 10, 55, 200, 100)
$transLabel = GUICtrlCreateLabel("Visibility:", 10, 90)
$trans = GUICtrlCreateCombo("Select Visibility", 10, 105, 200, 100)
GUICtrlSetData(-1, "0%|5%|10%|15%|20%|25%|30%|35%|40%|45%|50%|55%|60%|65%|70%|75%|80%|85%|90%|95%|100%")
repopList()
GUISetState()

Func repopList()
    GUICtrlSetData($win, "|")
    $winList = WinList()
    For $i = 1 To $winList[0][0]
        If $winList[$i][0] <> "" And $winList[$i][0] <> "Program Manager"  And BitAND(WinGetState($winList[$i][0]), 2) Then
            GUICtrlSetData($win, $winList[$i][0])
        EndIf
    Next
    GUICtrlSetData($win, "Select a Window Title", "Select a Window Title")
EndFunc  ;==>repopList

Func setTrans()
    $perc = StringTrimRight($perc, 1)
    $transNum = $perc * 2.55
    WinSetTrans($winName, "", $transNum)
EndFunc  ;==>setTrans

Do
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $repop
            GUICtrlSetData($trans, "Select Visibility")
            repopList()
        Case $msg = $trans
            $winName = GUICtrlRead($win)
            $perc = GUICtrlRead($trans)
            If $winName <> "Select a Window Title"  Then
                setTrans()
            EndIf
        Case $msg = $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE)
            ResetVisibility()
    EndSelect
Until $msg = $GUI_EVENT_CLOSE

Func ResetVisibility()
    For $i = 0 To _GUICtrlComboBoxGetCount($win) - 1
        $perc = "100%" 
        _GUICtrlComboBoxSetCurSel($win, $i)
        $winName = GUICtrlRead($win)
        setTrans()
    Next
EndFunc  ;==>ResetVisibility

;===============================================================================
;
; Description:          _GUICtrlComboBoxGetCount
; Parameter(s):     $h_combobox - controlID
; Requirement:          None
; Return Value(s):  The return value is the number of items in the list box.
;                           If an error occurs, it is CB_ERR
; User CallTip:     _GUICtrlComboBoxGetCount($h_combobox) Retrieve the number of items in the list box of a combo box (required: <ComboBox.au3>)
; Author(s):            Gary Frost (custompcs@charter.net)
; Note(s):              The index is zero-based, so the returned count is one greater
;                           than the index value of the last item.
;
;===============================================================================
Func _GUICtrlComboBoxGetCount($h_combobox)
    Return GUICtrlSendMsg($h_combobox, $CB_GETCOUNT, 0, 0)
EndFunc  ;==>_GUICtrlComboBoxGetCount

;===============================================================================
;
; Description:          _GUICtrlComboBoxSetCurSel
; Parameter(s):     $h_combobox - controlID
;                           $i_index - Specifies the zero-based index of the string to select
; Requirement:          None
; Return Value(s):  If the message is successful, the return value is the index of the item selected.
;                           If $i_index is greater than the number of items in the list or if $i_index is 1,
;                           the return value is CB_ERR and the selection is cleared
; User CallTip:     _GUICtrlComboBoxSetCurSel($h_combobox,$i_index) Select a string in the list of a combo box (required: <ComboBox.au3>)
; Author(s):            Gary Frost (custompcs@charter.net)
; Note(s):              If this $i_index is 1, any current selection in the list is removed and the edit control is cleared
;
;===============================================================================
Func _GUICtrlComboBoxSetCurSel($h_combobox, $i_index)
    Return GUICtrlSendMsg($h_combobox, $CB_SETCURSEL, $i_index, 0)
EndFunc  ;==>_GUICtrlComboBoxSetCurSel

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Today is joystick day :)

I made a version that when you press a button on your joystick, it will set the trasparency of the current window based on the x-axis of the joystick. Pushing the joystick down exits.

#include <DllMem.au3>
#include <GUIConstants.au3>

Local $joy
Dim $coor[8]

$joy    = _JoyInit()

while $coor[1] < 65500
    $coor   = _GetJoy($joy,0)
    if $coor[7] Then WinSetTrans("","",($coor[0]/65536) * 255)
    sleep(250)
WEnd

WinSetTrans("","",255)


;======================================
;   _JoyInit()
;======================================
Func _JoyInit()
    Local $joy
    Global $JOYINFOEX_struct    = "dword(13)"

    $joy    = _DllMemCreate($JOYINFOEX_struct)
    if Not $joy Then Return 0
    _DllMemSet($joy,$JOYINFOEX_struct,0,_DllMemStructSize($JOYINFOEX_struct),0)
    _DllMemSet($joy,$JOYINFOEX_struct,0,255,1)
    return $joy
EndFunc

;======================================
;   _GetJoy($lpJoy,$iJoy)
;   $lpJoy  Return from _JoyInit()
;   $iJoy   Joystick # 0-15
;   Return  Array containing X-Pos, Y-Pos, Z-Pos, R-Pos, U-Pos, V-Pos,POV
;           Buttons down
;
;           *POV This is a digital game pad, not analog joystick
;           65535   = Not pressed
;           0       = U
;           4500    = UR
;           9000    = R
;           Goes around clockwise increasing 4500 for each position
;======================================
Func _GetJoy($lpJoy,$iJoy)
    Local $coor,$ret

    Dim $coor[8]
    $ret = DllCall("Winmm.dll","int","joyGetPosEx",_
                    "int",$iJoy,_
                    "ptr",$lpJoy)
    if Not @error Then
        $coor[0]    = _DllMemGet($lpJoy,$JOYINFOEX_struct,0,2)
        $coor[1]    = _DllMemGet($lpJoy,$JOYINFOEX_struct,0,3)
        $coor[2]    = _DllMemGet($lpJoy,$JOYINFOEX_struct,0,4)
        $coor[3]    = _DllMemGet($lpJoy,$JOYINFOEX_struct,0,5)
        $coor[4]    = _DllMemGet($lpJoy,$JOYINFOEX_struct,0,6)
        $coor[5]    = _DllMemGet($lpJoy,$JOYINFOEX_struct,0,7)
        $coor[6]    = _DllMemGet($lpJoy,$JOYINFOEX_struct,0,10)
        $coor[7]    = _DllMemGet($lpJoy,$JOYINFOEX_struct,0,8)
    EndIf

    return $coor
EndFunc
Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...