Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Inspect clipboard content


  • Please log in to reply
1 reply to this topic
verojozsef
  • Members
  • 1 posts
  • Last active: Apr 18 2014 05:35 PM
  • Joined: 18 Apr 2014

Dear All,

 

I would like AHK to inspect the content of the clipboard, and take an action based on that. AHK should choose from three actions, depending on what type of character string is being stored on the clipboard. 

 

My goal is, to match three types of character strings, and perform an action depending on the type.

The first one would be an ID starting with "B", followed by 7 numbers (looks like B0123456). 

The second one would be an IP address.

And the third one would be any word, consisting of alphabetic characters.

 

I have tried to configure clipboard as a variable, but it returns true regardless the content of the clipboard, and performs the action, even if the character string stored on the clipboard, is not a match. Maybe I did something wrong with applying the variables, or with setting clipboard as a variable. 

 

Here is what I have tried:

------------------------------------------------
MyVar := %clipboard%
MyVar1 := B0123456
 
F7::
if MyVar = %MyVar1%
 {
Run notepad
}
Return
------------------------------------------------
The problem is,  that it takes the action, regardless of the content of the clipboard. (action: "Run notepad" is just for testing, of course, I would like to assign something else, as the real task)
 
Thank you in advance for your help.
 
Best regards,
Jozsef


noname
  • Members
  • 650 posts
  • Last active:
  • Joined: 12 Nov 2011

You are right it has something to do with variables there is a tutorial here with some examples:

http://www.autohotke...tuff-like-that/

 

 

For your example:

MyVar1 := "B0123456"
 
F7::
MyVar := clipboard
if (MyVar = MyVar1)   ;or you can use if MyVar = %MyVar1%
SoundBeep
else
msgbox %MyVar%`n%MyVar1%  ;just for testing
Return

winXP  and ahk unicode