Jump to content

determing active window name

Recommended Posts

I want to create an script that will change the transparency of the active window when a hot key is pressed. WinSetTrans() wants a title for an argument. If I have 2 or 3 or 4 windows titled "Notepad", one of which is active, how can I do this? WinSetTrans() seems ambiguous as to which window would be changed.



Link to post
Share on other sites


Btw, is there a special DllCall for this effect, like BOOL SetTrans(hwnd) ?

$hwnd = GUICreate("Animate Window", 300, 300)

DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00080000);fade-in
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00090000);fade-out
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040001);slide in from left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050002);slide out to left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040002);slide in from right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050001);slide out to right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040004);slide-in from top
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050008);slide-out to top
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040008);slide-in from bottom
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050004);slide-out to bottom
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040005);diag slide-in from Top-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x0005000a);diag slide-out to Top-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040006);diag slide-in from Top-Right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050009);diag slide-out to Top-Right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040009);diag slide-in from Bottom-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050006);diag slide-out to Bottom-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x0004000a);diag slide-in from Bottom-right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050005);diag slide-out to Bottom-right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00040010);explode
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00050010);implode

#define AW_HOR_POSITIVE         0x00000001
#define AW_HOR_NEGATIVE         0x00000002
#define AW_VER_POSITIVE         0x00000004
#define AW_VER_NEGATIVE         0x00000008
#define AW_CENTER                 0x00000010
#define AW_HIDE                 0x00010000
#define AW_ACTIVATE             0x00020000
#define AW_SLIDE                    0x00040000
#define AW_BLEND                    0x00080000

I don't know the autor of the script.

Link to post
Share on other sites

I always thought this was pretty cool..

designed by gafrost and ejoc ( i believe)

#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%")

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])
    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

    $msg = GUIGetMsg()
        Case $msg = $repop
            GUICtrlSetData($trans, "Select Visibility")
        Case $msg = $trans
            $winName = GUICtrlRead($win)
            $perc = GUICtrlRead($trans)
            If $winName <> "Select a Window Title"  Then
        Case $msg = $GUI_EVENT_CLOSE
Until $msg = $GUI_EVENT_CLOSE

Func ResetVisibility()
    For $i = 0 To _GUICtrlComboBoxGetCount($win) - 1
        $perc = "100%" 
        _GUICtrlComboBoxSetCurSel($win, $i)
        $winName = GUICtrlRead($win)
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

hope that can help



Link to post
Share on other sites

here's the one i use in *XPClean Menu*

Func Set_Trans()
    $loc = "out"
    If $Full = "show" Then GUISetState(@SW_MINIMIZE, $MAIN)
    $Trans_ans = InputBox("Set Menu-Bar Visability", "Please Type a number for the % of transparency ie..." & @CRLF & @CRLF & " 25 or 50 or " & @CRLF & @CRLF & " 75 or 100 ", ""," 3","", "", -1, -1, 15)
        Case @error = 0;OK - The string returned is valid
            If $Trans_ans > 24 And $Trans_ans < 101 Then
                $transNum = $Trans_ans * 2.55
                WinSetTrans($Start_Menu, "", $transNum)
                MsgBox(64, "Sorry!", " Please use numbers ONLY from " & @CRLF & @CRLF & " 25 to 100... 45, 65, etc ")
    If $Full = "show" Then WinSetState($header, "", @SW_RESTORE)
EndFunc  ;==>Set_Trans

just delete a few lines and set the "hotKey" and the WinSetTrans("TITLE"

hope that helps


Edited by Valuater


Link to post
Share on other sites

There is also an UDF for window animation, but I think you can't set transparency with it: MSDN

But does someone know the Dll function(s) which is(/are) called by the AutoIt WinSetTrans() ...I already found something with alphablend, but it was for DirectX or something like that.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...