Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win32console missing some console functions #1266

Closed
needhourger opened this issue Oct 29, 2018 · 3 comments
Closed

win32console missing some console functions #1266

needhourger opened this issue Oct 29, 2018 · 3 comments

Comments

@needhourger
Copy link

I wonder that I can't find functions like SetConsoleCursorPosstion???
not support? or just because i miss it?

@thopiekar
Copy link
Contributor

Depends. If it is a function, which has been added years ago, then it might be missing in PyWin32 still.
New functions always need to be added manually here, so the binding generator SWIG generates the "node" to Python.

Just take a look at the recent pull requests. If you like you can try adding it yourself and share it with us 😊

@achillis2016
Copy link

SetConsoleCursorPosition exists in pywin32 object PyConsoleScreenBuffer . The following message maybe helpful:

PyConsoleScreenBuffer Object
Handle to a console screen buffer Create using win32console::CreateConsoleScreenBuffer or win32console::GetStdHandle Use PyConsoleScreenBufferType(Handle) to wrap a pre-existing handle as returned by win32api::GetStdHandle. Will also accept a handle created by win32file::CreateFile for CONIN$ or CONOUT$. When an existing handle is wrapped, a copy is made using DuplicateHandle, and caller is still responsible for any cleanup of original handle.
Methods
Detach:Releases reference to handle without closing it
Close:Closes the handle
SetConsoleActiveScreenBuffer:Sets this handle as the currently display screen buffer
GetConsoleCursorInfo:Retrieves size and visibility of console's cursor
SetConsoleCursorInfo:Sets the size and visibility of console's cursor
GetConsoleMode:Returns the input or output mode of the console buffer
SetConsoleMode:Sets the input or output mode of the console buffer
ReadConsole:Reads characters from the console input buffer
WriteConsole:Writes characters at current cursor position
FlushConsoleInputBuffer:Flush input buffer for console
SetConsoleTextAttribute:Sets character attributes for subsequent write operations

SetConsoleCursorPosition:Sets the console screen buffer's cursor position

SetConsoleScreenBufferSize:Sets the size of the console screen buffer
SetConsoleWindowInfo:Changes size and position of a console's window
GetConsoleScreenBufferInfo:Returns the state of the screen buffer
GetLargestConsoleWindowSize:Returns the largest possible size for the console's window
FillConsoleOutputAttribute:Set text attributes for a consecutive series of characters
FillConsoleOutputCharacter:Sets consecutive character positions to a specified character
ReadConsoleOutputCharacter:Reads consecutive characters from a starting position
ReadConsoleOutputAttribute:Retrieves attributes from consecutive character cells
WriteConsoleOutputCharacter:Writes a string of characters at a specified position
WriteConsoleOutputAttribute:Sets the attributes of a range of character cells
ScrollConsoleScreenBuffer:Scrolls a region of the display
GetCurrentConsoleFont:Returns the currently displayed font
GetConsoleFontSize:Returns size of specified font for the console
SetConsoleFont:Changes the font used by the screen buffer
SetStdHandle:Replaces one of calling process's standard handles with this handle
SetConsoleDisplayMode:Sets the display mode of the console buffer
WriteConsoleInput:Places input records in the console's input queue
ReadConsoleInput:Reads input records and removes them from the input queue
PeekConsoleInput:Returns pending input records without removing them from the input queue
GetNumberOfConsoleInputEvents:Returns the number of unread records in the input queue

@mhammond mhammond changed the title About win32console win32console missing some console functions Mar 3, 2019
@Avasam
Copy link
Collaborator

Avasam commented Oct 15, 2024

@needhourger If you have a request for a specific missing method, you can open an issue for it or try adding it yourself!
Concerning SetConsoleCursorPosition, I'll chalk this up to bad documentation (see https://github.com/mhammond/pywin32/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen+label%3Adocumentation , especially #1992 )

import win32console
coord = win32console.PyCOORDType(0,0)
win32console .CreateConsoleScreenBuffer().SetConsoleCursorPosition(coord)
win32console.GetStdHandle(handle).SetConsoleCursorPosition(coord)
win32console.PyConsoleScreenBufferType(handle).SetConsoleCursorPosition(coord)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants