Mouseclick to external program

Announcements, general discussion
Post Reply
friedrich
Posts: 5
Joined: 17 Mar 2012, 20:22

Mouseclick to external program

Post by friedrich » 18 Mar 2012, 10:52

First of all my personal compliments for this software.

I started using it with the Buttons - Saitek X52.
In fact when using the Saitek 'Profile' it happens that the mouse-cursor is making unpredictable moves.
Now this problem is resolved using hidmacros.

I have one question regarding the correct us of the "MourseClick" Script.

Example:
- external program "Test Program" with 1 Button
- New Macro "Test"
HIDMacros.MouseClick 2160, 175, 1

On Mouseclick Button is activated.
In this case the Mouse-Cursor is not returning to previous Window.

The Mouse-Move coordinates x, y should be valid only for the program itself. When moving the program on the screen, it does not work anymore.
When referrering to the "Window Title" then it should work indipendently of the program position on the screen.

My Question:
What is the programming code together with the "HIDMacros.Mouseclick...." SPECIFYING/REFERRING to the external
program "Test Program" (Window Title).

Must it be within a complete Sub..end sub or Function ecc...

I have considered your example but something i'm doing wrong using .....AppActivate "Test Program".
"""
Dim wsh
Set wsh = CreateObject("Wscript.Shell")
wsh.AppActivate "Notepad"
"""

Many thanks for your kind help,
regards,
Friedrich

admin
Site Admin
Posts: 735
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Mouseclick to external program

Post by admin » 19 Mar 2012, 08:13

I'm sorry I just don't understand the question.
Is the problem in mouse cursor not returning to original position? Or problem with activating (setting focus) of your test program?
Do you have the same problems with "standard" applications like Notepad?
Petr Medek
LUAmacros author

friedrich
Posts: 5
Joined: 17 Mar 2012, 20:22

Re: Mouseclick to external program

Post by friedrich » 20 Mar 2012, 10:27

Thank you for your quick answer.

What i would like to do is:
activating a BUTTON on the external Program 'Test Program' and returning to FSX - Video screen,

(i can do it as long the external program is on the SAME PLACE on the screen)

Dim wsh
Set wsh= CreateObject("Wscript.Shell")
wsh.AppActivate "Test Program"
HIDMacros.MouseClick 1570, 182, 1
wsh.AppActivate "Microsoft Flight Simulator X"

This script is working. To point out that the Button-Click, with joystick or the "TEST"-Button on HID-macros must be 'not short and not too long'.

The problem is that when I MOVE the 'Test Program' on the screen, the "Test Program-Button-coordinates" x,y are not recognized anymore within the "Test Program".

Many thanks for a possible solution.
regards,
friedrich

admin
Site Admin
Posts: 735
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Mouseclick to external program

Post by admin » 21 Mar 2012, 08:02

What about finding window's position by the script, using AutoIt ActiveX object as I described here: http://www.hidmacros.eu/forum/viewtopic.php?f=6&t=6
Would it be a solution?
Petr Medek
LUAmacros author

friedrich
Posts: 5
Joined: 17 Mar 2012, 20:22

Re: Mouseclick to external program

Post by friedrich » 21 Mar 2012, 14:19

Hi,
Let us start to find a solution to it.

Actual xy position data:

1) external program on a 2. screen (same if on 1. screen)

2) HID mouseclick coordinates x,y = 1570, 182 (Button on "Test Program")
x,y result as per your HID Mouse coordinates Menu choice

3) "Test Program" - Visual Basic - BUTTON coordinates as per VB Function-result:
'PointToClient' x,y 150, 105 relativ to program View itself
'PointToScreen' = x,y 2975, 270 relativ to Screen

Now, i believe there is a way WITHIN YOUR application in order to consider the initial Button x,y coordinates together with the Application Position on the Screen making it possible to move the external program while the original x,y coordinates do not changes as BASIC calculation values. The change would occur within your application knowing the x,y original data (as per script) " 1570, 182 " and adapt the position in base of the actual Form/Application position on the screen.

I don't know how you calculate the x,y with your "Mouse coordinates"Menu.

I think there is a way if it is true that we know the start pos and the actual program pos.

What do you think ?

best regards,
Friedrich

admin
Site Admin
Posts: 735
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Mouseclick to external program

Post by admin » 22 Mar 2012, 08:55

I read mouse coordinates somehow directly from mouse-related function, do not remember how exactly.
Regarding reading window position directly in HIDmacros: you can think of some script code using Wscript.Shell, but I don't know it.
And of course I could add such function to HIDmacros object, but currently it is not implemented.
Petr Medek
LUAmacros author

friedrich
Posts: 5
Joined: 17 Mar 2012, 20:22

Re: Mouseclick to external program

Post by friedrich » 03 Apr 2012, 09:33

OK, i will try and see what can be done and shall revert.

Post Reply