Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Learned A Bit, Still Need Guidance
#1
In the time between creating my last help thread and posting this one, I have been messing around with some of the simple stuff in QM and reading the manual like it were a bible. Anyways, I'm just wondering if anybody can guide me in the right direction for understanding a few major key elements that QM is equipped with.

I'm not going to try to explain what I need to learn, instead I'm going to use noob code in order to try and explain what I'm trying to learn. Also, I don't know if I'm looking at it the right way, but I was wondering if it's a good idea to create functions with have "steps" of a macro. So, thank you for checking out this thread and all the help you provide me with will make me a better QM scripter.

if image.isFound(); then
click image;
wait for newImage;
else if newImage.isfound(); then
click newImage;

etc. Basically, what I'm trying to learn is how you can use if and else with finding an image on the screen. And instead of writing a big long list which the macro runs through, you could split up the list into separate functions? So instead of writing a long list, you would put each step of the macro within a function then the main macro would consist of only those functions perhaps. Another noob code of what im talking about:

new function isAtHome {
if image.isFound(); then
return true;
else
wait for image
return; }

new function step2 {
blah blah blah will contain the second portion which is completely identical to the first, simple looking for an image and when its found either click it drag it etc

MAIN MACRO:
if isAtHome = true then {
function step2



Again, I really appreciate help. And also, thank you for understanding the learning process and helping.
#2
Quote:if it's a good idea to create functions with have "steps" of a macro
...
And instead of writing a big long list which the macro runs through, you could split up the list into separate functions? So instead of writing a long list, you would put each step of the macro within a function then the main macro would consist of only those functions perhaps.
Yes, if you like it. If these functions will be used only in that same macro, it is better to use sub-functions. Else create new function through menu File -> New.

Macro Macro2479
Code:
Copy      Help
if sub.isAtHome(5 "k")
,sub.step2


#sub isAtHome
function param1 str'param2
;...


#sub step2
;...

Quote:how you can use if and else with finding an image on the screen
In dialog "Find image" uncheck "Error if not found". Then the dialog will create code with if.
Macro Macro2478
Code:
Copy      Help
int w=win("..." "...")
if(scan("image:hCD137C70" w 0 1|16))
,

Then you can add more code, and combine several scan in if/else.
Macro Macro2478
Code:
Copy      Help
int w=win("..." "...")
if(scan("image:hCD137C70" w 0 1|16))
,lef
else if(scan("image:hCD137C71" w 0 1|16))
,lef

;scan with flag 1: if found, moves the mouse and returns 1. If not found, returns 0.


Forum Jump:


Users browsing this thread: 1 Guest(s)