Damein Posted August 6, 2014 Share Posted August 6, 2014 So I have this widget that I have attached to the desktop and I wan't it to always remain there, behind all other windows. I also have it coded to use TrayOnEventMode. Now, when I right click the icon in the taskbar it brings the window to the front, but then when I click off of it it goes back to the desktop. Is there a way to prevent this from happening? I would like it to stay hidden on the desktop unless I go directly to the desktop. Here is the code expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Data\Icon.ico #AutoIt3Wrapper_Compression=0 #AutoIt3Wrapper_Res_Fileversion=1.4.0.0 #AutoIt3Wrapper_Res_LegalCopyright=R.S.S. #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;~ #AutoIt3Wrapper_Icon=Images\Icon.ico #include ".\Skins\Hex.au3" #include "_UskinLibrary.au3" #include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Timers.au3> _Uskin_LoadDLL() _USkin_Init(_Hex(True)) Opt("GUIOnEventMode", 1) Opt("TrayMenuMode", 3) Opt("TrayOnEventMode", 1) TrayCreateItem("Exit..") TrayItemSetOnEvent(-1, "_Exit") TrayCreateItem("Update..") TrayItemSetOnEvent(-1, "_Update") Global $MainGui, $CurrentGui, $PositionGui, $OptionsGui, $UpdateButton, $UpdatingButton, $CurrentStreams = 1 Global $OnlineColor = "0x00FF3C", $OfflineColor = "0xFF0000" Dim $StreamerButton[30] Global $h_Desktop_SysListView32 _GetDesktopHandle() $Width = @DesktopWidth $Height = @DesktopHeight $CheckFirstRun = IniRead(@ScriptDir & "/Data/Preferences.ini", "Settings", "FirstRun", "NA") If $CheckFirstRun = "0" Then MsgBox(0, "Welcome", "Welcome to the Twitch Desktop App. This program will help let you know when a streamer is online quickly!") MsgBox(0, "Welcome", "You can set various options on it which can all be found in the help file!") MsgBox(0, "Welcome", "But first, we must set the position of the window that you will be using!") IniWrite(@ScriptDir & "/Data/Preferences.ini", "Settings", "FirstRun", "1") _CreatePositionGui() Else _CreateMainGui() EndIf Func _CreatePositionGui() GUIDelete($MainGui) $CurrentGui = "PositionGui" $PositionGui = GUICreate("Position GUI", 200, 440, Default, Default, Default, Default, WinGetHandle(AutoItWinGetTitle())) GUISetFont(13) GUICtrlSetDefColor(0xFFFFFF) GUISetBkColor(0x000000) WinSetTrans($PositionGui, "", 200) $SavePositionButton = GUICtrlCreateButton("Set Positioning", 40, 160, 120, 30) GUICtrlSetOnEvent(-1, "_SavePosition") GUISetState() DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $PositionGui, "hwnd", $h_Desktop_SysListView32) MsgBox(0, "Positioning..", "Please move the window to where you would like it to reside then press the 'Set Positioning' button") EndFunc ;==>_CreatePositionGui Func _SavePosition() $PositionToSave = WinGetPos("Position GUI") IniWrite(@ScriptDir & "/Data/Preferences.ini", "Position", "X", $PositionToSave[0]) IniWrite(@ScriptDir & "/Data/Preferences.ini", "Position", "Y", $PositionToSave[1]) GUIDelete($PositionGui) _CreateMainGui() EndFunc ;==>_SavePosition Func _CreateMainGui() $Y = 20 $Count = 1 $XPos = IniRead(@ScriptDir & "/Data/Preferences.ini", "Position", "X", "NA") $YPos = IniRead(@ScriptDir & "/Data/Preferences.ini", "Position", "Y", "NA") $CurrentGui = "MainGUI" $MainGui = GUICreate("", 200, 440, $XPos, $YPos, BitOR($WS_POPUP, $WS_BORDER), Default, WinGetHandle(AutoItWinGetTitle())) GUISetFont(13) GUISetBkColor(0x000000) For $i = 1 To 20 If $Count = 6 Then $Y = 20 $Count = 1 EndIf $StreamerButton[$i] = GUICtrlCreateButton("", 20, $Y, 160, 30) $Y += 45 $Count += 1 GUICtrlSetOnEvent(-1, "_RunStream") Next $Streams = IniReadSection(@ScriptDir & "/Data/Preferences.ini", "Streams") For $i = 1 To 20 $SplitData = StringSplit($Streams[$i][1], "|") If $SplitData[0] > 1 Then GUICtrlSetData($StreamerButton[$i], $i & ". " & $SplitData[1]) GUICtrlSetColor($StreamerButton[$i], $OfflineColor) GUICtrlSetBkColor($StreamerButton[$i], 0x000000) Else GUICtrlSetData($StreamerButton[$i], "Streamer " & $i) GUICtrlSetColor($StreamerButton[$i], $OfflineColor) GUICtrlSetBkColor($StreamerButton[$i], 0x000000) EndIf Next For $i = 6 To 20 GUICtrlSetState($StreamerButton[$i], $GUI_HIDE) Next $NextButton = GUICtrlCreateButton("Next", 50, 255, 100, 30) GUICtrlSetColor($NextButton, 0xEFFF00) GUICtrlSetBkColor($NextButton, 0x000000) GUICtrlSetOnEvent(-1, "_Next") $OptionsButton = GUICtrlCreateButton("Options", 50, 300, 100, 30) GUICtrlSetColor($OptionsButton, 0xEFFF00) GUICtrlSetBkColor($OptionsButton, 0x000000) GUICtrlSetOnEvent(-1, "_CreateOptionsGui") $RepositionButton = GUICtrlCreateButton("Reposition", 50, 345, 100, 30) GUICtrlSetColor($RepositionButton, 0xEFFF00) GUICtrlSetBkColor($RepositionButton, 0x000000) GUICtrlSetOnEvent(-1, "_CreatePositionGui") $UpdateButton = GUICtrlCreateButton("Update", 50, 390, 100, 30) GUICtrlSetColor($UpdateButton, 0xEFFF00) GUICtrlSetBkColor($UpdateButton, 0x000000) GUICtrlSetOnEvent(-1, "_Update") $UpdatingButton = GUICtrlCreateButton("Updating..", 50, 390, 100, 30) GUICtrlSetColor($UpdatingButton, $OnlineColor) GUICtrlSetBkColor($UpdatingButton, 0x000000) GUICtrlSetState(-1, $GUI_HIDE) WinSetTrans($MainGui, "", 200) GUICtrlCreateLabel("Prophete Twitch Widget", 45, 0, 200, 15) GUICtrlSetColor(-1, $OfflineColor) GUICtrlSetFont(-1, 8) GUICtrlCreateLabel("An R.S.S. Production ©2014", 55, 425, 200, 20) GUICtrlSetColor(-1, $OfflineColor) GUICtrlSetFont(-1, 6) GUISetState() _Update() DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $MainGui, "hwnd", $h_Desktop_SysListView32) EndFunc ;==>_CreateMainGui Func _Next() If $CurrentStreams = 1 Then For $i = 1 To 5 GUICtrlSetState($StreamerButton[$i], $GUI_HIDE) Next For $i = 6 To 10 GUICtrlSetState($StreamerButton[$i], $GUI_SHOW) Next $CurrentStreams = 2 ElseIf $CurrentStreams = 2 Then For $i = 6 To 10 GUICtrlSetState($StreamerButton[$i], $GUI_HIDE) Next For $i = 11 To 15 GUICtrlSetState($StreamerButton[$i], $GUI_SHOW) Next $CurrentStreams = 3 ElseIf $CurrentStreams = 3 Then For $i = 11 To 15 GUICtrlSetState($StreamerButton[$i], $GUI_HIDE) Next For $i = 16 To 20 GUICtrlSetState($StreamerButton[$i], $GUI_SHOW) Next $CurrentStreams = 4 ElseIf $CurrentStreams = 4 Then For $i = 16 To 20 GUICtrlSetState($StreamerButton[$i], $GUI_HIDE) Next For $i = 1 To 5 GUICtrlSetState($StreamerButton[$i], $GUI_SHOW) Next $CurrentStreams = 1 EndIf EndFunc ;==>_Next Func _SetTimer() $TimerSet = 0 $TimerVar = 0 $CheckTimer = IniRead(@ScriptDir & "/Data/Preferences.ini", "Settings", "AutomaticUpdate", "NA") If $CheckTimer = 1 Then $TimerVar = IniRead(@ScriptDir & "/Data/Preferences.ini", "Settings", "UpdateTime", "NA") For $i = 1 To $TimerVar $TimerSet += 60000 Next AdlibRegister("_Update", $TimerSet) EndIf EndFunc ;==>_SetTimer Func _CreateOptionsGui() GUISetState(@SW_DISABLE, $MainGui) $CurrentGui = "OptionsGui" $OptionsGui = GUICreate("Options", 300, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetFont(13) $ManualUpdateButton = GUICtrlCreateButton("Manual Update", 55, 25, 180, 30) GUICtrlSetOnEvent(-1, "_ManualUpdateSet") $AutomaticUpdateButton = GUICtrlCreateButton("Automatic Update", 55, 65, 180, 30) GUICtrlSetOnEvent(-1, "_AutomaticUpdateSet") $NewUserButton = GUICtrlCreateButton("Update Streamer", 55, 105, 180, 30) GUICtrlSetOnEvent(-1, "_UpdateStreamer") $ChangeTimerButton = GUICtrlCreateButton("Change Update Timer", 55, 145, 180, 30) GUICtrlSetOnEvent(-1, "_ChangeUpdateTimer") GUISetState() EndFunc ;==>_CreateOptionsGui Func _ChangeUpdateTimer() $NewTimer = InputBox("Timer Update", "How many minutes would you like to pass before the Twitch Desktop App checks for live streams? Please enter a time of 1-60 (1 being 1 minute ect.)") If $NewTimer > "" Then If $NewTimer < 60 Then If StringIsAlNum($NewTimer) Then IniWrite(@ScriptDir & "/Data/Preferences.ini", "Settings", "UpdateTime", $NewTimer) EndIf EndIf Else MsgBox(48, "Error", "No time input, please try again.") EndIf $NewTimer = "" EndFunc ;==>_ChangeUpdateTimer Func _UpdateStreamer() $CurrentGui = "MainGui" GUIDelete($OptionsGui) $GetNumber = InputBox("Stream Update", "Please input a number 1-20 according to the number of the stream button you want to update. 1 being the top most button") If $GetNumber > "" Then If $GetNumber > 20 Then MsgBox(48, "Error", "You have input an incorrect number. Please try again.") Else $InputName = InputBox("Stream Update", "Please input the name you wish to show on the button.") $InputLink = InputBox("Stream Update", "Please input the link to the Twitch.tv stream you wish to associate with this button.") $Split = StringSplit($InputLink, "tv/", 1) If $Split[1] = "http://twitch." Or "www.twitch." Then $CheckSave = MsgBox(4, "Stream Update", "Is this information correct?" & @CRLF & @CRLF & "Stream Number: " & $GetNumber & @CRLF & "Stream Name: " & $InputName & @CRLF & "Stream Link: " & $InputLink) If $CheckSave = 6 Then IniWrite(@ScriptDir & "/Data/Preferences.ini", "Streams", $GetNumber, $InputName & "|" & "https://api.twitch.tv/kraken/streams/" & $Split[2] & "|" & "0") EndIf Else MsgBox(48, "Error", "Stream link invalid. Please go to Twitch.tv in a web browser and copy/paste the link of the stream to which you wish to use.") EndIf EndIf EndIf GUIDelete($MainGui) _CreateMainGui() EndFunc ;==>_UpdateStreamer Func _ManualUpdateSet() MsgBox(0, "Options..", "Manual updates have been set. Please use the 'Update' button on the window to check stream activity.") IniWrite(@ScriptDir & "/Data/Preferences.ini", "Settings", "ManualUpdate", "1") IniWrite(@ScriptDir & "/Data/Preferences.ini", "Settings", "AutomaticUpdate", "0") EndFunc ;==>_ManualUpdateSet Func _AutomaticUpdateSet() MsgBox(0, "Options..", "Automatic updates have been set. Please refer to the 'Change Update Timer' button to check or change the time inbetween checking of streams.") IniWrite(@ScriptDir & "/Data/Preferences.ini", "Settings", "ManualUpdate", "0") IniWrite(@ScriptDir & "/Data/Preferences.ini", "Settings", "AutomaticUpdate", "1") EndFunc ;==>_AutomaticUpdateSet Func _Update() GUICtrlSetState($UpdateButton, $GUI_HIDE) GUICtrlSetState($UpdatingButton, $GUI_SHOW) $StreamData = IniReadSection(@ScriptDir & "/Data/Preferences.ini", "Streams") For $i = 1 To $StreamData[0][0] If StringInStr($StreamData[$i][1], "|") Then $SplitData = StringSplit($StreamData[$i][1], "|") $Url = $SplitData[2] $sSource = BinaryToString(InetRead($Url)) If StringInStr($sSource, '"stream":null') Then IniWrite(@ScriptDir & "/Data/Preferences.ini", "Streams", $StreamData[$i][0], $SplitData[1] & "|" & $SplitData[2] & "|" & "0") GUICtrlSetColor($StreamerButton[$i], $OfflineColor) Else IniWrite(@ScriptDir & "/Data/Preferences.ini", "Streams", $StreamData[$i][0], $SplitData[1] & "|" & $SplitData[2] & "|" & "1") GUICtrlSetColor($StreamerButton[$i], $OnlineColor) EndIf Else Sleep(10) EndIf Next $CheckTimer = IniRead(@ScriptDir & "/Data/Preferences.ini", "Settings", "AutomaticUpdate", "NA") If $CheckTimer = 1 Then _SetTimer() EndIf Sleep(1000) GUICtrlSetState($UpdatingButton, $GUI_HIDE) GUICtrlSetState($UpdateButton, $GUI_SHOW) EndFunc ;==>_Update Func _Exit() If $CurrentGui = "MainGui" Then Exit ElseIf $CurrentGui = "OptionsGui" Then $CurrentGui = "MainGui" GUIDelete($OptionsGui) GUISetState(@SW_ENABLE, $MainGui) WinActivate($MainGui) EndIf EndFunc ;==>_Exit Func _RunStream() $ID = @GUI_CtrlId $Info = GUICtrlRead($ID, 1) $GetNumber = StringSplit($Info, ".") $CheckRun = MsgBox(4, "Run Stream..", "Are you sure you wish to run the stream of " & $GetNumber[2] & "?") If $CheckRun = 6 Then $CheckStream = IniRead(@ScriptDir & "/Data/Preferences.ini", "Streams", $GetNumber[1], "NA") If StringInStr($CheckStream, "|") Then $CheckRunMethod = InputBox("Run Stream", "Would you like to open this stream in a web browser or use LiveStreamer?" & @CRLF & @CRLF & "1 = Web" & @CRLF & "2 = LiveStreamer") If $CheckRunMethod = "" Then Sleep(10) ElseIf $CheckRunMethod = 1 Then $StreamData = IniRead(@ScriptDir & "/Data/Preferences.ini", "Streams", $GetNumber[1], "NA") $SplitData = StringSplit($StreamData, "|") $Split = StringSplit($SplitData[2], "streams/", 1) ShellExecute("http://www.twitch.tv/" & $Split[2]) ElseIf $CheckRunMethod = 2 Then $CheckQuality = InputBox("LiveStreamer", "What quality would you like to run this stream at?" & @CRLF & @CRLF & "1 = Mobile" & @CRLF & "2 = Medium" & @CRLF & "3 = High" & @CRLF & "4 = Source") If $CheckQuality = "" Then Sleep(10) Else If $CheckQuality < 5 Then If $CheckQuality = 1 Then $Quality = "Mobile" ElseIf $CheckQuality = 2 Then $Quality = "Medium" ElseIf $CheckQuality = 3 Then $Quality = "High" ElseIf $CheckQuality = 4 Then $Quality = "Source" EndIf EndIf $StreamData = IniRead(@ScriptDir & "/Data/Preferences.ini", "Streams", $GetNumber[1], "NA") $SplitData = StringSplit($StreamData, "|") $Split = StringSplit($SplitData[2], "streams/", 1) Run("livestreamer " & "http://twitch.tv/" & $Split[2] & " " & $Quality) EndIf EndIf $CheckRunMethod = "" $CheckQuality = "" Else MsgBox(48, "Error", "Error running stream. Please double check your stream link and or name.") EndIf Else Sleep(10) EndIf EndFunc ;==>_RunStream While 1 Sleep(10) WEnd Func _GetDesktopHandle() $h_Desktop_SysListView32 = 0 Local Const $hDwmApiDll = DllOpen("dwmapi.dll") Local $sChkAero = DllStructCreate("int;") DllCall($hDwmApiDll, "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($sChkAero)) Local $aero_on = DllStructGetData($sChkAero, 1) If Not $aero_on Then $h_Desktop_SysListView32 = WinGetHandle("Program Manager") Return 1 Else Local $hCBReg = DllCallbackRegister("_GetDesktopHandle_EnumChildWinProc", "hwnd", "hwnd;lparam") If $hCBReg = 0 Then Return SetError(2) DllCall("user32.dll", "int", "EnumChildWindows", "hwnd", _WinAPI_GetDesktopWindow(), "ptr", DllCallbackGetPtr($hCBReg), "lparam", 101) Local $iErr = @error DllCallbackFree($hCBReg) If $iErr Then Return SetError(3, $iErr, "") EndIf Return 2 EndIf EndFunc ;==>_GetDesktopHandle You will need the INI to run the program [Settings] FirstRun=0 ManualUpdate=1 AutomaticUpdate=0 UpdateTime=5 [Position] X=0 Y=0 [Streams] 1=Streamer 1 2=Streamer 2 3=Streamer 3 4=Streamer 4 5=Streamer 5 6=Streamer 6 7=Streamer 7 8=Streamer 8 9=Streamer 9 10=Streamer 10 11=Streamer 11 12=Streamer 12 13=Streamer 13 14=Streamer 14 15=Streamer 15 16=Streamer 16 17=Streamer 17 18=Streamer 18 19=Streamer 19 20=Streamer 20 Name it Preferences.ini in a folder labeled Data where you save the source. Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now