News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

GetCursorPos

Started by herge, October 27, 2008, 12:56:46 AM

Previous topic - Next topic

herge

 Hi All:

I am having trouble with this windows Api I am trying to
figure out the column position of a dos box.
we are getting values that do not change after
we write to the screen in a dos box.

CursorPos POINT <>
     org CursorPos
X dd 0
Y dd 0



   push ecx
   push edx
   invoke GetCursorPos,offset CursorPos
   mov ecx, X
   mov edx, Y
   pop edx



Regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

MichaelW

What is the "org CursorPos"?

I'm not sure what you are trying to do, but this is a quick demo of the GetCursorPos function, build as a console app.

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
      pt    POINT <>
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  @@:
    invoke GetCursorPos, ADDR pt

    ;----------------------------------------------------------------------
    ; Update the coordinates display only if at least one of them changes.
    ;----------------------------------------------------------------------

    .IF pt.x != esi || pt.y != edi

      ;---------------------------------------------
      ; The trailing tab character (9) advances the
      ; text cursor to the next tabstop position.
      ;---------------------------------------------

      print ustr$(pt.x),9

      ;----------------------------------------------------------------
      ; The spaces here overwrite any leftover characters from longer
      ; y-coordinate values, and the trailing carriage return character
      ; (13) with no line feed character (10) returns the text cursor
      ; to the start of the current line.
      ;----------------------------------------------------------------

      print ustr$(pt.y),"    ",13
      mov esi, pt.x
      mov edi, pt.y
    .ENDIF

    ;-------------------------------------------------
    ; Continue until the user presses the Escape key.
    ;-------------------------------------------------

    invoke GetAsyncKeyState, VK_ESCAPE
    test eax, eax
    jz @B

    inkey "Press any key to exit..."
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start




eschew obfuscation

herge

 Hi MichaelW:

Nice program. But I did have problems with
the @@ label. ie


C:\masm32\bin>\masm32\bin\ml /c /coff /Zi /Zd mi.asm 
Assembling: mi.asm
mi.asm(45) : error A2006: undefined symbol : @@


I wish @@ labels would always work but there don't.

Regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

jj2007

Quote from: herge on October 27, 2008, 07:51:54 AM
Nice program. But I did have problems with
the @@ label. ie

No problems here. In any case, "Cursor" in Windows jargon means the mouse. It seems you are looking for the text column position, which is quite a different story. Search MSDN.

sinsi

Have a look at GetConsoleScreenBufferInfo
Light travels faster than sound, that's why some people seem bright until you hear them.