Jump to content

get console click coords


Recommended Posts

Get the console font size.

then get the client size.

then just some maths calc. 

saludos

Link to comment
Share on other sites

maybe like this:

(click outside cmd or close cmd to exit)

Run(@ComSpec) ; start cmd
;
; default cmd should be 80 cols x 44 lines
$cols = 80
$rows = 44

WinActivate("[Class:ConsoleWindowClass]")
AutoItSetOption("MouseCoordMode", 2) ; relative coords to the client area of the active window
$size = WinGetClientSize("[Class:ConsoleWindowClass]")
$x = $size[0] / $cols
$y = $size[1] / $rows
;
Do
    Local $pos = MouseGetPos()
    ConsoleWrite("Mouse col= " & Int($pos[0] / $x) + 1 & @TAB & "row= " & Int($pos[1] / $y) + 1 & @CRLF)
    Sleep(300)
Until Not WinActive("[Class:ConsoleWindowClass]")
;
AutoItSetOption("MouseCoordMode", Default) ; reset to default coords mode

slightly modified version, to catch coordinates of cursor only on clicks

#include <Misc.au3>
Local $dll = DllOpen("user32.dll"), $pos
Run(@ComSpec) ; start cmd
;
; default cmd should be 80 cols x 44 lines
Local $cols = 80
Local $rows = 44
Local $MyConsole = WinWaitActive("[Class:ConsoleWindowClass]")
;
AutoItSetOption("MouseCoordMode", 2) ; relative coords to the client area of the active window
;
Local $size = WinGetClientSize("[Class:ConsoleWindowClass]")
Local $x = $size[0] / $cols
Local $y = $size[1] / $rows
;
While WinExists($MyConsole)
    If _IsPressed("01", $dll) And WinActive($MyConsole) Then
        $pos = MouseGetPos()
        ConsoleWrite("click on col= " & Int($pos[0] / $x) + 1 & @TAB & "row= " & Int($pos[1] / $y) + 1 & @CRLF)
        Sleep(300)
    EndIf
WEnd
DllClose($dll)
WinClose($MyConsole)
AutoItSetOption("MouseCoordMode", Default) ; reset to default coords mod

Edit:

added another version

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

This is to get the coordinates in your own scripts console. But you can attach to another console as well.

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Change2CUI=y
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
;funkey 2014.10.02
#include <WinAPI.au3>


#region EventTypes
Global Const $FOCUS_EVENT = 0x10
Global Const $KEY_EVENT = 0x01
Global Const $MENU_EVENT = 0x08
Global Const $MOUSE_EVENT = 0x02
Global Const $WINDOW_BUFFER_SIZE_EVENT_EVENT = 0x04
#endregion EventTypes

#region EventRecords
Global Const $tagFOCUS_EVENT_RECORD = "BOOL bSetFocus;DWORD dwPadding[3];"
Global Const $tagKEY_EVENT_RECORD = "BOOL bKeyDown;WORD wRepeatCount;WORD wVirtualKeyCode;WORD wVirtualScanCode;WCHAR UnicodeChar;DWORD dwControlKeyState;"
Global Const $tagMENU_EVENT_RECORD = "UINT dwCommandId;DWORD dwPadding[3];"
Global Const $tagMOUSE_EVENT_RECORD = "SHORT X;SHORT Y;DWORD dwButtonState;DWORD dwControlKeyState;DWORD dwEventFlags;"
Global Const $tagWINDOW_BUFFER_SIZE_RECORD = "SHORT X;SHORT Y;DWORD dwButtonState;DWORD dwControlKeyState;DWORD dwEventFlags;"

Global Const $tagINPUT_RECORD_FOCUS = "WORD EventType;struct;" & $tagFOCUS_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_KEY = "WORD EventType;struct;" & $tagKEY_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_MENU = "WORD EventType;struct;" & $tagMENU_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_MOUSE = "WORD EventType;struct;" & $tagMOUSE_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_WINDOW_BUFFER_SIZE = "WORD EventType;struct;" & $tagWINDOW_BUFFER_SIZE_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD = "WORD EventType;DWORD dwDummy[4]"
#endregion EventRecords

#region Console modes
Global Const $ENABLE_ECHO_INPUT = 0x04
Global Const $ENABLE_INSERT_MODE = 0x20
Global Const $ENABLE_LINE_INPUT = 0x02
Global Const $ENABLE_MOUSE_INPUT = 0x10
Global Const $ENABLE_PROCESSED_INPUT = 0x01
Global Const $ENABLE_QUICK_EDIT_MODE = 0x40
Global Const $ENABLE_WINDOW_INPUT = 0x08
Global Const $ENABLE_PROCESSED_OUTPUT = 0x01
Global Const $ENABLE_WRAP_AT_EOL_OUTPUT = 0x02
#endregion Console modes

#region Mouse events
Global Const $FROM_LEFT_1ST_BUTTON_PRESSED = 0x01
Global Const $FROM_LEFT_2ND_BUTTON_PRESSED = 0x04
Global Const $FROM_LEFT_3RD_BUTTON_PRESSED = 0x08
Global Const $FROM_LEFT_4TH_BUTTON_PRESSED = 0x10
Global Const $RIGHTMOST_BUTTON_PRESSED = 0x02

Global Const $DOUBLE_CLICK = 0x02
Global Const $MOUSE_HWHEELED = 0x08
Global Const $MOUSE_MOVED = 0x01
Global Const $MOUSE_WHEELED = 0x04
#endregion Mouse events

Global Const $STD_INPUT_HANDLE = -10
Global Const $STD_OUTPUT_HANDLE = -11
Global Const $STD_ERROR_HANDLE = -12

_FreeConsole()
_WinAPI_AttachConsole()

Global $hStdIn = _GetStdHandle($STD_INPUT_HANDLE)
If $hStdIn = $INVALID_HANDLE_VALUE Then
    ConsoleWrite("Error GetStdHandle" & @CRLF)
    Exit
EndIf

Global $hModeOld = _GetConsoleMode($hStdIn)
If @error Then
    ConsoleWrite("Error GetConsoleMode" & @CRLF)
    Exit
EndIf

If Not _SetConsoleMode($hStdIn, BitOR($ENABLE_WINDOW_INPUT, $ENABLE_MOUSE_INPUT)) Then
    ConsoleWrite("Error SetConsoleMode" & @CRLF)
    Exit
EndIf


Global $tRecord = DllStructCreate($tagINPUT_RECORD)
Global $iRecordsRead

While True
    If Not _ReadConsoleInput($hStdIn, $tRecord, 1, $iRecordsRead) Then
        ConsoleWrite("Error ReadConsoleInput" & @CRLF)
        _Exit()
    EndIf

    Switch DllStructGetData($tRecord, "EventType")
        Case $FOCUS_EVENT
            ;do nothing
        Case $KEY_EVENT
            _KeyEventProc($tRecord)
        Case $MENU_EVENT
            ;do nothing
        Case $MOUSE_EVENT
            _MouseEventProc($tRecord)
        Case $WINDOW_BUFFER_SIZE_EVENT_EVENT
            _ResizeEventProc($tRecord)
        Case Else
            ConsoleWrite("Error unknown event type" & @CRLF)
            _Exit()
    EndSwitch
WEnd

Func _Exit()
    _SetConsoleMode($hStdIn, $hModeOld)
    Exit
EndFunc   ;==>_Exit

Func _FreeConsole()
    Local $aRet = DllCall("kernel32.dll", "BOOL", "FreeConsole")
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_FreeConsole

Func _GetStdHandle($nStdHandle)
    Local $aRet = DllCall("kernel32.dll", "handle", "GetStdHandle", "DWORD", $nStdHandle)
   If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_GetStdHandle

Func _GetConsoleMode($hConsole)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "GetConsoleMode", "handle", $hConsole, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[2]
EndFunc   ;==>_GetConsoleMode

Func _SetConsoleMode($hConsole, $dwMode)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "SetConsoleMode", "handle", $hConsole, "DWORD", $dwMode)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_SetConsoleMode

Func _ReadConsoleInput($hConsole, ByRef $tRecord, $iRecordCount, ByRef $iRecordsRead)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "ReadConsoleInput", "handle", $hConsole, "struct*", $tRecord, "DWORD", $iRecordCount, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    $iRecordsRead = $aRet[4]
    Return $aRet[0]
EndFunc   ;==>_ReadConsoleInput

Func _KeyEventProc($tRecord)
    Local $tKeyRecord = DllStructCreate($tagINPUT_RECORD_KEY, DllStructGetPtr($tRecord))
    Local $bPressed = DllStructGetData($tKeyRecord, "bKeyDown")
    Local $cChar = DllStructGetData($tKeyRecord, "UnicodeChar")
    If $bPressed Then
        ConsoleWrite("Key pressed: " & $cChar & @CRLF)
    Else
        ConsoleWrite("Key released: " & $cChar & @CRLF)
    EndIf
    If $cChar = "q" Then _Exit() ; end script when pressed 'q'
EndFunc   ;==>_KeyEventProc

Func _MouseEventProc($tRecord)
    ConsoleWrite("Mouse event: ")
    Local $tMouseRecord = DllStructCreate($tagINPUT_RECORD_MOUSE, DllStructGetPtr($tRecord))
    Local $iMouseEvent = DllStructGetData($tMouseRecord, "dwEventFlags")
    Local $iButtonState = DllStructGetData($tMouseRecord, "dwButtonState")
    Local $x = DllStructGetData($tMouseRecord, "X")
    Local $y = DllStructGetData($tMouseRecord, "Y")

    ConsoleWrite(StringFormat("Position: [%03d,%03d] - ", $x, $y))

    Switch $iMouseEvent
        Case 0
            If $iButtonState = $FROM_LEFT_1ST_BUTTON_PRESSED Then
                ConsoleWrite("Left button pressed" & @CRLF)
            ElseIf $iButtonState = $RIGHTMOST_BUTTON_PRESSED Then
                ConsoleWrite("Right button pressed" & @CRLF)
            Else
                ConsoleWrite("Button pressed" & @CRLF)
            EndIf
        Case $DOUBLE_CLICK
            ConsoleWrite("Double clicked" & @CRLF)
        Case $MOUSE_HWHEELED
            ConsoleWrite("Horizontal wheeled" & @CRLF)
        Case $MOUSE_MOVED
            ConsoleWrite("Mouse moved" & @CRLF)
        Case $MOUSE_WHEELED
            ConsoleWrite("Vertical wheeled" & @CRLF)
        Case Else
            ConsoleWrite("Unknown mouse action" & @CRLF)
    EndSwitch
EndFunc   ;==>_MouseEventProc

Func _ResizeEventProc($tRecord)
    Local $tResizeRecord = DllStructCreate($tagINPUT_RECORD_WINDOW_BUFFER_SIZE, DllStructGetPtr($tRecord))
    Local $iColumns = DllStructGetData($tResizeRecord, "X")
    Local $iRows = DllStructGetData($tResizeRecord, "Y")

    ConsoleWrite("Console screen buffer is now " & $iColumns & " columns by " & $iRows & " rows" & @CRLF)
EndFunc   ;==>_ResizeEventProc

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

 

This is to get the coordinates in your own scripts console. But you can attach to another console as well.

....

 

I get "Error GetConsoleMode"

how to use it? thanks

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

I get "Error GetConsoleMode"

how to use it? thanks

Compile as console application and start itfrom console, not direct. End application with key 'q'.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Compile as console application and start itfrom console, not direct. End application with key 'q'.

 

Thanks, got it.

It seems cool.

Another help please, How do you attach to another console?

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

 

This is to get the coordinates in your own scripts console. But you can attach to another console as well.

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Change2CUI=y
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
;funkey 2014.10.02
#include <WinAPI.au3>


#region EventTypes
Global Const $FOCUS_EVENT = 0x10
Global Const $KEY_EVENT = 0x01
Global Const $MENU_EVENT = 0x08
Global Const $MOUSE_EVENT = 0x02
Global Const $WINDOW_BUFFER_SIZE_EVENT_EVENT = 0x04
#endregion EventTypes

#region EventRecords
Global Const $tagFOCUS_EVENT_RECORD = "BOOL bSetFocus;DWORD dwPadding[3];"
Global Const $tagKEY_EVENT_RECORD = "BOOL bKeyDown;WORD wRepeatCount;WORD wVirtualKeyCode;WORD wVirtualScanCode;WCHAR UnicodeChar;DWORD dwControlKeyState;"
Global Const $tagMENU_EVENT_RECORD = "UINT dwCommandId;DWORD dwPadding[3];"
Global Const $tagMOUSE_EVENT_RECORD = "SHORT X;SHORT Y;DWORD dwButtonState;DWORD dwControlKeyState;DWORD dwEventFlags;"
Global Const $tagWINDOW_BUFFER_SIZE_RECORD = "SHORT X;SHORT Y;DWORD dwButtonState;DWORD dwControlKeyState;DWORD dwEventFlags;"

Global Const $tagINPUT_RECORD_FOCUS = "WORD EventType;struct;" & $tagFOCUS_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_KEY = "WORD EventType;struct;" & $tagKEY_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_MENU = "WORD EventType;struct;" & $tagMENU_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_MOUSE = "WORD EventType;struct;" & $tagMOUSE_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_WINDOW_BUFFER_SIZE = "WORD EventType;struct;" & $tagWINDOW_BUFFER_SIZE_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD = "WORD EventType;DWORD dwDummy[4]"
#endregion EventRecords

#region Console modes
Global Const $ENABLE_ECHO_INPUT = 0x04
Global Const $ENABLE_INSERT_MODE = 0x20
Global Const $ENABLE_LINE_INPUT = 0x02
Global Const $ENABLE_MOUSE_INPUT = 0x10
Global Const $ENABLE_PROCESSED_INPUT = 0x01
Global Const $ENABLE_QUICK_EDIT_MODE = 0x40
Global Const $ENABLE_WINDOW_INPUT = 0x08
Global Const $ENABLE_PROCESSED_OUTPUT = 0x01
Global Const $ENABLE_WRAP_AT_EOL_OUTPUT = 0x02
#endregion Console modes

#region Mouse events
Global Const $FROM_LEFT_1ST_BUTTON_PRESSED = 0x01
Global Const $FROM_LEFT_2ND_BUTTON_PRESSED = 0x04
Global Const $FROM_LEFT_3RD_BUTTON_PRESSED = 0x08
Global Const $FROM_LEFT_4TH_BUTTON_PRESSED = 0x10
Global Const $RIGHTMOST_BUTTON_PRESSED = 0x02

Global Const $DOUBLE_CLICK = 0x02
Global Const $MOUSE_HWHEELED = 0x08
Global Const $MOUSE_MOVED = 0x01
Global Const $MOUSE_WHEELED = 0x04
#endregion Mouse events

Global Const $STD_INPUT_HANDLE = -10
Global Const $STD_OUTPUT_HANDLE = -11
Global Const $STD_ERROR_HANDLE = -12

_FreeConsole()
_WinAPI_AttachConsole()

Global $hStdIn = _GetStdHandle($STD_INPUT_HANDLE)
If $hStdIn = $INVALID_HANDLE_VALUE Then
    ConsoleWrite("Error GetStdHandle" & @CRLF)
    Exit
EndIf

Global $hModeOld = _GetConsoleMode($hStdIn)
If @error Then
    ConsoleWrite("Error GetConsoleMode" & @CRLF)
    Exit
EndIf

If Not _SetConsoleMode($hStdIn, BitOR($ENABLE_WINDOW_INPUT, $ENABLE_MOUSE_INPUT)) Then
    ConsoleWrite("Error SetConsoleMode" & @CRLF)
    Exit
EndIf


Global $tRecord = DllStructCreate($tagINPUT_RECORD)
Global $iRecordsRead

While True
    If Not _ReadConsoleInput($hStdIn, $tRecord, 1, $iRecordsRead) Then
        ConsoleWrite("Error ReadConsoleInput" & @CRLF)
        _Exit()
    EndIf

    Switch DllStructGetData($tRecord, "EventType")
        Case $FOCUS_EVENT
            ;do nothing
        Case $KEY_EVENT
            _KeyEventProc($tRecord)
        Case $MENU_EVENT
            ;do nothing
        Case $MOUSE_EVENT
            _MouseEventProc($tRecord)
        Case $WINDOW_BUFFER_SIZE_EVENT_EVENT
            _ResizeEventProc($tRecord)
        Case Else
            ConsoleWrite("Error unknown event type" & @CRLF)
            _Exit()
    EndSwitch
WEnd

Func _Exit()
    _SetConsoleMode($hStdIn, $hModeOld)
    Exit
EndFunc   ;==>_Exit

Func _FreeConsole()
    Local $aRet = DllCall("kernel32.dll", "BOOL", "FreeConsole")
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_FreeConsole

Func _GetStdHandle($nStdHandle)
    Local $aRet = DllCall("kernel32.dll", "handle", "GetStdHandle", "DWORD", $nStdHandle)
   If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_GetStdHandle

Func _GetConsoleMode($hConsole)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "GetConsoleMode", "handle", $hConsole, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[2]
EndFunc   ;==>_GetConsoleMode

Func _SetConsoleMode($hConsole, $dwMode)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "SetConsoleMode", "handle", $hConsole, "DWORD", $dwMode)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_SetConsoleMode

Func _ReadConsoleInput($hConsole, ByRef $tRecord, $iRecordCount, ByRef $iRecordsRead)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "ReadConsoleInput", "handle", $hConsole, "struct*", $tRecord, "DWORD", $iRecordCount, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    $iRecordsRead = $aRet[4]
    Return $aRet[0]
EndFunc   ;==>_ReadConsoleInput

Func _KeyEventProc($tRecord)
    Local $tKeyRecord = DllStructCreate($tagINPUT_RECORD_KEY, DllStructGetPtr($tRecord))
    Local $bPressed = DllStructGetData($tKeyRecord, "bKeyDown")
    Local $cChar = DllStructGetData($tKeyRecord, "UnicodeChar")
    If $bPressed Then
        ConsoleWrite("Key pressed: " & $cChar & @CRLF)
    Else
        ConsoleWrite("Key released: " & $cChar & @CRLF)
    EndIf
    If $cChar = "q" Then _Exit() ; end script when pressed 'q'
EndFunc   ;==>_KeyEventProc

Func _MouseEventProc($tRecord)
    ConsoleWrite("Mouse event: ")
    Local $tMouseRecord = DllStructCreate($tagINPUT_RECORD_MOUSE, DllStructGetPtr($tRecord))
    Local $iMouseEvent = DllStructGetData($tMouseRecord, "dwEventFlags")
    Local $iButtonState = DllStructGetData($tMouseRecord, "dwButtonState")
    Local $x = DllStructGetData($tMouseRecord, "X")
    Local $y = DllStructGetData($tMouseRecord, "Y")

    ConsoleWrite(StringFormat("Position: [%03d,%03d] - ", $x, $y))

    Switch $iMouseEvent
        Case 0
            If $iButtonState = $FROM_LEFT_1ST_BUTTON_PRESSED Then
                ConsoleWrite("Left button pressed" & @CRLF)
            ElseIf $iButtonState = $RIGHTMOST_BUTTON_PRESSED Then
                ConsoleWrite("Right button pressed" & @CRLF)
            Else
                ConsoleWrite("Button pressed" & @CRLF)
            EndIf
        Case $DOUBLE_CLICK
            ConsoleWrite("Double clicked" & @CRLF)
        Case $MOUSE_HWHEELED
            ConsoleWrite("Horizontal wheeled" & @CRLF)
        Case $MOUSE_MOVED
            ConsoleWrite("Mouse moved" & @CRLF)
        Case $MOUSE_WHEELED
            ConsoleWrite("Vertical wheeled" & @CRLF)
        Case Else
            ConsoleWrite("Unknown mouse action" & @CRLF)
    EndSwitch
EndFunc   ;==>_MouseEventProc

Func _ResizeEventProc($tRecord)
    Local $tResizeRecord = DllStructCreate($tagINPUT_RECORD_WINDOW_BUFFER_SIZE, DllStructGetPtr($tRecord))
    Local $iColumns = DllStructGetData($tResizeRecord, "X")
    Local $iRows = DllStructGetData($tResizeRecord, "Y")

    ConsoleWrite("Console screen buffer is now " & $iColumns & " columns by " & $iRows & " rows" & @CRLF)
EndFunc   ;==>_ResizeEventProc

Can You get a example to use this?? It's a console udf, yes? If yes I have 3 console udf's and none have this function

Link to comment
Share on other sites

I just wrote the functions I needed. I did not look at the UDFs.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Example???

$coords = *Get click coords*

ConsoleWrite($coords)

??

Tell me exactly what you want to do. Do you have your own console application or is it another console app where you want to get the cords? Please explain a bit more your situation and study the example I gave in post #5.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

sorry funkey, can I ask 2  things please
1) can I hook another dos windows and get data from that (get coords of cursor, get infos on events, copy text from screen...)?
2) or can I run a second dos from main script and get info on events that occurs on that child console?

  .... or both things?
Thanks and sorry for intrusion

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

sorry funkey, can I ask 2  things please

1) can I hook another dos windows and get data from that (get coords of cursor, get infos on events, copy text from screen...)?

2) or can I run a second dos from main script and get info on events that occurs on that child console?

  .... or both things?

Thanks and sorry for intrusion

Here is an example for your second question, give me some time to do some research for question number one.

;funkey 2014.10.03
#include <WinAPI.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>


#Region EventTypes
Global Const $FOCUS_EVENT = 0x10
Global Const $KEY_EVENT = 0x01
Global Const $MENU_EVENT = 0x08
Global Const $MOUSE_EVENT = 0x02
Global Const $WINDOW_BUFFER_SIZE_EVENT = 0x04
#EndRegion EventTypes

#Region EventRecords
Global Const $tagFOCUS_EVENT_RECORD = "BOOL bSetFocus;DWORD dwPadding[3];"
Global Const $tagKEY_EVENT_RECORD = "BOOL bKeyDown;WORD wRepeatCount;WORD wVirtualKeyCode;WORD wVirtualScanCode;WCHAR UnicodeChar;DWORD dwControlKeyState;"
Global Const $tagMENU_EVENT_RECORD = "UINT dwCommandId;DWORD dwPadding[3];"
Global Const $tagMOUSE_EVENT_RECORD = "SHORT X;SHORT Y;DWORD dwButtonState;DWORD dwControlKeyState;DWORD dwEventFlags;"
Global Const $tagWINDOW_BUFFER_SIZE_RECORD = "SHORT X;SHORT Y;DWORD dwButtonState;DWORD dwControlKeyState;DWORD dwEventFlags;"

Global Const $tagINPUT_RECORD_FOCUS = "WORD EventType;struct;" & $tagFOCUS_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_KEY = "WORD EventType;struct;" & $tagKEY_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_MENU = "WORD EventType;struct;" & $tagMENU_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_MOUSE = "WORD EventType;struct;" & $tagMOUSE_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_WINDOW_BUFFER_SIZE = "WORD EventType;struct;" & $tagWINDOW_BUFFER_SIZE_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD = "WORD EventType;DWORD dwDummy[4]"
#EndRegion EventRecords

#Region Console modes
Global Const $ENABLE_ECHO_INPUT = 0x04
Global Const $ENABLE_INSERT_MODE = 0x20
Global Const $ENABLE_LINE_INPUT = 0x02
Global Const $ENABLE_MOUSE_INPUT = 0x10
Global Const $ENABLE_PROCESSED_INPUT = 0x01
Global Const $ENABLE_QUICK_EDIT_MODE = 0x40
Global Const $ENABLE_WINDOW_INPUT = 0x08
Global Const $ENABLE_PROCESSED_OUTPUT = 0x01
Global Const $ENABLE_WRAP_AT_EOL_OUTPUT = 0x02
#EndRegion Console modes

#Region Mouse events
Global Const $FROM_LEFT_1ST_BUTTON_PRESSED = 0x01
Global Const $FROM_LEFT_2ND_BUTTON_PRESSED = 0x04
Global Const $FROM_LEFT_3RD_BUTTON_PRESSED = 0x08
Global Const $FROM_LEFT_4TH_BUTTON_PRESSED = 0x10
Global Const $RIGHTMOST_BUTTON_PRESSED = 0x02

Global Const $DOUBLE_CLICK = 0x02
Global Const $MOUSE_HWHEELED = 0x08
Global Const $MOUSE_MOVED = 0x01
Global Const $MOUSE_WHEELED = 0x04
#EndRegion Mouse events

Global Const $STD_INPUT_HANDLE = -10
Global Const $STD_OUTPUT_HANDLE = -11
Global Const $STD_ERROR_HANDLE = -12

If Not @Compiled Then Exit MsgBox(16, "Error", "This demo script only works when compiled")

Opt("GUIOnEventMode", 1)

Global $hGui = GUICreate("Console Info Window", 300, 100, @DesktopWidth - 300, 0)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUICtrlCreateLabel("Mouse position in console:", 10, 10, 150, 20, $SS_CENTERIMAGE)
Global $nPosition = GUICtrlCreateInput("", 160, 10, 70, 20, $ES_READONLY)
GUISetState()




_FreeConsole()

If Not _AllocConsole() Then
    ConsoleWrite("Error AllocConsole input" & @CRLF)
    Sleep(1000)
    Exit
EndIf

Global $hStdIn = _GetStdHandle($STD_INPUT_HANDLE)
If $hStdIn = $INVALID_HANDLE_VALUE Then
    ConsoleWrite("Error GetStdHandle input" & @CRLF)
    Sleep(1000)
    Exit
EndIf

Global $hStdOut = _GetStdHandle($STD_OUTPUT_HANDLE)
If $hStdOut = $INVALID_HANDLE_VALUE Then
    ConsoleWrite("Error GetStdHandle output" & @CRLF)
    Sleep(1000)
    Exit
EndIf

Global $hModeOld = _GetConsoleMode($hStdIn)
If @error Then
    _ConsoleWrite($hStdOut, "Error GetConsoleMode" & @CRLF)
    Sleep(1000)
    Exit
EndIf

If Not _SetConsoleMode($hStdIn, BitOR($ENABLE_WINDOW_INPUT, $ENABLE_MOUSE_INPUT)) Then
    _ConsoleWrite($hStdOut, "Error SetConsoleMode" & @CRLF)
    Sleep(1000)
    Exit
EndIf


Global $tRecord = DllStructCreate($tagINPUT_RECORD)
Global $iRecordsRead


_ResizeConsoleBuffer(150, 30)

While True
    If _GetNumberOfConsoleInputEvents($hStdIn) = 0 Then
        ContinueLoop
        Sleep(10)
    EndIf

    If Not _ReadConsoleInput($hStdIn, $tRecord, 1, $iRecordsRead) Then
        _ConsoleWrite($hStdOut, "Error ReadConsoleInput" & @CRLF)
        _Exit()
    EndIf

    Switch DllStructGetData($tRecord, "EventType")
        Case $FOCUS_EVENT
            ;do nothing
        Case $KEY_EVENT
            If Not _KeyEventProc($tRecord) Then ExitLoop
        Case $MENU_EVENT
            ;do nothing
        Case $MOUSE_EVENT
            _MouseEventProc($tRecord)
        Case $WINDOW_BUFFER_SIZE_EVENT
            _ResizeEventProc($tRecord)
        Case Else
            _ConsoleWrite($hStdOut, "Error unknown event type" & @CRLF)
            _Exit()
    EndSwitch
WEnd

Func _ResizeConsoleBuffer($w, $h)
    _SetConsoleScreenBufferSize($hStdOut, $w, $h)
    If @error Then
        _ConsoleWrite($hStdOut, "Error SetConsoleScreenBufferSize" & @CRLF)
    EndIf

    _SetConsoleWindowInfo($hStdOut, $w - 1, $h - 1)
    If @error Then
        _ConsoleWrite($hStdOut, "Error SetConsoleWindowInfo" & @CRLF)
    EndIf
EndFunc   ;==>_ResizeConsoleBuffer

Func _Exit()
    _SetConsoleMode($hStdIn, $hModeOld)
    Exit
EndFunc   ;==>_Exit

Func _FreeConsole()
    Local $aRet = DllCall("kernel32.dll", "BOOL", "FreeConsole")
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_FreeConsole

Func _AllocConsole()
    Local $aRet = DllCall("kernel32.dll", "BOOL", "AllocConsole")
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_AllocConsole

Func _FlushConsoleInputBuffer($hConsole)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "FlushConsoleInputBuffer", "handle", $hConsole)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_FlushConsoleInputBuffer

Func _GetStdHandle($nStdHandle)
    Local $aRet = DllCall("kernel32.dll", "handle", "GetStdHandle", "DWORD", $nStdHandle)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_GetStdHandle

Func _GetConsoleMode($hConsole)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "GetConsoleMode", "handle", $hConsole, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[2]
EndFunc   ;==>_GetConsoleMode

Func _SetConsoleMode($hConsole, $dwMode)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "SetConsoleMode", "handle", $hConsole, "DWORD", $dwMode)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_SetConsoleMode

Func _GetNumberOfConsoleInputEvents($hConsole)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "GetNumberOfConsoleInputEvents", "handle", $hConsole, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[2]
EndFunc   ;==>_GetNumberOfConsoleInputEvents

Func _ReadConsoleInput($hConsole, ByRef $tRecord, $iRecordCount, ByRef $iRecordsRead)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "ReadConsoleInput", "handle", $hConsole, "struct*", $tRecord, "DWORD", $iRecordCount, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    $iRecordsRead = $aRet[4]
    Return $aRet[0]
EndFunc   ;==>_ReadConsoleInput

Func _PeekConsoleInput($hConsole, ByRef $tRecord, $iRecordCount, ByRef $iRecordsRead)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "PeekConsoleInput", "handle", $hConsole, "struct*", $tRecord, "DWORD", $iRecordCount, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    $iRecordsRead = $aRet[4]
    Return $aRet[0]
EndFunc   ;==>_PeekConsoleInput

Func _ConsoleWrite($hConsoleOut, $sText)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "WriteConsole", "handle", $hConsoleOut, "str", $sText, "DWORD", StringLen($sText), "DWORD*", 0, "ptr", 0)
EndFunc   ;==>_ConsoleWrite

Func _SetConsoleWindowInfo($hConsoleOut, $w, $h)
    Local $tSmallRect = DllStructCreate("SHORT Left;SHORT Top;SHORT Right;SHORT Bottom;")
    DllStructSetData($tSmallRect, "Right", $w)
    DllStructSetData($tSmallRect, "Bottom", $h)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "SetConsoleWindowInfo", "handle", $hConsoleOut, "BOOL", True, "struct*", $tSmallRect)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_SetConsoleWindowInfo

Func _SetConsoleScreenBufferSize($hConsoleOut, $w, $h)
    Local $tCoord = DllStructCreate("SHORT X;SHORT Y;")
    DllStructSetData($tCoord, "X", $w)
    DllStructSetData($tCoord, "Y", $h)
    Local $tDword = DllStructCreate("DWORD Coord", DllStructGetPtr($tCoord))

    Local $aRet = DllCall("kernel32.dll", "BOOL", "SetConsoleScreenBufferSize", "handle", $hConsoleOut, "DWORD", DllStructGetData($tDword, "Coord"))
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_SetConsoleScreenBufferSize

Func _KeyEventProc($tRecord)
    Local $tKeyRecord = DllStructCreate($tagINPUT_RECORD_KEY, DllStructGetPtr($tRecord))
    Local $bPressed = DllStructGetData($tKeyRecord, "bKeyDown")
    Local $cChar = DllStructGetData($tKeyRecord, "UnicodeChar")
    If $cChar = "" Then Return 1 ;don't show modifier keys (ctrl, alt, shift, pause, F1, F2, ...)
    If $bPressed Then
        _ConsoleWrite($hStdOut, "Key pressed: " & $cChar & @CRLF)
    Else
        _ConsoleWrite($hStdOut, "Key released: " & $cChar & @CRLF)
    EndIf
    If Asc($cChar) = 27 Then Return 0 ; end script when 'Escape' is pressed
    Return 1
EndFunc   ;==>_KeyEventProc

Func _MouseEventProc($tRecord)
    ConsoleWrite("Mouse event: ")
    Local $tMouseRecord = DllStructCreate($tagINPUT_RECORD_MOUSE, DllStructGetPtr($tRecord))
    Local $iMouseEvent = DllStructGetData($tMouseRecord, "dwEventFlags")
    Local $iButtonState = DllStructGetData($tMouseRecord, "dwButtonState")
    Local $x = DllStructGetData($tMouseRecord, "X")
    Local $y = DllStructGetData($tMouseRecord, "Y")

    GUICtrlSetData($nPosition, StringFormat("%d,%d", $x, $y))
    _ConsoleWrite($hStdOut, StringFormat("Position: [%03d,%03d] - ", $x, $y))

    Switch $iMouseEvent
        Case 0
            If $iButtonState = $FROM_LEFT_1ST_BUTTON_PRESSED Then
                _ConsoleWrite($hStdOut, "Left button pressed" & @CRLF)
            ElseIf $iButtonState = $RIGHTMOST_BUTTON_PRESSED Then
                _ConsoleWrite($hStdOut, "Right button pressed" & @CRLF)
            Else
                _ConsoleWrite($hStdOut, "Button pressed" & @CRLF)
            EndIf
        Case $DOUBLE_CLICK
            _ConsoleWrite($hStdOut, "Double clicked" & @CRLF)
        Case $MOUSE_HWHEELED
            _ConsoleWrite($hStdOut, "Horizontal wheeled" & @CRLF)
        Case $MOUSE_MOVED
            _ConsoleWrite($hStdOut, "Mouse moved" & @CRLF)
        Case $MOUSE_WHEELED
            _ConsoleWrite($hStdOut, "Vertical wheeled" & @CRLF)
        Case Else
            _ConsoleWrite($hStdOut, "Unknown mouse action" & @CRLF)
    EndSwitch
EndFunc   ;==>_MouseEventProc

Func _ResizeEventProc($tRecord)
    Local $tResizeRecord = DllStructCreate($tagINPUT_RECORD_WINDOW_BUFFER_SIZE, DllStructGetPtr($tRecord))
    Local $iColumns = DllStructGetData($tResizeRecord, "X")
    Local $iRows = DllStructGetData($tResizeRecord, "Y")

    _ConsoleWrite($hStdOut, "Console screen buffer is now " & $iColumns & " columns by " & $iRows & " rows" & @CRLF)
EndFunc   ;==>_ResizeEventProc

You have to compile the script to test it, but this time it does not have to compile as console app. Escape ends the script.

Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

thanks funkey
got mechanism for point 2, (interesting)
staying tuned for point 1... see you next time
bye and thanks for taking the time

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Tell me exactly what you want to do. Do you have your own console application or is it another console app where you want to get the cords? Please explain a bit more your situation and study the example I gave in post #5.

I want to AutoIt made ​​consoles (cmd) and once you click the left mouse button clicks gave the coordinates. (Sorry for google translator)

Link to comment
Share on other sites

I want to AutoIt made ​​consoles (cmd) and once you click the left mouse button clicks gave the coordinates. (Sorry for google translator)

Then my last example should be what you want. But here is the same example at bit changed for you:

;funkey 2014.10.03
#include <WinAPI.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>


#Region EventTypes
Global Const $FOCUS_EVENT = 0x10
Global Const $KEY_EVENT = 0x01
Global Const $MENU_EVENT = 0x08
Global Const $MOUSE_EVENT = 0x02
Global Const $WINDOW_BUFFER_SIZE_EVENT = 0x04
#EndRegion EventTypes

#Region EventRecords
Global Const $tagFOCUS_EVENT_RECORD = "BOOL bSetFocus;DWORD dwPadding[3];"
Global Const $tagKEY_EVENT_RECORD = "BOOL bKeyDown;WORD wRepeatCount;WORD wVirtualKeyCode;WORD wVirtualScanCode;WCHAR UnicodeChar;DWORD dwControlKeyState;"
Global Const $tagMENU_EVENT_RECORD = "UINT dwCommandId;DWORD dwPadding[3];"
Global Const $tagMOUSE_EVENT_RECORD = "SHORT X;SHORT Y;DWORD dwButtonState;DWORD dwControlKeyState;DWORD dwEventFlags;"
Global Const $tagWINDOW_BUFFER_SIZE_RECORD = "SHORT X;SHORT Y;DWORD dwButtonState;DWORD dwControlKeyState;DWORD dwEventFlags;"

Global Const $tagINPUT_RECORD_FOCUS = "WORD EventType;struct;" & $tagFOCUS_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_KEY = "WORD EventType;struct;" & $tagKEY_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_MENU = "WORD EventType;struct;" & $tagMENU_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_MOUSE = "WORD EventType;struct;" & $tagMOUSE_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_WINDOW_BUFFER_SIZE = "WORD EventType;struct;" & $tagWINDOW_BUFFER_SIZE_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD = "WORD EventType;DWORD dwDummy[4]"
#EndRegion EventRecords

#Region Console modes
Global Const $ENABLE_ECHO_INPUT = 0x04
Global Const $ENABLE_INSERT_MODE = 0x20
Global Const $ENABLE_LINE_INPUT = 0x02
Global Const $ENABLE_MOUSE_INPUT = 0x10
Global Const $ENABLE_PROCESSED_INPUT = 0x01
Global Const $ENABLE_QUICK_EDIT_MODE = 0x40
Global Const $ENABLE_WINDOW_INPUT = 0x08
Global Const $ENABLE_PROCESSED_OUTPUT = 0x01
Global Const $ENABLE_WRAP_AT_EOL_OUTPUT = 0x02
#EndRegion Console modes

#Region Mouse events
Global Const $FROM_LEFT_1ST_BUTTON_PRESSED = 0x01
Global Const $FROM_LEFT_2ND_BUTTON_PRESSED = 0x04
Global Const $FROM_LEFT_3RD_BUTTON_PRESSED = 0x08
Global Const $FROM_LEFT_4TH_BUTTON_PRESSED = 0x10
Global Const $RIGHTMOST_BUTTON_PRESSED = 0x02

Global Const $DOUBLE_CLICK = 0x02
Global Const $MOUSE_HWHEELED = 0x08
Global Const $MOUSE_MOVED = 0x01
Global Const $MOUSE_WHEELED = 0x04
#EndRegion Mouse events

Global Const $STD_INPUT_HANDLE = -10
Global Const $STD_OUTPUT_HANDLE = -11
Global Const $STD_ERROR_HANDLE = -12

If Not @Compiled Then Exit MsgBox(16, "Error", "This demo script only works when compiled")

Opt("GUIOnEventMode", 1)

Global $hGui = GUICreate("Console Info Window", 300, 100, @DesktopWidth - 300, 10)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUICtrlCreateLabel("Mouse position in console:", 10, 10, 150, 20, $SS_CENTERIMAGE)
Global $nPosition = GUICtrlCreateInput("", 160, 10, 70, 20, $ES_READONLY)
GUISetState()




_FreeConsole()

If Not _AllocConsole() Then
    ConsoleWrite("Error AllocConsole input" & @CRLF)
    Sleep(1000)
    Exit
EndIf

Global $hStdIn = _GetStdHandle($STD_INPUT_HANDLE)
If $hStdIn = $INVALID_HANDLE_VALUE Then
    ConsoleWrite("Error GetStdHandle input" & @CRLF)
    Sleep(1000)
    Exit
EndIf

Global $hStdOut = _GetStdHandle($STD_OUTPUT_HANDLE)
If $hStdOut = $INVALID_HANDLE_VALUE Then
    ConsoleWrite("Error GetStdHandle output" & @CRLF)
    Sleep(1000)
    Exit
EndIf

Global $hModeOld = _GetConsoleMode($hStdIn)
If @error Then
    _ConsoleWrite($hStdOut, "Error GetConsoleMode" & @CRLF)
    Sleep(1000)
    Exit
EndIf

If Not _SetConsoleMode($hStdIn, BitOR($ENABLE_WINDOW_INPUT, $ENABLE_MOUSE_INPUT)) Then
    _ConsoleWrite($hStdOut, "Error SetConsoleMode" & @CRLF)
    Sleep(1000)
    Exit
EndIf


Global $tRecord = DllStructCreate($tagINPUT_RECORD)
Global $iRecordsRead


_ResizeConsoleBuffer(150, 30)

While True
    If _GetNumberOfConsoleInputEvents($hStdIn) = 0 Then
        ContinueLoop
        Sleep(10)
    EndIf

    If Not _ReadConsoleInput($hStdIn, $tRecord, 1, $iRecordsRead) Then
        _ConsoleWrite($hStdOut, "Error ReadConsoleInput" & @CRLF)
        _Exit()
    EndIf

    Switch DllStructGetData($tRecord, "EventType")
        Case $FOCUS_EVENT
            ;do nothing
        Case $KEY_EVENT
            If Not _KeyEventProc($tRecord) Then ExitLoop
        Case $MENU_EVENT
            ;do nothing
        Case $MOUSE_EVENT
            _MouseEventProc($tRecord)
        Case $WINDOW_BUFFER_SIZE_EVENT
            _ResizeEventProc($tRecord)
        Case Else
            _ConsoleWrite($hStdOut, "Error unknown event type" & @CRLF)
            _Exit()
    EndSwitch
WEnd

Func _ResizeConsoleBuffer($w, $h)
    _SetConsoleScreenBufferSize($hStdOut, $w, $h)
    If @error Then
        _ConsoleWrite($hStdOut, "Error SetConsoleScreenBufferSize" & @CRLF)
    EndIf

    _SetConsoleWindowInfo($hStdOut, $w - 1, $h - 1)
    If @error Then
        _ConsoleWrite($hStdOut, "Error SetConsoleWindowInfo" & @CRLF)
    EndIf
EndFunc   ;==>_ResizeConsoleBuffer

Func _Exit()
    _SetConsoleMode($hStdIn, $hModeOld)
    Exit
EndFunc   ;==>_Exit

Func _FreeConsole()
    Local $aRet = DllCall("kernel32.dll", "BOOL", "FreeConsole")
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_FreeConsole

Func _AllocConsole()
    Local $aRet = DllCall("kernel32.dll", "BOOL", "AllocConsole")
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_AllocConsole

Func _FlushConsoleInputBuffer($hConsole)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "FlushConsoleInputBuffer", "handle", $hConsole)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_FlushConsoleInputBuffer

Func _GetStdHandle($nStdHandle)
    Local $aRet = DllCall("kernel32.dll", "handle", "GetStdHandle", "DWORD", $nStdHandle)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_GetStdHandle

Func _GetConsoleMode($hConsole)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "GetConsoleMode", "handle", $hConsole, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[2]
EndFunc   ;==>_GetConsoleMode

Func _SetConsoleMode($hConsole, $dwMode)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "SetConsoleMode", "handle", $hConsole, "DWORD", $dwMode)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_SetConsoleMode

Func _GetNumberOfConsoleInputEvents($hConsole)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "GetNumberOfConsoleInputEvents", "handle", $hConsole, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[2]
EndFunc   ;==>_GetNumberOfConsoleInputEvents

Func _ReadConsoleInput($hConsole, ByRef $tRecord, $iRecordCount, ByRef $iRecordsRead)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "ReadConsoleInput", "handle", $hConsole, "struct*", $tRecord, "DWORD", $iRecordCount, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    $iRecordsRead = $aRet[4]
    Return $aRet[0]
EndFunc   ;==>_ReadConsoleInput

Func _PeekConsoleInput($hConsole, ByRef $tRecord, $iRecordCount, ByRef $iRecordsRead)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "PeekConsoleInput", "handle", $hConsole, "struct*", $tRecord, "DWORD", $iRecordCount, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    $iRecordsRead = $aRet[4]
    Return $aRet[0]
EndFunc   ;==>_PeekConsoleInput

Func _ConsoleWrite($hConsoleOut, $sText)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "WriteConsole", "handle", $hConsoleOut, "str", $sText, "DWORD", StringLen($sText), "DWORD*", 0, "ptr", 0)
EndFunc   ;==>_ConsoleWrite

Func _SetConsoleWindowInfo($hConsoleOut, $w, $h)
    Local $tSmallRect = DllStructCreate("SHORT Left;SHORT Top;SHORT Right;SHORT Bottom;")
    DllStructSetData($tSmallRect, "Right", $w)
    DllStructSetData($tSmallRect, "Bottom", $h)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "SetConsoleWindowInfo", "handle", $hConsoleOut, "BOOL", True, "struct*", $tSmallRect)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_SetConsoleWindowInfo

Func _SetConsoleScreenBufferSize($hConsoleOut, $w, $h)
    Local $tCoord = DllStructCreate("SHORT X;SHORT Y;")
    DllStructSetData($tCoord, "X", $w)
    DllStructSetData($tCoord, "Y", $h)
    Local $tDword = DllStructCreate("DWORD Coord", DllStructGetPtr($tCoord))

    Local $aRet = DllCall("kernel32.dll", "BOOL", "SetConsoleScreenBufferSize", "handle", $hConsoleOut, "DWORD", DllStructGetData($tDword, "Coord"))
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_SetConsoleScreenBufferSize

Func _KeyEventProc($tRecord)
    Local $tKeyRecord = DllStructCreate($tagINPUT_RECORD_KEY, DllStructGetPtr($tRecord))
    Local $bPressed = DllStructGetData($tKeyRecord, "bKeyDown")
    Local $cChar = DllStructGetData($tKeyRecord, "UnicodeChar")
    If $cChar = "" Then Return 1 ;don't show modifier keys (ctrl, alt, shift, pause, F1, F2, ...)
    If $bPressed Then
;~      _ConsoleWrite($hStdOut, "Key pressed: " & $cChar & @CRLF)
    Else
;~      _ConsoleWrite($hStdOut, "Key released: " & $cChar & @CRLF)
    EndIf
    If Asc($cChar) = 27 Then Return 0 ; end script when 'Escape' is pressed
    Return 1
EndFunc   ;==>_KeyEventProc

Func _MouseEventProc($tRecord)
    ConsoleWrite("Mouse event: ")
    Local $tMouseRecord = DllStructCreate($tagINPUT_RECORD_MOUSE, DllStructGetPtr($tRecord))
    Local $iMouseEvent = DllStructGetData($tMouseRecord, "dwEventFlags")
    Local $iButtonState = DllStructGetData($tMouseRecord, "dwButtonState")
    Local $x = DllStructGetData($tMouseRecord, "X")
    Local $y = DllStructGetData($tMouseRecord, "Y")

    GUICtrlSetData($nPosition, StringFormat("%d,%d", $x, $y))
;~  _ConsoleWrite($hStdOut, StringFormat("Position: [%03d,%03d] - ", $x, $y))

    Switch $iMouseEvent
        Case 0
            If $iButtonState = $FROM_LEFT_1ST_BUTTON_PRESSED Then
                _ConsoleWrite($hStdOut, StringFormat("Left mouse click at position: [%03d,%03d]" & @CRLF, $x, $y))
                MsgBox(48, "Info", StringFormat("Left mouse click at position: [%03d,%03d]", $x, $y))
            ElseIf $iButtonState = $RIGHTMOST_BUTTON_PRESSED Then
;~              _ConsoleWrite($hStdOut, "Right button pressed" & @CRLF)
            Else
;~              _ConsoleWrite($hStdOut, "Button pressed" & @CRLF)
            EndIf
        Case $DOUBLE_CLICK
;~          _ConsoleWrite($hStdOut, "Double clicked" & @CRLF)
        Case $MOUSE_HWHEELED
;~          _ConsoleWrite($hStdOut, "Horizontal wheeled" & @CRLF)
        Case $MOUSE_MOVED
;~          _ConsoleWrite($hStdOut, "Mouse moved" & @CRLF)
        Case $MOUSE_WHEELED
;~          _ConsoleWrite($hStdOut, "Vertical wheeled" & @CRLF)
        Case Else
;~          _ConsoleWrite($hStdOut, "Unknown mouse action" & @CRLF)
    EndSwitch
EndFunc   ;==>_MouseEventProc

Func _ResizeEventProc($tRecord)
    Local $tResizeRecord = DllStructCreate($tagINPUT_RECORD_WINDOW_BUFFER_SIZE, DllStructGetPtr($tRecord))
    Local $iColumns = DllStructGetData($tResizeRecord, "X")
    Local $iRows = DllStructGetData($tResizeRecord, "Y")

;~  _ConsoleWrite($hStdOut, "Console screen buffer is now " & $iColumns & " columns by " & $iRows & " rows" & @CRLF)
EndFunc   ;==>_ResizeEventProc

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

thanks funkey

got mechanism for point 2, (interesting)

staying tuned for point 1... see you next time

bye and thanks for taking the time

I don't think point 1 can be done, but I had nearly no time to research, so I'm not sure about it. You can of course read and write the standard streams of the console applications.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

 

Then my last example should be what you want. But here is the same example at bit changed for you:

;funkey 2014.10.03
#include <WinAPI.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>


#Region EventTypes
Global Const $FOCUS_EVENT = 0x10
Global Const $KEY_EVENT = 0x01
Global Const $MENU_EVENT = 0x08
Global Const $MOUSE_EVENT = 0x02
Global Const $WINDOW_BUFFER_SIZE_EVENT = 0x04
#EndRegion EventTypes

#Region EventRecords
Global Const $tagFOCUS_EVENT_RECORD = "BOOL bSetFocus;DWORD dwPadding[3];"
Global Const $tagKEY_EVENT_RECORD = "BOOL bKeyDown;WORD wRepeatCount;WORD wVirtualKeyCode;WORD wVirtualScanCode;WCHAR UnicodeChar;DWORD dwControlKeyState;"
Global Const $tagMENU_EVENT_RECORD = "UINT dwCommandId;DWORD dwPadding[3];"
Global Const $tagMOUSE_EVENT_RECORD = "SHORT X;SHORT Y;DWORD dwButtonState;DWORD dwControlKeyState;DWORD dwEventFlags;"
Global Const $tagWINDOW_BUFFER_SIZE_RECORD = "SHORT X;SHORT Y;DWORD dwButtonState;DWORD dwControlKeyState;DWORD dwEventFlags;"

Global Const $tagINPUT_RECORD_FOCUS = "WORD EventType;struct;" & $tagFOCUS_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_KEY = "WORD EventType;struct;" & $tagKEY_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_MENU = "WORD EventType;struct;" & $tagMENU_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_MOUSE = "WORD EventType;struct;" & $tagMOUSE_EVENT_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD_WINDOW_BUFFER_SIZE = "WORD EventType;struct;" & $tagWINDOW_BUFFER_SIZE_RECORD & "endstruct;"
Global Const $tagINPUT_RECORD = "WORD EventType;DWORD dwDummy[4]"
#EndRegion EventRecords

#Region Console modes
Global Const $ENABLE_ECHO_INPUT = 0x04
Global Const $ENABLE_INSERT_MODE = 0x20
Global Const $ENABLE_LINE_INPUT = 0x02
Global Const $ENABLE_MOUSE_INPUT = 0x10
Global Const $ENABLE_PROCESSED_INPUT = 0x01
Global Const $ENABLE_QUICK_EDIT_MODE = 0x40
Global Const $ENABLE_WINDOW_INPUT = 0x08
Global Const $ENABLE_PROCESSED_OUTPUT = 0x01
Global Const $ENABLE_WRAP_AT_EOL_OUTPUT = 0x02
#EndRegion Console modes

#Region Mouse events
Global Const $FROM_LEFT_1ST_BUTTON_PRESSED = 0x01
Global Const $FROM_LEFT_2ND_BUTTON_PRESSED = 0x04
Global Const $FROM_LEFT_3RD_BUTTON_PRESSED = 0x08
Global Const $FROM_LEFT_4TH_BUTTON_PRESSED = 0x10
Global Const $RIGHTMOST_BUTTON_PRESSED = 0x02

Global Const $DOUBLE_CLICK = 0x02
Global Const $MOUSE_HWHEELED = 0x08
Global Const $MOUSE_MOVED = 0x01
Global Const $MOUSE_WHEELED = 0x04
#EndRegion Mouse events

Global Const $STD_INPUT_HANDLE = -10
Global Const $STD_OUTPUT_HANDLE = -11
Global Const $STD_ERROR_HANDLE = -12

If Not @Compiled Then Exit MsgBox(16, "Error", "This demo script only works when compiled")

Opt("GUIOnEventMode", 1)

Global $hGui = GUICreate("Console Info Window", 300, 100, @DesktopWidth - 300, 10)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUICtrlCreateLabel("Mouse position in console:", 10, 10, 150, 20, $SS_CENTERIMAGE)
Global $nPosition = GUICtrlCreateInput("", 160, 10, 70, 20, $ES_READONLY)
GUISetState()




_FreeConsole()

If Not _AllocConsole() Then
    ConsoleWrite("Error AllocConsole input" & @CRLF)
    Sleep(1000)
    Exit
EndIf

Global $hStdIn = _GetStdHandle($STD_INPUT_HANDLE)
If $hStdIn = $INVALID_HANDLE_VALUE Then
    ConsoleWrite("Error GetStdHandle input" & @CRLF)
    Sleep(1000)
    Exit
EndIf

Global $hStdOut = _GetStdHandle($STD_OUTPUT_HANDLE)
If $hStdOut = $INVALID_HANDLE_VALUE Then
    ConsoleWrite("Error GetStdHandle output" & @CRLF)
    Sleep(1000)
    Exit
EndIf

Global $hModeOld = _GetConsoleMode($hStdIn)
If @error Then
    _ConsoleWrite($hStdOut, "Error GetConsoleMode" & @CRLF)
    Sleep(1000)
    Exit
EndIf

If Not _SetConsoleMode($hStdIn, BitOR($ENABLE_WINDOW_INPUT, $ENABLE_MOUSE_INPUT)) Then
    _ConsoleWrite($hStdOut, "Error SetConsoleMode" & @CRLF)
    Sleep(1000)
    Exit
EndIf


Global $tRecord = DllStructCreate($tagINPUT_RECORD)
Global $iRecordsRead


_ResizeConsoleBuffer(150, 30)

While True
    If _GetNumberOfConsoleInputEvents($hStdIn) = 0 Then
        ContinueLoop
        Sleep(10)
    EndIf

    If Not _ReadConsoleInput($hStdIn, $tRecord, 1, $iRecordsRead) Then
        _ConsoleWrite($hStdOut, "Error ReadConsoleInput" & @CRLF)
        _Exit()
    EndIf

    Switch DllStructGetData($tRecord, "EventType")
        Case $FOCUS_EVENT
            ;do nothing
        Case $KEY_EVENT
            If Not _KeyEventProc($tRecord) Then ExitLoop
        Case $MENU_EVENT
            ;do nothing
        Case $MOUSE_EVENT
            _MouseEventProc($tRecord)
        Case $WINDOW_BUFFER_SIZE_EVENT
            _ResizeEventProc($tRecord)
        Case Else
            _ConsoleWrite($hStdOut, "Error unknown event type" & @CRLF)
            _Exit()
    EndSwitch
WEnd

Func _ResizeConsoleBuffer($w, $h)
    _SetConsoleScreenBufferSize($hStdOut, $w, $h)
    If @error Then
        _ConsoleWrite($hStdOut, "Error SetConsoleScreenBufferSize" & @CRLF)
    EndIf

    _SetConsoleWindowInfo($hStdOut, $w - 1, $h - 1)
    If @error Then
        _ConsoleWrite($hStdOut, "Error SetConsoleWindowInfo" & @CRLF)
    EndIf
EndFunc   ;==>_ResizeConsoleBuffer

Func _Exit()
    _SetConsoleMode($hStdIn, $hModeOld)
    Exit
EndFunc   ;==>_Exit

Func _FreeConsole()
    Local $aRet = DllCall("kernel32.dll", "BOOL", "FreeConsole")
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_FreeConsole

Func _AllocConsole()
    Local $aRet = DllCall("kernel32.dll", "BOOL", "AllocConsole")
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_AllocConsole

Func _FlushConsoleInputBuffer($hConsole)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "FlushConsoleInputBuffer", "handle", $hConsole)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_FlushConsoleInputBuffer

Func _GetStdHandle($nStdHandle)
    Local $aRet = DllCall("kernel32.dll", "handle", "GetStdHandle", "DWORD", $nStdHandle)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_GetStdHandle

Func _GetConsoleMode($hConsole)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "GetConsoleMode", "handle", $hConsole, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[2]
EndFunc   ;==>_GetConsoleMode

Func _SetConsoleMode($hConsole, $dwMode)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "SetConsoleMode", "handle", $hConsole, "DWORD", $dwMode)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_SetConsoleMode

Func _GetNumberOfConsoleInputEvents($hConsole)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "GetNumberOfConsoleInputEvents", "handle", $hConsole, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[2]
EndFunc   ;==>_GetNumberOfConsoleInputEvents

Func _ReadConsoleInput($hConsole, ByRef $tRecord, $iRecordCount, ByRef $iRecordsRead)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "ReadConsoleInput", "handle", $hConsole, "struct*", $tRecord, "DWORD", $iRecordCount, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    $iRecordsRead = $aRet[4]
    Return $aRet[0]
EndFunc   ;==>_ReadConsoleInput

Func _PeekConsoleInput($hConsole, ByRef $tRecord, $iRecordCount, ByRef $iRecordsRead)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "PeekConsoleInput", "handle", $hConsole, "struct*", $tRecord, "DWORD", $iRecordCount, "DWORD*", 0)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    $iRecordsRead = $aRet[4]
    Return $aRet[0]
EndFunc   ;==>_PeekConsoleInput

Func _ConsoleWrite($hConsoleOut, $sText)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "WriteConsole", "handle", $hConsoleOut, "str", $sText, "DWORD", StringLen($sText), "DWORD*", 0, "ptr", 0)
EndFunc   ;==>_ConsoleWrite

Func _SetConsoleWindowInfo($hConsoleOut, $w, $h)
    Local $tSmallRect = DllStructCreate("SHORT Left;SHORT Top;SHORT Right;SHORT Bottom;")
    DllStructSetData($tSmallRect, "Right", $w)
    DllStructSetData($tSmallRect, "Bottom", $h)
    Local $aRet = DllCall("kernel32.dll", "BOOL", "SetConsoleWindowInfo", "handle", $hConsoleOut, "BOOL", True, "struct*", $tSmallRect)
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_SetConsoleWindowInfo

Func _SetConsoleScreenBufferSize($hConsoleOut, $w, $h)
    Local $tCoord = DllStructCreate("SHORT X;SHORT Y;")
    DllStructSetData($tCoord, "X", $w)
    DllStructSetData($tCoord, "Y", $h)
    Local $tDword = DllStructCreate("DWORD Coord", DllStructGetPtr($tCoord))

    Local $aRet = DllCall("kernel32.dll", "BOOL", "SetConsoleScreenBufferSize", "handle", $hConsoleOut, "DWORD", DllStructGetData($tDword, "Coord"))
    If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc   ;==>_SetConsoleScreenBufferSize

Func _KeyEventProc($tRecord)
    Local $tKeyRecord = DllStructCreate($tagINPUT_RECORD_KEY, DllStructGetPtr($tRecord))
    Local $bPressed = DllStructGetData($tKeyRecord, "bKeyDown")
    Local $cChar = DllStructGetData($tKeyRecord, "UnicodeChar")
    If $cChar = "" Then Return 1 ;don't show modifier keys (ctrl, alt, shift, pause, F1, F2, ...)
    If $bPressed Then
;~      _ConsoleWrite($hStdOut, "Key pressed: " & $cChar & @CRLF)
    Else
;~      _ConsoleWrite($hStdOut, "Key released: " & $cChar & @CRLF)
    EndIf
    If Asc($cChar) = 27 Then Return 0 ; end script when 'Escape' is pressed
    Return 1
EndFunc   ;==>_KeyEventProc

Func _MouseEventProc($tRecord)
    ConsoleWrite("Mouse event: ")
    Local $tMouseRecord = DllStructCreate($tagINPUT_RECORD_MOUSE, DllStructGetPtr($tRecord))
    Local $iMouseEvent = DllStructGetData($tMouseRecord, "dwEventFlags")
    Local $iButtonState = DllStructGetData($tMouseRecord, "dwButtonState")
    Local $x = DllStructGetData($tMouseRecord, "X")
    Local $y = DllStructGetData($tMouseRecord, "Y")

    GUICtrlSetData($nPosition, StringFormat("%d,%d", $x, $y))
;~  _ConsoleWrite($hStdOut, StringFormat("Position: [%03d,%03d] - ", $x, $y))

    Switch $iMouseEvent
        Case 0
            If $iButtonState = $FROM_LEFT_1ST_BUTTON_PRESSED Then
                _ConsoleWrite($hStdOut, StringFormat("Left mouse click at position: [%03d,%03d]" & @CRLF, $x, $y))
                MsgBox(48, "Info", StringFormat("Left mouse click at position: [%03d,%03d]", $x, $y))
            ElseIf $iButtonState = $RIGHTMOST_BUTTON_PRESSED Then
;~              _ConsoleWrite($hStdOut, "Right button pressed" & @CRLF)
            Else
;~              _ConsoleWrite($hStdOut, "Button pressed" & @CRLF)
            EndIf
        Case $DOUBLE_CLICK
;~          _ConsoleWrite($hStdOut, "Double clicked" & @CRLF)
        Case $MOUSE_HWHEELED
;~          _ConsoleWrite($hStdOut, "Horizontal wheeled" & @CRLF)
        Case $MOUSE_MOVED
;~          _ConsoleWrite($hStdOut, "Mouse moved" & @CRLF)
        Case $MOUSE_WHEELED
;~          _ConsoleWrite($hStdOut, "Vertical wheeled" & @CRLF)
        Case Else
;~          _ConsoleWrite($hStdOut, "Unknown mouse action" & @CRLF)
    EndSwitch
EndFunc   ;==>_MouseEventProc

Func _ResizeEventProc($tRecord)
    Local $tResizeRecord = DllStructCreate($tagINPUT_RECORD_WINDOW_BUFFER_SIZE, DllStructGetPtr($tRecord))
    Local $iColumns = DllStructGetData($tResizeRecord, "X")
    Local $iRows = DllStructGetData($tResizeRecord, "Y")

;~  _ConsoleWrite($hStdOut, "Console screen buffer is now " & $iColumns & " columns by " & $iRows & " rows" & @CRLF)
EndFunc   ;==>_ResizeEventProc

I do not fully understand this example. Did you could shorten the code only to return after a mouse click coordinates?

Link to comment
Share on other sites

I do not fully understand this example. Did you could shorten the code only to return after a mouse click coordinates?

No, that's enough help for you for a while. Please read the script carefully, then read the AutoIt documentation and then here is a link to Microsoft's console functions: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682073%28v=vs.85%29.aspx

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...