BetaLeaf

Episode Seeker

5 posts in this topic

I watch alot of anime and stuff and some sites don't have navigation to go to the next or previous episode or it's inconvenient. To resolve my delima, I created a script to change episodes at the press of a hotkey. It will work with any site that tracks the episode via url, in sequential order, and isn't also tracked by another identifier. Sites like Hulu and Crunchyroll won't work (tho their navigations is anything but inconvient). No this is for more obscure websites that have a simple url layout like www.example.com/video/bleach-024-engligh-dub.

To start up it will give you instructions. Hover over the first digit of the episode in the url(in the above example,  you would put your mouse over the 0) and press Ctrl+Insert to set the coordinates. From now on, when you press Ctrl+Left/Right, you will go forward or back an episode based on which button you pressed. It clicks the url, copies the ep number only, changes the ep number in variable, format it for leading 0 to match the source, and paste back in and submit, all in half a sec. It also attempts to exit full screen by pressing esc.

Here is the source. You don't need to do anything special to compile it. All of my works are open source and licensed with GPLv3. Enjoy =D

Global $x = "656";some default coordinates to load on start
Global $y = "44" ;^
Opt("WinTitleMatchMode", -2);Case insensitive ANYWHERE match mode
HotKeySet("^{ins}", "GetCoord")
HotKeySet("^{left}", "SeekPrev")
HotKeySet("^{right}", "SeekNext")
MsgBox(0, "How To Use", "Move your mouse under the first digit in the url that keeps track of which episode you are on, then press Ctrl+Insert.")
While 1;idle when not in use
    Sleep(1000)
WEnd
Func SeekPrev()
    Seek("Left")
EndFunc   ;==>SeekPrev
Func SeekNext()
    Seek("Right")
EndFunc   ;==>SeekNext
Func Seek($direction)
    ClipPut("");Erase contents of clipboard.
    Select ;First one that is true is the only one that gets used. If you have other browsers running, you may need to reorder this list.
        Case ProcessExists("iexplorer.exe") = True ;If iexplorer.exe is running then...
            $wintitle = "Internet Explorer";Use internet explorer.
        Case ProcessExists("MicrosoftEdge.exe") = True
            $wintitle = "Microsoft Edge"
        Case ProcessExists("opera.exe") = True
            $wintitle = "Opera"
        Case ProcessExists("firefox.exe") = True
            $wintitle = "Firefox"
        Case ProcessExists("chrome.exe") = True
            $wintitle = "Chrome"
        Case Else;Throws an error message incase you used a browser that is not set up.
            MsgBox(0, "Incompatible browser used.", "Unable to find a compatible browser to manipulate. Please use one of the follow browsers and try again: Chrome, Firefox, Opera, Microsoft Edge, Internet Explorer." & @CRLF & "You could also add an entry for your own browser. See Lines 24-33.")
            Exit
    EndSelect
    WinActivate($wintitle);Activate the window if it wasn't focused
    ControlSend($wintitle, "", "", "{esc}");Exit fullscreen (Note: ESC does not exit fullscreen on some sites)
    Sleep(50);give your browser some time to exit fullscreen.
    ControlClick($wintitle, "", "", "left", 2, $x, $y);Click where you set the coordinates.
    Do
        ControlSend($wintitle, "", "", "^c");Copy selected text to clipboard.
        $clipboard = ClipGet();Get the contents of the clipboard and store it in a string variable.
    Until StringLen($clipboard) > 0 ;Error Check Function, Make sure something was copied into the clipboard, else it waits until something is copied. It should be the value of the current ep you are on.
    $format = '%0' & StringLen($clipboard) & 'd'; Set the text format to be the same length as the original, padded with any 0's the original had.
    If $direction = "Left" Then ;If launched with Seek("Left") then decrease ep counter
        $clipboard = $clipboard - 1
    Else;Else Increase it
        $clipboard = $clipboard + 1
    EndIf
    $clipboard = StringFormat($format, $clipboard);format updated clipboard variable
    ClipPut($clipboard);write to clipboard the contents of $clipboard
    ControlSend($wintitle, "", "", "^v");paste clipboard, replacing the old ep in the url with tne new one.
    Sleep(50);Some browsers need to wait a moment after pasting, else it won't submit the correct request to the requested page.
    ControlSend($wintitle, "", "", "{enter}");Submit request to website.
EndFunc   ;==>Seek
Func GetCoord();This function sets the coordinates to be used in Seek()
    Local $coord = MouseGetPos();Get mouse Coordinates
    $x = $coord[0];Rewrites previous global variable
    $y = $coord[1];Rewrites previous global variable
    MsgBox(0, "Coordinates Updated", "X = " & $x & "." & @CRLF & "y = " & $y & "." & @CRLF & @CRLF & "Press Ctrl+Left to Seek Back" & @CRLF & "Press Ctrl+Right to Seek Forward")
EndFunc   ;==>GetCoord

 


My Scripts:

False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

AutoISO  - Automatic ISO Image creation using ImgBurn.

SoundBoard - Play any song or sound you want at the press of a hotkey

Share this post


Link to post
Share on other sites



I had to re-start the PC after running your code 

Care to enlighten the OP what exactly happened so they can fix it.

1 person likes this

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Care to enlighten the OP what exactly happened so they can fix it.

sure, I loaded the code an run it here on this same page. It did not like it. No big deal. The Ctrl key got stuck or something. I should have not run it. I was lazy and curious . My bad.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Yea, sorry. I have no idea how to fix CTRL key getting stuck. I have tried sending down and up commands in previous scripts but it still glitches up. You can also just close the script from the tray in the taskbar (near the clock) if you have issues.

It should also be noted that this script was designed to work with sites that host videos and follow a certain url pattern. It's pointless to use this script on this website.

Edited by BetaLeaf
1 person likes this

My Scripts:

False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

AutoISO  - Automatic ISO Image creation using ImgBurn.

SoundBoard - Play any song or sound you want at the press of a hotkey

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • WoodGrain
      By WoodGrain
      Hi All,
      Could someone please PLEASE tell me what I'm doing wrong here?
      I feel like I'm close to figuring this out, I think I've identified what is causing the issue.
      Whenever I try to use the hotkey CTRL+SHIFT+T (or any other letter other than T for that matter) to paste the text to notepad, my CTRL and SHIFT keys are held down *IF* I release them *WHILE* the raw text is being written.
      It seems to be that if I release the CTRL+SHIFT keys:
      Before the Send Raw text starts to write to the screen: the CTRL and SHIFT keys ARE NOT held down, this is good During the Send Raw text being written to the screen: the CTRL and SHIFT keys ARE held down perpetually until I physically press them on the keyboard, this is bad After the Send Raw text has written all text to the screen: the CTRL and SHIFT keys ARE NOT held down, this is good This is also the case if I were to use the Windows Key as the hot key instead of the CTRL+SHIFT, I would need to tap the WIN key physically on my keyboard if I released it while the raw tet was being sent to the screen (eg, WIN+T).
      This issue also happens no matter which program I try to write the text to.
      Here's some example code:
      (I've put a bunch of "a's" in there to give enough time to test releasing the CTRL+SHIFT before/during/after the writing of them)
      HotKeySet("^+t", "WriteTxt") Func WriteTxt() WinWaitActive("Untitled - Notepad") $var = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" send($var, 1) EndFunc While 1 Sleep(500) WEnd Thanks guys!
    • TheOnlyOne
      By TheOnlyOne
      So currently I have some code waiting for a status to change(there is different indicators to check if this status has changed) 
      Func oneRow($count) $globaltimer = _Timer_SetTimer($gui, 60000*10, "reset") $errTimer = TimerInit() While (1)         If PixelGetColor(1117, 326) = 0xC6C6C6 Then ExitLoop (1)         Sleep(500)         MouseClick("right")         Sleep(600)         If PixelGetColor(1117, 326) = 0xC6C6C6 Then ExitLoop (1)         If TimerDiff($errTimer) > 5000 Then             If PixelGetColor(1100, 310) = 0x707070 Or PixelGetColor(901, 305) = 0xE0E0E0 Or PixelGetColor(1043, 383) = 0xC6C6C6 Then                 Sleep(100)                 Send("{esc}")                 Sleep(1000)             EndIf         EndIf     WEnd .... EndFunc   ;==>oneRow The two timers is for error checking. This works just fine the problem comes when I go into the while 1 loop, my hotkeys at the top of the program seems to stop working, for an example 
      HotKeySet("{f1}", "stop") Func stop() Exit EndFunc ;==>stop Does not work at all after the while loop. The globaltimer is never called even though i tried setting the delay all the way down to 3 seconds. So I thought that maybe one of the function I use is blocking so the timer would never be called/the hotkey wouldn't work? if i make an delay just before the while loop the hotkey works just fine. Oh and the errTimer is supossed to not reset after 5 seconds but should keep making the check it does if five seconds have passed
    • RobOtter
      By RobOtter
      Hi,
      is there a function or a UDF for parsing a hotkey definition string like "^a" or "+!{F1}" ?
      I´d like to create a settings GUI where users are able to define their custom hotkeys for a specific function and then save it to an ini. Of course, at the next start of the program, these settings have to read and not only the HotkeySet() command needs to be fed with it but also the settings GUI.
      As I do not want to present the user just the hotkey string but a rather user-friendly display (like checkboxes for the separate modifier keys and a drop down list of supported trigger keys), I need to fiddle on the saved string.
      I would envision a function that takes a hotkey string and returns for example an array like this: [isCtrl][isAlt][isShift][isWin][triggerKey][isTriggerVirtual]. And of course, there needs to be a function decoding the array back to the respective string representation.
       
      Thanks for your hints!
    • Kovacic
      By Kovacic
      I know there is a simple way to do this, but I can't remember and can't find the proper way.. I just need to set a hotkey that is only active while the GUI is up. When the GUI is minimized or no longer in focus, I need it to release the bound key. I have the enter key bound for barcode scanning and when the app is minimized, it holds on to the enter key. I know there is a simple way to fix this, but I don't recall how.. I cant post the app because its massive and wont start if you try to use it outside our environment. Here is my little test script..
       
      Any ideas are greatly appreciated!
       
      #include <Misc.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("Form1", 318, 118, 192, 124) GUISetState(@SW_SHOW) HotKeySet("{ENTER}", "HotKeyPressed") Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("12", $hDLL) Then _IsKeyPressed() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func HotKeyPressed() TrayTip("HotKey", "I see the Enter key using the HotKeySet function.", 10, 1) EndFunc ;==>HotKeyPressed Func _IsKeyPressed() TrayTip("_IsKeyPressed", "I see the Alt button using the _IsKeyPressed function.", 10, 1) EndFunc ;==>_IsKeyPressed  
    • binhnx
      By binhnx
      Let start with some examples:
      1. (As seen in another topic: '?do=embed' frameborder='0' data-embedContent>> ).
      Script copied from that topic
      Interrupt function can be any hotkey/event/adlib/callback.
      If-check inside interrupted function/script 
      ; HotKeySet, or any function that can cause script interrupt HotKeySet("{Delete}", "RemoveSelectedControl") ;... Dim $InfoAboutControls[4096] Global $HandleForCurrentControl ;... While 1 $msg = GuiGetMsg() ;.... ;---Code to process moving a control (drag-n-drop)--- ; If check in MAIN LOOP (interruptible function). If $HandleForCurrentControl > 0 Then;Make sure we have a valid control handle ; ***** oops user pressed Delete key and we get pre-empted ; ***** user removed the selected control. ; ***** Returning from the RemoveSelectedControl function and resuming here: GuiCtrlSetPos($InfoAboutControls[$HandleForCurrentControl], $newLeftPosition, $newTopPosition) EndIf WEnd Func RemoveSelectedControl() $HandleForCurrentControl = -1 EndFunc 2. If-check inside interrupt function
      Hotkey only.
      Flag is set right after if check.
      It's possible or not this function print twice or more?
      HotKeySet("{Delete}", "_TestHotkey") Func _TestHotkey() Static $bFlag = True If ($bFlag) Then ; ***** Right here, user pressed Delete key ; ***** bFlag is currently not set ; ***** And the script will execute this function twice or more times, instead of just once $bFlag = False ConsoleWrite("This should be printed only ONCE") EndIf EndFunc 3. Same as 2, but with global flag
      The question is: can I rely on if-checking with a flag, to ensure that my script doesn't do any strange things, as describe in the above examples?