Request for very simple script.

Discussion in 'Webmastering & Programming' started by tarxsix, Jul 22, 2019.

  1. tarxsix

    tarxsix n00b

    Messages:
    21
    Joined:
    Dec 18, 2010
    Hi, Sorry to bother you with this but I know very little about scripting.
    I'm looking for a file that I could run that would select a already running WinAmp and press 'c' (the pause button).
    I'm running Windows 10 Pro.

    I've been trying to look up on how to do this but cant put it together in my head. Can anyone help?

    Regards,
    Tar.
     
  2. JVene

    JVene n00b

    Messages:
    20
    Joined:
    Apr 25, 2019
    A lot depends upon what language you're willing to use. "Script" is not well defined as to what tools you can use.

    The basic notion is to obtain a handle to the desktop (the parent to all top level windows), loop through all that exist looking for the winamp name (probably part of the title), then sending a message to that app for the keystroke for the 'c'.

    I think C# and VB can do this (I don't use either much), but it is certainly possible in C/C++ (not exactly for a novice, though).
     
  3. tarxsix

    tarxsix n00b

    Messages:
    21
    Joined:
    Dec 18, 2010
    Thank for the reply! I guess I would like to use something free? Would I need to install something? Honestly I thought I would just need to enter some text into notepad and save it as a bat file? Or do you mean the language that I would be using in notepad?
     
  4. modi123

    modi123 [H]ardness Supreme

    Messages:
    5,378
    Joined:
    Sep 6, 2006
  5. tarxsix

    tarxsix n00b

    Messages:
    21
    Joined:
    Dec 18, 2010
    Thanks! Using PowerShell I tried creating the script and it opened WinAmp the first time but did not the 2nd as the window name changes with every song. So I tried the following:

    $wshell = New-Object -ComObject wscript.shell;
    $wshell.AppActivate('* Winamp *')
    Sleep 1
    $wshell.SendKeys('c')


    But that did not work also. Any suggestions?
    Also to run the ps1 file I have to right click and 'run with powershell'. Can I save it as a executable?
     
  6. modi123

    modi123 [H]ardness Supreme

    Messages:
    5,378
    Joined:
    Sep 6, 2006
  7. ryan_975

    ryan_975 [H]ardForum Junkie

    Messages:
    14,150
    Joined:
    Feb 6, 2006
    Try something like this ( haven't tested it ):

    $proc = get-process winamp
    $wshell = New-Object -ComObject wscript.shell;
    $wshell.AppActivate($proc.MainWindowTitle)
    Sleep 1
    $wshell.SendKeys('c')
     
  8. tarxsix

    tarxsix n00b

    Messages:
    21
    Joined:
    Dec 18, 2010

    It's working! Thanks so much! And everyone else!