Batch to launch aprogram based on specific word in clipboard

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
russs
Posts: 3
Joined: 29 Nov 2010 05:15

Batch to launch aprogram based on specific word in clipboard

#1 Post by russs » 29 Nov 2010 05:28

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

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

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

#2 Post by orange_batch » 29 Nov 2010 14:37

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

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

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

#3 Post by !k » 30 Nov 2010 21:06

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

Post Reply