Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DirectX - Mouse Won't Move
#1
Hi,

I'm trying to make a macro for use in a directx program. It is for a game, although not poker, but for a NeverWinter Nights Mod created by me -- the macro is used for testing.

Anyways, the game is in window mode. There seems to be two sets of mouse pointers. One when the game is activate and the other when the desktop is active.

I.E. The desktop pointer and game pointer do not follow each other.

When running a macro to move the mouse inside the active game window, it will not. It won't record those mouse movements inside the game window either.


Any solutions around this?
#2
hey gintaras i see you're online - help with this please! =D
#3
To move the mouse pointer, QM internally uses Windows API function SendInput. Another function that can be used is SetCursorPos (can be used from macros too). Also, using journal playback hook. I don't know how DirectX programs get mouse position. Probably it is at lower level, ie they don't get input generated programmatically.
#4
so there is no known workaround?
#5
I don't know much about DirectX programming, as well as about driver programming. This did not work:

Code:
Copy      Help
typelib DxVBLibA {E1211242-8E94-11D1-8808-00C04FC2C603} 1.0
DxVBLibA.DirectX8 dx._create
DxVBLibA.DirectInput8 di=dx.DirectInputCreate
DxVBLibA.DirectInputDevice8 dm=di.CreateDevice("{6F1D2B60-D5A0-11CF-BFC7-444553540000}")
dm.SetCooperativeLevel(_hwndqm DxVBLibA.DISCL_NONEXCLUSIVE|DxVBLibA.DISCL_BACKGROUND)
dm.SetCommonDataFormat(DxVBLibA.DIFORMAT_MOUSE2)
dm.Acquire

mou 0.5 0.5

DxVBLibA.DirectInputDeviceObjectInstance oi=dm.GetObjectInfo(0 DxVBLibA.DIPH_BYOFFSET)
int oid=oi.GetType>>8&255
out oid

ARRAY(DxVBLibA.DIDEVICEOBJECTDATA) a.create(1)
a[0].lData=128
a[0].lOfs=oid

dm.SendDeviceData(1 a DxVBLibA.DISDD_DEFAULT) ;;0x80004001, Not implemented
0.5
a[0].lData=0
dm.SendDeviceData(1 a DxVBLibA.DISDD_DEFAULT)
#6
Yeah, it's weird. You think you could use the simple record fuction and then simulate user control even within directx, i mean i thought they would be getting the mouse input from the same place - i guess not.

here is something odd --


when using this line of code (along with activating the window)

mou 163 406
lef+ 10 104


it will move the mouse position inside the directx app, but only to the top left corner. If i reverse the code (lef+ first) it goes to the very bottom right corner.

The X Y position don't effect it either (cause if it did, i wouldnt be writing this post).
#7
so this bug tells me that quick macros can interact with the mouse inside the directx app, just i don't know how to make it fully work.
#8
so i tested it a bit longer, and using those two bits of code with different XY will move the mouse around but seemingly in random spots.

Gintaras do you have any idea why this effects it but won't work normally?
#9
autohotkey.com works with the directx app and it moves the mouse

but i the interface (or lackthereof). I would love if quick macros could fix it or come up with a workaround to this issue, i would buy it in a second. i love it for everything else.
#10
There is another free program, AutoIt. These 2 programs are similar. AutoIt has a COM component that includes some its functions. You can try it. Example (in QM):

Code:
Copy      Help
typelib AUTOIT "C:\Program Files\AutoIt3\AutoItX\AutoItX3.dll"
AUTOIT.AutoItX3 ai._create
ai.MouseClick("LEFT" 300 300 1 5)
ai.MouseClick("LEFT" 400 400 1 5)
ai.MouseClick("LEFT" 500 300 1 5)

In the example used AutoItX3.dll is installed with AutoIt. Maybe autohotkey has a COM component too, I don't know (maybe it can be downloaded separately).
#11
so close yet so far, unless im doing something wrong.

The code you made works, but changing the X Y to the positions for the window (using AutoIt Active Window Info) makes the mouse, again, go up to the top left or bottom right corner.

I noticed using AutoIt Active window finder, if the X Y of the macro was 500 500 it will try and go to 20 20, or something odd like that.


I can't explain why this is happening, other then something to do with the two mouse cursors and directx.
#12
I installed Neverwinter Nights Demo. In full screen mode QM mouse commands work well. How to set window mode? Do i need your Mod? Or full version? Or newer DirectX?

XP SP2, DirectX 8.
#13
I'm curious about this as well because I am in a similar situation. I have a fairly complex script which works wonderfully, but it fails to pass along the mouse clicks to the DirectX window. How was this eventually resolved?
#14
not resolved
#15
Gintaras Wrote:There is another free program, AutoIt. These 2 programs are similar. AutoIt has a COM component that includes some its functions. You can try it. Example (in QM):

Code:
Copy      Help
typelib AUTOIT "C:\Program Files\AutoIt3\AutoItX\AutoItX3.dll"
AUTOIT.AutoItX3 ai._create
ai.MouseClick("LEFT" 300 300 1 5)
ai.MouseClick("LEFT" 400 400 1 5)
ai.MouseClick("LEFT" 500 300 1 5)

In the example used AutoItX3.dll is installed with AutoIt. Maybe autohotkey has a COM component too, I don't know (maybe it can be downloaded separately).

I installed the autoit to use your code above, can be run, but I created the code, but can not run, I hope you can help me have a look, thanks a lot

However, in the autoit editor, it can be run successfully, the following picture

Macro Macro2
Code:
Copy      Help
typelib AUTOIT "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll"
AUTOIT.AutoItX3 ai._create

ai.Run("notepad.exe")
ai.WinWaitActive("Untitled - Notepad")
ai.Send("This is some text.")


Attached Files Image(s)
   
#16
I am not too understand the autoit, I hope you can help me look at the QM, how to use Autohotkey input passwords, passwords can not correctly enter the problem, I have been troubled by a month, Thank you very much :oops:
#17
Macro Macro2770
Code:
Copy      Help
typelib AUTOIT "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll"
AUTOIT.AutoItX3 ai._create

ai.Run("notepad.exe" "" 1)
ai.WinWaitActive("Untitled - Notepad" "" 0)
ai.Send("This is some text." 0)
#18
You are right, but I do not understand why .au3 file, do not need to add those parameters, add parameters will be very troublesome, do not add can be achieved? Tongue
#19
Yes, but then need to use IDispatch, like in the example with AutoHotkey COM dll.

IDispatch ai._create("AutoIt ProgId, I don't know it")
ai.Run("notepad.exe")
...
#20
Feel Autoit than AHK complex, QM call AHK, more convenient, regardless of Autoit, thank you for your help Smile
#21
I put the dll file, put the QM folder, and then generate exe file, and then exe files and Dll files together to copy to another computer, double-click the exe file does not respond, how is this going on?

On the local computer also did not respond, but QM debugging is successful Confusedhock:


Attached Files Image(s)
   
#22
Don't need the typelib line when using IDispatch.

The COM dll can be anywhere, but it must be registered on that computer. If moved to another folder, need to register again.

Using unregistered dll also possible. Read in _create help.
#23
Understanding is not clear :oops: are There relevant cases, I can refer?
#24
Do you want to know how to:

1. Register COM components on a computer?
2. Use unregistered COM components?
#25
Yes! Ensure Generate exe, the other computer can run
#26
Why generated exe file on the QM computer can not run? Confusedhock:
#27
Don't know, I cannot test. What error it shows in QM output?

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

This macro shows various ways of using a COM dll.

Macro Macro2772
Code:
Copy      Help
;;this works, if the COM dll is registered
;typelib AUTOIT "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll"
;AUTOIT.AutoItX3 ai._create

;;this also works, if the COM dll is registered
;IDispatch ai._create("AutoItX3.Control")

;this will work in exe on computers where the COM dll is not registered
typelib AUTOIT "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll"
AUTOIT.AutoItX3 ai._create(0 "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll")
;The first path - where is the dll on your computer when creating exe.
;The second path - where is the dll when the exe runs.

;this works in any case
ai.Run("notepad.exe" "" 1)
ai.WinWaitActive("Untitled - Notepad" "" 0)
ai.Send("This is some text." 0)

;;this works works only if registered
;IDispatch d=ai
;d.Run("notepad.exe" "" 1)
;d.WinWaitActive("Untitled - Notepad")
;d.Send("This is some text.")
#28
An error occurred while generating exe


Attached Files Image(s)
   
#29
The typelib was somewhere declared differently. Restart QM.
#30
Leaving only one line on it, I later tested on other computers, thank you


Macro Macro3
Code:
Copy      Help
;typelib AUTOIT "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll"
AUTOIT.AutoItX3 ai._create(0 "$qm$\AutoItX3.dll")


Forum Jump:


Users browsing this thread: 2 Guest(s)