Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
wait/macro sync issue
#1
Hello,

This is my first post, even though I've been using QM for several months now.

I'm trying to get a some text from program X, open a new file on program Y, then write the text from program X onto Y. Seems very simple, the problem is I can't figure out how to get the macro to wait the right amount of time for program Y to receive the text. Here's the macro:

str empt.getclip ;;epmty clipboard
act win("Centricity EMR" "Transparent Windows Client")
key Cc ;;copy selection
str s
s.getclip
int i=mac("Blank Report")
wait 0 H i ;;wait until report ready
act(win("SpeechQ Report Station - [Attending Recording]" "WindowsForms10.Window.8.app11"))
key (s)

Blank report is another dummy macro that gets a new blank report ready in program Y:

int w3=act(win("SpeechQ Report Station" ))
lef 50 284 w3
int w4=wait(5 win("New Report"))
lef 378 105 w4
lef 608 99 w4
int w5=win("" "ComboLBox")
lef+ 442 34 w5
lef- 439 93 w5
lef 214 97 w5
act w4
lef+ 389 230 w4
lef- 390 230 w4

I keep getting a "window not found" error at the line act(win("SpeechQ Report Station - [Attending Recording]" "WindowsForms10.Window.8.app11")). I think it's because Blank report is not done running by the time I go try to activate the window, even though I thought waiting for the synchronization handle would take care of the problem. That said, I can't come up with a workaround.

If I add the line:

int i=mac("Blank Report")
wait 0 H i ;;wait until report ready
wait 0 WC "SpeechQ Report Station - [Attending Recording]"
act(win("SpeechQ Report Station - [Attending Recording]" "WindowsForms10.Window.8.app11"))

the macro "hangs", i.e. waits indefinetely.

If I add the line:

int i=mac("Blank Report")
wait 0 H i ;;wait until report ready
5
act(win("SpeechQ Report Station - [Attending Recording]" "WindowsForms10.Window.8.app11"))

It waits 5 seconds, then runs Blank Report, then gives me the "window not found" error. That one I'm really confused about, it looks like the two threads are running independently. I've also tried running Blank Report without waiting for the synchronization handle, and it also didn't help.

Any help would be greatly appreciated. And please forgive my ignorance.

Diego Covarrubias
[email protected]
#2
I think it is because both macros are of type Macro.
Two items of type Macro cannot run simultaneously. One of them must be of type Function.
That is why wait does not wait. Sorry that QM does not give an error or warning here. :oops:

What to do now:
Open macro "Blank Report".
Open "Properties" dialog for it.
In "Macro properties" tab, check "Convert to function".
OK, Yes.
It renames the macro to "Blank_Report" (because function names cannot contain spaces). Change the name in the first macro.

You probably don't need to run the second macro in separate thread. You can simply call it as function.
Replace
Code:
Copy      Help
int i=mac("Blank_Report")
wait 0 H i ;;wait until report ready
to
Code:
Copy      Help
Blank_Report
#3
That did the trick! Thanks so much.


Forum Jump:


Users browsing this thread: 1 Guest(s)