Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Work without activating window
#1
Hi,

Is it possible to automate clicking around in google chrome WITHOUT activating a google chrome window?

I'd like to run this macro in the background while I type notes somewhere else.
#2
Use accessible objects. Look in floating toolbar.
#3
Cool. Thanks!
#4
Gintaras,

How do I search for accessible objects within a specified area? For example (also, I want to do this without activating the program window), I want to search only the visible portion of a long webpage. Does that make sense?
#5
Cannot search only in visible part, unless the web browser marks other objects as invisible, then uncheck +visible.

Cannot search in a specified rectangle, but can search in another (parent) accessible object.

Acc aParent.Find(...)
Acc a.Find(aParent.a ...)

Actually searching in visible part or rectangle is possible with a callback function that gets object location and compares with the rectangle, but it makes slower.
#6
"Actually searching in visible part or rectangle is possible with a callback function that gets object location and compares with the rectangle, but it makes slower."

How do I do this?
#7
Macro Macro2183
Code:
Copy      Help
out

;Chrome, http://www.quickmacros.com/help/Functions/IDP_ACC.html, searching for text "acc".

int w=win("Google Chrome" "Chrome_WidgetWin_1")
act w

;at first we need the rectangle, in screen coordinates
RECT r
int capture=1 ;;change this: set to 0 or 1
if capture ;;capture rectangle at run time
,int w2 ;;may be a child window, not w
,if(2!CaptureWindowAndRect(w2 r)) ret
,MapWindowPoints w2 0 +&r 2 ;;client to screen coord
else ;;specify rectangle in macro
,SetRect &r 10 500 600 600
,MapWindowPoints w 0 +&r 2 ;;client to screen coord

;show rectangle; remove this later
OnScreenRect 0 r; 1; OnScreenRect 2

;search for an object; use callback function
Acc a.Find(w "STATICTEXT" "acc" "" 0x3011 0 0 0 &sub.Callback_Acc_Find &r)

;results
a.Mouse


#sub Callback_Acc_Find
function# Acc&a level RECT&r

;Callback function for Acc.Find or acc.
;Read more about <help #IDP_ENUMWIN>callback functions</help>.

;a - the found object.
;cbParam - cbParam passed to Acc.Find.

;Return:
;0 - stop. Let a will be the found object.
;1 - continue.
;2 - continue, but skip children of a.


;out a.Name
int x y
a.Location(x y)
if(PtInRect(&r x y)) ret

ret 1

Question 2: use dialog Text. The first button in the floating toolbar.
#8
Awesome! Thank you, Gintaras!
#9
I tried using the code above, but not sure how to proceed.

"Move mouse to a window or control, and press Shift. You can shift+move mouse to draw rectangle."

I tried drawing a rectangle and also pressing shift, but the macro just ends.

Please help.
#10
Move mouse to the top-left corner of the imaginary rectangle where the accessible object is.
Press Shift.
Move mouse to the bottom-right corner of the imaginary rectangle. It draws an on-screen rectangle.
Release Shift.
If a.Find finds the object in the rectangle, a.Move shows the object. Else error.

Or edit macro:
int capture=0
...
SetRect &r ...
#11
Doing the shift+mouse rectangle method gives me this

Error (RT) in <open ":1541: /779">Macro2: this variable not initialized. <help #IDP_ERR>?

Also, the code doesn't have a.move. It has a.mouse.

Is that a problem?

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

I tried the manual method by setrect and I get the same variable not initialized error

Error (RT) in <open ":1607: /991">Macro2: this variable not initialized. <help #IDP_ERR>?

The onscreen rectangle is in the right place though.
#12
Cannot be this error, unless this line (or other code) in your macro is modified and incorrect:
Acc a.Find(w "STATICTEXT" "acc" "" 0x3011 0 0 0 &sub.Callback_Acc_Find &r)
#13
ahh, ya. I changed that. Now, it says object not found. I could find the acc obj by the regular way. I tried the rect over many other areas, but same problem. I'm on firefox x32.


I just learned that I can find the accessible object without act w or having the object visible. That part is solved. Now, the problem is that I need to click it and then enter some text (again, without activating the window). Is that possible?
#14
Hi Gintaras,

Any updates?
#15
Acc.SetValue will not work in Firefox. Only in Internet Explorer.
Creating macros that work without activating the window is quite difficult. If possible, run the macros on another computer or virtual PC, for example vmware player.
#16
I'll try vmware. Thanks, Gintaras!


Forum Jump:


Users browsing this thread: 2 Guest(s)