Jump to content

My clickthrough window doesn't always work


covaks
 Share

Recommended Posts

Any ideas why this would work on some PCs, but not others?

On mine, it works fine. The targetted window goes semi transparant and I can click through it. (eg: notepad or calc)

On some PCs (same XP Pro/SP/updates, etc), all it does is make the window semi transparant, but I can still click on the window (notepad/calc) and interact with it.

I think it's some setting in the OS, maybe, I don't know.. I can't figure out why it works on some PCs, but not others with the same setup.

Func _ClickThrough()
    Local $hWnd, $CTWindow
    
    $CTWindow = IniRead($INI_FILE,"User","CTWindow","")
    If $CTWindow = "" Then $CTWindow = WinGetTitle("[ACTIVE]")
        
    $hWnd = WinGetHandle($CTWindow)
            
    If $bClickThrough Then
        WinSetOnTop($hWnd, "", 1)
        Local $TransparancyValue = IniRead($INI_FILE,"User","CTTransparancy",255)
        If $TransparancyValue < 0 OR $TransparancyValue > 255 Then
            MsgBox(0,"","Your transparancy value in the .ini file is invalid..  Setting value to 255 (no transparancy)." & @CRLF & _
                     "Please update with a new value between 0 (invis) and 255 (solid)")
            $TransparancyValue = 255
        EndIf
        WinSetTrans($hWnd,"",$TransparancyValue)
        $bClickThrough = Not $bClickThrough
        _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOr($WS_EX_TRANSPARENT,$WS_EX_LAYERED))
    Else
        _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE,BitAnd(_WinAPI_GetWindowLong($hWnd,$GWL_EXSTYLE),BitNOT($WS_EX_TRANSPARENT)))
        _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE,BitAnd(_WinAPI_GetWindowLong($hWnd,$GWL_EXSTYLE),BitNOT($WS_EX_LAYERED)))
        WinSetOnTop($hWnd, "", 0)
        WinSetTrans($hWnd,"",255)
        $bClickThrough = Not $bClickThrough
    EndIf
EndFunc
Link to comment
Share on other sites

Seems like you need to set the window's extended style to include $WS_EX_TRANSPARENT before you try to preform click through:

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

Run("notepad")
WinWaitActive("[CLASS:Notepad]")
$hWndNotepad = WinGetHandle("[CLASS:Notepad]")
$hWndSciTE = WinGetHandle("[CLASS:SciTEWindow]")

$aSciTE = WinGetPos($hWndSciTE)
WinMove($hWndNotepad, "", $aSciTE[0], $aSciTE[1])
WinSetTrans($hWndNotepad, "", 150)
_WinAPI_SetWindowLong($hWndNotepad, $GWL_EXSTYLE, _
    BitOR(_WinAPI_GetWindowLong($hWndNotepad, $GWL_EXSTYLE), $WS_EX_TRANSPARENT))

MouseClick("right", $aSciTE[0]+100, $aSciTE[1]+100)
Link to comment
Share on other sites

  • 2 months later...

The ability to make any window transparent with click-through is very interesting.

"_WinAPI_SetWindowLong($hWndNotepad, $GWL_EXSTYLE, _

BitOR(_WinAPI_GetWindowLong($hWndNotepad, $GWL_EXSTYLE), $WS_EX_TRANSPARENT))"

How do I set it to normal again, which is without transparency and click through ?

thx

Link to comment
Share on other sites

The ability to make any window transparent with click-through is very interesting.

"_WinAPI_SetWindowLong($hWndNotepad, $GWL_EXSTYLE, _

BitOR(_WinAPI_GetWindowLong($hWndNotepad, $GWL_EXSTYLE), $WS_EX_TRANSPARENT))"

How do I set it to normal again, which is without transparency and click through ?

thx

It's all there. Just read the code you have quoted. What's it saying?

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

"_WinAPI_SetWindowLong($hWndNotepad, $GWL_EXSTYLE, _

BitOR(_WinAPI_GetWindowLong($hWndNotepad, $GWL_EXSTYLE), $WS_EX_TRANSPARENT))"

Performing a BitXOR doesn't make it work.

_WinAPI_SetWindowLong($hWndNotepad, $GWL_EXSTYLE, _

BitXOR(_WinAPI_GetWindowLong($hWndNotepad, $GWL_EXSTYLE), $WS_EX_TRANSPARENT))

Any suggestion ?

thx

Link to comment
Share on other sites

"_WinAPI_SetWindowLong($hWndNotepad, $GWL_EXSTYLE, _

BitOR(_WinAPI_GetWindowLong($hWndNotepad, $GWL_EXSTYLE), $WS_EX_TRANSPARENT))"

Performing a BitXOR doesn't make it work.

_WinAPI_SetWindowLong($hWndNotepad, $GWL_EXSTYLE, _

BitXOR(_WinAPI_GetWindowLong($hWndNotepad, $GWL_EXSTYLE), $WS_EX_TRANSPARENT))

Any suggestion ?

thx

Are you saying that setting the extended style to transparent has the unforeseen effect of setting the window style to transparent?
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

martin,

I thought that XOR might work

0100 or 0010 = 0110

0110 xor 0010 = 0100 (return back to org) ;

xor should have made sense to disable it. Unfortunately it doesn't in this case. To use bitAnd doesn't make sense.

though I have treated it simple, the solution could be otherwise.

Still stuck in this. Though this feature is very useful for implementing click-through application for video player.

Link to comment
Share on other sites

I would have written it like this because it makes sense to me

_WinAPI_SetWindowLong($hWndNotepad, $GWL_EXSTYLE, _
 BitAnd(_WinAPI_GetWindowLong($hWndNotepad, $GWL_EXSTYLE), BitNot($WS_EX_TRANSPARENT))

but I think that your way (XOR) is exactly the same in this situation so I'm surprised it doesn't work.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hi guys :huggles: ,

I finally get it working by going through Visual Basic example (http://www.builderau.com.au/program/windows/print.htm?TYPE=story&AT=320270917-339024644t-320000994c).

The solution requires a combination of AND and OR at the right place. This feature is very handy especially for those who use video player.

So here is the solutions. It will call up notepad and then set transparency and pass through. To reset, just put false as indicate in the code, and the notepad will be reset to normal state

#include <Constants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("WinTitleMatchMode", -2) ; Allow match anywhere in the window's title
Opt("MustDeclareVars", 1)

Dim Const $notepad = "notepad"

If True Then ; set this to true or false since no way to retrieve Trans-level
    If Not WinGetTitle($notepad) Then Run($notepad)

    WinActivate($notepad)
    WinWaitActive($notepad)
    WinSetOnTop($notepad, "", 1)

    Dim $hWndNotepad = WinGetHandle($notepad)

    WinSetTrans($hWndNotepad, "", 100) ; Set transparency level
    _WinAPI_SetWindowLong($hWndNotepad, $GWL_EXSTYLE, _
            BitOR(_WinAPI_GetWindowLong($hWndNotepad, $GWL_EXSTYLE), $WS_EX_TRANSPARENT))
Else
    If WinGetTitle($notepad) Then
        WinSetOnTop($notepad, "", 1)
        Dim $hWndNotepad = WinGetHandle($notepad)
        WinSetTrans($hWndNotepad, "", 255) ; No transparency
        _WinAPI_SetWindowLong($hWndNotepad, $GWL_EXSTYLE, _
                BitAND(_WinAPI_GetWindowLong($hWndNotepad, $GWL_EXSTYLE), BitNOT($WS_EX_TRANSPARENT)))
    EndIf
EndIf

thx :D

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...