E1M1 Posted September 16, 2010 Share Posted September 16, 2010 I have console application made in autoit. But how do I get console's handle? #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ConsoleWrite("test") I want to use console functions from MSDN but I have no idea how to get handle to console created by autoit. Here's 1 func I want to use. http://msdn.microsoft.com/en-us/library/ms686025%28VS.85%29.aspx edited Link to comment Share on other sites More sharing options...
Mat Posted September 16, 2010 Share Posted September 16, 2010 (edited) I have written a complete library for all the console functions, but haven't written examples or anything...Read the source code for Au3Int, I use the following function a lot:Func _Au3Int_Clr() Local $hConsole, $aRet $aRet = DllCall("kernel32.dll", "hwnd", "GetStdHandle", "dword", -11) If @error Or (Not IsArray($aRet)) Or ($aRet[0] = -1) Then Return SetError(1, 0, False) $hConsole = $aRet[0] Local $tScreenBufferInfo = DllStructCreate("short X; short Y; short; short; short; short; short; short; short; short; short") $aRet = DllCall("kernel32.dll", "bool", "GetConsoleScreenBufferInfo", "hwnd", $hConsole, "ptr", DllStructGetPtr($tScreenBufferInfo)) If @error Or (Not IsArray($aRet)) Or (Not $aRet[0]) Then Return SetError(2, 0, False) $aRet = DllCall("kernel32.dll", "int", "FillConsoleOutputCharacterW", _ "handle", $hConsole, _ "byte", 0x20, _ "dword", DllStructGetData($tScreenBufferInfo, "X") * DllStructGetData($tScreenBufferInfo, "Y"), _ "dword", 0, _ "dword*", 0) If @error Or (Not IsArray($aRet)) Or (Not $aRet[0]) Then Return SetError(3, 0, False) $aRet = DllCall("kernel32.dll", "int", "SetConsoleCursorPosition", "hwnd", $hConsole, "dword", 0) If @error Or (Not IsArray($aRet)) Or (Not $aRet[0]) Then Return SetError(4, 0, False) Return True EndFunc ;==>_Au3Int_ClrI took it from an older version of the source code as in the newer version I updated the code to use functions and look neater. That will clear the console, and set the cursor to the first square.I'll bge home in an hour, and I'll be able to pm you the full UDF (Maybe you'll be able to write some examples for those particular functions... MatEdit: I should have mentioned exactly what -11 means... It's all in the docs at home and as constants so maybe i'll wait, but there are three handles you can get to the buffer, that is the out one. Edited September 16, 2010 by Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
E1M1 Posted September 16, 2010 Author Share Posted September 16, 2010 Yea pm me your udf so I could use it in my notepad project. Image below shouws what I have done so far. edited Link to comment Share on other sites More sharing options...
Mat Posted September 16, 2010 Share Posted September 16, 2010 Looks awesome A blast from the past. AutoIt Project Listing Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now