Hi all, I'm trying to get and set cursor position.
This is what I have so far:
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
.code
start:
main proc
local pt:POINT
invoke GetCursorPos,addr pt
invoke Sleep,1000
invoke SetCursorPos,addr pt.x,addr pt.y
invoke ExitProcess,0
main endp
end start
When I run it and I don't even move the mouse, after 1 second it teleports to lower right corner. If I invoke a MessageBox with pt.x or pt.y as title/text, I only get 2 incomprehensible characters, similar to "}" or "". Like those square thingy, when it cannot be rendered. What am I doing wrong here?
Thanks in advance. :)
=>
invoke SetCursorPos,pt.x,pt.y
Quote from: ThexDarksider on October 07, 2009, 04:50:14 PM
If I invoke a MessageBox with pt.x or pt.y as title/text, I only get 2 incomprehensible characters, similar to "}" or "".
are you converting the numbers to strings before passing to MessageBox? e.g.:
include \masm32\macros\macros.asm
...
push 0
push sdword$(pt.x)
push sdword$(pt.y)
push 0
call MessageBox
Now it works, both cursor placement and MessageBox. Thanks! ;)
The only other thing I had to do is include msvcrt.inc and link against msvcrt.lib, because I saw something like "undefined symbol _crt_sprintf" or something like that, I guess that's ok lol.
That is necessary because of sdword$. Don't worry about it and congrats on figuring it out.
Paul