Sign in to follow this  
Followers 0
The Prince

Manipulating the contents of the clipboard

8 posts in this topic

I am doing the following:

;1) Open my account summary (3d party java window), Print the screen using

Send("!{printscreen}")

;2) Open Ms paint and past the print screen and save it Monochrome Bitmap [*.bmp]

Send("!f")

Send("a")

; 3) Open Softi Free OCR

;4) Convert the print screen Bitmap to text using the OCR,

;5) copy results using

send("^a"); selecting all

$q=ClipGet()

MsgBox(0,"ttt",$q)

;6) The result looks like this:

Balance 100

Profit 20

Net Assets value 120

Net Assets % 20

Available Units 300

10 lines

Which is always fixed item of text, while the numeric values changes.

Then I have to do different actions depending on numbers

How could I let AutoIt for example do actions, if profits became 30, or another action if Available units became 500???

I succeeded in pasting the results into Excel as text, then using Left, Right and Med functions to extract the required numbers, and then AutoIt will tack decisions, but its long unstable process.

I have tried using string functions such as:

StringTrimRight("$q",10)

$q = StringTrimLeft($q,8)

$q1 = StringRight($q,7)

but it wasnt the best way,

Any ideas is highly appreciated

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Answer is StringSplit

#include <GuiConstants.au3>

GUICreate("Test", 220, 220)
$hList = GUICtrlCreateListView("Item|Value", 10,10, 200,200)
GUISetState ()
$text = _
    "Balance 100" & @CRLF & _
    "Profit 20" & @CRLF & _
    "Net Assets value 120" & @CRLF & _
    "Net Assets % 20" & @CRLF & _
    "Available Units 300"

$array = StringSplit($text, @CRLF, 1)

For $i = 1 To $array[0]
    $line = StringSplit($array[$i], ' ')
    $text2 = ''
    For $j = 1 To $line[0] - 1
        $text2 &= $line[$j] & ' '
    Next
    $text2 &= '|' & $line[$j] ; here in $line[$j] is your value
        GUICtrlCreateListViewItem($text2, $hList)
Next

GUICtrlSendMsg($hList, $LVM_SETCOLUMNWIDTH, 0, 120)
GUICtrlSendMsg($hList, $LVM_SETCOLUMNWIDTH, 1, 50)

While GUIGetMsg() <> -3
WEnd

EDIT: removed unneeded #include <Guilist.au3>

Edited by Zedna

Share this post


Link to post
Share on other sites

Thanks Zedna, this is much faster than going to excel, in the above example if profit increase to 40, I want a MsgBox to tell me that Profit is > 35, thanks in advance

Share this post


Link to post
Share on other sites

Do it yourself. We don't write scripts for free.

:/

Work on the code.... you need to be able to store the variable in some sort of file and then look at it again to compare the old value(s) with the new one(s).


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Thanks Zedna, this is much faster than going to excel, in the above example if profit increase to 40, I want a MsgBox to tell me that Profit is > 35, thanks in advance

Blue Drache is right.

I will not do such trivial tasks for you.

I like help with some principials/interesting problems on which I also training myself.

Don't be lazy to look into HelpFile as I do everytime.

Share this post


Link to post
Share on other sites

I have a feeling that we all stare at that damn help file all day long.... why can't you?

Share this post


Link to post
Share on other sites

I think I should apologize, may be its a language communication problem, I do understand your point, helping should not be given to lazy people, they should work hard to improve their knowledge, then if they have some problems, many members in this thread will give them hints where to search.

In my case I spent weeks trying to automate certain tasks using several softwares, I succeed partially in doing that, but results are not the best, since I have to open number of softwares:

1- printscreen of a java window,

2- open MsPaint and save it as image,

3- close paint, open OCR software,

4- Open the paint file,

5- OCR,

6- copy the results,

7- close the OCR program,

8- open excel,

9-past the results,

10- converting text by using text functions in excel (left, right, med functions)

11- copying the new numerical results, each one as a separate variable using Autoit, for example profit value is $prof, Balance value is $bal,10 variables.

12-Then outit will take decisions according to those values, if $prof > 500 for example, Autoit activate the main javae screen send F2 key to do certain actions.

13- This should be repeated every 5minits.

I think I have invented the wheel in my project, but since its still primitive, I need help in improving my project, I dont want to become a programmer, or to be expert in Autoit, I just want to know the orders which are necessary to make my project working in an acceptable way, I am using some Autoit commands since more than one year and it help me a lot in doing some tasks, mainly I use send, mouseclick, winactvat, close, run, simple loops, inputbos, massage box, if statements.

My short term objective, is to decrease the number of softwares used to the minimum, and my post as indicated in its title is concerning steps 8-12, avoiding using of excel,

Let me Identify it in another way, I have 10 lines of text in the clipboard, (Balance 100 is one line, Profit 20 is another line), I want Autoit to identify balance as a variable $bal, if its value changed, Autoit will send a massagebox telling that balance is more than 30.

This might be very easy to many, but it might takes me weeks studding all those help files, and the 1200 functions in the lib, hints are highly appreciated,

and thanks again to Zedna, and apology for Blue_Drache and danwilli.

Share this post


Link to post
Share on other sites

You don't want to manipulate the clipboard, you only want to manipulate the strings in it. Manipulating the contents of the clipboard is easy.

$var = ClipGet()

Bingo, the contents of the clipboard are copied into a variable. If the variable is a string, take a gander at all the wonderful string functions.

StringInStr()

StringMid()

StringLeft()

StringRight()

StringStripWS()

and more...

By using the string functions and transfering what you need into and out of temporary variables (if required), you can make whatever that OCR returns say and do whatever you want.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0