With this script you can print Unicode text in the CMD screen
the script is easy to use
just you write the text that contains Unicode in the first input
and the script automatically reflect the code in the second input
you can copy the text to the clipboard
or you can try printing the text in the CMD window
I apologize to everyone for colors and shape if not appropriate
I'm a blind man and I do not see
Thank you for your understanding
Greetings to all of youCmdUtM.au3
this is a follow-up to
i sporadically and very rarely get an access violation exception.
here is some simplyfied repro code:
#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include-once #include <Array.au3> #include <security.au3> ;~ #include "ESC_Globals.au3" Global Const $WTS_CURRENT_SESSION = -1 Global Const $WTS_CURRENT_SERVER_HANDLE = 0 Global Const $WTS_CLIENTPROTOCOLTYPE = 16 Global Const $WTS_CONNECTSTATE = 8 Global Const $WTS_USERNAME = 5 Global Const $tagWTS_SESSION_INFO = _ "dword SessionId;" & _ "ptr WinStationName;" & _ "uint State" Global Const $tagWTS_PROCESS_INFO = _ "DWORD SessionId;" & _ "DWORD ProcessId;" & _ "PTR pProcessName;" & _ "PTR pUserSid" For $i = 0 To 1000 * 20 ConsoleWrite("iteration " & $i & @CRLF) _GetProcessList() Sleep(1000) Next MsgBox(0, "COMPLETED", "everything done") ;***************************************** ;# returns an array: ProcessName | ProcessID | SessionID | ProcessOwner Func _GetProcessList() Local $i, $aRet ConsoleWrite("_GetProcessList() --> " & @AutoItPID & @CRLF) Local $aProcessList = ProcessList() $aRet = DllCall("WTSApi32.dll", "int", "WTSEnumerateProcesses", "int", $WTS_CURRENT_SERVER_HANDLE, "int", 0, "int", 1, "ptr*", 0, "int*", 0) If @error Or ($aRet == 0) Then MsgBox(4096 + 48, "Error", "Failed invoking WTSEnumerateProcesses") Return (SetError(1, 0, -1)) EndIf Local $array[$aRet] Local $mem = DllStructCreate($tagWTS_PROCESS_INFO, $aRet) For $i = 0 To $aRet - 1 ConsoleWrite("IT: " & $i) ;# DEBUG $mem = DllStructCreate($tagWTS_PROCESS_INFO, $aRet + ($i * DllStructGetSize($mem))) ConsoleWrite(" - PID: ") ;# DEBUG $array[$i] = Int(DllStructGetData($mem, "ProcessId"), 1) ;# convert to Int32 ConsoleWrite($array[$i]) ;# DEBUG ConsoleWrite("; SID: ") ;# DEBUG $array[$i] = Int(DllStructGetData($mem, "SessionId"), 1) ;# convert to Int32 ConsoleWrite($array[$i]) ;# DEBUG Local $name1 = "???" For $j = 1 To $aProcessList If $aProcessList[$j] == $array[$i] Then $name1 = $aProcessList[$j] ExitLoop EndIf Next ConsoleWrite("; NAME1: " & $name1) ;# DEBUG ConsoleWrite("; NAM") ;# DEBUG Local $ret2 = DllStructGetData($mem, "pProcessName") ConsoleWrite("E") ;# DEBUG Local $ret3 = DllStructCreate("char", $ret2) Local $myRet = @error ConsoleWrite(": ") ;# DEBUG If $myRet == 0 Then Local $string = "" & DllStructGetData($ret3, 1) & "" ;# <==== here it sometimes CRASHES $array[$i] = $string ConsoleWrite($array[$i]) ;# DEBUG Else MsgBox(4096 + 48, "Error", "Failed for DllStructCreate: " & $myRet) ;# i never got here $array[$i] = "???" ConsoleWrite($array[$i]) ;# DEBUG EndIf ConsoleWrite("; OWNER") ;# DEBUG Local $ret3 = _Security__LookupAccountSid(DllStructGetData($mem, "pUserSid")) ConsoleWrite(": ") ;# DEBUG If IsArray($ret3) Then $array[$i] = "" & $ret3 & "/" & $ret3 & "" ConsoleWrite($array[$i]) ;# DEBUG EndIf ConsoleWrite(@CRLF) ;# DEBUG Next ConsoleWrite("endLoop." & @CRLF) ;# DEBUG DllCall("WTSApi32.dll", "int", "WTSFreeMemory", "int", $aRet) ConsoleWrite("_GetProcessList() <-- " & @AutoItPID & @CRLF) ;# DEBUG Return $array EndFunc ;==>_GetProcessList
first of all i'd like to understand WHY it crashes in DllStructGetData.
and then i'd like to AVOID it, of course
so far i have found no way to add some try-catch logic in AutoIt.
any ideas why it would crash under very rare circumstances?
my script is 32bit executed on windows 64bit OS.
i have seen it on both, windows 7 and windows 10.
i have seen it with both, script execution and compiled exe.
Thanks to this post (https://www.autoitscript.com/forum/topic/189553-writing-to-cmd/?do=findComment&comment=1361142) I can now write a helpfile to the cmd when for instance passing parameter -h or -help at cmd. But then cmd is blocked by the script (I had to free it with CTRL+BREAK):
#include <WinAPI.au3> _WinAPI_AttachConsole() $hConsole = _WinAPI_GetStdHandle(1) _WinAPI_WriteConsole($hConsole, "Print helpfile................" & @CRLF) Inside MSDN Library then I found this sentence: A process can use the FreeConsole function to detach itself from its console.
But I don't find something like _WinAPI_FreeConsole(). How can I do it in another way?
A fullscreen console with custom commands!
This funny project started as a question in the help section:
I'd like to share this script with everyone that is interested.
Why would I want it?
You like the old style fullscreen console (like in the old day's), You can add custom commands, You can customize the font a lot more compared to cmd.exe, You can share ideas or add tweaks to the script.
Still to do:
Write a simple custom programming language to implement this tool. Writing a little help file / pdf to describe my little programming language. Add little sound effects like a beep if there is a syntax error (optional). Clean up and modify Console.Au3 content. Add an option to have to type a login password (optional). Make an optional installer that also gives scripts for this tool a custom icon and open with command. ...Call Neo?
xxaviarxx: debugging, some ideas. jguinch: debugging, adding a bunch of tweaks and ideas. kylomas: debugging, new ideas.
Edits and updates:
Added usage of tab key in edit control Edit has focus now on startup I'm currently rewriting a simple custom programming language to implement this tool.
UDF download: Console.au3
Good evening guys,
i'm having a problem, not about the code (i'm only thinking about it at the moment) but about the way i can do it.
I have a webpage (photo N.1) it has some elements in it.
I need only the table (photo N.2), looking at the code and with _IEFunctions i can easy find the table but how i can i "copy" it?
As i said it's really easy to found with a script but what should i do then? Copy the source? And how can i display it to the user?
In my head i'd like to display it inside a GUI, is that possible?
Thanks in advance
Edit: Posted 2 times same photo. Now should be OK