Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Background clicking
#1
Is there any way I can make a macro click inside a window in the background, possibly while playing a game/surfing the web.
The point is I want a macro that can exist and operate while its in the background of the rest of the system activity.

I currently have this
Code:
Copy      Help
lef 677 276 w1 1 ;;SunAwtCanvas
wait 1
lef 519 635 w1 1 ;;SunAwtCanvas
wait 1
lef 364 563 w1 1 ;;SunAwtCanvas
wait 1
lef 760 506 w1 1 ;;SunAwtCanvas
wait 54
lef 677 276 w1 1 ;;SunAwtCanvas
wait 1
lef 519 635 w1 1 ;;SunAwtCanvas
wait 1
lef 364 563 w1 1 ;;SunAwtCanvas
wait 1
lef 760 506 w1 1 ;;SunAwtCanvas
wait 54
#2
Try SendClickMessage
Mouseclick issue

Also try accessible object functions, but need QM 2.4.2 if it is a Java window.
#3
Gintaras Wrote:Try SendClickMessage

Also try accessible object functions, but need QM 2.4.2 if it is a Java window.

in relation to your link, how do i get that code to work? im new to QM

Code:
Copy      Help
rep 1500
    SendClickMessage 677 276 w1 1 ;;SunAwtCanvas
    wait 0.7
    SendClickMessage 519 635 w1 1 ;;SunAwtCanvas
    wait 1
    SendClickMessage 364 563 w1 1 ;;SunAwtCanvas
    wait 1
    SendClickMessage 760 506 w1 1 ;;SunAwtCanvas
    wait 52.7
    SendClickMessage 677 276 w1 [1] [1]
#endregion

I have this but sendclickmessage is just grey it isnt colored
#4
create a new function
name it SendClickMessage
then copy the code from Gintaras's post from the link he posted and paste it into the new function you created in qm editor
then your function wont be gray and should work if your code is correct.If not come back and someone will help you get it working.
#5
Kevin Wrote:create a new function
name it SendClickMessage
then copy the code from Gintaras's post from the link he posted and paste it into the new function you created in qm editor
then your function wont be gray and should work if your code is correct.If not come back and someone will help you get it working.

That must've been what I did wrong ! Smile I named the function wrong. Thanks I'll try again when I get home and keep you updated.
#6
Code:
Copy      Help
;/
function x y hwnd [flags] [button] ;;flags: 1 client area. button: 0,1 left, 2 right, 3 middle, 4 left double

Sends mouse click message to the window without moving the mouse.
This works not with all windows.
The window can be inactive. However the function activates some windows.
In most cases works synchronously, ie waits while the window is processing the messages.
No errors, no return value, no autodelay.
To insert code with this function, use the Mouse dialog and then replace 'lef' to 'SendClickMessage'.

x y - mouse coordinates relative to hwnd. If flag 1 used - relative to client area of hwnd.
hwnd - handle of window or child window.

EXAMPLE
SendClickMessage 17 15 id(129 win("Calculator" "SciCalc"))


if(!(flags&1)) RECT r; GetWindowRect(hwnd &r); x+=r.left; y+=r.top; ScreenToClient(hwnd +&x) ;;window to client
int w1=child(x y hwnd 8); err
if(w1)
    MapWindowPoints(hwnd w1 +&x 1)
    hwnd=w1

int m1 m2 mk m11
sel button
    case 2 m1=WM_RBUTTONDOWN; m2=WM_RBUTTONUP; mk=MK_RBUTTON
    case 3 m1=WM_MBUTTONDOWN; m2=WM_MBUTTONUP; mk=MK_MBUTTON
    case else m1=WM_LBUTTONDOWN; m2=WM_LBUTTONUP; mk=MK_LBUTTON
m11=m1

int xy=y<<16|x
g1
SendMessage(hwnd WM_SETCURSOR hwnd m1<<16|HTCLIENT)
SendMessage(hwnd m11 mk xy)

SendMessage(hwnd WM_SETCURSOR hwnd m2<<16|HTCLIENT)
SendMessage(hwnd m2 0 xy)

if(button=4) button=0; m11=WM_LBUTTONDBLCLK; goto g1

As function SendClickMessage

Code:
Copy      Help
int w1=act(win("SunAwtFrame"))
rep 1500
    SendClickMessage 677 276 w1 1 ;;SunAwtCanvas
    wait 0.7
    SendClickMessage 519 635 w1 1 ;;SunAwtCanvas
    wait 1
    SendClickMessage 364 563 w1 1 ;;SunAwtCanvas
    wait 1
    SendClickMessage 760 506 w1 1 ;;SunAwtCanvas
    wait 52.7
#endregion
As code for function to perform on.

I'm getting an issue where its just clicking where my mouse is, and it isnt changing to the xy pos
#7
It depends on window. The function does not work if the window, when it receives the mouse message, gets mouse coordinates not from message parameters but eg calls GetCursorPos. Or if gets window from point.

I tested SendClickMessage with a SunAwtFrame window. Generally it does not work because of the both above reasons. With some modifications it works, but only when the part of the window is visible, not under other windows.

Accessible object functions in QM 2.4.2 work with Java windows, but cannot click exactly at specified position. DoDefaultAction can be used only to click a button etc, but not to click at specified x y.


Forum Jump:


Users browsing this thread: 1 Guest(s)