
blackmage999
Members-
Posts
18 -
Joined
-
Last visited
Everything posted by blackmage999
-
Does AutoIt have a "find shape" function?
blackmage999 replied to Jarus's topic in AutoIt General Help and Support
You might look at the UDF, post #64. -
sounds like you might need on OCR if the text your looking at is in a image file like .jpg, .bmp, .png, ect... it all depends on what your trying to extract the text out of. an example would help
-
you might take a look at this thread
-
you are using the last parameter wrong. its supposed to be a number from 0 - 255 and used when the color of the image your looking for would vary in shades. using the images on this browser, i used this code and got the correct results #include <ImageSearch.au3> $x1=0 $y1=0 WinActivate("Image Search Library - AutoIt Forums - Google Chrome", "") WinWaitActive("Image Search Library - AutoIt Forums - Google Chrome", "") $result = _ImageSearch(@DesktopDir & "\sq.bmp",1,$x1,$y1,0) if $result=1 Then MsgBox(0, "", "found") Else MsgBox(0, "", "not found") Exit EndIf And one more suggestion. I find that using BMP's get correct results more often...could just be me though :-p
-
There is an image search UDF in the example scripts forum. the download is a couple pages in (the link in the first post is broken i believe) Edit: download link is in post #64
-
I just have a .au3 I named "blank" for test snippets and code I'm not worried about saving
-
Autoit OCR without 3rd party software.
blackmage999 replied to civilcalc's topic in AutoIt Example Scripts
I assume you're talking about the "$ocrlearn". While testing the UDF, I put $ocrlearn = "" as a quick work around. It dosn't look like its used for anything at the moment. I think its either something hes planing or something he took out. Looks like $glue1 = "" through $glue6 = "" don't get called either. This is what I was using for testing purposes #include <OCR.au3> $ocrlearn = "" ; A B C D E F G H I J K L M N O P Q R S T U V W X Y Z $data = _OCR(209,263,593,278,0,15791353,@DesktopDir & "\font.txt",$ocrlearn) ; the cords make a box around the letters MsgBox(0, "", $data) I think the number of lines required before it sees a space should be dependent on the height of the search area. I'll try to work on this some time this week, maybe try to reverse engineer it and post my results. I might think of something new or I could just fail horribly :-p -
Autoit OCR without 3rd party software.
blackmage999 replied to civilcalc's topic in AutoIt Example Scripts
It took me a second to read through it all and understand it, but I got there (and that's saying a lot because half the time I cant even read my own script :-p). I was playing around with it using it on the SciTE editor and results were fairly good. The only problems I had were the first entry being skipped (which I fixed by putting @@@@ on the first line) and if there were too many glued letters, it started returning the code for the letters (I tried doing "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG" and it returned a real mess). I'm also trying to figure out how to make it see spaces... -
Are you actualy asking for help or asking us to code something for you? If you need help, lets see what you got so far and we can go from there.
-
Autoit OCR without 3rd party software.
blackmage999 replied to civilcalc's topic in AutoIt Example Scripts
why not use If StringInStr($database,$string[$a]) Then ;check if value already exists in database $pos = StringInStr($database,$string[$a]) $data = $data&StringMid($database,($pos-4),1) Else instead of If StringInStr($database,"@ "&$string[$a]&" @") Then ;check if value already exists in database $pos = StringInStr($database,$string[$a]&" @") $pos2 = StringInStr($database,"@",0,1,$pos-10) $data = $data&StringMid($database,$pos2,($pos-$pos2)) Else I had the trouble of the first entry in the font file not being recognized, and doing that fixed it. To be honest, I didn't completely understand what you had written for that spot in the first place (the -10 threw me off). I'm still fairly new, and this project will be a great learning experience for me. I love the idea, and the simplicity of it boggles my mind. For a language trying to emulate human input, an OCR seems like a logical step to achieving that goal. Edit: the reason the "glued" letters aren't appearing separately is because the last element of the first letter is getting added to the first element of the second letter TA @ 524|516|964|572|516|4|524|768|708|180|140|1020|512 @ T @ _524|516|964|572|516|4|12 @ A @ ___________________512|768|708|180|140|1020|512 @ So I guess that's why you had the original check in there, because my fix only returns the A...so now to figure out why the first entry in the font file is getting skipped :-( -
you mean page 4 (posts 63 and 64)
-
I downloaded seangriffin's tesseract installer but when I run tesseract through the command line, i get an error log that reads: Unable to load unicharset file C:\Program Files\Tesseract\;C:\Program Files\Tesseract-OCR\tessdata/eng.unicharset I double checked and i do have the eng.unicharset. The thing thats throwing me off is the "Tesseract-OCR"...that directory wasn't in the install package. Is there something missing from it or am i just missing something?
-
Using Tesseract.exe with a file, not ScreenCap?
blackmage999 replied to Gui's topic in AutoIt General Help and Support
I too am looking to do this. I was using freeOCR that used tesseract, but it was too slow (i had to WinActivate, click on the open button, type in the file, click ocr, remove the line breaks, put it to clipboard, then clear the output screen). It took about 6 seconds to ocr each file. Not to metion the fact that it just stoped working (still have no idea why). Being able to get the ocr results without having to go through all that extra stuff would decrease the time my program took to identify each line dramatically. Going through the tesseract udf i found this line of code... ShellExecuteWait(@ProgramFilesDir & "\tesseract\tesseract.exe", $capture_filename & " " & $ocr_filename) http://www.autoitscript.com/autoit3/docs/functions/ShellExecuteWait.htm Im assuming thats what it uses to call the ORC...I have no experience using ShellExecuteWait, nor do know how to use it. the help file is very confusing to me and i would wonder if someone could explain it to me better. tried using this... #include <ScreenCapture.au3> _ScreenCapture_Capture(@DesktopDir & "\test images 2\WhatScreen.tif", 17, 111, 175, 125) Sleep(1000) ShellExecuteWait(@ProgramFilesDir & "\tesseract\tesseract.exe", @DesktopDir & "\test images 2\WhatScreen.tif" & " " & @DesktopDir & "\test images 2\WhatScreen.txt") but no .txt file -
Is there a way to call the OCR for an image already created (point it to the path)? Going through this udf i found this line of code... ShellExecuteWait(@ProgramFilesDir & "\tesseract\tesseract.exe", $capture_filename & " " & $ocr_filename) Tried using this... #include <ScreenCapture.au3> _ScreenCapture_Capture(@DesktopDir & "\test images 2\WhatScreen.tif", 17, 111, 175, 125) Sleep(1000) ShellExecuteWait(@ProgramFilesDir & "\tesseract\tesseract.exe", @DesktopDir & "\test images 2\WhatScreen.tif" & " " & @DesktopDir & "\test images 2\WhatScreen.txt") but no .txt file swimming through that sea of code got me confused and i cant tell what i would replace the variables with. The help file for ShellExecuteWait is very confusing to me and i was wondering if anyone could explain it to me better.
-
First of all, sorry about my last post about game automation. I've downloaded other scripts for MTGO on here so I didn't even think to look to see if it was ok. All my post was really about was how to get tesseract installed and incorporated into AutoIt, and to see if I was on the right track to learning how to script with AutoIt. So far I only have scripts for games, so Im not sure how I can post a full script to be checked. I guess to get around that, could someone give me a project to do that I can post on here so I can see where if im on the right track to learning the language? and also any help with using tesseract would be greatly appricated.
-
Im working on a magic online bot, and this is what i have so far. right now im at a stand still because my OCR program suddenly stopped working. I was using freeOCR, and for some reason, whenever i try to use it (even on a file that ive ocr'd before and got a result out of) it returns NOTHING... at all. Meh...I was unhappy with it anyways. It took too long to go through a collection of cards and I need something faster to set it up to buy cards rather then just sell them. I was hoping to get a simple sell bot up and running, but i cant now because i have no ocr program. I tried tesseract, but i cant for the life of me figure out how to use it. If i could figure out how to install it, and if i figured out how to use the tesseract.au3 i found on these forums, i might be able to speed it up a little. looking around, it looks like what i need is an ocr program that i can use on the command line. Im not even sure how the command line works...im learning as i go here. Any help or comments would be appricated. #include <ScreenCapture.au3> #Include <File.au3> WinActivate("Magic Online", "") $ChecksumMenuClick = PixelChecksum(75, 625, 210, 710) $ChecksumCommunityClick = PixelChecksum(220, 625, 350, 685) $ChecksumMarketplaceClick = PixelChecksum(360, 625, 490, 640) $ChecksumWhatScreen = PixelChecksum(54, 9, 175, 18) $ChecksumOCRDone = PixelChecksum(670, 350, 815, 370) $ChecksumBuySellDone = PixelChecksum(835, 55, 1000 ,550) $ChecksumGetGiveNumber = PixelChecksum(69, 552, 85, 561) ;wait for a change in what room im in Func WaitFOCRhange() While $ChecksumWhatScreen = PixelChecksum(54, 9, 175, 18) Sleep(100) WEnd Call ("WhatScreen") EndFunc ;capture image of top left corner (shows what screen im in) Func WhatScreen() ;Capture image _ScreenCapture_Capture(@DesktopDir & "\test images 2\WhatScreen.jpg", 54, 9, 175, 18) ;activate my Optical character recognition program WinActivate("FreeOCR V3 Free OCR Software", "") Sleep(100) MouseClick("left", 400, 300, 1) Sleep(100) Send("WhatScreen.jpg{enter}") Sleep(100) MouseClick("left", 530, 300, 1) ;wait for ocr to finish While $ChecksumOCRDone = PixelChecksum(670, 350, 815, 370) Sleep(100) Wend ;get ocr result Send("{Down}{Down}{bs}{bs}") MouseClick("left", 645, 440, 1) MouseClick("left", 645, 360, 1) WinActivate("Magic Online", "") $WhatScreen = ClipGet() ;compare ocr result to top left corner If $WhatScreen = "CARD Trade" Then Call ("Trade") ElseIf $WhatScreen = "HDME" Then Call("JoinClassifieds") ElseIf $WhatScreen = "CDMMUNITY Classifieds" Then Call("EnterAd") EndIf EndFunc ;Join the room to post that im selling cards Func JoinClassifieds() ;click menu MouseClick("left", 100, 725, 1) While $ChecksumMenuClick = PixelChecksum(75, 625, 210, 710) Sleep(100) WEnd ;click community MouseClick("left", 100, 630, 1) While $ChecksumCommunityClick = PixelChecksum(220, 625, 350, 685) Sleep(100) WEnd ;click marketplace MouseClick("left", 260, 630, 1) While $ChecksumMarketplaceClick = PixelChecksum(360, 625, 490, 640) Sleep(100) WEnd ;click classifieds MouseClick("left", 400, 630, 1) While $ChecksumWhatScreen = PixelChecksum(54, 9, 175, 18) Sleep(100) WEnd EndFunc ;Enter an ad in the classifieds saying that im selling cards Func EnterAd() ;check to see if i already have an ad posted MouseClick("left", 500, 450, 1) MouseClick("left", 400, 15, 1) Send("blackmage999") $IsAdBoxHidden = PixelGetColor( 130 , 40 ) if $IsAdBoxHidden <> 0x000000 then MouseClick("left", 750, 40, 1) EndIf $IsAdUp = PixelSearch( 40, 125, 125, 140, 0x000000 ) If @error Then ;click edit posting and set my ad MouseClick("left", 730, 40, 2) Send("Selling Any 160 cards for 1") ;click submit MouseClick("left", 400, 50, 1) While $ChecksumWhatScreen = PixelChecksum(54, 9, 175, 18) Sleep(100) WEnd Else Call ("WaitFOCRhange") EndIf EndFunc ;trade function (work in progress Func Trade() ;dock chat window $FindDock = PixelSearch( 766, 36, 994, 568, 0xFEFEFE ) If Not @error Then MouseClick("left", $FindDock[0], $FindDock[1], 1) Else $coord = PixelSearch( 766, 0, 994, 38, 0xFEFEFE ) If Not @error Then MouseClick("left", $FindDock[0], $FindDock[1], 1) EndIf EndIf ;get player name MouseClick("left", 880, 615, 1) Send("^c") $PlayerName = ClipGet() ;open credit file or create new $PlayerCreditFile = FileOpen(@DesktopDir & "\PlayerCredits\" & $PlayerName & ".txt", 8) ;get player credits from .txt file $PlayerCredit = FileRead($PlayerCreditFile) If $PlayerCredit = "" Then $PlayerCredit = 0 EndIf FileClose($PlayerCreditFile) ;enter in chat that im selling 160 cards for 1 ticket MouseClick("left", 900, 560, 1) Send("Preping chat. Please wait.{enter}...{enter}...{enter}...{enter}...{enter}...{enter}") Send("...{enter}...{enter}...{enter}...{enter}...{enter}...{enter}...{enter}...{enter}") Send("Hello " & $PlayerName & ". I am selling 160 cards for 1. You have " & $PlayerCredit & " credits.{enter}") $PlayerCardsTaken = $PlayerCredit * 160 $PlayerCardsLeft = 160 - $PlayerCardsTaken Send("You have taken " & $PlayerCardsTaken & " cards. Please take " & $PlayerCardsLeft & "more. Type done when you're ready.{enter}") ;check what the player has typed While $ChecksumBuySellDone = PixelChecksum(835, 55, 1000, 550) Sleep(100) WEnd MouseClick("left", 900, 535, 1) Send("^c") $PlayerMessage = ClipGet() $PlayerMessage = StringLower($PlayerMessage) $BuySellorDone = StringRight($PlayerMessage, 4) ;decide what to do based on ClipGet If $BuySellorDone = "sell" Then MouseClick("left", 900, 560, 1) Send("I do not buy cards at the moment. This bot is still a work in progress.") ElseIf $BuySellorDone = " buy" Then MouseClick("left", 900, 560, 1) Send("Take the cards you want and type done when your ready.") ElseIf $BuySellorDone = "done" Then ;check to see if i need to take a ticket or not If $PlayerCredit = 0 Or $PlayerCredit > 1 Then $TakeTicket = True Else $TakeTicket = False EndIf ;take ticket If $TakeTicket = true then ;search for "event ticket" MouseClick("left", 140, 40, 1) Send("event ticket") Sleep(100) MouseClick("left", 600, 118, 1) ;check to see if the item i clicked is a ticket _ScreenCapture_Capture(@DesktopDir & "\test images\Event Ticket.jpg", 17, 111, 175, 125) WinActivate("FreeOCR V3 Free OCR Software", "") Sleep(100) MouseClick("left", 400, 300, 1) Sleep(100) Send("Event Ticket.jpg{enter}") Sleep(100) MouseClick("left", 530, 300, 1) While $ChecksumOCRDone = PixelChecksum(670, 350, 815, 370) Sleep(100) Wend Sleep(100) Send("{Down}{Down}{bs}{bs}") Sleep(100) MouseClick("left", 645, 440, 1) MouseClick("left", 645, 360, 1) $WhatCard = ClipGet() if $WhatCard = "Event Ticket" Then WinActivate("Magic Online", "") ;dbl click the ticket to take it MouseClick("left", 50, 120, 2) EndIf Send("Please hit comfirm and I will check your cards.") ;click confirm MouseClick("left", 340, 70, 1) While $ConfirmCheck = PixelChecksum(835, 55, 1000, 550) Sleep(100) WEnd ;check the number of cards the player has taken _ScreenCapture_Capture(@DesktopDir & "\BotData\OCR\PlayerGetNumberTaken.jpg", 69, 552, 85, 561) WinActivate("FreeOCR V3 Free OCR Software", "") Sleep(100) MouseClick("left", 400, 300, 1) Sleep(100) Send("PlayerGetNumberTaken.jpg{enter}") Sleep(100) MouseClick("left", 530, 300, 1) While $ChecksumWhatScreen = PixelChecksum(54, 9, 175, 18) Sleep(100) WEnd Sleep(100) Send("{Down}{Down}{bs}{bs}") Sleep(100) MouseClick("left", 645, 440, 1) MouseClick("left", 645, 360, 1) $OCRResult = FileOpen(@DesktopDir & "\BotData\GiveGetNumbers\" & $OCRPlayerNumberCards & ".txt", 0) $PlayerNumberCards = FileRead($OCRPlayerNumberCards) FileClose($OCRResult) ;;; I need to put a checksum here to see if the trade window is closed, then check to ;;; see if my ticket number has changed (need to write a check before trade also) ;write to the players credit file (not finished) $PlayerCreditThisSession = $PlayerNumberCards * .00625 EndFunc
-
Im using this code in one of my scripts, but it fails to create a .txt. any help on what the problem might be would be appricated Edit: I just relized i used +'s instead of &'s...fixed, but still fails to create my .txt