Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
max 255 local variables
#1
I bought the license for Quick Macros and I am quite satisfied, I like to tinker with the codes, I have a little problem though ...max 255 local variables!

Code:
Copy      Help
OnScreenDisplay "Test" 2 0 0 "" 0 0 1|4|128 "spla" 1111111111111111 0 "c:\macro\slash.jpg"
2
\Dialog_Editor


BEGIN DIALOG
0 "" 0x90C80AC8 0x0 0 0 315 192 "Macro"
3 Static 0x54000C0E 0x20 0 0 362 192 ""
1 Button 0x54038001 0x0 0 164 316 29 "OK"
END DIALOG
DIALOG EDITOR: "" 0x2030408 "" "" "" ""

str controls = "3"
str sb3
sb3 = "c:\macro\slash.jpg" ;;picture
if(!ShowDialog("Macro" 0 &controls)) ret
out sb3
_s.searchpath("$program files$\programm\test.exe")
if(_s.len)
    run "$$program files$\programm\test.exe"
    2
    sel mes("Test rilevato ed in fase di avvio, attendi che compaia a schermo e che sia completamente caricato, quindi premi il tasto OK" "ATTENZIONE" "")
        case 'C'
    int w=wait(1000 WC win("test" "WindowsForms10.Window.8.app.0.33c0d9d"))
else
    sel mes("test non trovato nella directory di default, avvia test manualmente ed attendi che il programma sia completamente caricato e VISIBILE a schermo, quindi cliccare sul pulsate OK!" "ATTENZIONE" "")
        case 'C'
2
int w1=wait(1000 WV win("test" "WindowsForms10.Window.8.app.0.33c0d9d"))
sel mes("Premi il tasto OK per avviare il processo di Login!" "test rilevato, pronto a partire!" "")
    case 'C'
3
int w2=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 1000 S "C:\macro\immagini\test1.bmp" child("_ctl.Window" "test" w2) 0 1|4|16|0x400 40 ;; '_ctl.Window'
lef
int w3=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 1000 S "C:\macro\immagini\Username.bmp" child("_ctl.Window" "test" w3) 0 1|4|16|0x400 80 ;; '_ctl.Window'
1
lef
1
opt slowkeys 1; spe 100
BlockInput 1
key (_s.getfile("C:\macro\Username\username1.txt"))
BlockInput 0
opt slowkeys 0
1
int w4=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 1000 S "C:\macro\immagini\password1.bmp" child("_ctl.Window" "test" w4) 0 1|0x400 70 ;; '_ctl.Window'
0.5
lef
0.5
opt slowkeys 1; spe 100
BlockInput 1
key (_s.getfile("C:\macro\Password\username1.txt"))
BlockInput 0
opt slowkeys 0
0.5
int w5=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 1000 S "C:\macro\immagini\login1.bmp" child("_ctl.Window" "test" w5) 0 1|16|0x400 70 ;; '_ctl.Window'
0.5
lef
int w6=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 1000 S "C:\macro\immagini\mypage.bmp" child("_ctl.Window" "test" w6) 0 1|16|0x400 70 ;; '_ctl.Window'
1
lef
3
int w7=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 0 S "C:\macro\immagini\1.bmp" child("_ctl.Window" "test" w7) 0 4|16 40 ;; '_ctl.Window'
int w8=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 10 S "C:\macro\immagini\back.bmp" child("" "WindowsForms10.Window.8.app.0.33c0d9d" w8 0x0 "" 2) 0 1|4|16|0x400 40 ;;barra degli strumenti
0.5
lef
int w9=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 15 S "C:\macro\immagini\mypage.bmp" child("_ctl.Window" "test" w9) 0 1|4|16|0x400 40 ;; '_ctl.Window'
2
int w10=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 10 S "C:\macro\immagini\exit.bmp" child("" "WindowsForms10.Window.8.app.0.33c0d9d" w10 0x0 "" 2) 0 1|4|16|0x400 40 ;;barra degli strumenti
lef
0.5
int w11=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 10 S "C:\macro\immagini\close.bmp" child("_ctl.Window" "test" w11) 0 1|4|16|0x400 70 ;; '_ctl.Window'
0.5
lef
1
int w12=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 10 S "C:\macro\immagini\menubluesta.bmp" child("_ctl.Window" "test" w12) 0 1|4|16|0x400 20 ;; '_ctl.Window'
0.7
lef
int w18=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 10 S "C:\macro\immagini\impostazioni.bmp" child("_ctl.Window" "test" w18) 0 1|4|16|0x400 40 ;; '_ctl.Window'
0.3
lef
0.3
int w19=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 10 S "C:\macro\immagini\applications.bmp" child("_ctl.Window" "test" w19) 0 1|4|16|0x400 40 ;; '_ctl.Window'
0.2
lef
int w13=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 10 S "C:\macro\immagini\manageapp.bmp" child("_ctl.Window" "test" w13) 0 1|4|16|0x400 40 ;; '_ctl.Window'
0.5
lef
int w14=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 10 S "C:\macro\immagini\2.bmp" child("_ctl.Window" "test" w14) 0 1|4|16|0x400 40 ;; '_ctl.Window'
0.5
lef
0.3
int w15=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 10 S "C:\macro\immagini\cleardata.bmp" child("_ctl.Window" "test" w15) 0 1|4|16|0x400 40 ;; '_ctl.Window'
0.3
lef
0.3
int w16=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 10 S "C:\macro\immagini\ok.bmp" child("_ctl.Window" "test" w16) 0 1|4|16|0x400 40 ;; '_ctl.Window'
0.3
lef
2.5
int w17=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 10 S "C:\macro\immagini\home.bmp" child("" "WindowsForms10.Window.8.app.0.33c0d9d" w17 0x0 "" 2) 0 1|4|16|0x400 40 ;;barra degli strumenti
1.5
lef
2
if(dir("C:\RobBot\Username\username2.txt"))
    int w20=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
    wait 1000 S "C:\macro\immagini\test1.bmp" child("_ctl.Window" "test" w20) 0 1|4|16|0x400 40 ;; '_ctl.Window'
    lef
else
    mes- "Tutto fatto!" "Login completati" "isa"
int w21=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 1000 S "C:\macro\immagini\Username.bmp" child("_ctl.Window" "test" w21) 0 1|4|16|0x400 80 ;; '_ctl.Window'
1
lef
1
opt slowkeys 1; spe 100
BlockInput 1
key (_s.getfile("C:\macro\Username\username2.txt"))
BlockInput 0
opt slowkeys 0
1
int w22=win("test" "WindowsForms10.Window.8.app.0.33c0d9d")
wait 1000 S "C:\macro\immagini\password1.bmp" child("_ctl.Window" "test" w22) 0 1|0x400 70 ;; '_ctl.Window'
0.5
lef
0.5
opt slowkeys 1; spe 100
BlockInput 1
key (_s.getfile("C:\macro\Password\username2.txt"))
BlockInput 0
opt slowkeys 0
0.5

Tried this part, if it finds the file, it must do essentially the same operations as declared from the global variable 5 to the end, then repeat again if it finds a new file.

Initially I repeated all operations always declaring new variables, it worked fine until the 255 error ... then ... how can I leave the variables to be fixed w5 so do not have to always declare and get at least 200 jobs instead of the current 13 max.

excuse my bad english, I hope be able to understand me
#2
Don't need to declare new variable for each window. Reuse existing variable. If it is the same window, then need just single win(...).

int w1=wait(1000 WV win("test" "WindowsForms10.Window.8.app.0.33c0d9d"))
...
wait 1000 S "C:\macro\immagini\test1.bmp" child("_ctl.Window" "test" w1) 0 1|4|16|0x400 40 ;; '_ctl.Window'
...
wait 1000 S "C:\macro\immagini\Username.bmp" child("_ctl.Window" "test" w1) 0 1|4|16|0x400 80 ;; '_ctl.Window'
...

If a macro needs more than 255 variables, it almost always means that the macro is incorrectly programmed. It should either reuse variables (like in this case), or replace similar code blocks with single loop (rep or for), or move parts of the macro to functions and call them, or use arrays or user-defined types. Then the macro also will be smaller, sometimes many times smaller.

When posting QM code, please copy the code in QM using menu Edit -> Other Formats. Don't use the Code button when pasting here.
#3
More info
http://www.quickmacros.com/help/Other/I ... MACRO.html
#4
thanks
I begin to understand something more, I'm spending hours reading the guide, but do not fully understand the examples of the various functions, so excuse me if I ask you to continue to ask for help ...

An array is a container, and can contain any variable right?
I thought there was a command to open an array and a command to close it, but in the examples is declared and that's it.

can be inserted into a single array or variable the following?

w5 = win ("test", "WindowsForms10.Window.8.app.0.33c0d9d")
1000 S wait "C: \ macro \ images \ login1.bmp" child ("_ctl.Window" "test" w5) 0 1 | 16 | 70 0x400;; '_ctl.Window'
0.5
lef
w6 = win ("test", "WindowsForms10.Window.8.app.0.33c0d9d")
1000 S wait "C: \ macro \ images \ mypage.bmp" child ("_ctl.Window" "test" w6) 0 1 | 16 | 70 0x400;; '_ctl.Window'
1
lef

Can you give me an example with this data so that it can understand how to do it and walk with my legs in the future?

I'm sorry, I feel like a child who has discovered a beautiful new toy and I would like to learn to use it.
#5
Code cannot be added to an array or other variable. Do you want to repeatedly execute this code? What parts must be different in each loop?

When posting QM code, please copy the code in QM using menu Edit -> Other Formats -> Forum. Don't use the Code button when pasting here.
#6
problem: I have 20 actions / variables declared:

int w1 = win ("test", "WindowsForms10.Window.8.app.0.33c0d9d")
1000 S wait "C: \ macro \ images \ test1.bmp" child ("_ctl.Window" "test" w2) 0 1 | 4 | 16 | 40 0x400;; '_ctl.Window'
lef
int w2 ...... etc.
int w3 ...... etc.

Of these 20 actions, each cycle will only change 5 (names of files containing data and instructions of use)

the macro completed the first cycle, meets the following:

if (dir ("C: \ macro \ Username \ username2.txt"))
w2 = win ("test", "WindowsForms10.Window.8.app.0.33c0d9d")
1000 S wait "C: \ macro \ images \ Rob1.bmp" child ("_ctl.Window" "test" w2) 0 1 | 4 | 16 | 40 0x400;; '_ctl.Window'
lef
else
mes-"All done!" "Login completed," "isa"
w3 = win ("test", "WindowsForms10.Window.8.app.0.33c0d9d")
1000 S wait "C: \ macro \ images \ Username.bmp" child ("_ctl.Window" "test" w3) 0 1 | 4 | 16 | 80 0x400;; '_ctl.Window'
1
lef
1
opt slowkeys 1; spe 100
BlockInput 1
key (_s.getfile ("C: \ macro \ Username \ username2.txt"))
BlockInput 0
opt slowkeys 0
1
w4 = win ("test", "WindowsForms10.Window.8.app.0.33c0d9d")
1000 S wait "C: \ macro \ images \ password1.bmp" child ("_ctl.Window" "test" w4) 0 1 | 70 0x400;; '_ctl.Window'
0.5
lef
0.5
opt slowkeys 1; spe 100
BlockInput 1
key (_s.getfile ("C: \ macro \ Password \ username2.txt"))
BlockInput 0
opt slowkeys 0
0.5

After these instructions, reprocesses the actions declared by a w5 w19 until it encounters the block with username3.txt instead of username2.txt, and resumes the cycle until find the file specified

I think conceptually simple, I know there is a solution but I can not find it
#7
In this case probably it is best to move the 20-line code to a function. Like in the guide.
Example:

Create function Func4258:

function w str'bmpFile
spe -1
wait 1000 S bmpFile child ("_ctl.Window" "test" w2) 0 1 | 4 | 16 | 40 0x400;; '_ctl.Window'
lef
...

to call the function:
int w1 = win ("test", "WindowsForms10.Window.8.app.0.33c0d9d")
Func4258 w1 "C: \ macro \ images \ test1.bmp"
...
Func4258 w1 "C: \ macro \ images \ test2.bmp"
...

Why in your code \ and | are surrounded with spaces? Like C: \ macro \ images \ test1.bmp
#8
Use google translate and put the spaces in automatically, the paths are correctly written without a space in the macro.

So, the problem is that from what I understand, creating a function, it does not work if I convert the macro to exe, and I just do what I want to run it on shared PC in the office without having to install the program to not go against the license .

There are other solutions?

I was able to triple the number of cycles performed, unfortunately at one point tells me that there are too many instructions for a single macro.
#9
Does not work in exe if the macro creates functions a run time, with RunTextAsFunction or newitem. But why to do it? Simply create one or several functions with menu File -> New and move parts of code there. Replace changing numbers and "strings" with parameter variables.
#10
Thanks, I solved everything, I used the function as a container, and whether or not I think I did this as it should, it works perfectly!


Forum Jump:


Users browsing this thread: 1 Guest(s)