Jump to content
Sign in to follow this  
rcmaehl

ConsoleWrite only outputting ASCII/ANSI?

Recommended Posts

I might be doing something wrong but I'm running a CUI compiled application in Powershell ISE and it's not outputting unicode characters in the console. I for a fact Powershell ISE supports unicode so I'm thinking it's something with AutoIt. Does ConsoleWrite just not output Unicode? Do CUI compiled applications run inside the old Windows Console when executed through Powershell? is there something else preventing this?


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Share this post


Link to post
Share on other sites

Should work with console in UTF8 and consolewriting string converted to UTF8.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
15 hours ago, jchd said:

and consolewriting string converted to UTF8.

What do you mean? I mean if I run in Powershell:

echo η γλώσσα μου έδωσαν ελληνική

It outputs

η γλώσσα μου έδωσαν ελληνική

However, if I run a compiled CUI autoit script that's just

ConsoleWrite("η γλώσσα μου έδωσαν ελληνική" & @CRLF)

It outputs

? ???ssa µ?? ?d?sa? e???????

Is there a setting I have to set in Autoit?

 

Edit: Never mind. Under "Unicode Support" it clearly states:
 

Quote

Console operations are converted to ANSI.

 

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Share this post


Link to post
Share on other sites

What does this do?

ConsoleWrite(BinaryToString(StringToBinary("η γλώσσα μου έδωσαν ελληνική", 4), 1) & @CRLF)

 


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
4 minutes ago, jchd said:

What does this do?

ConsoleWrite(BinaryToString(StringToBinary("η γλώσσα μου έδωσαν ελληνική", 4), 1) & @CRLF)

 

Writes properly in SciTE console now before compiling. After compiling Powershell outputs:

η γλώσσα μου έδωσαν ελληνική

instead of 

? ???ssa µ?? ?d?sa? e???????



However, I noticed after posting the last post that in Unicode Support in the help file it states:

Quote

Console operations are converted to ANSI.

Which means I probably need to put in a feature request ticket for this in the bug tracker if possible.

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Share this post


Link to post
Share on other sites

Maybe there is a possibility to set the console to Unicode (UTF8), by forcing "chcp 65001" or something equivalent as the initial default codepage setting, but I'm not much experienced with CUI.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Just now, jchd said:

Maybe there is a possibility to set the console to Unicode (UTF8), by forcing "chcp 65001" or something equivalent as the initial default codepage setting, but I'm not much experienced with CUI.

Already tried that. Nothing changed.


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Share this post


Link to post
Share on other sites

There must be a registry setting hidden somewhere, but only MS knows where.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Are you saying that it works compiled on your system?


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Share this post


Link to post
Share on other sites

Yes I made it work. In registry go to HKCU/Console and add two new keys:

CodePage (DW) = FDE9 (this is 65001)

Facename (String) = "Lucida Console" (warning, case sensitive!!!)

#AutoIt3Wrapper_Change2CUI=y

ConsoleWrite(BinaryToString(StringToBinary("η γλώσσα μου έδωσαν ελληνική ЊЋЌЎЏАБВГДЕЖЗИЙКЛЩЯ ⅛⅜⅝⅞ ∙≠≡≤≥⌂", 4), 1) & @CRLF)
Sleep(5000)

You can use any fixed pitch font, like DejaVu Sans Mono, etc. Change window size, fontsize, ... accordingly so that out is easily readable.

EDIT: forgot to mention that it's quite possible that some other CUI tool wouldn't like those settings. Also verify that your system boots correctly after changes.

Best of luck!

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
On 4/11/2016 at 11:33 AM, jchd said:

EDIT: forgot to mention that it's quite possible that some other CUI tool wouldn't like those settings. Also verify that your system boots correctly after changes.

Ouch. Would prefer not to suggest changing the registry with something that could mess up boot as a bypass to a glitch I can't fix.


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Share this post


Link to post
Share on other sites

Since this setting is in user reg space, I don't believe it would stop booting. Also you can change regsitry at program startup and revert changes at termination. Just try.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By emendelson
      After fifteen years of working in AutoIt, I'm still a beginner, so I have ConsoleWrite() lines all over my scripts to help me find my mistakes. Is it likely that these lines are slowing down my compiled scripts? If so, would it make sense to replace all the ConsoleWrite() lines with
      If Not @Compiled Then ConsoleWrite("data") Or is it better simply to comment out those lines when I have things working correctly?
      I'm not sure there's a clear answer to this question, but I hope someone knows a lot more about it than I do.
    • By rmckay
      Hello,
      I've added ConsoleWrite lines to functions I've created.  The format for the ConsolWrite statements is : (@CRLF & $sPath  &  '('  &  @ScriptLineNumber  &  ') : *** Func _ABC() ***: '  &  @crlf ).  $sPath  is defined as the filepath to the file containing the function - Local $sPath = "C:\Users\Owner\Documents\AutoIt\NT8 Download Replay Data\DownloadReplayFunctions02.au3" 
      Local $sPath = "C:\Users\Owner\Documents\AutoIt\NT8 Download Replay Data\DownloadReplayFunctions02.au3" ConsoleWrite(@CRLF & $sPath & '(' & @ScriptLineNumber & ') : *** Func _oMenuItemHistoricalData() ***: ' & @crlf ) The result is that I can access the functions from the Scite output window when the function is located in another file which is included in the main file.  For some reason Scite adds a line to the code when I switch to the Include file from the output window.

      Why does the line get added to the script and can I stop if from appearing?
      Thanks,
    • By Luigi
      Greetings,
      Is possible build a script to send/receive commands in "Native Messagin" ?

      If you install this extension:
      https://chrome.google.com/webstore/detail/native-messaging-example/mefhabneoickhhbiglkmehhmemefkopf/related
      And this complement:
      https://github.com/Mandar-Shinde/Google-Chrome-Native-Messaging/releases/download/V1.0/GoogleNativeClient.exe

      You have a work example to send / receive messages from Google Chrome's plugin and NativeMessagingApp.exe.

      I found the source NativeMessagingApp.exe's here:
      https://github.com/Mandar-Shinde/Google-Chrome-Native-Messaging
      I try build this script... But not work...
       
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Outfile=C:\Users\Public\GoogleNativeClient\NativeMessagingApp2.exe #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #NoTrayIcon #include-once #include <Array.au3> #include <JSMN.au3> ; https://github.com/chechelaky/AutoIt/blob/master/JSMN.au3 #include <Debug.au3> Global $msg = "@empty" Global Const $CLIENT_START = '{"text":"Client Started"}' Global Const $CLIENT_STOP = '{"text":"Client Stopped"}' Global Const $CLIENT_CLICK = '{"text":"Client Click"}' _DebugSetup("NativeMessagingApp2", True, 4, @ScriptDir & "\NativeMessagingApp2.log", True) Global $read, $json, $out = "" If IsArray($CmdLine) Then ;~ $msg = @LF & "Google Chrome Native Messaging App V1" & @LF & @LF & _ ;~ "GPLV3 software distributed under the License is distributed on an ""AS IS"" BASIS" & @LF & _ ;~ "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied." & @LF & _ ;~ "See the License for the specific language governing permissions and" & @LF & _ ;~ "limitations under the License." & @LF & @LF ;~ Local $size = UBound($CmdLine, 1) - 1 ;~ $msg &= "App running with args=" & $size & @LF ;~ For $ii = 0 To $size ;~ $msg &= $ii & " : " & $CmdLine[$ii] & @LF ;~ Next ;~ _DebugOut($msg) EndIf sendMessage($CLIENT_START) While Sleep(10) $read = ConsoleRead() If @error And $out Then _DebugOut("$read...............: " & $out) $json = Jsmn_decode($out) If @error Then _DebugOut("$json...............: @Error") Else _DebugOut("$json...............: @Ok") EndIf If IsObj($json) And $json.Exists("text") Then sendMessage('{"text":"' & $json.Item("text") & '"}') Else sendMessage('{"text":"@Error"}') EndIf $out = "" Else $out &= $read EndIf WEnd Func sendMessage($var) ConsoleWrite($var & @CRLF) _DebugOut("sendMessage===>" & $var) EndFunc ;==>Say  
      Edit the file:
      C:\Users\Public\GoogleNativeClient\com.google.chrome.example.echo-win.json

      And replace:
      "path": "NativeMessagingApp.exe",
      By:
      "path": "NativeMessagingApp2.exe",
      Then plugin call the AutoIt script...

      But is not functional...

       
      About the file mainwindow.cpp, have this function:
      inline QString sendMessage(QString data){ unsigned int len = data.length(); cout.write(reinterpret_cast<const char *>(&len), 4); cout << data.toUtf8().data() << flush; return ""; } How re-write this to AutoIt?
      How execute a flush?



      Best regards.
    • By Danyfirex
      Hello guys.  It's been awhile since I shared something. So today I want to share my last project.
      What's Loga?
      Loga is a simple logging library to keep track of code with an integrated console.
      Features.
      Common log levels. Integrated console. Multiple instances. Custom color and font for each instance log level. Define output format with macros. Conditional and occasional Logging. Easy to use. Basic Usage:
      #include "..\Loga.au3" ;This are some of the default settings: ;Default log level $LOGA_LEVEL_TRACE ;output format: {Symbol}{LogIndex} {LevelName} {LongDateTime} {Message} ;Log to File is enabled. ;Log file name format: YYYYMMDDHHMM-Loga-InstanceIndex.log ;Custom Console is disabled by default. ;By default log to STDOUT. _LogaTrace("I'm Trace") _LogaDebug("I'm Debug") _LogaInfo("I'm Info") _LogaWarn("I'm Warn") _LogaError("I'm Error") _LogaFatal("I'm Fatal")  
      More examples here.
       
      Check Loga on GitHub.
       
      Loga Latest Release v1.0.2.
       
      Saludos
       
       
       
       
    • By boomingranny
      Use this UDF to add a console gui to your script (with log file):
      It uses the Hidden Autoit window (that you probably didn't even know existed)
      Closing Console window will terminate script.
      example of console:

      #include-once #include <GuiEdit.au3> EnableConsoleGui("example.log") ;example: ;------------------------ ConsoleWrite ("Hello World") For $i = 1 To 10 ConsoleWrite (".") Sleep(200) Next ConsoleWrite ("done") ConsoleWrite(@CRLF) ConsoleWrite ("close me to exit"&@CRLF) While 1 Sleep(1000) WEnd ;------------------------ ;end of example code Func EnableConsoleGui($Logfile="") ;EnableConsoleGUI ;by Daniel Barnes 20/04/2018 ;Uses AutoIt's Hidden window as a console (output only) Global $pidChild ;if we don't have a parent (as the parent window would have our script name) If Not WinExists(StringTrimRight(@ScriptName,4)) Then Opt("TrayIconHide",1) ;get Autoit's hidden window handle local $hWnd = WinGetHandle(AutoItWinGetTitle()) ;move the autoit hidden window to the middle of the screen WinMove($hWnd, "", (@DesktopWidth / 2) - 250, (@DesktopHeight / 2) - 250, 500, 500) ;get the Handle of the edit box in Autoit's hidden window $hEditBox = ControlGetHandle($hWnd,"","[CLASS:Edit; INSTANCE:1]") ;show it WinSetState($hWnd, "", @SW_SHOW) ;set its title = our script name WinSetTitle($hWnd,"",StringTrimRight(@ScriptName,4)) ;Spawn a child "copy" of the script, enabling reading of its console... If @Compiled Then ;2 = $STDOUT_CHILD. This avoids requiring the AutoItConstants.au3 in this sample code $pidChild= Run( FileGetShortName(@ScriptFullPath),@ScriptDir,"",2) Else ;2 = $STDOUT_CHILD. This avoids requiring the AutoItConstants.au3 in this sample code $pidChild= Run( FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath),@ScriptDir,"",2) EndIf OnAutoItExitRegister("EnableConsoleGui_CloseChildPID") ;read the console, while the child window exists (and the console window is visible) While ProcessExists($pidChild) $ConsoleRead = StdoutRead($pidChild) If $ConsoleRead then $text = StringLeft(ControlGetText($hWnd,"",$hEditBox),65535) If $Logfile Then FileWrite($Logfile,$ConsoleRead) $text &= $ConsoleRead ControlSetText($hWnd,"",$hEditBox,$text) ConsoleWrite($ConsoleRead) ;scroll to bottom of console edit window _GUICtrlEdit_SetSel($hEditBox, 65535, 65535) endif Sleep(250) WEnd exit endif EndFunc Func EnableConsoleGui_CloseChildPID() ;if this func isn't used ;when you close the console gui ;the child "clone" of your script will keep running ProcessClose($pidChild) EndFunc
×
×
  • Create New...