Jump to content
Macro Express Forums

If Clipboard Contains...


Recommended Posts

Macro does a CLIPBOARD COPY..

If clipboard contains...

 

I want to search the clipboard and see if it contains a specific number

in my example I am looking to see if the number 201 or 202 or 203 or 204... 299

is in the clipboard.

 

Do I have to set up 99 variables and and 99 lines of code to accomplish this?

  set variable a to 201

  set variable b to 202 etc

  and

  if clipboard contains "a"

  or 

  if clipboard contains "b" etc

 

Can this be done easier / cleaner?

 

Thanks

Frank

 

 

Link to comment
Share on other sites

This might be easier using RegEx, but maybe something like this?

 

Text Type (Simulate Keystrokes): <CONTROL>c
Variable Set String %Clip% from the clipboard contents
 
Variable Set Integer %Values% to 200
 
Repeat Start (Repeat 100 times)
  If Variable %Clip% Contains "%Values%"
    Text Box Display: %Values%
  End If
   
  Variable Modify Integer %Values%: Increment
   
End Repeat

 

Link to comment
Share on other sites

No examples were given of the clipboard contents, but often a string like that would appear in the same place. So if one could get the exact position, then extract the 3 characters to a new string variable, then cast that to an integer. Now one can evaluate it mathematically using greater/less than. 

 

Another tack might be to act like one's own RegEx Engine. Start at the first character and evaluate each character. Then have a logic trap with three levels. Default Boolean variable would be false, then if it makes it to the bottom of the logic trap, change to true and advance. 

 

If Character is "2"

 If Character is between 0-9

  If Character is between 0-9

   True and abort loop

  EndIf 

 EndIf

EndIf

Bear in mind that doing a string evaluation works like a numeral. The string 5 is greater than the string 4.

Zero to nine is 0x31 to 0x39, To make the evaluation easier I would say use foreslash 0x30 and colon 0x3A to make it greater than and not have to add "equals to". 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...