Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
test macro file => compiled version .exe takes argument
#1
Hello,

My apologies for the difficult description for a "simple problem".
I am currently finishing up my first macro, but I have the following "problem".

The compiled macro (.exe) uses an argument which I provide in a windows shortcut.
I have the compiled executable "winlauncher.exe"
And it gets a parameter in the form of a path to a textfile and a extra string which are provided in the windows shortcut of the .exe file.
The shortcut would look something like this:
Code:
Copy      Help
c:\winlauncher.exe winlist=c:\winlist.txt config=config2
executable => c:\winlauncher.exe
path to a text file => winlist=c:\winlist.txt
extra string => config=config2

I currently make a test variable "test_command" and fill it with the arguments:
path to a text file => winlist=c:\winlist.txt
extra string => config=config2

So it looks something like this
Code:
Copy      Help
str test_command="winlist=c:\winlist.txt config=config2"

Then I create a piece of code that checks if the current filename is "qm"
Macro temp
Code:
Copy      Help
str is_qm.getfilename(ExeFullPath)
if(is_qm="qm")
,;...actions using the "test_command" variable
else
,;...actions using the predifined "_command" variable

Based on the code above I decide to use: "_command" or my test command variable "test_command"

Is there a better way to approach this?
Or is the method I am using fine?

Edit:
I now have another "major" problem, the function "RunTextAsFunction" can't be used in a macro that you want to compile to exe
Code:
Copy      Help
Error in RunTextAsFunction:  cannot be used in exe.

its a simple key function

Code:
Copy      Help
RunTextAsFunction F"key {vwinkey}"

The macro works, but compiling to .exe is not possible
#2
Your description is very clear.

The best way:
Macro Macro1794
Code:
Copy      Help
#if EXE
;...actions using the predifined "_command" variable
#else
;...actions using the "test_command" variable
#endif

---------------

How to use variable keys with key:
Macro Macro1795
Code:
Copy      Help
;For text, use string variable in ().
;For other keys, use virtual-key code of the key in (). Look for the table in QM help.
;Cannot use variable QM key codes in exe, unless the macro converts each QM key code to virtual-key code using function QmKeyCodeToVK.

str s="text" ;;text
int vk=VK_RETURN ;;Enter

key (s)
key (vk)

other example
Macro Macro1796
Code:
Copy      Help
int k1 k2
k1=VK_LWIN
k2='R'

key (k1)(k2) ;;Win+R
#3
That's it!! THANKS!!

My first windows macro is 99% done exept for one last thing.
Everything in the macro works but the RUN command seems to freeze a bit when I use the command:
Code:
Copy      Help
run "D:\__DIRECT\___PORTABLE_APPS\__File_&_system-tools\virtual_desktops_portable\VirtuaWin.exe"

If I create a new macro with only the above command, it works.

But I get a pop-up: "Waiting while the window is hung" when I use it like this:


Macro winlauncher
Code:
Copy      Help
,,,;;PROCESS VIRTUAWIN
,,,int vwinkey=arr[0]
,,,str vwin=arr[1]            
,,,if(!empty(vwin))
,,,,int pid = ProcessNameToId("virtuawin" 0 1)
,,,,if(pid=0)
,,,,,run vwin "" "" "" 2
,,,,,key CSAF"{vwinkey}"
,,,,else
,,,,,key CSAF"{vwinkey}"

I am trying to wait for the "virtuawin" proces and if the pid is higher = 0 then it must be booted.

Whatever switch I use for "RUN" i keep getting the pop-up and it takes about 4 to 5 times longer to load "virtuawin.exe".
For example using this I keep getting the same problem:
Code:
Copy      Help
run vwin "" "" "" 0x200

important note: virtuawin always starts minimized and shows a green icon in the systray when loaded.

As an alternative I could use the windows command way
Code:
Copy      Help
cmd /c  " .... "
But I don't know how to put that in QM.
#4
Add a delay after run.
Also, to not show the "hung" message box, you can use opt hungwindow.

Macro Macro1797
Code:
Copy      Help
run vwin "" "" "" 0x200
2
opt hungwindow 3
key (vwinkey)
#5
Thanks again for your quick and helpful response!!!!!!!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)