Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
control-level triggers
#1
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]
https://imgur.com/hUOf3Ya

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]
https://imgur.com/VTKVUWI



Thank in advance for all the help!
#2
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:

Function show_hide_toolbar_word_saveas
Code:
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
rep
,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)
,,visible=c!=0
,,if(visible) hid- tb; else hid tb
,0.5
#3
2. Use a filter function with the mouse click trigger. Read about filter functions in QM Help.
#4
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.
#5
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
Code:
Copy      Help
int hwnd=TriggerWindow
;top
rep
,0.2
,Acc a.Find(hwnd "STATICTEXT" "Save As" "class=NetUIHWND" 0x5 0.3)
,err
,,if !IsWindow(hwnd)
,,,ret        
,if(a.Hwnd)
,,err
,,,continue
,,break
,if !IsWindow(hwnd)
,,ret

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
rep
,if(!IsWindow(tb)) 
,,if(IsWindow(hwnd))
,,,goto top
,,else
,,,ret
,int c=cwh
,if visible!=(c!=0)
,,visible=c!=0
,,if(visible) hid- tb; else hid tb
,0.5
#6
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?
#7
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?
#8
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.
#9
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:
 
Code:
Copy      Help
 
int w=wait(3 WV win("Siemens Healthineers Enterprise Worklist" "WindowsForms10.Window.8.app*"))
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
      case "US TECH ABDOMEN LIMITED"
         sel coordinate
            case "201 731"
               liver=value
            case "199 1290"
               RKidney=value
            case "435 862"
               gallbladder=value
            case  "185 989"
               CBD=value


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,
Cuitino
#10
int w=wait(10 WV win("Siemens Healthineers Enterprise Worklist" "WindowsForms10.Window.8.app*"))
3
Acc a.Find(w "DOCUMENT" "US TECH" "" 0x2000 10)

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

My hospital has subscription to QM 2.4.2.2, 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?
#14
Better install new version. Upgrades are free.
#15
It worked! Thank you!


Forum Jump:


Users browsing this thread: 1 Guest(s)