Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
control-level triggers
Hello again and thank you for answering my questions thus far.
I got a few more tasks that I have been unable to figure out on my own:

1. add a button (can be done by way of a toolbar) to a specific control within a window. for example, 

lets say that I want to add a button to the "save as" client of microsoft word, like the following:
[Image: UxXJztu]

And I only want the button to show up when "save as" is visible, and to disappear when not visible.

2. Is it possible to create a trigger such that a mouse click within a specific location of a control creates an action?

Say I want the label "Save As" to perform an action when clicked:
[Image: LsrgtBE]

Thank in advance for all the help!
1. Create this function. Edit the "edit this" lines to match your toolbar's name and control properties.
It opens and then shows/hides the toolbar when the control is visible or not.
Let this function have toolbar's trigger, ie run when the toolbar's owner window is created. The trigger should be "created and active" or "created and visible". Not "active" because this code does not support it well. The toolbar should not have a trigger.

Function show_hide_toolbar_word_saveas
Copy      Help
int w=TriggerWindow
int tb=mac("Toolbar name" w) ;;edit this. Opens the toolbar and attaches it to the trigger window of this function.
int visible=1
,if(!IsWindow(tb)) ret
,int c=child("Control name" "Control class" w 0x400) ;;edit this. Finds the control if exists and is visible.
,if visible!=(c!=0)
,,if(visible) hid- tb; else hid tb
2. Use a filter function with the mouse click trigger. Read about filter functions in QM Help.
Thank you Gintaras for the quick response
Unfortunately the code doesn't seem to work on my end. 

First, I get the error "this variable not initialized" every time I restart the application that I attempt to automate.  Every time I restart the application, I need to manually use the"find accessible objects" from the QM toolbar for the targeted control to be recognized by QM. Once I do that, the error disappears.
But then the control doesn't seem to have a child id ( "id" doesn't even appear in the list of the control's properties), and is assigned the value 0 by default.
Its very hard to attach a toolbar to that particular part of word but this is working for me on microsoft office 2106 word on windows 10

function starts when word window is created and active

Function WordSaveAsToolbarLauncher
Trigger !ca"- Word" "OpusApp"     Help - how to add the trigger to the macro
Copy      Help
int hwnd=TriggerWindow
,Acc a.Find(hwnd "STATICTEXT" "Save As" "class=NetUIHWND" 0x5 0.3)
,,if !IsWindow(hwnd)
,if !IsWindow(hwnd)

int cwh= a.Hwnd
int tb=mac("Toolbar1" cwh) ;;edit this(Toolbar1) to match your toolbar name. Opens the toolbar and attaches it to the trigger window of this function.
int visible=1
,,,goto top
,int c=cwh
,if visible!=(c!=0)
,,if(visible) hid- tb; else hid tb
Thank you Kevin. The code works when I use "active" as the trigger.

Now I'm attempting to do the same (ie attach a toolbar) for a different software. When I first start the software and run the code, I get the error "this variable not initialized" for the child window 'a'.  The only way for the code to find the child window is when I manually use the "find accessible objects" from the QM toolbar. After that, the code works. But when I restart the software again, the same issue occurs.
What should I add to the code to avoid having to manually point to the child window every time?
In other words, the child windows become "apparent" only after manually using the "find accessible objects" tool from QM, until the next time I restart the parent window. All the child windows are visible on the screen at all times.

Any ideas?
What program is it? Sounds like the program maybe has accessible objects disabled till you use find acc dialog. Show your code you are trying and tell us what program. Maybe then will have more ideas.
The program is a hospital-based software called Medicalis by Siemens Healthineers. It provides an integration platform for clinical and radiologic data.

I use the following code:
Copy      Help
int w=wait(3 WV win("Siemens Healthineers Enterprise Worklist" "*"))
Acc a.Find(w "DOCUMENT" "US TECH" "" 0x2000 10)

ARRAY(Acc) ac
a.GetChildObjects(ac -1 "" "" "" 16) ;;flag 16: +invisible
for _i 0 ac.len
   Acc& r=ac[_i]
   str role name value coordinate
   str liver gallbladder CBD RKidney LKidney
   int x y 
   r.Role(role); name=r.Name ; r.Location(x y) ; value=r.Value
   out F"{role} {name} {x} {y} {value}"
   coordinate=F"{x} {y}"
   sel a.Name
         sel coordinate
            case "201 731"
            case "199 1290"
            case "435 862"
            case  "185 989"

out F"{liver} {CBD} {RKidney} {gallbladder} {LKidney}"

This gives me the error: "Error Macro1: this variable not initialized". Pointing to the second line.

After I use the the "find accessible objects," the error gets resolved and the code works. I don't add any new code.

I do notice the "in web page" check box gets marked in the "find accessible objects "dialog.
I did try using "find HTML element," but none of the child windows (or even the parent window) are identified when I pull the drag tool over them. 

What code does "find accessible objects" run to make the child windows detectable?

Thanks in advance for any help,
int w=wait(10 WV win("Siemens Healthineers Enterprise Worklist" "*"))
Acc a.Find(w "DOCUMENT" "US TECH" "" 0x2000 10)

try waiting.
I tried increasing the wait time. It doesn't work
Try: in Options check "Enable Chrome acc when it starts". Press F1 to read more.
Thanks Gintaras,

My hospital has subscription to QM, and so this option is not provided in QM Options (Tools- Options -- General Tab)

I do think though that this would resolve the issue, as it does seem like the program pull pages from chrome.
Is there a work around?
Better install new version. Upgrades are free.
It worked! Thank you!

Forum Jump:

Users browsing this thread: 1 Guest(s)