Jump to content



Photo

Click Through Transparent Window


  • Please log in to reply
2 replies to this topic

#1 Lakes

Lakes

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 762 posts

Posted 19 August 2010 - 12:18 PM

AutoIt         
#include <Constants.au3> #include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include<StaticConstants.au3> Opt("GUIOnEventMode", 1) Global $hMain, $iW = 800, $iH = 800, $msg, $ColourSlider, $Mx, $My, $Col1, $Trans1 ; Create Slider GUI $hGUI1 = GUICreate("SliderGUI", 217, 126, 86, 793) $iSlider1 = GUICtrlCreateSlider(6, 74, 201, 21) $TransLabel = GUICtrlCreateLabel("Adjust Transparency", 66, 62, 101, 17) $Clickthru = GUICtrlCreateCheckbox("Clickthru", 10, 108, 13, 13) ;GUICtrlSetState(-1, 1) $Tog_label = GUICtrlCreateLabel("Toggle Clck Through", 30, 108, 104, 17) GUICtrlSetLimit($iSlider1, 254, 1) GUICtrlSetData ($iSlider1, 150) GUICtrlSetOnEvent($Clickthru, "SystemEvents") $ColourSlider = GUICtrlCreateSlider(4, 19, 201, 21) $ColourLabel = GUICtrlCreateLabel("Adjust Colour", 79, 4, 66, 17) GUICtrlSetLimit($ColourSlider, 254, 1) GUICtrlSetData ($ColourSlider, 150) GUISetOnEvent($GUI_EVENT_CLOSE, "SystemEvents") GUISetState(@SW_SHOW) ;Create Transparent GUI $hMain = GUICreate("", $iW ,$iH,  -1, -1,   BitOR($WS_POPUP,$WS_BORDER,$WS_SIZEBOX),$WS_EX_TOPMOST)  GUISetBkColor(0x00)            ;Set GUI Colour GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "SystemEvents") GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "SystemEvents") GUISetState(@SW_SHOW) WinSetTrans($hMain, "", 150) ; toggle Transparency While 1     sleep(50)     $Trans = GUICtrlRead($iSlider1)     $Col = GUICtrlRead($ColourSlider)     $Colour = ($Col * 256 * 256) + ($Col * 256) + ($Col)     If $Col <> $Col1 then               ;Only update window if slider value changes         GUISetBkColor($Colour)          ;Set GUI Colour         $Col = $Col1     Endif     If $Trans <> $Trans1 Then         WinSetTrans($hMain, "", $Trans)         $Trans = $Trans1     Endif WEnd Func SystemEvents()     Switch @GUI_CtrlId         Case $GUI_EVENT_CLOSE             Exit         Case $Clickthru             If BitAND(GUICtrlRead($Clickthru), $GUI_CHECKED) Then                 _WinAPI_SetWindowLong($hMain, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hMain, $GWL_EXSTYLE), $WS_EX_TRANSPARENT))             Else                 $NoTrans = BitNOT($WS_EX_TRANSPARENT)                 _WinAPI_SetWindowLong($hMain, $GWL_EXSTYLE, BitAND(_WinAPI_GetWindowLong($hMain, $GWL_EXSTYLE), $NoTrans))             EndIf         Case $GUI_EVENT_PRIMARYDOWN             Drag($hMain)         Case $GUI_EVENT_PRIMARYUP             ;         Case $GUI_EVENT_SECONDARYDOWN             ;     EndSwitch EndFunc ;by Zedna Func Drag($h) ;~  dllcall("user32.dll","int","ReleaseCapture")     DllCall("user32.dll","int","SendMessage","hWnd", $h,"int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0) EndFunc

Edited by Lakes, 19 August 2010 - 06:17 PM.








#2 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,244 posts

Posted 19 August 2010 - 12:33 PM

It's not a good idea to set stuff like that, use the events:

AutoIt         
#include <Constants.au3> #include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Opt("GUIOnEventMode", 1) Global $hMain, $iW = 800, $iH = 800, $msg, $ColourSlider, $Mx, $My ; Create Slider GUI $hGUI1 = GUICreate("SliderGUI", 217, 126, 86, 793) $iSlider1 = GUICtrlCreateSlider(6, 74, 201, 21) $TransLabel = GUICtrlCreateLabel("Adjust Transparency", 66, 62, 101, 17) $Clickthru = GUICtrlCreateCheckbox("Clickthru", 10, 108, 13, 13) $Tog_label = GUICtrlCreateLabel("Toggle Clck Through", 30, 108, 104, 17) GUICtrlSetLimit($iSlider1, 254, 1) GUICtrlSetData($iSlider1, 150) GUICtrlSetOnEvent($iSlider1, "SystemEvents") GUICtrlSetOnEvent($Clickthru, "SystemEvents") $ColourSlider = GUICtrlCreateSlider(4, 19, 201, 21) $ColourLabel = GUICtrlCreateLabel("Adjust Colour", 79, 4, 66, 17) GUICtrlSetLimit($ColourSlider, 254, 1) GUICtrlSetData($ColourSlider, 150) GUISetOnEvent($GUI_EVENT_CLOSE, "SystemEvents") GUICtrlSetOnEvent($ColourSlider, "SystemEvents") GUISetState(@SW_SHOW) ;Create Transparent GUI $hMain = GUICreate("", $iW, $iH, -1, -1, BitOR($WS_POPUP, $WS_BORDER, $WS_SIZEBOX), BitOR($WS_EX_TOPMOST, $WS_EX_CONTROLPARENT)) GUISetBkColor(0x00) ;Set GUI Colour GUISetState(@SW_SHOW) WinSetTrans($hMain, "", 150) While 1     Sleep(10) WEnd Func SystemEvents()     Switch @GUI_CtrlId         Case $GUI_EVENT_CLOSE             Exit         Case $Clickthru             If BitAND(GUICtrlRead($Clickthru), $GUI_CHECKED) Then                 _WinAPI_SetWindowLong($hMain, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hMain, $GWL_EXSTYLE), $WS_EX_TRANSPARENT))             Else                 $NoTrans = BitNOT($WS_EX_TRANSPARENT)                 _WinAPI_SetWindowLong($hMain, $GWL_EXSTYLE, BitAND(_WinAPI_GetWindowLong($hMain, $GWL_EXSTYLE), $NoTrans))             EndIf         Case $iSlider1             $Trans = GUICtrlRead($iSlider1)             WinSetTrans($hMain, "", $Trans)         Case $ColourSlider             $Col = GUICtrlRead($ColourSlider)             $Colour = ($Col * 256 * 256) + ($Col * 256) + ($Col)             GUISetBkColor($Colour) ;Set GUI Colour     EndSwitch EndFunc

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#3 Lakes

Lakes

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 762 posts

Posted 19 August 2010 - 03:51 PM

Lost the window sizing and the window only updates after you release the mouse button.

EDIT: Updated script in first post.

Edited by Lakes, 19 August 2010 - 06:18 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users