Conditionally send keystrokes

Welcome Forums General PowerShell Q&A Conditionally send keystrokes

This topic contains 2 replies, has 2 voices, and was last updated by

6 months, 2 weeks ago.

  • Author
  • #113506

    Topics: 1
    Replies: 1
    Points: 1
    Rank: Member

    This is my first post and I am a complete beginner to this wonderful language.

    I have 2 folders both containing MP4 files named like partn.mp4  where n is an integer.

    I have a playlist file that contains the absolute path of each file like C:\Series\Show\part1.mp4, C:\Series\Adv\part2.mp4 and so on...

    Series contains even numbered files (part1.mp4, part3.mp4,...), Adv contains odd ones.

    Media player classic will play these files if given the playlist as an argument.

    What I need is a way to send a Ctrl-4 to odd numbered ones, I only limited myself to 3 parts for simplicity, so I need to send the keystroke to part2.mp4

    This code sends the keystroke to all files.

    Other codes that I've tried create race conditions and only the last file will play, any help.

    I am not attached to creating a playlist, any solution is fine.

    mpc-hc.exe playlist.m3u /play
    Foreach ($line in get-content playlist.m3u) {
    If ($line.substring($line.length-5,1) -match 2) {
  • #113521

    Topics: 8
    Replies: 736
    Points: 2,059
    Helping Hand
    Rank: Community Hero

    I don't know why you are doing this, but...

    You can

    if((($line -split 'part')[-1] -replace '.mp4') % 2){
    # Send key here
  • #113524

    Topics: 1
    Replies: 1
    Points: 1
    Rank: Member

    Let me explain, it is an assignment where the general idea is to insert commercials in a movie in order to fight piracy, this implementation proposes to split the movie into parts (odd numbered ones) and put it in a folder and advertisers in another one (even numbered), so to play them you must play one from each folder while having info about the commercial being played (the Ctrl-4).

    I am open to suggestions.

    I came with an idea of getting the entire movie, and trigger the commercial every 10 minutes while hiding the player's window, but I am finding it too difficult for a beginner.

    Anyway thanks, I'll try the code and get back.

The topic ‘Conditionally send keystrokes’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort