AdmiralAlkex Posted July 19, 2015 Share Posted July 19, 2015 (edited) Give the script your username on Twitch or Hitbox (empty string to skip) and it'll alert you when the people you are following goes online.$sTwitchUsername = IniRead(@ScriptDir & "\Settings.ini", "Section", "Twitch", "") ;NAME ON TWITCH $sHitboxUsername = IniRead(@ScriptDir & "\Settings.ini", "Section", "Hitbox", "") ;NAME ON HITBOX $iMinRefresh = IniRead(@ScriptDir & "\Settings.ini", "Section", "RefreshMinutes", 5) ;HOW MANY MINUTES BETWEEN EVERY CHECK FOR NEW STREAMSUses Livestreamer for playback if available (highly recommended) otherwise opens in your browser.In comparison to similar scripts that I have seen posted here, this takes your username and pulls the people you are already following instead of having you manually entering everyone again, greatly simplifying things.The Twitch and Hitbox API's were largely implemented by glancing at the python-twitch and Hitboxy python libs.For the future, I'm thinking maybe quality-selector, nicer popup instead of traymenu and balloon tip (maybe some sort of toast thing) and SVPtube-like functionality (play link from clipboard)Uses A Non-Strict JSON UDF.Download from Downloads or GitHub (both source and executable available at both locations).Old attachments had 16 downloads. Edited November 10, 2015 by AdmiralAlkex edited for 1.0 release Xandy, jvanegmond, trancexx and 1 other 4 .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 5, 2015 Author Share Posted August 5, 2015 Update to v0.13ADDED:*Will check if livestreamer is installed and if not open stream in browser*Some quotes to random arrayFIXED:*At least 1 loc that liked to crashCHANGED:*Stuff. Now uses maps so run with Beta AutoIt Download from first post. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 26, 2015 Author Share Posted August 26, 2015 (edited) Update to .14ADDED:*Added progress to tray-icon*More quote stuffCHANGED:*Simplified tray menu. The sub menus seemed like a waste of time*Removed maps. Because reason. Don't have to use Beta AutoIt anymore Download from first post. Edited August 26, 2015 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 10, 2015 Author Share Posted November 10, 2015 Update to 1.0[insert picture of doge]Much speed. Wow. Such responsiveness.No but seriously, better API usage and a tiny bit of caching means that we are down to 1 GET per 100 channels for Twitch and 1 TOTAL for Hitbox, instead of the previously 1 per channel. It didn't make any sense to have a progress anymore so the tray will just tell you what it's working on instead.U=update checkT=TwitchH=HitboxADDED:*Will alert you if there's a new version to download*Auto-refreshes after computer resumes from sleep*More quotesFIXED:*Twitch much faster*Hitbox much fasterCHANGED:*Set default timer to 10 minutes*Simplified tray progress Download from first post. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Damein Posted November 18, 2015 Share Posted November 18, 2015 Little idea for you to clean up the Tray menu. Sort the tray items into categories like Twitch does?So since you already have it setup with a | inbetween the Stream Name / Game Name make it create a new Tray Menu for each new Game Name and then if it finds the same game name after it creates the Tray Menu throw it into the TrayMenuItem instead of all new items? I know some people have hundreds of streams they follow so the method used at the moment would be REALLY hard to sift through the ones you like watching a lot. Maybe even throw in a favorites menu item and an option to add a stream to favorites? 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...
AdmiralAlkex Posted November 19, 2015 Author Share Posted November 19, 2015 Little idea for you to clean up the Tray menu.---I know some people have hundreds of streams they follow so the method used at the moment would be REALLY hard to sift through the ones you like watching a lot.Yeah the tray menu is not great at all, I agree. But I'm hesitant to work much more on it, I think I would rather replace it with something else completely. Like, you click the icon, up pops a GUI with sorting, categories, search, thumbnails and all that cool stuff. No idea yet though how it would look and work.The next update will probably be play link from clipboard (only if you have Livestreamer installed). Maybe after that if I find the inspiration and time... Maybe even throw in a favorites menu item and an option to add a stream to favorites?I like that. They could have more eye-catching notifications so you don't miss 'em as easily. And be placed in the list so they are the fastest to click on. Mobius 1 .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Damein Posted December 3, 2015 Share Posted December 3, 2015 (edited) So I hope you don't mind... but I was bored today and decided to try my hand at this. I'm sure whatever you would do if you chose to would be much more elegant but I think it came out alright for only working on it for a few hours. Not sure if what I did broke it or not but if I click "Refresh" with the edited script I get"C:\Users\Salat_000\Downloads\StreamHelper_Source_151110_01\StreamHelper.au3" (444) : ==> Subscript used on non-accessible variable.: $tLayout = $aData[0] $tLayout = $aData^ ERROR I did add in another TrayItem so that might be the reason? Anyways, here is a snap shot of the GUI The GUI's scroll bar increases in size as more games are live. And here is the edited StreamHelper.au3expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.12.0 (Stable) Author: Alexander Samuelsson AKA AdmiralAlkex Script Function: Stuff #ce ---------------------------------------------------------------------------- $sTwitchUsername = IniRead(@ScriptDir & "\Settings.ini", "Section", "Twitch", "") ;NAME ON TWITCH $sHitboxUsername = IniRead(@ScriptDir & "\Settings.ini", "Section", "Hitbox", "") ;NAME ON HITBOX $iRefresh = IniRead(@ScriptDir & "\Settings.ini", "Section", "RefreshMinutes", 10) * 60000 ;HOW MANY TIME UNITS BETWEEN EVERY CHECK FOR NEW STREAMS $iPrintJSON = IniRead(@ScriptDir & "\Settings.ini", "Section", "PrintJSON", "") ;PRINT ON JSON $sCheckForUpdates = IniRead(@ScriptDir & "\Settings.ini", "Section", "CheckForUpdates", "-1") ;JUST TYPE SOMETHING TO CHECK Opt("TrayMenuMode", 3) Opt("TrayOnEventMode", 1) #include <AutoItConstants.au3> #include "Json.au3" #include "StreamHelperGUI.au3" #include <Array.au3> #include <InetConstants.au3> #include <Date.au3> #include <GDIPlus.au3> #include <WinAPIShellEx.au3> #include <WindowsConstants.au3> #include <WinAPIDiag.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> TrayCreateItem("") Local $idRefresh = TrayCreateItem("Refresh") TrayItemSetOnEvent( -1, _TrayStuff) Local $idGui = TrayCreateItem("Show GUI") TrayItemSetOnEvent( -1, _TrayStuff) Global $sAppName = "StreamHelper v" & (@Compiled ? FileGetVersion(@ScriptFullPath) : "uncompiled") If $sCheckForUpdates = "-1" Then If MsgBox($MB_YESNO, $sAppName, "Automatically check for updates?") = $IDYES Then IniWrite(@ScriptDir & "\Settings.ini", "Section", "CheckForUpdates", "Tomato") Else IniWrite(@ScriptDir & "\Settings.ini", "Section", "CheckForUpdates", "") EndIf EndIf $sCheckForUpdates = IniRead(@ScriptDir & "\Settings.ini", "Section", "CheckForUpdates", "-1") TrayCreateItem("") Local $idAbout = TrayCreateItem("About") TrayItemSetOnEvent( -1, _TrayStuff) Local $idExit = TrayCreateItem("Exit") TrayItemSetOnEvent( -1, _TrayStuff) Global Enum $eDisplayName, $eUrl, $ePreview, $eGame, $eCreated, $eTrayId, $eStatus, $eTime, $eOnline, $eService, $eMax Global Enum $eTwitch, $eHitbox, $eLink Global $sNew Global $aStreams[0][$eMax] Global $iLivestreamerInstalled = StringInStr(EnvGet("path"), "Livestreamer") > 0 Global Const $AUT_WM_NOTIFYICON = $WM_USER + 1 ; Application.h Global Const $AUT_NOTIFY_ICON_ID = 1 ; Application.h Global Const $PBT_APMRESUMEAUTOMATIC = 0x12 Dim $Illegals[10] = [9, "\", "/", ":", "*", "?", '"', "<", ">", "|"], $IllegalsFound = 0 Global $GameCount = 0, $StreamCount = 0 Dim $GameList[0] Dim $GamerInfo[0] AutoItWinSetTitle("AutoIt window with hopefully a unique title|Ketchup the second") Global $TRAY_ICON_GUI = WinGetHandle(AutoItWinGetTitle()) ; Internal AutoIt GUI _GDIPlus_Startup() Global $hBitmap, $hImage, $hGraphic $hBitmap = _WinAPI_CreateSolidBitmap(0, 0xFFFFFF, 16, 16) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) _MAIN() GUICreate("detect WM_POWERBROADCAST") GUIRegisterMsg($WM_POWERBROADCAST, "_PowerEvents") While 1 Sleep(3600000) WEnd #Region TWITCH Func _Twitch() ConsoleWrite("Twitching" & @CRLF) _ProgressSpecific("T") _TwitchGet($sTwitchUsername) $iTrayRefresh = True EndFunc Func _TwitchGet($sUsername) $iLimit = 100 $iOffset = 0 $sQuotedUsername = URLEncode($sUsername) $sBaseUrl = "https://api.twitch.tv/kraken/users/" & $sQuotedUsername & "/follows/channels" While True $sUrl = $sBaseUrl & OPTIONS_OFFSET_LIMIT_TWITCH($iOffset, $iLimit) $avTemp = FetchItems($sUrl, "follows") If UBound($avTemp) = 0 Then ExitLoop Local $sOptions For $iX = 0 To UBound($avTemp) -1 $oChannel = Json_ObjGet($avTemp[$iX], "channel") $sName = Json_ObjGet($oChannel, "name") $sOptions &= $sName & ',' Next $sOptions = StringTrimRight($sOptions, 1) $sUrl = 'https://api.twitch.tv/kraken/streams?channel=' & $sOptions & '&limit=' & $iLimit $oChannel = FetchItems($sUrl, "streams") For $iX = 0 To UBound($oChannel) -1 $oChannel2 = Json_ObjGet($oChannel[$iX], "channel") $sUrl = Json_ObjGet($oChannel2, "url") If $sUrl = "" Then $sUrl = "http://www.twitch.tv/" & Json_ObjGet($oChannel2, "name") $sDisplayName = Json_ObjGet($oChannel2, "display_name") $sStatus = Json_ObjGet($oChannel2, "status") $oPreview = Json_ObjGet($oChannel[$iX], "preview") $sMedium = Json_ObjGet($oPreview, "medium") $sGame = Json_ObjGet($oChannel[$iX], "game") $sCreated = Json_ObjGet($oChannel[$iX], "created_at") $asSplit = StringSplit($sCreated, "T") $asDate = StringSplit($asSplit[1], "-") $asTime = StringSplit(StringTrimRight($asSplit[2], 1), ":") $tSystemTime = DllStructCreate($tagSYSTEMTIME) $tSystemTime.Year = $asDate[1] $tSystemTime.Month = $asDate[2] $tSystemTime.Day = $asDate[3] $tSystemTime.Hour = $asTime[1] $tSystemTime.Minute = $asTime[2] $tSystemTime.Second = $asTime[3] $tFileTime = _Date_Time_SystemTimeToFileTime($tSystemTime) $tLocalTime = _Date_Time_FileTimeToLocalFileTime($tFileTime) $sTime = _Date_Time_FileTimeToStr($tLocalTime, 1) $iHours = _DateDiff("h", $sTime, _NowCalc()) $iMinutes = _DateDiff("n", $sTime, _NowCalc()) $iMinutes -= $iHours * 60 $sTime = StringFormat("%02i:%02i", $iHours, $iMinutes) $IllegalsFound = 0 For $i = 1 To $Illegals[0] - 1 If StringInStr($sGame, $Illegals[$i]) Then $sGameRemovedChar = StringReplace($sGame, $Illegals[$i], "") $IllegalsFound = 1 EndIf Next If $IllegalsFound = 1 Then $FilePath = @ScriptDir & "/Imgs/" & $sGameRemovedChar & ".bmp" If FileExists(@ScriptDir & "/Imgs/ " & $sGameRemovedChar & ".bmp") Then Sleep(10) Else $ReplaceWS = StringReplace($sGame, " ", "%20") InetGet("http://static-cdn.jtvnw.net/ttv-boxart/" & $ReplaceWS & "-272x380.jpg", $FilePath) EndIf $ConjoinInfo = $sDisplayName & "|" & $sGameRemovedChar $StreamCount += 1 $Search = _ArraySearch($GameList, $sGameRemovedChar) If @Error Then _ArrayAdd($GameList, $sGameRemovedChar) $GameCount += 1 Else Sleep(10) EndIf Else $FilePath = @ScriptDir & "/Imgs/" & $sGame & ".bmp" If FileExists(@ScriptDir & "/Imgs/ " & $sGame & ".bmp") Then Sleep(10) Else $ReplaceWS = StringReplace($sGame, " ", "%20") InetGet("http://static-cdn.jtvnw.net/ttv-boxart/" & $ReplaceWS & "-272x380.jpg", $FilePath) EndIf $ConjoinInfo = $sDisplayName & "|" & $sGame $StreamCount += 1 $Search = _ArraySearch($GameList, $sGame) If @Error Then _ArrayAdd($GameList, $sGame) $GameCount += 1 Else Sleep(10) EndIf EndIf _ArrayAdd($GamerInfo, $ConjoinInfo, 1, -1, "|") _StreamSet($sDisplayName, $sUrl, $sMedium, $sGame, $sCreated, $sTime, $sStatus, $eTwitch) Next If UBound($oChannel) <= 100 Then ExitLoop $iOffset += $iLimit WEnd $IllegalsFound = 0 FileDelete(@ScriptDir & "/Data/TwitchInfo.ini") For $i = 0 To $StreamCount - 1 $SplitData = StringSplit($GamerInfo[$i], "|") IniReadSection(@ScriptDir & "/Data/TwitchInfo.ini", $SplitData[2]) If @Error Then IniWriteSection(@ScriptDir & "/Data/TwitchInfo.ini", $SplitData[2], "") EndIf IniWrite(@ScriptDir & "/Data/TwitchInfo.ini", $SplitData[2], $SplitData[1], "1") Next Return "Potato on a Stick" EndFunc Func OPTIONS_OFFSET_LIMIT_TWITCH($iOffset, $iLimit) Return '?offset=' & $iOffset & '&limit=' & $iLimit EndFunc #EndRegion TWITCH #Region HITBOX Func _Hitbox() ConsoleWrite("Hitboxing" & @CRLF) _ProgressSpecific("H") _HitboxGet($sHitboxUsername) $iTrayRefresh = True EndFunc Func _HitboxGet($sUsername) $iLimit = 100 $iOffset = 0 Static Local $iUserID = "" If $iUserID = "" Then $sQuotedUsername = URLEncode($sUsername) $sUserUrl = "https://api.hitbox.tv/user/" & $sQuotedUsername FetchItems($sUserUrl, "", "user_id") $iUserID = @extended If $iUserID = "" Then Return EndIf $sUrl = "https://api.hitbox.tv/media/live/list?follower_id=" & $iUserID $oLivestream = FetchItems($sUrl, "livestream") If UBound($oLivestream) = 0 Then Return For $iX = 0 To UBound($oLivestream) -1 $oChannel = Json_ObjGet($oLivestream[$iX], "channel") $sUrl = Json_ObjGet($oChannel, "channel_link") $sDisplayName = Json_ObjGet($oLivestream[$iX], "media_display_name") $sStatus = Json_ObjGet($oLivestream[$iX], "media_status") $sThumbnail = Json_ObjGet($oLivestream[$iX], "media_thumbnail") $sGame = Json_ObjGet($oLivestream[$iX], "category_name") $sCreated = Json_ObjGet($oLivestream[$iX], "media_live_since") $asSplit = StringSplit($sCreated, " ") $asDate = StringSplit($asSplit[1], "-") $asTime = StringSplit($asSplit[2], ":") $tSystemTime = DllStructCreate($tagSYSTEMTIME) $tSystemTime.Year = $asDate[1] $tSystemTime.Month = $asDate[2] $tSystemTime.Day = $asDate[3] $tSystemTime.Hour = $asTime[1] $tSystemTime.Minute = $asTime[2] $tSystemTime.Second = $asTime[3] $tFileTime = _Date_Time_SystemTimeToFileTime($tSystemTime) $tLocalTime = _Date_Time_FileTimeToLocalFileTime($tFileTime) $sTime = _Date_Time_FileTimeToStr($tLocalTime, 1) $iHours = _DateDiff("h", $sTime, _NowCalc()) $iMinutes = _DateDiff("n", $sTime, _NowCalc()) $iMinutes -= $iHours * 60 $sTime = StringFormat("%02i:%02i", $iHours, $iMinutes) _StreamSet($sDisplayName, $sUrl, $sThumbnail, $sGame, $sCreated, $sTime, $sStatus, $eHitbox) Next Return "Potato on a Stick" EndFunc Func OPTIONS_OFFSET_LIMIT_HITBOX($iOffset, $iLimit) Return '&offset=' & $iOffset & '&limit=' & $iLimit EndFunc #EndRegion #Region COMMON Func FetchItems($sUrl, $sKey, $sExtendedKey = Null) Local $sRetExtended $oJSON = getJson($sUrl) If IsObj($oJSON) = False Then Return "" If IsString($sExtendedKey) Then $sRetExtended = Json_ObjGet($oJSON, $sExtendedKey) EndIf $aFollows = Json_ObjGet($oJSON, $sKey) If UBound($aFollows) > 0 Then Return SetExtended($sRetExtended, $aFollows) Else Return SetExtended($sRetExtended, "") EndIf EndFunc Func getJson($sUrl) $dJsonString = InetRead($sUrl, $INET_FORCERELOAD) If $iPrintJSON Then ConsoleWrite(BinaryToString($dJsonString) & @CRLF) $oJSON = Json_Decode(BinaryToString($dJsonString)) Return $oJSON EndFunc ;From https://www.autoitscript.com/forum/topic/95850-url-encoding/?do=findComment&comment=689045 Func URLEncode($urlText) $url = "" For $i = 1 To StringLen($urlText) $acode = Asc(StringMid($urlText, $i, 1)) Select Case ($acode >= 48 And $acode <= 57) Or _ ($acode >= 65 And $acode <= 90) Or _ ($acode >= 97 And $acode <= 122) $url = $url & StringMid($urlText, $i, 1) Case $acode = 32 $url = $url & "+" Case Else $url = $url & "%" & Hex($acode, 2) EndSelect Next Return $url EndFunc ;==>URLEncode #EndRegion #Region GUI Func _TrayRefresh() _ArraySort($aStreams, 1) For $iX = 0 To UBound($aStreams) -1 If $aStreams[$iX][$eOnline] = True Then If $aStreams[$iX][$eTrayId] = 0 Then If $aStreams[$iX][$eGame] <> "" Then $aStreams[$iX][$eTrayId] = TrayCreateItem($aStreams[$iX][$eDisplayName] & " | " & $aStreams[$iX][$eGame], -1, 0) $sNew &= $aStreams[$iX][$eDisplayName] & " | " & $aStreams[$iX][$eGame] & @CRLF Else $aStreams[$iX][$eTrayId] = TrayCreateItem($aStreams[$iX][$eDisplayName], -1, 0) $sNew &= $aStreams[$iX][$eDisplayName] & @CRLF EndIf TrayItemSetOnEvent( -1, _TrayStuff) Else TrayItemSetText($aStreams[$iX][$eTrayId], $aStreams[$iX][$eDisplayName] & " | " & $aStreams[$iX][$eGame]) EndIf $aStreams[$iX][$eOnline] = False Else If $aStreams[$iX][$eTrayId] <> 0 And $aStreams[$iX][$eService] <> $eLink Then TrayItemDelete($aStreams[$iX][$eTrayId]) $aStreams[$iX][$eTrayId] = 0 EndIf EndIf Next EndFunc Func _TrayStuff() Switch @TRAY_ID Case $idAbout Local $asText[] = ["I am unfinished", "Ouch", "Quit poking me!", "Bewbs", "Pizza", "25W lightbulb (broken)", "Estrellas Salt & Vinäger chips är godast", "Vote Pewdiepie for King of Sweden", "Vote Robbaz for King of Sweden", "Vote Anderz for King of Sweden", "I'm sorry trancexx", "Vote Knugen for King of Sweden", '"Is it creepy that I follow you, should I stop doing it?" -Xandy', '"I can''t be expected to perform under pressure!" -jaberwacky', '"The square root of 76 is brown" -One F Jef', "42", '"THERE... ARE... FOUR LIGHTS!" - Picard', '"A. I was jogging, B. your cousin''s a liar, and C. some peacocks are poisonous" - Dennis Finch', '"If you ever take advice from a duck, remember: Don''t. Ducks can''t talk. You''re probably on drugs" - Pewdiepie'] $iRandom = Random(0, UBound($asText) -1, 1) MsgBox(0, @ScriptName, "Add text here" & @CRLF & @CRLF & "Created by Alexander Samuelsson AKA AdmiralAlkex" & @CRLF & @CRLF & "[" & $iRandom +1 & "/" & UBound($asText) & "] " & $asText[$iRandom]) Case $idRefresh _MAIN() Case $idExit Exit Case $idGui _CatchArray($GameList, $Illegals) _CreateGui() Case Else Local $sUrl ;Remove this variable? For $iX = 0 To UBound($aStreams) -1 If $aStreams[$iX][$eTrayId] = @TRAY_ID Then $sUrl = $aStreams[$iX][$eUrl] ExitLoop EndIf Next If $iLivestreamerInstalled And $aStreams[$iX][$eService] <> $eLink Then Run("livestreamer " & $sUrl & " best", "", @SW_HIDE) Else ShellExecute($sUrl) EndIf EndSwitch EndFunc ;Based on https://www.autoitscript.com/forum/topic/115222-set-the-tray-icon-as-a-hicon/ Func _TraySet($sText) _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF) $hFamily = _GDIPlus_FontFamilyCreate('Arial') $hFont = _GDIPlus_FontCreate($hFamily, 9, 1, 2) $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0) $hFormat = _GDIPlus_StringFormatCreate() $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000) $aData = _GDIPlus_GraphicsMeasureString($hGraphic, $sText, $hFont, $tLayout, $hFormat) $tLayout = $aData[0] DllStructSetData($tLayout, 1, (_GDIPlus_ImageGetWidth($hImage) - DllStructGetData($tLayout, 3)) / 2) DllStructSetData($tLayout, 2, (_GDIPlus_ImageGetHeight($hImage) - DllStructGetData($tLayout, 4)) / 2) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sText, $hFont, $aData[0], $hFormat, $hBrush) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_BrushDispose($hBrush) $hIcon = _GDIPlus_HICONCreateFromBitmap($hImage) Local $tNOTIFY = DllStructCreate($tagNOTIFYICONDATA) $tNOTIFY.Size = DllStructGetSize($tNOTIFY) $tNOTIFY.hWnd = $TRAY_ICON_GUI $tNOTIFY.ID = $AUT_NOTIFY_ICON_ID $tNOTIFY.hIcon = $hIcon $tNOTIFY.Flags = BitOR($NIF_ICON, $NIF_MESSAGE) $tNOTIFY.CallbackMessage = $AUT_WM_NOTIFYICON _WinAPI_ShellNotifyIcon($NIM_MODIFY, $tNOTIFY) _WinAPI_DestroyIcon($hIcon) EndFunc Func _ProgressSpecific($sText) _TraySet($sText) EndFunc Func _MAIN() AdlibUnRegister(_MAIN) Global $sNew = "" If $sCheckForUpdates <> "" Then _CheckUpdates() If $sTwitchUsername <> "" Then _Twitch() If $sHitboxUsername <> "" Then _Hitbox() ConsoleWrite("Getters done" & @CRLF) _TrayRefresh() TraySetIcon() If $sNew <> "" Then $iSkipped = 0 While StringLen($sNew) > 240 $iPos = StringInStr($sNew, @CRLF, $STR_CASESENSE, -1) $sNew = StringLeft($sNew, $iPos -1) $iSkipped += 1 WEnd If $iSkipped > 0 Then $sNew &= @CRLF & "+" & $iSkipped & " more" EndIf TrayTip("Now streaming", $sNew, 10) EndIf AdlibRegister(_MAIN, $iRefresh) EndFunc #EndRegion GUI #Region INTENRAL INTERLECT Func _StreamSet($sDisplayName, $sUrl, $sThumbnail, $sGame, $sCreated, $sTime, $sStatus, $iService) ConsoleWrite("Found streamer: " & $sDisplayName & @CRLF) For $iIndex = 0 To UBound($aStreams) -1 If $aStreams[$iIndex][$eUrl] = $sUrl Then ExitLoop Next If $iIndex = UBound($aStreams) Then ReDim $aStreams[$iIndex +1][$eMax] EndIf $aStreams[$iIndex][$eDisplayName] = $sDisplayName $aStreams[$iIndex][$eUrl] = $sUrl $aStreams[$iIndex][$ePreview] = $sThumbnail $aStreams[$iIndex][$eGame] = $sGame $aStreams[$iIndex][$eCreated] = $sCreated $aStreams[$iIndex][$eTime] = $sTime $aStreams[$iIndex][$eStatus] = $sStatus $aStreams[$iIndex][$eOnline] = True $aStreams[$iIndex][$eService] = $iService EndFunc Func _PowerEvents($hWnd, $Msg, $wParam, $lParam) Switch $wParam Case $PBT_APMRESUMEAUTOMATIC AdlibUnRegister(_MAIN) AdlibRegister(_ComputerResumed) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_PowerEvents Func _ComputerResumed() If _WinAPI_IsInternetConnected() Then AdlibUnRegister(_ComputerResumed) _MAIN() EndIf EndFunc Func _CheckUpdates() ConsoleWrite('"Updateing"' & @CRLF) _ProgressSpecific("U") $sCheckForUpdates = "" Local $dData = InetRead("https://dl.dropboxusercontent.com/u/18344147/SoftwareUpdates/StreamHelper.txt", $INET_FORCERELOAD) Local $sData = BinaryToString($dData) $aRet = StringSplit($sData, "|") If @error Then Return If $aRet[0] <> 2 Then Return If $aRet[1] <= 1 Then Return ;Version _StreamSet("Update found! Click to open website", "https://github.com/TzarAlkex/StreamHelper/releases", "", "", "", "", "", $eLink) EndFunc #EndRegion Edited parts are Local $idGui = TrayCreateItem("Show GUI") TrayItemSetOnEvent(-1, _TrayStuff) Func _TrayStuff() ....... Case $idGui _CatchArray($GameList, $Illegals) _CreateGui() expandcollapse popupFunc _TwitchGet($sUsername) ......... $iMinutes = _DateDiff("n", $sTime, _NowCalc()) $iMinutes -= $iHours * 60 $sTime = StringFormat("%02i:%02i", $iHours, $iMinutes) $IllegalsFound = 0 For $i = 1 To $Illegals[0] - 1 If StringInStr($sGame, $Illegals[$i]) Then $sGameRemovedChar = StringReplace($sGame, $Illegals[$i], "") $IllegalsFound = 1 EndIf Next If $IllegalsFound = 1 Then $FilePath = @ScriptDir & "/Imgs/" & $sGameRemovedChar & ".bmp" If FileExists(@ScriptDir & "/Imgs/ " & $sGameRemovedChar & ".bmp") Then Sleep(10) Else $ReplaceWS = StringReplace($sGame, " ", "%20") InetGet("http://static-cdn.jtvnw.net/ttv-boxart/" & $ReplaceWS & "-272x380.jpg", $FilePath) EndIf $ConjoinInfo = $sDisplayName & "|" & $sGameRemovedChar $StreamCount += 1 $Search = _ArraySearch($GameList, $sGameRemovedChar) If @error Then _ArrayAdd($GameList, $sGameRemovedChar) $GameCount += 1 Else Sleep(10) EndIf Else $FilePath = @ScriptDir & "/Imgs/" & $sGame & ".bmp" If FileExists(@ScriptDir & "/Imgs/ " & $sGame & ".bmp") Then Sleep(10) Else $ReplaceWS = StringReplace($sGame, " ", "%20") InetGet("http://static-cdn.jtvnw.net/ttv-boxart/" & $ReplaceWS & "-272x380.jpg", $FilePath) EndIf $ConjoinInfo = $sDisplayName & "|" & $sGame $StreamCount += 1 $Search = _ArraySearch($GameList, $sGame) If @error Then _ArrayAdd($GameList, $sGame) $GameCount += 1 Else Sleep(10) EndIf EndIf _ArrayAdd($GamerInfo, $ConjoinInfo, 1, -1, "|") Func _TwitchGet($sUsername) ........ If UBound($oChannel) <= 100 Then ExitLoop $iOffset += $iLimit WEnd $IllegalsFound = 0 FileDelete(@ScriptDir & "/Data/TwitchInfo.ini") For $i = 0 To $StreamCount - 1 $SplitData = StringSplit($GamerInfo[$i], "|") IniReadSection(@ScriptDir & "/Data/TwitchInfo.ini", $SplitData[2]) If @error Then IniWriteSection(@ScriptDir & "/Data/TwitchInfo.ini", $SplitData[2], "") EndIf IniWrite(@ScriptDir & "/Data/TwitchInfo.ini", $SplitData[2], $SplitData[1], "1") Next And then the GUI is in another labeled StreamHelperGUI.au3 expandcollapse popup#include "GUIScrollbars_Ex.au3" #include <Skin.au3> #include <GDIPlus.au3> #include <Array.au3> #include <GuiButton.au3> Opt("GUIOnEventMode", 1) #include ".\Skins\Axis.au3" #include "_UskinLibrary.au3" _Uskin_LoadDLL() _USkin_Init(_Axis(True)) Global $MainGUI, $X = 200, $Count = 0, $GameGui, $iLivestreamerInstalled, $sUrl Global $ButtonX = 40, $ButtonY = 160, $GameCount, $GameList Dim $Button[4000], $img[4000], $GameName[4000] Func _CreateGui() $MainGUI = GUICreate("Stream Helper", 800, 600) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState(@SW_SHOW) $RefreshButton = GUICtrlCreateButton("Refresh", 250, 20, 300, 65) GUICtrlSetFont(-1, 16) For $i = 0 To $GameCount $Count += 1 $Button[$i] = GUICtrlCreatePic($img[$i], $ButtonX, $ButtonY, 200, 280) If $i < $GameCount Then $GameName[$i + 5] = $GameList[$i] EndIf GUICtrlSetOnEvent(-1, "_ButtonPushed") $ButtonX += 250 If $Count = 3 Then $X += 200 $ButtonX = 40 $ButtonY += 320 $Count = 0 EndIf Next For $i = 1 To $GameCount $X += 70 Next _GUIScrollbars_Generate($MainGUI, 0, $X) EndFunc ;==>_CreateGui Func _CatchArray(ByRef $GameList, ByRef $Illegals) For $z = 0 To $GameCount - 1 $img[$z] = @ScriptDir & "/Imgs/" & $GameList[$z] & ".bmp" Next EndFunc ;==>_CatchArray Func _ButtonPushed() GUISetState(@SW_DISABLE, $MainGUI) Global $ID = @GUI_CtrlId $ReadGameInfo = IniReadSection(@ScriptDir & "/Data/TwitchInfo.ini", $GameName[$ID + 1]) $GameGui = GUICreate($GameName[$ID + 1], 400, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseGameGUI") Global $ListView = GUICtrlCreateListView($GameName[$ID + 1], 10, 30, 380, 100) For $i = 1 To $ReadGameInfo[0][0] GUICtrlCreateListViewItem($ReadGameInfo[$i][0], $ListView) Next $RunStreamButton = GUICtrlCreateButton("Run Stream", 100, 150, 200, 40) GUICtrlSetOnEvent(-1, "_RunStream") GUICtrlSetFont(-1, 16) GUISetState() EndFunc ;==>_ButtonPushed Func _RunStream() GUISetState(@SW_ENABLE, $MainGUI) $ReadStream1 = ControlListView($GameGui, $GameName[$ID + 1], $ListView, "GetSelected") $ReadStream2 = ControlListView($GameGui, $GameName[$ID + 1], $ListView, "GetText", $ReadStream1) $sUrl = "www.twitch.tv/" & $ReadStream2 If $iLivestreamerInstalled = True Then Run("livestreamer " & $sUrl & " best", "", @SW_HIDE) GUIDelete($GameGui) Else ShellExecute($sUrl) GUIDelete($GameGui) EndIf EndFunc ;==>_RunStream Func _CloseGameGUI() GUIDelete($GameGui) GUISetState(@SW_ENABLE, $MainGUI) WinActivate($MainGUI) EndFunc ;==>_CloseGameGUI Func _Exit() $X = 200 $Count = 0 $ButtonX = 40 $ButtonY = 160 GUIDelete($MainGUI) EndFunc ;==>_Exit So yeah, there we have it. I didn't do the Favorites section because I got tired. I also didn't attach the Refresh button to your refresh function because I've never tried mixing a non-GuiOnEventMode with a enabled one and wasn't sure about getting it to notice the Case on the TrayMenu. You'll need to create a Directory labeled "Imgs" and another one labeled "Data" inside the ScriptDir. And disable the Skin things if you want. Edited December 3, 2015 by Damein 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...
Damein Posted December 3, 2015 Share Posted December 3, 2015 (edited) Alright.. I felt lame not doing the favorites thing and leaving it pretty much incomplete so I decided to finish that part today.Snapshots of the GUI / Favorites Section Here is the new GUI script expandcollapse popup#include "GUIScrollbars_Ex.au3" #include <Skin.au3> #include <GDIPlus.au3> #include <Array.au3> #include <GuiButton.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) #include ".\Skins\Axis.au3" #include "_UskinLibrary.au3" _Uskin_LoadDLL() _USkin_Init(_Axis(True)) Global $MainGUI, $X = 200, $Count = 0, $GameGui, $iLivestreamerInstalled, $sUrl, $FavoritesGui Global $ButtonX = 40, $ButtonY = 160, $GameCount, $GameList Dim $Button[4000], $img[4000], $GameName[4000] Func _CreateGui() $MainGUI = GUICreate("Stream Helper", 800, 600) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState(@SW_SHOW) $RefreshButton = GUICtrlCreateButton("Refresh", 60, 20, 300, 65) GUICtrlSetFont(-1, 16) $FavoritedButton = GUICtrlCreateButton("Favorites", 420, 20, 300, 65) GUICtrlSetFont(-1, 16) GUICtrlSetOnEvent(-1, "_FavoritesGUI") For $i = 0 To $GameCount $Count += 1 $Button[$i] = GUICtrlCreatePic($img[$i], $ButtonX, $ButtonY, 200, 280) If $i < $GameCount Then $GameName[$i + 6] = $GameList[$i] EndIf GUICtrlSetOnEvent(-1, "_ButtonPushed") $ButtonX += 250 If $Count = 3 Then $X += 300 $ButtonX = 40 $ButtonY += 320 $Count = 0 EndIf Next For $i = 1 To $GameCount $X += 70 Next _GUIScrollbars_Generate($MainGUI, 0, $X) EndFunc ;==>_CreateGui Func _FavoritesGui() GUISetState(@SW_DISABLE, $MainGUI) $ReadFavoritesInfo = IniReadSection(@ScriptDir & "/Data/Favorites.ini", "Favorites") $FavoritesGui = GUICreate("Favorites", 400, 400) GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseFavoritedGUI") Global $ListView = GUICtrlCreateListView("Favorited Streams", 10, 30, 380, 280) _GUICtrlListView_SetColumnWidth($ListView, 0, 350) For $i = 1 To $ReadFavoritesInfo[0][0] If $ReadFavoritesInfo[$i][1] = "0" Then $ReadFavoritesInfo[$i][1] = "Offline" EndIf GUICtrlCreateListViewItem($ReadFavoritesInfo[$i][0] & " - " & $ReadFavoritesInfo[$i][1], $ListView) Next $RunStreamButton = GUICtrlCreateButton("Run Stream", 10, 335, 180, 50) GUICtrlSetOnEvent(-1, "_RunStreamFromFavorites") GUICtrlSetFont(-1, 10) $FavoritesButton = GUICtrlCreateButton("Remove From Favorites", 210, 335, 180, 50) GUICtrlSetOnEvent(-1, "_RemoveFromFavorites") GUICtrlSetFont(-1, 10) GUISetState() EndFunc ;==>_FavoritesGui Func _CatchArray(ByRef $GameList, ByRef $Illegals) For $z = 0 To $GameCount - 1 $img[$z] = @ScriptDir & "/Imgs/" & $GameList[$z] & ".bmp" Next EndFunc ;==>_CatchArray Func _ButtonPushed() GUISetState(@SW_DISABLE, $MainGUI) Global $ID = @GUI_CtrlId $ReadGameInfo = IniReadSection(@ScriptDir & "/Data/TwitchInfo.ini", $GameName[$ID + 1]) $GameGui = GUICreate($GameName[$ID + 1], 400, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseGameGUI") Global $ListView = GUICtrlCreateListView($GameName[$ID + 1], 10, 30, 380, 100) _GUICtrlListView_SetColumnWidth($ListView, 0, 350) For $i = 1 To $ReadGameInfo[0][0] GUICtrlCreateListViewItem($ReadGameInfo[$i][0], $ListView) Next $RunStreamButton = GUICtrlCreateButton("Run Stream", 10, 150, 180, 40) GUICtrlSetOnEvent(-1, "_RunStreamFromMain") GUICtrlSetFont(-1, 14) $FavoritesButton = GUICtrlCreateButton("Add to Favorites", 210, 150, 180, 40) GUICtrlSetOnEvent(-1, "_AddToFavorites") GUICtrlSetFont(-1, 14) GUISetState() EndFunc ;==>_ButtonPushed Func _AddToFavorites() $ReadStream1 = ControlListView($GameGui, $GameName[$ID + 1], $ListView, "GetSelected") $ReadStream2 = ControlListView($GameGui, $GameName[$ID + 1], $ListView, "GetText", $ReadStream1) $ReadFavoritesData = IniReadSection(@ScriptDir & "/Data/Favorites.ini", "Favorites") For $i = 1 To $ReadFavoritesData[0][0] If $ReadStream2 = $ReadFavoritesData[$i][0] Then MsgBox(48, "Error", "Stream is already in your favorites!") Else IniWrite(@ScriptDir & "/Data/Favorites.ini", "Favorites", $ReadStream2, $GameName[$ID + 1]) EndIf Next EndFunc ;==>_AddToFavorites Func _RunStreamFromMain() GUISetState(@SW_ENABLE, $MainGUI) $ReadStream1 = ControlListView($GameGui, $GameName[$ID + 1], $ListView, "GetSelected") $ReadStream2 = ControlListView($GameGui, $GameName[$ID + 1], $ListView, "GetText", $ReadStream1) $sUrl = "www.twitch.tv/" & $ReadStream2 If $iLivestreamerInstalled = True Then Run("livestreamer " & $sUrl & " best", "", @SW_HIDE) GUIDelete($GameGui) Else ShellExecute($sUrl) GUIDelete($GameGui) EndIf EndFunc ;==>_RunStreamFromMain Func _RunStreamFromFavorites() GUISetState(@SW_ENABLE, $MainGUI) $ReadStream1 = ControlListView($FavoritesGui, "Favorited Streams", $ListView, "GetSelected") $ReadStream2 = ControlListView($FavoritesGui, "Favorited Streams", $ListView, "GetText", $ReadStream1) $SplitFavorites = StringSplit($ReadStream2, "-") $ReadStream2 = StringStripWS($SplitFavorites[1], 8) $sUrl = "www.twitch.tv/" & $ReadStream2 If $iLivestreamerInstalled = True Then Run("livestreamer " & $sUrl & " best", "", @SW_HIDE) GUIDelete($FavoritesGui) Else ShellExecute($sUrl) GUIDelete($FavoritesGui) EndIf EndFunc ;==>_RunStreamFromFavorites Func _RemoveFromFavorites() $ReadStream1 = ControlListView($FavoritesGui, "Favorited Streams", $ListView, "GetSelected") $ReadStream2 = ControlListView($FavoritesGui, "Favorited Streams", $ListView, "GetText", $ReadStream1) $ReadFavorites = IniReadSection(@ScriptDir & "/Data/Favorites.ini", "Favorites") For $i = 1 To $ReadFavorites[0][0] $SplitFavorites = StringSplit($ReadStream2, "-") $RemoveWS = StringStripWS($SplitFavorites[1], 8) If $RemoveWS = $ReadFavorites[$i][0] Then IniDelete(@ScriptDir & "/Data/Favorites.ini", "Favorites", $ReadFavorites[$i][0]) GUIDelete($FavoritesGui) _FavoritesGui() Else Sleep(10) EndIf Next EndFunc ;==>_RemoveFromFavorites Func _CloseGameGUI() GUIDelete($GameGui) GUISetState(@SW_ENABLE, $MainGUI) WinActivate($MainGUI) EndFunc ;==>_CloseGameGUI Func _CloseFavoritedGUI() GUIDelete($FavoritesGui) GUISetState(@SW_ENABLE, $MainGUI) WinActivate($MainGUI) EndFunc ;==>_CloseFavoritedGUI Func _Exit() $X = 200 $Count = 0 $ButtonX = 40 $ButtonY = 160 GUIDelete($MainGUI) EndFunc ;==>_Exit And the revised StreamHelper.au3 expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.12.0 (Stable) Author: Alexander Samuelsson AKA AdmiralAlkex Script Function: Stuff #ce ---------------------------------------------------------------------------- $sTwitchUsername = IniRead(@ScriptDir & "\Settings.ini", "Section", "Twitch", "") ;NAME ON TWITCH $sHitboxUsername = IniRead(@ScriptDir & "\Settings.ini", "Section", "Hitbox", "") ;NAME ON HITBOX $iRefresh = IniRead(@ScriptDir & "\Settings.ini", "Section", "RefreshMinutes", 10) * 60000 ;HOW MANY TIME UNITS BETWEEN EVERY CHECK FOR NEW STREAMS $iPrintJSON = IniRead(@ScriptDir & "\Settings.ini", "Section", "PrintJSON", "") ;PRINT ON JSON $sCheckForUpdates = IniRead(@ScriptDir & "\Settings.ini", "Section", "CheckForUpdates", "-1") ;JUST TYPE SOMETHING TO CHECK Opt("TrayMenuMode", 3) Opt("TrayOnEventMode", 1) #include <AutoItConstants.au3> #include "Json.au3" #include "StreamHelperGUI.au3" #include <Array.au3> #include <InetConstants.au3> #include <Date.au3> #include <GDIPlus.au3> #include <WinAPIShellEx.au3> #include <WindowsConstants.au3> #include <WinAPIDiag.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> TrayCreateItem("") Local $idRefresh = TrayCreateItem("Refresh") TrayItemSetOnEvent(-1, _TrayStuff) Local $idGui = TrayCreateItem("Show GUI") TrayItemSetOnEvent(-1, _TrayStuff) Global $sAppName = "StreamHelper v" & (@Compiled ? FileGetVersion(@ScriptFullPath) : "uncompiled") If $sCheckForUpdates = "-1" Then If MsgBox($MB_YESNO, $sAppName, "Automatically check for updates?") = $IDYES Then IniWrite(@ScriptDir & "\Settings.ini", "Section", "CheckForUpdates", "Tomato") Else IniWrite(@ScriptDir & "\Settings.ini", "Section", "CheckForUpdates", "") EndIf EndIf $sCheckForUpdates = IniRead(@ScriptDir & "\Settings.ini", "Section", "CheckForUpdates", "-1") TrayCreateItem("") Local $idAbout = TrayCreateItem("About") TrayItemSetOnEvent(-1, _TrayStuff) Local $idExit = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, _TrayStuff) Global Enum $eDisplayName, $eUrl, $ePreview, $eGame, $eCreated, $eTrayId, $eStatus, $eTime, $eOnline, $eService, $eMax Global Enum $eTwitch, $eHitbox, $eLink Global $sNew Global $aStreams[0][$eMax] Global $iLivestreamerInstalled = StringInStr(EnvGet("path"), "Livestreamer") > 0 Global Const $AUT_WM_NOTIFYICON = $WM_USER + 1 ; Application.h Global Const $AUT_NOTIFY_ICON_ID = 1 ; Application.h Global Const $PBT_APMRESUMEAUTOMATIC = 0x12 Dim $Illegals[10] = [9, "\", "/", ":", "*", "?", '"', "<", ">", "|"], $IllegalsFound = 0 Global $GameCount = 0, $StreamCount = 0, $StreamFound Dim $GameList[0] Dim $GamerInfo[0] AutoItWinSetTitle("AutoIt window with hopefully a unique title|Ketchup the second") Global $TRAY_ICON_GUI = WinGetHandle(AutoItWinGetTitle()) ; Internal AutoIt GUI _GDIPlus_Startup() Global $hBitmap, $hImage, $hGraphic $hBitmap = _WinAPI_CreateSolidBitmap(0, 0xFFFFFF, 16, 16) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) _MAIN() GUICreate("detect WM_POWERBROADCAST") GUIRegisterMsg($WM_POWERBROADCAST, "_PowerEvents") While 1 Sleep(3600000) WEnd #Region TWITCH Func _Twitch() ConsoleWrite("Twitching" & @CRLF) _ProgressSpecific("T") _TwitchGet($sTwitchUsername) $iTrayRefresh = True EndFunc ;==>_Twitch Func _TwitchGet($sUsername) $iLimit = 100 $iOffset = 0 $sQuotedUsername = URLEncode($sUsername) $sBaseUrl = "https://api.twitch.tv/kraken/users/" & $sQuotedUsername & "/follows/channels" While True $sUrl = $sBaseUrl & OPTIONS_OFFSET_LIMIT_TWITCH($iOffset, $iLimit) $avTemp = FetchItems($sUrl, "follows") If UBound($avTemp) = 0 Then ExitLoop Local $sOptions For $iX = 0 To UBound($avTemp) - 1 $oChannel = Json_ObjGet($avTemp[$iX], "channel") $sName = Json_ObjGet($oChannel, "name") $sOptions &= $sName & ',' Next $sOptions = StringTrimRight($sOptions, 1) $sUrl = 'https://api.twitch.tv/kraken/streams?channel=' & $sOptions & '&limit=' & $iLimit $oChannel = FetchItems($sUrl, "streams") For $iX = 0 To UBound($oChannel) - 1 $oChannel2 = Json_ObjGet($oChannel[$iX], "channel") $sUrl = Json_ObjGet($oChannel2, "url") If $sUrl = "" Then $sUrl = "http://www.twitch.tv/" & Json_ObjGet($oChannel2, "name") $sDisplayName = Json_ObjGet($oChannel2, "display_name") $sStatus = Json_ObjGet($oChannel2, "status") $oPreview = Json_ObjGet($oChannel[$iX], "preview") $sMedium = Json_ObjGet($oPreview, "medium") $sGame = Json_ObjGet($oChannel[$iX], "game") $sCreated = Json_ObjGet($oChannel[$iX], "created_at") $asSplit = StringSplit($sCreated, "T") $asDate = StringSplit($asSplit[1], "-") $asTime = StringSplit(StringTrimRight($asSplit[2], 1), ":") $tSystemTime = DllStructCreate($tagSYSTEMTIME) $tSystemTime.Year = $asDate[1] $tSystemTime.Month = $asDate[2] $tSystemTime.Day = $asDate[3] $tSystemTime.Hour = $asTime[1] $tSystemTime.Minute = $asTime[2] $tSystemTime.Second = $asTime[3] $tFileTime = _Date_Time_SystemTimeToFileTime($tSystemTime) $tLocalTime = _Date_Time_FileTimeToLocalFileTime($tFileTime) $sTime = _Date_Time_FileTimeToStr($tLocalTime, 1) $iHours = _DateDiff("h", $sTime, _NowCalc()) $iMinutes = _DateDiff("n", $sTime, _NowCalc()) $iMinutes -= $iHours * 60 $sTime = StringFormat("%02i:%02i", $iHours, $iMinutes) $IllegalsFound = 0 For $i = 1 To $Illegals[0] - 1 If StringInStr($sGame, $Illegals[$i]) Then $sGameRemovedChar = StringReplace($sGame, $Illegals[$i], "") $IllegalsFound = 1 EndIf Next If $IllegalsFound = 1 Then $FilePath = @ScriptDir & "/Imgs/" & $sGameRemovedChar & ".bmp" If FileExists(@ScriptDir & "/Imgs/ " & $sGameRemovedChar & ".bmp") Then Sleep(10) Else $ReplaceWS = StringReplace($sGame, " ", "%20") InetGet("http://static-cdn.jtvnw.net/ttv-boxart/" & $ReplaceWS & "-272x380.jpg", $FilePath) EndIf $ConjoinInfo = $sDisplayName & "|" & $sGameRemovedChar $StreamCount += 1 $Search = _ArraySearch($GameList, $sGameRemovedChar) If @error Then _ArrayAdd($GameList, $sGameRemovedChar) $GameCount += 1 Else Sleep(10) EndIf Else $FilePath = @ScriptDir & "/Imgs/" & $sGame & ".bmp" If FileExists(@ScriptDir & "/Imgs/ " & $sGame & ".bmp") Then Sleep(10) Else $ReplaceWS = StringReplace($sGame, " ", "%20") InetGet("http://static-cdn.jtvnw.net/ttv-boxart/" & $ReplaceWS & "-272x380.jpg", $FilePath) EndIf $ConjoinInfo = $sDisplayName & "|" & $sGame $StreamCount += 1 $Search = _ArraySearch($GameList, $sGame) If @error Then _ArrayAdd($GameList, $sGame) $GameCount += 1 Else Sleep(10) EndIf EndIf _ArrayAdd($GamerInfo, $ConjoinInfo, 1, -1, "|") _StreamSet($sDisplayName, $sUrl, $sMedium, $sGame, $sCreated, $sTime, $sStatus, $eTwitch) Next If UBound($oChannel) <= 100 Then ExitLoop $iOffset += $iLimit WEnd $IllegalsFound = 0 FileDelete(@ScriptDir & "/Data/TwitchInfo.ini") For $i = 0 To $StreamCount - 1 $SplitData = StringSplit($GamerInfo[$i], "|") IniReadSection(@ScriptDir & "/Data/TwitchInfo.ini", $SplitData[2]) If @error Then IniWriteSection(@ScriptDir & "/Data/TwitchInfo.ini", $SplitData[2], "") EndIf IniWrite(@ScriptDir & "/Data/TwitchInfo.ini", $SplitData[2], $SplitData[1], "1") Next $ReadFavorites = IniReadSection(@ScriptDir & "/Data/Favorites.ini", "Favorites") For $a = 1 To $ReadFavorites[0][0] For $b = 0 To $StreamCount - 1 $SplitData = StringSplit($GamerInfo[$b], "|") If $ReadFavorites[$a][0] = $SplitData[1] Then IniWrite(@ScriptDir & "/Data/Favorites.ini", "Favorites", $ReadFavorites[$a][0], $SplitData[2]) $StreamFound = 1 EndIf Next If $StreamFound = 1 Then Sleep(10) Else IniWrite(@ScriptDir & "/Data/Favorites.ini", "Favorites", $ReadFavorites[$a][0], "0") EndIf $StreamFound = 0 Next Return "Potato on a Stick" EndFunc ;==>_TwitchGet Func OPTIONS_OFFSET_LIMIT_TWITCH($iOffset, $iLimit) Return '?offset=' & $iOffset & '&limit=' & $iLimit EndFunc ;==>OPTIONS_OFFSET_LIMIT_TWITCH #EndRegion TWITCH #Region HITBOX Func _Hitbox() ConsoleWrite("Hitboxing" & @CRLF) _ProgressSpecific("H") _HitboxGet($sHitboxUsername) $iTrayRefresh = True EndFunc ;==>_Hitbox Func _HitboxGet($sUsername) $iLimit = 100 $iOffset = 0 Static Local $iUserID = "" If $iUserID = "" Then $sQuotedUsername = URLEncode($sUsername) $sUserUrl = "https://api.hitbox.tv/user/" & $sQuotedUsername FetchItems($sUserUrl, "", "user_id") $iUserID = @extended If $iUserID = "" Then Return EndIf $sUrl = "https://api.hitbox.tv/media/live/list?follower_id=" & $iUserID $oLivestream = FetchItems($sUrl, "livestream") If UBound($oLivestream) = 0 Then Return For $iX = 0 To UBound($oLivestream) - 1 $oChannel = Json_ObjGet($oLivestream[$iX], "channel") $sUrl = Json_ObjGet($oChannel, "channel_link") $sDisplayName = Json_ObjGet($oLivestream[$iX], "media_display_name") $sStatus = Json_ObjGet($oLivestream[$iX], "media_status") $sThumbnail = Json_ObjGet($oLivestream[$iX], "media_thumbnail") $sGame = Json_ObjGet($oLivestream[$iX], "category_name") $sCreated = Json_ObjGet($oLivestream[$iX], "media_live_since") $asSplit = StringSplit($sCreated, " ") $asDate = StringSplit($asSplit[1], "-") $asTime = StringSplit($asSplit[2], ":") $tSystemTime = DllStructCreate($tagSYSTEMTIME) $tSystemTime.Year = $asDate[1] $tSystemTime.Month = $asDate[2] $tSystemTime.Day = $asDate[3] $tSystemTime.Hour = $asTime[1] $tSystemTime.Minute = $asTime[2] $tSystemTime.Second = $asTime[3] $tFileTime = _Date_Time_SystemTimeToFileTime($tSystemTime) $tLocalTime = _Date_Time_FileTimeToLocalFileTime($tFileTime) $sTime = _Date_Time_FileTimeToStr($tLocalTime, 1) $iHours = _DateDiff("h", $sTime, _NowCalc()) $iMinutes = _DateDiff("n", $sTime, _NowCalc()) $iMinutes -= $iHours * 60 $sTime = StringFormat("%02i:%02i", $iHours, $iMinutes) _StreamSet($sDisplayName, $sUrl, $sThumbnail, $sGame, $sCreated, $sTime, $sStatus, $eHitbox) Next Return "Potato on a Stick" EndFunc ;==>_HitboxGet Func OPTIONS_OFFSET_LIMIT_HITBOX($iOffset, $iLimit) Return '&offset=' & $iOffset & '&limit=' & $iLimit EndFunc ;==>OPTIONS_OFFSET_LIMIT_HITBOX #EndRegion HITBOX #Region COMMON Func FetchItems($sUrl, $sKey, $sExtendedKey = Null) Local $sRetExtended $oJSON = getJson($sUrl) If IsObj($oJSON) = False Then Return "" If IsString($sExtendedKey) Then $sRetExtended = Json_ObjGet($oJSON, $sExtendedKey) EndIf $aFollows = Json_ObjGet($oJSON, $sKey) If UBound($aFollows) > 0 Then Return SetExtended($sRetExtended, $aFollows) Else Return SetExtended($sRetExtended, "") EndIf EndFunc ;==>FetchItems Func getJson($sUrl) $dJsonString = InetRead($sUrl, $INET_FORCERELOAD) If $iPrintJSON Then ConsoleWrite(BinaryToString($dJsonString) & @CRLF) $oJSON = Json_Decode(BinaryToString($dJsonString)) Return $oJSON EndFunc ;==>getJson ;From https://www.autoitscript.com/forum/topic/95850-url-encoding/?do=findComment&comment=689045 Func URLEncode($urlText) $url = "" For $i = 1 To StringLen($urlText) $acode = Asc(StringMid($urlText, $i, 1)) Select Case ($acode >= 48 And $acode <= 57) Or _ ($acode >= 65 And $acode <= 90) Or _ ($acode >= 97 And $acode <= 122) $url = $url & StringMid($urlText, $i, 1) Case $acode = 32 $url = $url & "+" Case Else $url = $url & "%" & Hex($acode, 2) EndSelect Next Return $url EndFunc ;==>URLEncode #EndRegion COMMON #Region GUI Func _TrayRefresh() _ArraySort($aStreams, 1) For $iX = 0 To UBound($aStreams) - 1 If $aStreams[$iX][$eOnline] = True Then If $aStreams[$iX][$eTrayId] = 0 Then If $aStreams[$iX][$eGame] <> "" Then $aStreams[$iX][$eTrayId] = TrayCreateItem($aStreams[$iX][$eDisplayName] & " | " & $aStreams[$iX][$eGame], -1, 0) $sNew &= $aStreams[$iX][$eDisplayName] & " | " & $aStreams[$iX][$eGame] & @CRLF Else $aStreams[$iX][$eTrayId] = TrayCreateItem($aStreams[$iX][$eDisplayName], -1, 0) $sNew &= $aStreams[$iX][$eDisplayName] & @CRLF EndIf TrayItemSetOnEvent(-1, _TrayStuff) Else TrayItemSetText($aStreams[$iX][$eTrayId], $aStreams[$iX][$eDisplayName] & " | " & $aStreams[$iX][$eGame]) EndIf $aStreams[$iX][$eOnline] = False Else If $aStreams[$iX][$eTrayId] <> 0 And $aStreams[$iX][$eService] <> $eLink Then TrayItemDelete($aStreams[$iX][$eTrayId]) $aStreams[$iX][$eTrayId] = 0 EndIf EndIf Next EndFunc ;==>_TrayRefresh Func _TrayStuff() Switch @TRAY_ID Case $idAbout Local $asText[] = ["I am unfinished", "Ouch", "Quit poking me!", "Bewbs", "Pizza", "25W lightbulb (broken)", "Estrellas Salt & Vinäger chips är godast", "Vote Pewdiepie for King of Sweden", "Vote Robbaz for King of Sweden", "Vote Anderz for King of Sweden", "I'm sorry trancexx", "Vote Knugen for King of Sweden", '"Is it creepy that I follow you, should I stop doing it?" -Xandy', '"I can''t be expected to perform under pressure!" -jaberwacky', '"The square root of 76 is brown" -One F Jef', "42", '"THERE... ARE... FOUR LIGHTS!" - Picard', '"A. I was jogging, B. your cousin''s a liar, and C. some peacocks are poisonous" - Dennis Finch', '"If you ever take advice from a duck, remember: Don''t. Ducks can''t talk. You''re probably on drugs" - Pewdiepie'] $iRandom = Random(0, UBound($asText) - 1, 1) MsgBox(0, @ScriptName, "Add text here" & @CRLF & @CRLF & "Created by Alexander Samuelsson AKA AdmiralAlkex" & @CRLF & @CRLF & "[" & $iRandom + 1 & "/" & UBound($asText) & "] " & $asText[$iRandom]) Case $idRefresh _MAIN() Case $idExit Exit Case $idGui _CatchArray($GameList, $Illegals) _CreateGui() Case Else Local $sUrl ;Remove this variable? For $iX = 0 To UBound($aStreams) - 1 If $aStreams[$iX][$eTrayId] = @TRAY_ID Then $sUrl = $aStreams[$iX][$eUrl] ExitLoop EndIf Next If $iLivestreamerInstalled And $aStreams[$iX][$eService] <> $eLink Then Run("livestreamer " & $sUrl & " best", "", @SW_HIDE) Else ShellExecute($sUrl) EndIf EndSwitch EndFunc ;==>_TrayStuff ;Based on https://www.autoitscript.com/forum/topic/115222-set-the-tray-icon-as-a-hicon/ Func _TraySet($sText) _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF) $hFamily = _GDIPlus_FontFamilyCreate('Arial') $hFont = _GDIPlus_FontCreate($hFamily, 9, 1, 2) $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0) $hFormat = _GDIPlus_StringFormatCreate() $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000) $aData = _GDIPlus_GraphicsMeasureString($hGraphic, $sText, $hFont, $tLayout, $hFormat) $tLayout = $aData[0] DllStructSetData($tLayout, 1, (_GDIPlus_ImageGetWidth($hImage) - DllStructGetData($tLayout, 3)) / 2) DllStructSetData($tLayout, 2, (_GDIPlus_ImageGetHeight($hImage) - DllStructGetData($tLayout, 4)) / 2) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sText, $hFont, $aData[0], $hFormat, $hBrush) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_BrushDispose($hBrush) $hIcon = _GDIPlus_HICONCreateFromBitmap($hImage) Local $tNOTIFY = DllStructCreate($tagNOTIFYICONDATA) $tNOTIFY.Size = DllStructGetSize($tNOTIFY) $tNOTIFY.hWnd = $TRAY_ICON_GUI $tNOTIFY.ID = $AUT_NOTIFY_ICON_ID $tNOTIFY.hIcon = $hIcon $tNOTIFY.Flags = BitOR($NIF_ICON, $NIF_MESSAGE) $tNOTIFY.CallbackMessage = $AUT_WM_NOTIFYICON _WinAPI_ShellNotifyIcon($NIM_MODIFY, $tNOTIFY) _WinAPI_DestroyIcon($hIcon) EndFunc ;==>_TraySet Func _ProgressSpecific($sText) _TraySet($sText) EndFunc ;==>_ProgressSpecific Func _MAIN() AdlibUnRegister(_MAIN) Global $sNew = "" If $sCheckForUpdates <> "" Then _CheckUpdates() If $sTwitchUsername <> "" Then _Twitch() If $sHitboxUsername <> "" Then _Hitbox() ConsoleWrite("Getters done" & @CRLF) _TrayRefresh() TraySetIcon() If $sNew <> "" Then $iSkipped = 0 While StringLen($sNew) > 240 $iPos = StringInStr($sNew, @CRLF, $STR_CASESENSE, -1) $sNew = StringLeft($sNew, $iPos - 1) $iSkipped += 1 WEnd If $iSkipped > 0 Then $sNew &= @CRLF & "+" & $iSkipped & " more" EndIf TrayTip("Now streaming", $sNew, 10) EndIf AdlibRegister(_MAIN, $iRefresh) EndFunc ;==>_MAIN #EndRegion GUI #Region INTENRAL INTERLECT Func _StreamSet($sDisplayName, $sUrl, $sThumbnail, $sGame, $sCreated, $sTime, $sStatus, $iService) ConsoleWrite("Found streamer: " & $sDisplayName & @CRLF) For $iIndex = 0 To UBound($aStreams) - 1 If $aStreams[$iIndex][$eUrl] = $sUrl Then ExitLoop Next If $iIndex = UBound($aStreams) Then ReDim $aStreams[$iIndex + 1][$eMax] EndIf $aStreams[$iIndex][$eDisplayName] = $sDisplayName $aStreams[$iIndex][$eUrl] = $sUrl $aStreams[$iIndex][$ePreview] = $sThumbnail $aStreams[$iIndex][$eGame] = $sGame $aStreams[$iIndex][$eCreated] = $sCreated $aStreams[$iIndex][$eTime] = $sTime $aStreams[$iIndex][$eStatus] = $sStatus $aStreams[$iIndex][$eOnline] = True $aStreams[$iIndex][$eService] = $iService EndFunc ;==>_StreamSet Func _PowerEvents($hWnd, $Msg, $wParam, $lParam) Switch $wParam Case $PBT_APMRESUMEAUTOMATIC AdlibUnRegister(_MAIN) AdlibRegister(_ComputerResumed) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_PowerEvents Func _ComputerResumed() If _WinAPI_IsInternetConnected() Then AdlibUnRegister(_ComputerResumed) _MAIN() EndIf EndFunc ;==>_ComputerResumed Func _CheckUpdates() ConsoleWrite('"Updateing"' & @CRLF) _ProgressSpecific("U") $sCheckForUpdates = "" Local $dData = InetRead("https://dl.dropboxusercontent.com/u/18344147/SoftwareUpdates/StreamHelper.txt", $INET_FORCERELOAD) Local $sData = BinaryToString($dData) $aRet = StringSplit($sData, "|") If @error Then Return If $aRet[0] <> 2 Then Return If $aRet[1] <= 1 Then Return ;Version _StreamSet("Update found! Click to open website", "https://github.com/TzarAlkex/StreamHelper/releases", "", "", "", "", "", $eLink) EndFunc ;==>_CheckUpdates #EndRegion INTENRAL INTERLECT Which now also has the added $ReadFavorites = IniReadSection(@ScriptDir & "/Data/Favorites.ini", "Favorites") For $a = 1 To $ReadFavorites[0][0] For $b = 0 To $StreamCount - 1 $SplitData = StringSplit($GamerInfo[$b], "|") If $ReadFavorites[$a][0] = $SplitData[1] Then IniWrite(@ScriptDir & "/Data/Favorites.ini", "Favorites", $ReadFavorites[$a][0], $SplitData[2]) $StreamFound = 1 EndIf Next If $StreamFound = 1 Then Sleep(10) Else IniWrite(@ScriptDir & "/Data/Favorites.ini", "Favorites", $ReadFavorites[$a][0], "0") EndIf $StreamFound = 0 Next I think it works quite nicely Unless you decide to write your own version I'll probably clean up the GUI a bit. Edited December 3, 2015 by Damein 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...
dynamitemedia Posted January 5, 2016 Share Posted January 5, 2016 this is great ! can you put this in a zip file? i cant get the gui to do anythingin your first post you had more images in the gui, is that still possible in the second version? argumentum 1 Link to comment Share on other sites More sharing options...
Damein Posted January 6, 2016 Share Posted January 6, 2016 Yeah, I can throw it all in a zip. And the images only show up when anyone your following is playing. So in the first image I had a lot more people I was following playing various games where as the 2nd one only a few games were being played so there was no reason to show them all. StreamHelper_Source w GUI.rar 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...
dynamitemedia Posted January 6, 2016 Share Posted January 6, 2016 so a couple of questions...1.) did you set the images? or can they be retrieved by the api? -- which file pulls this info if i want to change it2.) why when i start it i see twitching, with no images. and if i close the gui and reopen the images will be there? when i hit refresh it does nothing.3.) how or where do i change the code for a wider or full screen look, and go with more images across the row? -- and again which file do i need to make these changes4.) does this paginate or all using scroll?this is pretty slick for sure! Link to comment Share on other sites More sharing options...
Damein Posted January 7, 2016 Share Posted January 7, 2016 1:I did not set the images, the images get downloaded only if the people you are following are playing that specific game. That is included in the StreamHelper.au3 in this section starting on line 171 $FilePath = @ScriptDir & "/Imgs/" & $sGame & ".bmp" If FileExists(@ScriptDir & "/Imgs/ " & $sGame & ".bmp") Then Sleep(10) Else $ReplaceWS = StringReplace($sGame, " ", "%20") InetGet("http://static-cdn.jtvnw.net/ttv-boxart/" & $ReplaceWS & "-272x380.jpg", $FilePath) EndIf $ConjoinInfo = $sDisplayName & "|" & $sGame $StreamCount += 1 2:As for the no images until you close / re-open I don't recall this happening and cannot test at the moment. Might be a bug that I didn't encounter, not sure. 3:The file in question would be the StreamHelperGUI.au3 For the making the GUI larger, just simply adjust the Width & Height found on line 23. But know that if you do that you will have to adjust everything else too. If this is something you really want and aren't sure how to accomplish it let me know and I can adjust the script for you. 4:Never used the word paginate before but if you are referring to how it aligns the images / decides how many to input that's done in a couple different ways. Step 1: Found in StreamHelper.au3 on line 193 and 212 (Depending on an IF/Else statement) it adds +1 to a variable (GameCount) to determine how many different types of games are being played (IE: How many different images we need to produce) Step 2: Found in StreamHelperGUI.au3 on line 34 is a For statement going from 0 to X depending on how many games we found in StreamHelper.au3. It goes up +1 each time (Obviously) and then adds +250 to the X axis until it reaches 3 (Currently how many games are shown per row) and then resets the X axis to 40 (Starting Point) and sets a new Y axis to +320 to account for a new row. It then adds +300 to the variable X which is used to determine the length of the Scrollbar needed to view all of the images which is found on line 56 in StreamHelperGUI.au3 still. Hope that clears it all up. If anything isn't clear let me know and I'll try to rephrase or anything. dynamitemedia 1 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...
dynamitemedia Posted January 8, 2016 Share Posted January 8, 2016 # 3 and #4 thanks yes i would really like the option of clicking it to full screen and when you do that would then change the rows and columns of videos.actually what i meant was pagination.... like only showing 20 on each page and clicking an arrow to go back and forth a page of thumbnail images Link to comment Share on other sites More sharing options...
Damein Posted January 9, 2016 Share Posted January 9, 2016 3 / 4 you would have to change everything still. Give me a few days and I'll look into it. The pagination can be easily done as well using a new Function... something like this. Func _Next() If $CurrentRow = 1 Then For $i = 1 to 20 GuiCtrlSetState($Img[$i] (I don't recall the Var atm), $GUI_SHOW) Next For $i = 21 To X (How many overall images we have) GuiCtrlSetState($Img[$i] (I don't recall the Var atm), $GUI_HIDE) Next EndIf ; Then create seperate If statements depending on the current row displayed. ; This isn't 100% how you would do it, I wrote it all free hand ; Just an idea of how it would work EndFunc If this is something you also don't want to try and tackle solo when I look at the GUI I'll look at that as well. 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...
Damein Posted January 9, 2016 Share Posted January 9, 2016 So I started looking into it and I realized I'm not quite sure how to adjust how many images to have in the row according to your resolution. Because what if someone has a much smaller resolution than its setup for and it won't show properly. There may be a way to decipher it via using like @Width and @Height and than doing some math.. I'll have to think about it. 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...
Damein Posted January 9, 2016 Share Posted January 9, 2016 Updated:The GUI now has 4 different sizes depending on 4 different variations of resolutions. Obviously this isn't exact because someone could have a resolution in between one of the preprogrammed ones or even higher. But since I am not like.. mass producing the software or anything I don't mind just doing it as such. The GUI is also resizeable and the number of items per row is matched by your resolution as well. In regards to dynamitemedia, you should be able to see what I changed to accomplish this below. If you wish to add more items per row you will need to change the sizes of the images to allow more images to fit into the GUI.expandcollapse popup#include "GUIScrollbars_Ex.au3" #include <Skin.au3> #include <GDIPlus.au3> #include <Array.au3> #include <GuiButton.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) #include ".\Skins\Axis.au3" #include "_UskinLibrary.au3" _Uskin_LoadDLL() _USkin_Init(_Axis(True)) Global $MainGUI, $X = 200, $Count = 0, $GameGui, $iLivestreamerInstalled, $sUrl, $FavoritesGui Global $ButtonX = 20, $ButtonY = 160, $GameCount, $GameList Dim $Button[4000], $img[4000], $GameName[4000] $Width = @DesktopWidth $Height = @DesktopHeight If $Width >= 1000 And $Width < 1200 Then $MaxInaRow = 3 $ButtonX = 60 EndIf If $Width >= 1200 And $Width < 1300 Then $MaxInaRow = 4 $ButtonX = 50 EndIf If $Width >= 1300 And $Width < 1600 Then $MaxInaRow = 5 $ButtonX = 25 EndIf If $Width >= 1600 And $Width < 2000 Then $MaxInaRow = 6 $ButtonX = 20 EndIf Func _CreateGui() $MainGUI = GUICreate("Stream Helper", $Width - 100, $Height - 100, -1, -1, BitOR($WS_SIZEBOX, $WS_SYSMENU)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState(@SW_SHOW) If $MaxInaRow = 6 Then $RefreshButton = GUICtrlCreateButton("Refresh", $Width - 1200, 30, 300, 65) ElseIf $MaxInaRow = 5 Then $RefreshButton = GUICtrlCreateButton("Refresh", $Width - 1050, 30, 300, 65) ElseIf $MaxInaRow = 4 Then $RefreshButton = GUICtrlCreateButton("Refresh", $Width - 1000, 30, 300, 65) ElseIf $MaxInaRow = 3 Then $RefreshButton = GUICtrlCreateButton("Refresh", $Width - 900, 30, 300, 65) EndIf GUICtrlSetResizing(-1, $GUI_DOCKAUTO) GUICtrlSetFont(-1, 16) If $MaxInaRow = 6 Then $FavoritedButton = GUICtrlCreateButton("Favorites", $Width - 850, 30, 300, 65) ElseIf $MaxInaRow = 5 Then $FavoritedButton = GUICtrlCreateButton("Favorites", $Width - 700, 30, 300, 65) ElseIf $MaxInaRow = 4 Then $FavoritedButton = GUICtrlCreateButton("Favorites", $Width - 650, 30, 300, 65) ElseIf $MaxInaRow = 3 Then $FavoritedButton = GUICtrlCreateButton("Favorites", $Width - 550, 30, 300, 65) EndIf GUICtrlSetResizing(-1, $GUI_DOCKAUTO) GUICtrlSetFont(-1, 16) GUICtrlSetOnEvent(-1, "_FavoritesGUI") For $i = 0 To $GameCount $Count += 1 $Button[$i] = GUICtrlCreatePic($img[$i], $ButtonX, $ButtonY, 200, 280) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) If $i < $GameCount Then $GameName[$i + 6] = $GameList[$i] EndIf GUICtrlSetOnEvent(-1, "_ButtonPushed") If $MaxInaRow = 3 Then $ButtonX += 290 ElseIf $MaxInaRow = 4 Then $ButtonX += 290 ElseIf $MaxInaRow = 5 Then $ButtonX += 250 ElseIf $MaxInaRow = 6 Then $ButtonX += 250 EndIf If $Count = $MaxInaRow Then $X += 300 If $MaxInaRow = 3 Then $ButtonX = 60 ElseIf $MaxInaRow = 4 Then $ButtonX = 50 ElseIf $MaxInaRow = 5 Then $ButtonX = 25 ElseIf $MaxInaRow = 6 Then $ButtonX = 20 EndIf $ButtonY += 320 $Count = 0 EndIf Next For $i = 1 To $GameCount $X += 70 Next _GUIScrollbars_Generate($MainGUI, 0, $X) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) EndFunc ;==>_CreateGui Func _FavoritesGui() GUISetState(@SW_DISABLE, $MainGUI) $ReadFavoritesInfo = IniReadSection(@ScriptDir & "/Data/Favorites.ini", "Favorites") $FavoritesGui = GUICreate("Favorites", 400, 400) GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseFavoritedGUI") Global $ListView = GUICtrlCreateListView("Favorited Streams", 10, 30, 380, 280) _GUICtrlListView_SetColumnWidth($ListView, 0, 350) For $i = 1 To $ReadFavoritesInfo[0][0] If $ReadFavoritesInfo[$i][1] = "0" Then $ReadFavoritesInfo[$i][1] = "Offline" EndIf GUICtrlCreateListViewItem($ReadFavoritesInfo[$i][0] & " - " & $ReadFavoritesInfo[$i][1], $ListView) Next $RunStreamButton = GUICtrlCreateButton("Run Stream", 10, 335, 180, 50) GUICtrlSetOnEvent(-1, "_RunStreamFromFavorites") GUICtrlSetFont(-1, 10) $FavoritesButton = GUICtrlCreateButton("Remove From Favorites", 210, 335, 180, 50) GUICtrlSetOnEvent(-1, "_RemoveFromFavorites") GUICtrlSetFont(-1, 10) GUISetState() EndFunc ;==>_FavoritesGui Func _CatchArray(ByRef $GameList, ByRef $Illegals) For $z = 0 To $GameCount - 1 $img[$z] = @ScriptDir & "/Imgs/" & $GameList[$z] & ".bmp" Next EndFunc ;==>_CatchArray Func _ButtonPushed() GUISetState(@SW_DISABLE, $MainGUI) Global $ID = @GUI_CtrlId $ReadGameInfo = IniReadSection(@ScriptDir & "/Data/TwitchInfo.ini", $GameName[$ID + 1]) $GameGui = GUICreate($GameName[$ID + 1], 400, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseGameGUI") Global $ListView = GUICtrlCreateListView($GameName[$ID + 1], 10, 30, 380, 100) _GUICtrlListView_SetColumnWidth($ListView, 0, 350) For $i = 1 To $ReadGameInfo[0][0] GUICtrlCreateListViewItem($ReadGameInfo[$i][0], $ListView) Next $RunStreamButton = GUICtrlCreateButton("Run Stream", 10, 150, 180, 40) GUICtrlSetOnEvent(-1, "_RunStreamFromMain") GUICtrlSetFont(-1, 14) $FavoritesButton = GUICtrlCreateButton("Add to Favorites", 210, 150, 180, 40) GUICtrlSetOnEvent(-1, "_AddToFavorites") GUICtrlSetFont(-1, 14) GUISetState() EndFunc ;==>_ButtonPushed Func _AddToFavorites() $ReadStream1 = ControlListView($GameGui, $GameName[$ID + 1], $ListView, "GetSelected") $ReadStream2 = ControlListView($GameGui, $GameName[$ID + 1], $ListView, "GetText", $ReadStream1) $ReadFavoritesData = IniReadSection(@ScriptDir & "/Data/Favorites.ini", "Favorites") For $i = 1 To $ReadFavoritesData[0][0] If $ReadStream2 = $ReadFavoritesData[$i][0] Then MsgBox(48, "Error", "Stream is already in your favorites!") Else IniWrite(@ScriptDir & "/Data/Favorites.ini", "Favorites", $ReadStream2, $GameName[$ID + 1]) EndIf Next EndFunc ;==>_AddToFavorites Func _RunStreamFromMain() GUISetState(@SW_ENABLE, $MainGUI) $ReadStream1 = ControlListView($GameGui, $GameName[$ID + 1], $ListView, "GetSelected") $ReadStream2 = ControlListView($GameGui, $GameName[$ID + 1], $ListView, "GetText", $ReadStream1) $sUrl = "www.twitch.tv/" & $ReadStream2 If $iLivestreamerInstalled = True Then Run("livestreamer " & $sUrl & " best", "", @SW_HIDE) GUIDelete($GameGui) Else ShellExecute($sUrl) GUIDelete($GameGui) EndIf EndFunc ;==>_RunStreamFromMain Func _RunStreamFromFavorites() GUISetState(@SW_ENABLE, $MainGUI) $ReadStream1 = ControlListView($FavoritesGui, "Favorited Streams", $ListView, "GetSelected") $ReadStream2 = ControlListView($FavoritesGui, "Favorited Streams", $ListView, "GetText", $ReadStream1) $SplitFavorites = StringSplit($ReadStream2, "-") $ReadStream2 = StringStripWS($SplitFavorites[1], 8) $sUrl = "www.twitch.tv/" & $ReadStream2 If $iLivestreamerInstalled = True Then Run("livestreamer " & $sUrl & " best", "", @SW_HIDE) GUIDelete($FavoritesGui) Else ShellExecute($sUrl) GUIDelete($FavoritesGui) EndIf EndFunc ;==>_RunStreamFromFavorites Func _RemoveFromFavorites() $ReadStream1 = ControlListView($FavoritesGui, "Favorited Streams", $ListView, "GetSelected") $ReadStream2 = ControlListView($FavoritesGui, "Favorited Streams", $ListView, "GetText", $ReadStream1) $ReadFavorites = IniReadSection(@ScriptDir & "/Data/Favorites.ini", "Favorites") For $i = 1 To $ReadFavorites[0][0] $SplitFavorites = StringSplit($ReadStream2, "-") $RemoveWS = StringStripWS($SplitFavorites[1], 8) If $RemoveWS = $ReadFavorites[$i][0] Then IniDelete(@ScriptDir & "/Data/Favorites.ini", "Favorites", $ReadFavorites[$i][0]) GUIDelete($FavoritesGui) _FavoritesGui() Else Sleep(10) EndIf Next EndFunc ;==>_RemoveFromFavorites Func _CloseGameGUI() GUIDelete($GameGui) GUISetState(@SW_ENABLE, $MainGUI) WinActivate($MainGUI) EndFunc ;==>_CloseGameGUI Func _CloseFavoritedGUI() GUIDelete($FavoritesGui) GUISetState(@SW_ENABLE, $MainGUI) WinActivate($MainGUI) EndFunc ;==>_CloseFavoritedGUI Func _Exit() $X = 200 $Count = 0 $ButtonX = 40 $ButtonY = 160 GUIDelete($MainGUI) EndFunc ;==>_Exit 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...
dynamitemedia Posted January 10, 2016 Share Posted January 10, 2016 also doesn't the api actually grab the thumbnail of what is being played other than just the game logo image? like a thumbnail from the actual game play or their avatar?yea pagination would be awesome and be cleaner i think..do you think we could display images directly from web instead of the folder? i'm trying to find in here where that is displayed to see if it can be done. Link to comment Share on other sites More sharing options...
Damein Posted January 10, 2016 Share Posted January 10, 2016 Possibly, but I used the game logos to minimize the internet usage. dynamitemedia 1 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...
dynamitemedia Posted January 10, 2016 Share Posted January 10, 2016 looks awesome.... i am still getting the NO images when i open up, i have to close and then go to taskbar and hit show gui again to actually show the games... Link to comment Share on other sites More sharing options...
Damein Posted January 10, 2016 Share Posted January 10, 2016 That's odd because I don't have that problem. As soon as I launch the script and click show GUI the first time all my images show in the correct order. 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