This is my first post on this forum and, first of all, i want to say thank to all, because in 1 day or reading this forum i'm already able to write some line of code without previous experience of programming, really useful.
Ok, let's go to my problem, and i ask sorry in advance for my bad english.
I want to realize a very complex tool for my backgammon club; This tool must be able to watch a match in online backgammon room, must identify the moves of the match, export to a file in a determined format, pass this file to a Backgammon Analysys software that can classify the skill (like expert, novice, ecc) of the observed players, and after this recognize the classified players a database.
This is a resume of my intention, just for make you all to know my pourpose.
I already started to write the line of codes for the first operation, of course i still haven't more knowledge of Macro Scheduler, but most of the issue i was be able to solve by myself, but i cannot be able to solve this 2 problem.
First Problem.
I need to use the image recognition on the screen for a pourpose,
this is the code. (comment are in italian, but the code is very simple)
Code: Select all
label>graphicrec
//Nella cartella c:\imgmacro dovranno andare i file immagine sui quali effettuare la
//comparazione.
//Prendo uno screenshot della situazioneattuale e lo salvo nella cartella img macro col nome
//actualscreen.bmp
GetScreenRes>Xres,Yres
wait>2
ScreenCapture>0,0,Xres,Yres,C:\imgmacro\screenactual.bmp
MessageModal>screenshot catturato, premere ok per iniziare la comparazione
FindImagePos>C:\imgmacro\compactive.bmp,C:\imgmacro\screenactual.bmp,10,1,Xcoord,Ycoord,matchfound
MessageModal>Ho effettuato la comparazione, e ho trovato le seguenti coordinate X %Xcoord% e Y %Ycoord%, ho trovato %matchfound% corrispondenze
I use the findimagepos for compare a previous stored fragment of image and i expect to store the results on the array Xcoord, Ycoord and matchfound.
I set a MessageModal for show me the result, but the problem is that i have the value 1 on the array matchfound, so the compare process has gived a match, but i havent anything on the array Xcoord and Ycoord, so the message modal dialog show me directly %Xcoord% and %Ycoord% because this array has not be setted.
What's wrong?
Second Problem
I need to check if the screen res is 1600X1200, if isn't block the script (and this work good in my code); after this i need to get the full window name of a child windows of the backgammon software for move in a certain position, and after start all the getpixelcolor
control for identify the moves. I can see this window name on the tool Window Viewer of macro scheduler. The name of this window every change but some text of the name is stille the same; So i thinked to use the procedure FindWindowWithText for get the full name and after move whenever i want.
This is my code for this
Code: Select all
GetScreenRes>Xres,Yres
If>Xres=1600,control2,ResError
ENDIF
// setto il label di errore e il messaggio.
Label>ResError
Let>MSG_STAYONTOP=1
Let>MSG_CENTERED=1
//in futuro rimuovere questi messaggi.
MessageModal>La risoluzione dello schermo non è impostata a 1600x1200. Questa automazione ha bisogno di una risoluzione 1600x1200 per funzionare.
// Chiudo le macro.
goto>endprocedure
// dopo aver controllato la res X, controllo la Y, un pò brutto come codice
Label>control2
if>Yres=1200,continue,ResError
ENDIF
Label>continue
//Avviso che il check della risoluzione è andato a buon fine.
//in futuro togliere questi messaggi.
MessageModal>Screen Resolution is OK (1600x1200).
//controllo se una finestra di gioco è aperta tramite il testo ricorrente "vs."
Let>WIN_USEHANDLE=0
//cerco una finestra che contenga il testo desiderato "vs.", se la trovo
//memorizzo il nome finestra in una variabile, altrimenti quella variabile conterrÃÂ
//il valore NOT FOUND
FindWindowWithText>vs.,1,NomeFinestra
If>NomeFinestra=NOT FOUND,windowerror,Muovifinestra
Label>windowerror
MessageModal>Non ho trovato una finestra di gioco BgRoom, pertanto non posso spostarla. Ricontrollare eventuali errori.
goto>endprocedure
Label>Muovifinestra
MessageModal>Ho trovato una possibile finestra di Gioco BgRoom, chiamata %NomeFinestra%, ora tento di spostarla nella posizione prestabilita.
MoveWindow>%NomeFinestra%,5,8
label>endprocedure
MessageModal>La procedura è stata completata, è possibile che sia stata completata con successo oppure un errore abbia rimandato a fine procedura. Segue Messaggio che Mostra i valori delle principali variabili della procedura, al fine di procedere ad un debugging.
Wait>1
MessageModal> Valore variabili risoluzione X è %Xres%, Y è %Yres%, Il nome finestra Bgroom Rilevata è %NomeFinestra%.
Like i said before i can be able to see the window name that i need
(i remember, is a child of the Backgammon oline room software) with the Macro Scheduler Window viewer tree tool.
I did any mistake?
Thank you to all who want to reply to my message, i hope to know you all iin the near future.
Best Regards
Alex