AutoHotkey Community

It is currently May 27th, 2012, 4:37 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: March 5th, 2010, 6:42 pm 
Offline

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
Code:
!c::
   MouseGetPos,,,win, cont
   ControlGetText, Clipboard, %cont%, ahk_id %win%
Return

press alt+c to copy the text of the control under the mouse to the clipboard.

with my testing, it seems it doesn't work with every control (thus why i said "most controls" in my last post).
you may be trying to use some odd-ball control and may not be possible with any 'easy' method. and i'm to lazy to try any harder then this.

_________________
rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2010, 6:56 pm 
Offline

Joined: January 28th, 2008, 9:40 pm
Posts: 140
Location: KC
it seems this isnt solved.. how many digits are in that number? is it in the same exact location every time? if so i have an OCR script that may help..unfortunatly you have to train it by showing it every number combination possible ..if this is an option for you i can help you set it up

_________________
The early bird gets the worm but the second rat gets the cheese!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2010, 8:00 pm 
Offline

Joined: January 29th, 2010, 6:05 pm
Posts: 41
Location: Decatur, AL
It is in the same position every time, and it usually falls between 1 and 9.

There are a few instances where it will be higher, 12, 32, 300, but those are few and far between and I could just manually do those.

Its the ones that are between 1 and 9 that I work with all day long, and if they could be automated that would be fantastic.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2010, 8:49 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
sinkfaze wrote:
The control name indicates that it's a list or sub-list from a listbox..
Seems like this may not be as straight forward as we thought.
Laraptor, can you please post a screen shot of the window or control with the number in it?

It will help us know exactly what your looking at ;).

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2010, 9:01 pm 
Offline

Joined: January 29th, 2010, 6:05 pm
Posts: 41
Location: Decatur, AL
How do i post a screeny? It doesnt seem to be as easy as ctrl+c and ctrl+v[/img]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2010, 9:13 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
Like this:
Image
:lol:

Press PrintScreen, use this (ClipBoardPictureSaver)
or
open paint, paste into paint, save as image.

Upload to imagehost (there are many others, just Google: free image host), copy & paste the url here in img tags like this:
Code:
[img]http://e.imagehost.org/0284/PIC1_5.jpg[/img]

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2010, 10:13 pm 
Offline

Joined: January 28th, 2008, 9:40 pm
Posts: 140
Location: KC
You can try to modify this code yourself or if you can get me a screenshot of what you need scanned <control + Printscreen, Open new mspaint..paste and save...email that to me or post it here...> ill see if i can get it to scan for you...


my OCR script

Code:

coordmode,pixel ,screen
coordmode,mouse ,screen
IfNotExist, give
   {
      FileCreateDir, give   ;if you dont have a give folder make one
   }
notfound :=999

beginagain:

begin:
onexit, exitsub                     ;always delete colors.txt
iniread, x,myfile.ini,ocr3,5         ;get location to start ocr
iniread, y,myfile.ini,ocr3,6         ;get location to start ocr
ye :=(y + 20)                       ;Define search box height in pixels
xe :=(x + 20)                       ;Define search box width  in pixels
sleep, 200                     ;make sure values had time to load. Needed??


Start:                         
;mousemove, x,y                 ;Uncoment to check the area being scanned.
PixelGetColor, color, X, Y      ;search for start of character
if color = 0x000000            ;Change this to the color of the character you are scanning..careful because the edges of the lines may shade a bit
{
Start2:                         
;mousemove, x,y                 ; Uncomment to check the area searched SLOWS IT
PixelGetColor, color, X, Y      ;black found start saving results
fileappend, %color%, give\colors.txt    ;add current color to txt
if color = 0x000000         ;Change this to the color of the character you are scanning..careful because the edges of the lines may shade a bit
count=0                         ;black was found reset count for end of string trim
else
{
count+=8                ;black not found trim 8 more chars off at end
}   

                 



if x>%xe%                           ;IF END OF SEARCH AREA
{                                   ;Start processing data to black or white
fileread tobetrimmed, give\colors.txt
count2 = 1                     ;start at first character in file
loop
{

StringMid, check, tobetrimmed, %count2%, 8 ;this replaces 8 non "0x000000" at a time

if check =         ;no more characters to replace
break

if check != 0x000000
StringReplace, tobetrimmed, tobetrimmed, %check%, 0xFFFFFF, All
count2 += 8                             ;change to next 8 characters
}

 
StringTrimRight, trimmed, tobetrimmed, %count%    ;trim and save colors
filedelete give\colors.txt                               ;
fileappend, %trimmed%, give\colors.txt                 ;

loopcount=0                ; count loops so you dont search infinatly
char=0                     ; set char to 0 so you search from 0-9     
start3:                    ;start of compare current colors vs saved

if (loopcount > 500)         ; DIDNT FIND A MATCH in up to 500 files
{
InputBox, UserInput, i didnt recognize #, what number was that?., , 200, 100
fileappend, %trimmed%, give\%userinput%.txt
filedelete, give\colors.txt
exitapp
}

fileread, sig, give\%char%.txt
IfInString, sig, %trimmed%
{
Msgbox, I recognized %char%   

filedelete give\colors.txt
exitapp
}
else
{
char+=1
loopcount+=1
gosub, start3
}
msgbox !!!!!
FileMove, give\colors.txt, give\%UserInput%.txt ,1    ;rename colors.txt
exitapp
gosub, begin
}
else
{
y+=1
}

if y>%ye%                ;Bottom of search area reached goto next colum and top
{
x+=1
iniread, y,myfile.ini,ocr3,6
}
gosub, start2
}
                        ;black wasnt found yet keep searching
if x>%xe%               ;if far right wall passed
{
filedelete, give\colors.txt
gosub, exitsub
}
else
{
y+=1     ;check the next pixel down
}

if y>%ye%    ;if the bottom wall has been passed
{
x+=1    ;go to next column
iniread, y,myfile.ini,ocr3,6  ;Reset Y to top of search area
}
gosub, start

exitsub:
filedelete, give\colors.txt    ;clean up colors.txt so next ocr doesnt append to it
exitapp



This script was meant to be called when needed....scan the pre defined area and give the option to save a new character/number if it didnt recognize it....i used an INI file to save locations i needed to scan but you should be able to delete the INI part and add a hard coded x, y location

You may want to paste THIS

Code:

[ocr3]
boxstart= This section is for locations the bot should check 5 is X    6 is Y
5=69
6=548


Into a file called myfile.ini... another program i used to set this up drew a box around the area to be scanned and saved the location so you could outline the area to scan...but it was done in pieces.. so it would be like 3 more scripts but if you need that you can check the forums for MTGO and find Atrain , Part1 and Part2

_________________
The early bird gets the worm but the second rat gets the cheese!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2010, 2:35 am 
Offline

Joined: January 28th, 2008, 9:40 pm
Posts: 140
Location: KC
Ok......reworked to copy the result and paste it <you need to know the location you want the program to click to activate> or remove that if its already active

Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
coordmode,pixel ,screen
coordmode,mouse ,screen
IfNotExist, give
   {
      FileCreateDir, give   ;if you dont have a give folder make one
   }
notfound :=999

beginagain:

begin:
onexit, exitsub                     ;always delete colors.txt
iniread, x,myfile.ini,ocr3,5         ;get location to start ocr
iniread, y,myfile.ini,ocr3,6         ;get location to start ocr
ye :=(y + 20)                       ;Define search box height in pixels
xe :=(x + 20)                       ;Define search box width  in pixels
sleep, 200                     ;make sure values had time to load. Needed??


Start:                         
;mousemove, x,y                 ;Uncoment to check the area being scanned.
PixelGetColor, color, X, Y      ;search for start of character
if color = 0x000000            ;Change this to the color of the character you are scanning..careful because the edges of the lines may shade a bit
{
Start2:                         
;mousemove, x,y                 ; Uncomment to check the area searched SLOWS IT
PixelGetColor, color, X, Y      ;black found start saving results
fileappend, %color%, give\colors.txt    ;add current color to txt
if color = 0x000000         ;Change this to the color of the character you are scanning..careful because the edges of the lines may shade a bit
count=0                         ;black was found reset count for end of string trim
else
{
count+=8                ;black not found trim 8 more chars off at end
}   

                 



if x>%xe%                           ;IF END OF SEARCH AREA
{                                   ;Start processing data to black or white
fileread tobetrimmed, give\colors.txt
count2 = 1                     ;start at first character in file
loop
{

StringMid, check, tobetrimmed, %count2%, 8 ;this replaces 8 non "0x000000" at a time

if check =         ;no more characters to replace
break

if check != 0x000000
StringReplace, tobetrimmed, tobetrimmed, %check%, 0xFFFFFF, All
count2 += 8                             ;change to next 8 characters
}

 
StringTrimRight, trimmed, tobetrimmed, %count%    ;trim and save colors
filedelete give\colors.txt                               ;
fileappend, %trimmed%, give\colors.txt                 ;

loopcount=0                ; count loops so you dont search infinatly
char=0                     ; set char to 0 so you search from 0-9     
start3:                    ;start of compare current colors vs saved

if (loopcount > 500)         ; DIDNT FIND A MATCH in up to 500 files
{
InputBox, UserInput, i didnt recognize #, what number was that?., , 200, 100
fileappend, %trimmed%, give\%userinput%.txt
filedelete, give\colors.txt
exitapp
}

fileread, sig, give\%char%.txt
IfInString, sig, %trimmed%
{
clipboard=%char%
Mouseclick, left, 100, 100
Send, {CTRLDOWN}v{CTRLUP}
filedelete give\colors.txt
exitapp
}
else
{
char+=1
loopcount+=1
gosub, start3
}
msgbox !!!!!
FileMove, give\colors.txt, give\%UserInput%.txt ,1    ;rename colors.txt
exitapp
gosub, begin
}
else
{
y+=1
}

if y>%ye%                ;Bottom of search area reached goto next colum and top
{
x+=1
iniread, y,myfile.ini,ocr3,6
}
gosub, start2
}
                        ;black wasnt found yet keep searching
if x>%xe%               ;if far right wall passed
{
filedelete, give\colors.txt
gosub, exitsub
}
else
{
y+=1     ;check the next pixel down
}

if y>%ye%    ;if the bottom wall has been passed
{
x+=1    ;go to next column
iniread, y,myfile.ini,ocr3,6  ;Reset Y to top of search area
}
gosub, start

exitsub:
filedelete, give\colors.txt    ;clean up colors.txt so next ocr doesnt append to it
exitapp



change the ini file to reflect the upper left corner of your search area.....change the location that it clicks before it sends Ctrl V or remove that click if you dont need it

_________________
The early bird gets the worm but the second rat gets the cheese!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 3:18 pm 
Offline

Joined: January 29th, 2010, 6:05 pm
Posts: 41
Location: Decatur, AL
Here is the final working version. Added the hard x,y cord since in my case the vaule never moves from one spot.

Code:
coordmode,pixel ,relative
coordmode,mouse ,relative
IfNotExist, give
   {
      FileCreateDir, give   ;if you dont have a give folder make one
   }
notfound :=999

beginagain:

begin:
onexit, exitsub                     ;always delete colors.txt
iniread, x,myfile.ini,ocr3,5         ;get location to start ocr
iniread, y,myfile.ini,ocr3,6         ;get location to start ocr
ye :=(y + 12)                       ;Define search box height in pixels
xe :=(x + 50)                       ;Define search box width  in pixels
sleep, 200                     ;make sure values had time to load. Needed??


Start:                         
;mousemove, x,y                 ;Uncoment to check the area being scanned.
PixelGetColor, color, X, Y      ;search for start of character
if color = 0x000000            ;Change this to the color of the character you are scanning..careful because the edges of the lines may shade a bit
{
Start2:                         
;mousemove, x,y                 ; Uncomment to check the area searched SLOWS IT
PixelGetColor, color, X, Y      ;black found start saving results
fileappend, %color%, give\colors.txt    ;add current color to txt
if color = 0x000000         ;Change this to the color of the character you are scanning..careful because the edges of the lines may shade a bit
count=0                         ;black was found reset count for end of string trim
else
{
count+=8                ;black not found trim 8 more chars off at end
}   

                 



if x>%xe%                           ;IF END OF SEARCH AREA
{                                   ;Start processing data to black or white
fileread tobetrimmed, give\colors.txt
count2 = 1                     ;start at first character in file
loop
{

StringMid, check, tobetrimmed, %count2%, 8 ;this replaces 8 non "0x000000" at a time

if check =         ;no more characters to replace
break

if check != 0x000000
StringReplace, tobetrimmed, tobetrimmed, %check%, 0xFFFFFF, All
count2 += 8                             ;change to next 8 characters
}

 
StringTrimRight, trimmed, tobetrimmed, %count%    ;trim and save colors
filedelete give\colors.txt                               ;
fileappend, %trimmed%, give\colors.txt                 ;

loopcount=0                ; count loops so you dont search infinatly
char=0                     ; set char to 0 so you search from 0-9     
start3:                    ;start of compare current colors vs saved

if (loopcount > 500)         ; DIDNT FIND A MATCH in up to 500 files
{
InputBox, UserInput, i didnt recognize #, what number was that?., , 200, 100
clipboard = %userinput%
mouseclick, left, 395, 389
Send, {CTRLDOWN}v{CTRLUP}

fileappend, %trimmed%, give\%userinput%.txt
filedelete, give\colors.txt
exitapp
}

fileread, sig, give\%char%.txt
IfInString, sig, %trimmed%
{

clipboard = %char%
mouseclick, left, 395, 389
Send, {CTRLDOWN}v{CTRLUP}

filedelete give\colors.txt
exitapp
}
else
{
char+=1
loopcount+=1
gosub, start3
}
msgbox !!!!!
FileMove, give\colors.txt, give\%UserInput%.txt ,1    ;rename colors.txt
exitapp
gosub, begin
}
else
{
y+=1
}

if y>%ye%                ;Bottom of search area reached goto next colum and top
{
x+=1
iniread, y,myfile.ini,ocr3,6
}
gosub, start2
}
                        ;black wasnt found yet keep searching
if x>%xe%               ;if far right wall passed
{
filedelete, give\colors.txt
gosub, exitsub
}
else
{
y+=1     ;check the next pixel down
}

if y>%ye%    ;if the bottom wall has been passed
{
x+=1    ;go to next column
iniread, y,myfile.ini,ocr3,6  ;Reset Y to top of search area
}
gosub, start

exitsub:
filedelete, give\colors.txt    ;clean up colors.txt so next ocr doesnt append to it
exitapp


Thanks to everyone for all of your help and espically to Neverlevel for this amazing capture script :lol:


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn and 65 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group