Page 1 of 1

Batch to launch aprogram based on specific word in clipboard

Posted: 29 Nov 2010 05:28
by russs
Hi all,

This is my first subject in this forum, so please bare with me if I make any mistake :)

I want to make a batch that runs as a background task and checks every now and then for specific syntax in windows clipboard, if it finds a matching word, it executes a program.

Example:

the word we are seeking has the form WORDXXX, so I want whenever I copy a word that matches WORDXXX (like WORD123, WORDxyz or WORDEEE), I want an executable to be run.

The algorithm sounds to me like:

While (true)
{
while (true)
{
check clipboard for text matching WORDXXX
if (match == true) then execute "c:\program.exe"
}
}


The main hardships I am encountering are:

1/ how to check the clipboard for text
2/ how to implement the RegEx that checks the text in clipboard to find if it matches the WORD


Any help will be greatly appreciated :)

Kind regards,
Russs

Re: Batch to launch aprogram based on specific word in clipb

Posted: 29 Nov 2010 14:37
by orange_batch
Mmm are you familiar with DOS batch? I think you might have the wrong idea about it like a lot of people (that it can do anything like magic). It relies on command line tools for most things. Usually such tools aren't made for the command line because it would be silly to have some roundabout reliance on DOS batch.

Anyways, clipboard data is stored in Windows system memory, so unless you can access that object you can't do it. WMIC might be able to do it, but that's all I can say.

http://ss64.com/nt/wmic.html

Re: Batch to launch aprogram based on specific word in clipb

Posted: 30 Nov 2010 21:06
by !k
russs wrote:1/ how to check the clipboard for text
2/ how to implement the RegEx that checks the text in clipboard to find if it matches the WORD

1. use cliptext or ConClip or similar
2. use №1 + findstr /R