Sign in to follow this  
Followers 0
Klovis

Click throw a window

4 posts in this topic

#1 ·  Posted (edited)

Well when ever I run this script on my computer I can still click my desktop, but when I run it on my cousins computer then he can't click anything. I need to have the images over everything, but maybe there's a way to be able to click through it?

The troublesome script

#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <Misc.au3>

Opt("MustDeclareVars", 1)

Global Const $AC_SRC_ALPHA = 1
Global $hGUI_Graphics
Global $hImageGS, $hImageRed1, $hImageRed2, $hImageRed3, $hImagePin

Global $hGUI, $TCPAccept = 10, $TCPListen, $TCPPrevious = 255, $TCPRecv
TCPStartup()
$TCPListen = TCPListen(@IPAddress1, 5000)

;pin position and size
Global $hPen, $radius = 60, $x = 615, $y = 335


$hGUI_Graphics = GUICreate("Graphics", 1280, 720, -1, -1, -1, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST))
GUISetState(@SW_SHOW)

_GDIPlus_Startup()
$hPen = _GDIPlus_PenCreate(0xFFFF0000, 5)
$hImageGS = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\gs.png")
$hImageRed1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\first.png")
$hImageRed2 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\second.png")
$hImageRed3 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\third.png")

Do
    $TCPAccept = TCPAccept($TCPListen)
Until $TCPAccept <> -1

While 1
    $TCPRecv = TCPRecv($TCPAccept, 1000000)
    If $TCPRecv <> "" And $TCPRecv <> $TCPPrevious Then
        $TCPPrevious = $TCPRecv
        ConsoleWrite("What is recieved >> " & $TCPPrevious & @CRLF)
        If $TCPPrevious > $TCPPrevious +1 Then
            Do
                $TCPPrevious = $TCPPrevious + 1
            Until $TCPPrevious = $TCPRecv
        EndIf
        If $TCPPrevious < $TCPPrevious -1 Then
            Do
                $TCPPrevious = $TCPPrevious - 1
            Until $TCPPrevious = $TCPRecv
        EndIf
        Local $freq11 = StringMid($TCPRecv, StringInStr($TCPRecv, "channel1")+17, 13)
        Local $freq21 = StringMid($TCPRecv, StringInStr($TCPRecv, "channel2")+17, 13)
        Local $freq12 = StringMid($TCPRecv, StringInStr($TCPRecv, "channel1")+32, 13)
        Local $freq22 = StringMid($TCPRecv, StringInStr($TCPRecv, "channel2")+32, 13)
        Global $c12aa = Round(((Number($freq11)+Number($freq21))/2)/100000000)
        If $c12aa>255 Then $c12aa = 255
        Global $c12ab = Round(((Number($freq12)+Number($freq22))/2)/10000000)
        If $c12ab>255 Then $c12ab = 255
        GUICtrlSetData($Label6, $c12aa &@CRLF& $c12ab &@CRLF& $c)
        _Update()
    EndIf
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

_GDIPlus_ImageDispose($hImageGS)
_GDIPlus_ImageDispose($hImageRed1)
_GDIPlus_ImageDispose($hImageRed2)
_GDIPlus_ImageDispose($hImageRed3)
_GDIPlus_PenDispose($hPen)
_GDIPlus_Shutdown()

Func _Update()
    Local $iSliderValue = $c12ab
    Local $iSliderValuer = $c12aa
    Local $iSliderPerc = $c12aa/2.55 ;has to be between 1 and 100

    Local $hBitmap
    Switch $iSliderPerc
        Case $iSliderPerc<0
            Return
        Case 0
            Return
        Case 1 To 49
        ;Case 0 To 49
            $hBitmap = $hImageRed1
        Case 50 To 79
            $hBitmap = $hImageRed2
        Case 80 To 100
            $hBitmap = $hImageRed3
        Case $iSliderPerc>100
            $hBitmap = $hImageRed3
    EndSwitch
    Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsDrawImage ($hGraphic, $hImageGS, 515, 250)

    Local $radian = (($iSliderValuer/190)+.8) * 3.14159265358979 ;use (($iSliderValue/255)+1) for 270 to 90 degrees
    _GDIPlus_GraphicsDrawLine($hGraphic, $x, $y, $x + Cos($radian) * $radius,$y +  Sin($radian) * $radius, $hPen)

    _GDIPlus_GraphicsDispose($hGraphic)

    Local $iTrans = Round(($iSliderValue-92)*1.564)  ;1.564 is 255/163, 163 is 255-92, 92 is 36% of 255
    ConsoleWrite($iTrans & @CRLF)
    If $iTrans < 0 Then $iTrans = 0
    SetBitMap($hGUI_Graphics, $hBitmap, $iTrans)

    If $iSliderValue < 91 Then SetBitmap($hGUI_Graphics, $hBitmap, 0) ; 92 is 36% of 255
    ;no need to do all the other stuff if we're not gonna show it.

    _WinAPI_DeleteObject($hBitmap)
EndFunc

Func SetBitmap($hGUI, $hImage, $iOpacity)
  Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
  $hScrDC  = _WinAPI_GetDC(0)
  $hMemDC  = _WinAPI_CreateCompatibleDC($hScrDC)
  $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
  $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
  $tSize   = DllStructCreate($tagSIZE)
  $pSize   = DllStructGetPtr($tSize  )
  DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
  DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
  $tSource = DllStructCreate($tagPOINT)
  $pSource = DllStructGetPtr($tSource)
  $tBlend  = DllStructCreate($tagBLENDFUNCTION)
  $pBlend  = DllStructGetPtr($tBlend)
  DllStructSetData($tBlend, "Alpha" , $iOpacity )
  DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
  _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
  _WinAPI_ReleaseDC   (0, $hScrDC)
  _WinAPI_SelectObject($hMemDC, $hOld)
  _WinAPI_DeleteObject($hBitmap)
  _WinAPI_DeleteDC  ($hMemDC)
EndFunc
Edited by Klovis

Share this post


Link to post
Share on other sites



I haven't tried this on W7 but I've used this approach when I have wanted a click-through window. See if this works on your cousin's computer.

;by trancexx, April 21 2009

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


Global $hGui = GUICreate("Click-through topmost GUI", -1, -1, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_TRANSPARENT));, $WS_EX_LAYERED)) ; you can omit WS_EX_LAYERED because it's added by winsettrans
GUISetBkColor(0x0)
WinSetTrans($hGui, '', 165)

GUISetState()


While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop ;this is one of trancexx's jokes
WEnd

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.

Share this post


Link to post
Share on other sites

Cool it works thanks

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