Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run different variables accordingly
#1
First of all, I would like to thanks for the software creator. It's a greally powerful program. I just download and play around it, it's a really time saving software.

I have a macro like this:

run "F:\Program Files\Avidemux\avidemux2.exe" "--load G:\files\av\divx\filename --begin bframe --end eframe"
wait 15
act win("Avidemux 2 filename" "gdkWindowToplevel")
'Cs
5 win("Select file to save " "gdkWindowToplevel")
'filenameDTTTY
ifa win("GDK client window" "gdkWindowToplevel")
'RY
ifa win("Q Factor (set 4)" "gdkWindowToplevel")
'RB3TTY
wait 0 WV "GDK client window"
'Y
lef 358 21 win("Avidemux 2 filename" "gdkWindowToplevel")
'Cq

There are several variables:

filename
bframe
eframe

Each filename must follow with its own bframe and eframe accordingly. Since I have hunderds of file need to edit. I just copy the above marco hundereds times and then edit the filename, bframe and eframe one by one.

But I think there must be some better way to do it without copy the macro hundereds times. Hope some body can point me the right direction. Thanks.
#2
You can make just single macro. It woul pick these filenames/bframes/eframes from a list. Then I need to know in what media and format is (or will be) the list? Is it a text file, Excel sheet, ... ? Or you would like to enter these values in a dialog at the run time? Or ...

Of course, you can create multiple macros, but then better would be to place the code in a function. Then each macro would be only single line. Or, you could place all in single menu or toolbar. Create function Maxbear_1 and paste this code using menu Edit -> Other formats -> Paste escaped:

Code:
Copy      Help
;/
function str'filename str'bframe str'eframe

;Space and slash at the beginning prevents the function from executing if you accidentally press the Run button. This function only can be called from a macro or function.
;filename, bframe and eframe are local string variables that are populated when the function is called.


spe -1 ;;set speed to the default macro speed

;In QM, variables cannot be inserted directly into quoted strings like in php.
;Instead, are used str functions "format" or "from" to create the final string. You can use the Text dialog (select "Text with variables").


str s1 s2 ;;create two string variables
s1.format("--load G:\files\av\divx\%s --begin %s --end %s" filename bframe eframe) ;;format is better when there are many variables and text between. %s in the first string are replaced with values of the variables.
s2.from("Avidemux 2 " filename) ;;from is easier to use, and is better to join two or three strings, although can be used to join more strings and numeric values.

run "F:\Program Files\Avidemux\avidemux2.exe" s1
wait 15
act win(s2 "gdkWindowToplevel")
'Cs
5 win("Select file to save " "gdkWindowToplevel")
'(filename)DTTTY ;;here string variable can be inserted by enclosing in ()
ifa win("GDK client window" "gdkWindowToplevel")
,'RY
ifa win("Q Factor (set 4)" "gdkWindowToplevel")
,'RB3TTY
wait 0 WV "GDK client window"
'Y
lef 358 21 win(s2 "gdkWindowToplevel")
'Cq

Each macro would look like this:

Code:
Copy      Help
Maxbear_1 "test.txt" "abc" "xyz"

Instead of using multiple macros, you could use single menu or toolbar, like this:

Code:
Copy      Help
test :Maxbear_1 "test.txt" "abc" "xyz"
test2 :Maxbear_1 "test2.txt" "abc2" "xyz2"
test3 :Maxbear_1 "test3.txt" "abc3" "xyz3"
#3
Thanks a lot.

Actually, filename is a video filename. I usually store all my values in a txt file.

I tried to run your function. But I always stop at this line:

5 win("Select file to save " "gdkWindowToplevel")

It said can't find that windows

It's strange, If I don't use your function and use my macro, it's ok. But if I use your fuction, it just stop at that line. It's just a windows under avidemux to ask you to save a file and enter the filename. Don't know why can't that winodws.

Is there any more general term that I can refer to a window? For example, next window in a software?
#4
Sorry, some filename instances were not replaced. Copy/paste the function code again, now should work.
#5
Quote:But I think there must be some better way to do it without copy the macro hundereds times.

If filenames and other data are stored in a text file, you could open the file in notepad, and use a hotkey to run macro for each line. The macro selects line using Shift+End, copies to a variable using str function getsel, moves to the next line using Home Down, parses using tok or regexp, and calls the function. If you need help, please post part of the file because I need to know how to parse.
#6
Thanks a lot.

I tried the function again. I got the following error when the software request me to enter the saved filename. It just stop there and didn't enter any filename.

Error (RT) in Maxbear_1: wait timeout

Here is my macro to call the function:

Maxbear_1 "bn0066a.avi" "14875" "151995"

As for the text values, I store the value in this way:

filename bframe eframe

e.g.

bn0001.avi 1234 8765
bn0002.avi 3456 7890
bn0003.avi 4567 6789
....... so on.
#7
5 win("Select file to save " "gdkWindowToplevel")

In this line? Check whether window name is or contains "Select file to save ". Does it really ends with space, and does it match case.
#8
Open the list file in notepad, place text cursor at the beginning of a line, and run this macro. Run this macro for each line. This macro gets the line, moves the cursor to the next line, parses, and calls Maxbear_1.

Code:
Copy      Help
key HSE
str s.getsel
s.rtrim
if(!s.len) ret
key HD
ARRAY(str) a
findrx s "(.+) (\d+) (\d+)" 0 0 a

;to see parsed values, uncomment (delete spaces) following 3 lines
;out a[1]
;out a[2]
;out a[3]


Maxbear_1 a[1] a[2] a[3]


Forum Jump:


Users browsing this thread: 1 Guest(s)