Author Topic: Help needed for javascript url.  (Read 2087 times)

0 Members and 1 Guest are viewing this topic.

xtermin8r

  • $upporter
  • Sr. Member
  • *****
  • Posts: 366
  • Karma: 9
  • Crunchie
    • View Profile
Help needed for javascript url.
« on: April 23, 2013, 11:05:12 AM »
hi
i need some help, i want to copy a link from a web  page which is javascript:playSound('../Audios/L014/L014_017.mp3'); by using System.GetClipboardText and strip out  the filename L014_017.mp3, and get the OSD to display this filename using voxcommando ?

Thanks in advance.
« Last Edit: April 23, 2013, 11:25:03 AM by xtermin8r »
Neural Net Based Artificial Intelligence.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Help needed for javascript url.
« Reply #1 on: April 23, 2013, 11:30:49 AM »
hi
i need some help, i want to copy a link from a web  page which is javascript:playSound('../Audios/L014/L014_017.mp3'); by using System.GetClipboardText and strip out  the filename L014_017.mp3, and get the OSD to display this filename using voxcommando ?

Thanks in advance.

are you asking for help on how to use regex to pull "L014_017.mp3" from "javascript:playSound('../Audios/L014/L014_017.mp3');" ?

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Help needed for javascript url.
« Reply #2 on: April 23, 2013, 11:35:01 AM »
the best part of this (I think) is the command name I came up with  :biglaugh

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="684" name="regextermin8ter" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <cmdString>javascript:playSound('../Audios/L014/L014_017.mp3');</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <cmdString>([^/]*?mp3)</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <cmdString>{Match.1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Help needed for javascript url.
« Reply #3 on: April 23, 2013, 11:38:01 AM »
the magic pattern is

Code: [Select]
([^/]*?mp3)
everything between the (  ) will be returned as a match.  the [^/] means match everything except '/'

and the *? means match as many characters as necessary.  Actually in this case just * will probably work.

xtermin8r

  • $upporter
  • Sr. Member
  • *****
  • Posts: 366
  • Karma: 9
  • Crunchie
    • View Profile
Re: Help needed for javascript url.
« Reply #4 on: April 23, 2013, 11:42:57 AM »
Thanks a million James, you are a star, will try it now.
Neural Net Based Artificial Intelligence.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Help needed for javascript url.
« Reply #5 on: April 23, 2013, 11:50:59 AM »
Thank you!

Finding regex patterns is one of my favourite games!   ::wiggle

xtermin8r

  • $upporter
  • Sr. Member
  • *****
  • Posts: 366
  • Karma: 9
  • Crunchie
    • View Profile
Re: Help needed for javascript url.
« Reply #6 on: April 23, 2013, 12:29:56 PM »
Thanks James works perfectly.  :clap

this is what i have done:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="684" name="regextermin8r" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>System.GetClipboardText</cmdType>
    <cmdString />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <cmdString>([^/]*?mp3)</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <cmdString>{Match.1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Window.Focus</cmdType>
    <cmdString>wavepad</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>SendKeys</cmdType>
    <cmdString>+^(I)</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.Pause</cmdType>
    <cmdString>2000</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>SendKeys</cmdType>
    <cmdString>{Match.1}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

The website and urls in question http://www.madinaharabic.com/Arabic_Language_Course/Lessons/L001_001.html
the software wavepad http://www.nch.com.au/wavepad/index.html

You and your program have simplified my life once again Thanks.        

name="regextermin8r"    nice  :biglaugh
« Last Edit: April 23, 2013, 12:49:29 PM by xtermin8r »
Neural Net Based Artificial Intelligence.

xtermin8r

  • $upporter
  • Sr. Member
  • *****
  • Posts: 366
  • Karma: 9
  • Crunchie
    • View Profile
Re: Help needed for javascript url.
« Reply #7 on: April 23, 2013, 01:31:23 PM »
hi everyone
Creating Arabic audio lessons with help from VoxCommando
the demo of the above method http://youtu.be/xTOPxYN4jyU
« Last Edit: April 23, 2013, 05:19:45 PM by xtermin8r »
Neural Net Based Artificial Intelligence.