Posts: 46
Threads: 10
Joined: Aug 2010
Hi Macroians!
I try to collect infos with Firefox.
For this i use the scan function. But there are several problems that make it much harder
to collect the information i need. I hope somebody can help me.
My Problem is, that i cant find out how to use the scan function for the same pictures.
There are 20 Pictures on one site.
scan needs to scan everything on the screen, scroll down, scan again etc..
and give the pictures a number to identify. I think it has to do something with arrays, but
i dont got enough experience to use it. When it scrolled to the end, the "function" needs to stop.
After that, the macro needs to scroll up again and click
on the first picture. A new site shows up. There i need to copy
the information after "Character Class:" How can i do that?
The copied information should be pasted in Notepad++
Then switch back to Firefox, go one site back and click on the second Image.
The last two things should repeat until the array has reached the last number.
I also tried to record and do the actions by hand, but that doesnt work, because
the site changes the layout a bit. Thanks in Advance for any help, and sorry for my bad grammar. :oops:
* I tried to do that in different ways, but every thing i tried brings up another problem, so i wanted to start from zero with professional help. :wink:
Posts: 12,147
Threads: 143
Joined: Dec 2002
Tried accessible object functions?
Also you can try to use Internet Explorer and html element functions. In most cases it is the best method to collect info from a web page.
In the newest QM version, 2.3.2, in scan you can specify match number...
scan ... 1
scan ... 2
...
To copy information also can be used accessible object or html element functions. Or maybe possible to click, or press Tab key until the field is focused, and then getsel.
Posts: 46
Threads: 10
Joined: Aug 2010
Thanks for Your help Gintaras!
Now i understood acc a bit. Before it can find a accessible object, it needs to find the window. :lol:
But what if I use acc and i want to click the same word every time in different lines/div's?
Like i discribet it with scan..
Do i need an array, or is there a simple method for solving that?
It would be good if the Macro klicks every Link before it visits the next page with Links.
Posts: 12,147
Threads: 143
Joined: Dec 2002
To do something for each related accessible object, we usually find the first object, and then repeatedly call Navigate to get next object, until error.
Acc a=acc(...) ;;find first object
rep
,;do something with a
,a.Navigate("xxxx"); err break ;;get next object
How to create the xxxx string:
you can see object relationships at the bottom of the 'Find accessible object' dialog;
you can create and test the string in the same dialog, 'Navigate' field.
-------
With html elements we would use different code. Maybe easier, maybe not, depends on the page. But need Internet Explorer.
Posts: 46
Threads: 10
Joined: Aug 2010
Thanks again!
With your help i understood much more of QM now and solved the Problem.
Only thing i need to know now. How can i execute another part of the script if acc errors?
Posts: 12,147
Threads: 143
Joined: Dec 2002
Acc a=acc(...)
err
,another part
,of the script
Posts: 46
Threads: 10
Joined: Aug 2010
Ah its that easy?! wow
Let me see if i understood..
err is some kind of "if" statement especially for errors, and it works for other errors too?
That would be cool!
Posts: 12,147
Threads: 143
Joined: Dec 2002
Yes.
AnyStatementThatMayThrowError
err
,this code runs
,only on error
Posts: 46
Threads: 10
Joined: Aug 2010
Thanks very much Gintaras!
I thaught that all problems are solved now..
but now i see that i need to repeat this proces until scan finds an image.
repeat
acc "blah"
err
"fubar"
if (scan == true) {
goto next
}
else goto repeat
im not sure if this code will work because im still new to QM.
But i will buy it for sure!
Its such a good program. And the price is very good too!
Posts: 12,147
Threads: 143
Joined: Dec 2002
Macro Macro1439
;repeat
acc "blah"
err
,"fubar"
,if scan(...)
,,goto next
,else goto repeat
or
Macro Macro1438
rep
,acc "blah"
,err
,,"fubar"
,,if scan(...)
,,,goto next
,,else continue
Posts: 46
Threads: 10
Joined: Aug 2010
Thanks again
I dont want to go on your nervers.. but i got one last question..
what if i want to repeat this part of the macro 20 times?
I think it has something to do with for loops. but i never learned them xD
Posts: 12,147
Threads: 143
Joined: Dec 2002
I like to answer.
To learn how to repeat 20 times, click rep and press F1.
Or type repeat in the small edit box in the top-right, and press Enter.
Posts: 46
Threads: 10
Joined: Aug 2010
WOW! QM is genius, I love it !
It seems so complex the first time, but with a little help its much easier^^
Posts: 46
Threads: 10
Joined: Aug 2010
Ok now i tried the following:
i+1
if(i>20)
out "i is 20 now!"
i == 0
goto FUBAR
But QM tells me:
"Error in test2: unknown identifier."
i even tried to declare the variable on the beginning of the code with:
i = 0
Thank you for your helpfullness!
Edit: i found out how to do that
int i
declares the variable^^
Posts: 12,147
Threads: 143
Joined: Dec 2002
In QM, variables must be declared, like
int i
or
str s
or
Acc a
...
Posts: 46
Threads: 10
Joined: Aug 2010
Is there a reason why acc couldnt find Text in Firefox?
Before two days it did work, and the page hasnt changed.
Posts: 12,147
Threads: 143
Joined: Dec 2002
Maybe the text object is not in screen. Then try to add flag 16.
Try to capture the object again. If something changed, the code will be different.
Posts: 46
Threads: 10
Joined: Aug 2010
Text object is in screen. Not only one of it.
Maybe its because i used "next"?
If i use "next", and the code got a rep on the beginning,
the "next" searches for the next "TEXT" object if the code repeats, am i right?
Posts: 12,147
Threads: 143
Joined: Dec 2002
"next" gets next sibling object that you see in object tree in the find dialog. It can be any object, not only TEXT.
Posts: 46
Threads: 10
Joined: Aug 2010
ah ok that makes next very complicated. Now i change my strategy and use scan
Posts: 12,147
Threads: 143
Joined: Dec 2002
Yes, often it is complicated.
For example, this will enumerate all "QUOTE" buttons in this page (QM forum view topic).
Macro Macro1439
Acc a=acc("Reply with quote" "LINK" win(" - Mozilla Firefox" "MozillaUIWindowClass") "" "" 0x1001)
rep
,out a.Value
,a.Navigate("parent5 next first2 next first last first"); err break
,
Posts: 46
Threads: 10
Joined: Aug 2010
Ok now i downloaded the newest version of QM to try the new scan function.
I read the QM Help about that, but i cant understand how to enumerate the scanned images.
And if i enumerated them, how can i say the macro that it should click always the next scan-number when the scan before was already clicked?
Thanks in Advance^^
Posts: 12,147
Threads: 143
Joined: Dec 2002
scan ... 1 ;;click object 1
scan ... 2 ;;click object 2
...
Do you want to find all, store coordinates into array, and later click?
Posts: 12,147
Threads: 143
Joined: Dec 2002
Macro Macro1451
ARRAY(RECT) a
RECT r
int i
;find all
for i 1 1000
,if(!scan("Macro1451.bmp" 0 r 128 0 i)) break
,a[]=r
;display coordinates of all
for i 0 a.len
,r=a[i]
,out F"{r.left} {r.top} {r.right} {r.bottom}"
Posts: 46
Threads: 10
Joined: Aug 2010
ARRAY(RECT) a
RECT r
int i
;find all
for i 1 1000 ;;can find up to 1000 pictures?
,if(!scan("Macro1451.bmp" 0 r 128 0 i)) break ;;what does break? Stop when all images found?
,a[]=r
;display coordinates of all
for i 0 a.len ;;instead of display i can use this to click the images?
,r=a[i] ;;this saves the coordinates of the click-area in the array a?
,out F"{r.left} {r.top} {r.right} {r.bottom}"
If i would play the for loop, will it click all images "at the same time"? Or does it click only one image per code?
Can you tell me if im right with my thaughts?
Btw.: how can i syntax-highlight the code? :oops:
Posts: 12,147
Threads: 143
Joined: Dec 2002
Macro Macro1451
ARRAY(RECT) a
RECT r
int i
;find all images
for i 1 1000000 ;;the 1000000 is just some number greater than the number of images
,if(!scan("Macro1451.bmp" 0 r 128 0 i)) break ;;find image 1, 2, and so on. Exit the loop when not found more.
,a[]=r ;;add coordinates of current image to array
;move mouse to each image
for i 0 a.len
,r=a[i] ;;store a[i] to r. Not necessary, but I like r.left better than a[i].left etc.
,mou r.left r.top
,wait 1
-----------
Quote:how can i syntax-highlight the code?
In QM, copy using menu Edit -> Other formats -> first item. Then simply paste here.
Posts: 46
Threads: 10
Joined: Aug 2010
Ive made it! :mrgreen:
QM selects now the second Icon. (Used the navigate option.)
But how can i tell qm that it should always select the next icon every time the code repeats?
The divs are always with the same structure.
something like that:
div
div
text
icon
div
div
text
icon
In my case the navigate code looks like this:
parent6 next last first child2 first first first
Posts: 12,147
Threads: 143
Joined: Dec 2002
Please show the macro.
What is the URL, if I can access it?
|