Unknown6656 / AutoIt-Interpreter

A C# AutoIt interpreter designed to be platform-independent

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[System.InvalidOperationException] (80131509h) An error occurred when writing the STDOUT console mode

mast3rz3ro opened this issue · comments

Hi there,

This happens when I try to run it

E:\AutoIt_Interpreter_0.8.1803.7550>autoit3
[System.InvalidOperationException] (80131509h) An error occurred when writing the STDOUT console mode.:
   at Unknown6656.Controls.Console.ConsoleExtensions.set_STDOUTConsoleMode(ConsoleMode value)
   at Unknown6656.Controls.Console.ConsoleExtensions..cctor()
[System.TypeInitializationException] (80131534h) The type initializer for 'Unknown6656.Controls.Console.ConsoleExtensions' threw an exception.:
   at Unknown6656.Controls.Console.ConsoleExtensions.SaveConsoleState()
   at Unknown6656.AutoIt3.CLI.MainProgram.Start(String[] argv) in L:\Projects.VisualStudio\AutoItInterpreter\new\AutoItInterpreter\CommandLineInterface\MainProg
ram.cs:line 178
   at <Program>$.<Main>$(String[] args) in L:\Projects.VisualStudio\AutoItInterpreter\new\AutoItInterpreter\EntryPoint.cs:line 14

I'm using Windows 7 x64

Hey @mast3rz3ro thank you for reporting the bug. I think I know where this error comes from. Win7 does not seem to support the console mode required for the AutoIt Interpreter to run correctly. I am not sure how exactly I can fix the bug, as officially Win7 would not expose the APIs required. However, I'll try to do my best.

If it is not to much trouble for you, could you tell me whether you get the same error when trying to run the same built of AutoIt on Win10 or Win11?

Thanks.

Ok, after having done some research, I've found this:

[...] the new support for ANSI Terminal Control which was added to the Windows 10 console host in build 16257 (and later), [which] is n̲o̲t̲ e̲n̲a̲b̲l̲e̲d̲ by default.
Unless the specific software you're using enables ANSI processing by calling the SetConsoleMode API with the ENABLE_VIRTUAL_TERMINAL_PROCESSING (0x0004) flag, you won't see colors or get ANSI processing for that application.

Bottom line: All the formatting done by the underlying library Unknown6656.Core is performed by making usage of ANSI escape sequences, in order to guarantee same results on Linux, MacOS, and Windows.
However, ANSI escape sequences are only supported by Windows10 v.16257 or newer.

Now I have the two options:

  1. Don't support anything older than Windows10
  2. Ignore the failed API call and permit the emittance of ANSI escape sequences to the STDIN/STDOUT/STDERR streams. This will result in the following:
    image
    The upper line will be displayed on anything older than Windows10 v.16257, the bottom line on anything newer.

I hope that I have fixed the issue with 52a8806.
The changes have been incorporated into the newest release: https://github.com/Unknown6656/AutoIt-Interpreter/releases

Please let me know whether you encounter any issue.

Hi,

Sorry for my late respond.

I have tried to run both previous and latest releases on both Windows 7 and Windows 10 but I'm still not able to get it working.

Here's the output on Windows 7 with latest release:

C:\Users\Unknown\Downloads\Compressed\AutoIt-Interpreter_0.9.2146.8608>autoit3 test.au3
.--------------------------------------------------.
|                     WARNING!                     |
|                                                  |
| Your terminal does NOT support VT100/ANSI escape |
| sequences. This WILL lead to a severely degraded |
|      user experience. You have been warned.      |
'--------------------------------------------------'

(Press any key to continue)
←[38;2;255;255;255m

←[38;2;250;128;114mERROR in "C:\Users\Unknown\Downloads\Compressed\AutoIt-Interpreter_0.9.2146.8608\
test.au3", line 1:
    The script or include file 'ButtonConstants.au3' could not be resolved. Verify that the path is
correct and the file in question is accessible. If you have an include resolver plugin, verify wheth
er the .dll can be correctly loaded from the plugin-folder.
If you believe that this is a bug, please report it to ←[4mhttps://github.com/Unknown6656/AutoIt-Int
erpreter/issues/new?template=bug_report.md←[24m.
[System.InvalidOperationException] "A task may only be disposed if it is in a completion state (RanT
oCompletion, Faulted or Canceled).":
   at System.Threading.Tasks.Task.Dispose(Boolean disposing)
   at System.Threading.Tasks.Task.Dispose()
   at Unknown6656.AutoIt3.Runtime.ExternalServices.ExternalServiceProvider`1.Run[T](String[] argv)

←[38;2;255;255;255m_________________________________________________________________________________
__________________
←[38;2;0;255;127mExit code: 0     Time: 00:00:10.0303699 (Total), 00:00:00.1609460 (Script)
←[38;2;255;255;255m←[38;2;255;255;255m[System.ComponentModel.Win32Exception] (80004005h) The operati
on completed successfully.:
   at Unknown6656.Controls.Console.ConsoleExtensions.set_STDINConsoleMode(ConsoleMode value)
   at Unknown6656.Controls.Console.ConsoleExtensions.RestoreConsoleState(ConsoleState state)
   at Unknown6656.AutoIt3.CLI.MainProgram.Start(String[] argv)
   at Program.<Main>$(String[] args)


C:\Users\Unknown\Downloads\Compressed\AutoIt-Interpreter_0.9.2146.8608>
C:\Users\Unknown\Downloads\Compressed\AutoIt-Interpreter_0.9.2146.8608>

Here's the output on Windows 10 with previous release:

C:\Users\Admin\Desktop\Auoit\AutoIt_Interpreter_0.8.1803.7550>autoit3 test.au3
WARNING in "C:\Users\Admin\Desktop\Auoit\AutoIt_Interpreter_0.8.1803.7550\include\ButtonConstants.au3", line 1:
    The directive '#include-once' is unknown or cannot be parsed. If you have a plugin for that directive, verify whether the .dll can be correctly loaded from the plugin-folder.
WARNING in "C:\Users\Admin\Desktop\Auoit\AutoIt_Interpreter_0.8.1803.7550\include\GUIConstantsEx.au3", line 1:
    The directive '#include-once' is unknown or cannot be parsed. If you have a plugin for that directive, verify whether the .dll can be correctly loaded from the plugin-folder.
WARNING in "C:\Users\Admin\Desktop\Auoit\AutoIt_Interpreter_0.8.1803.7550\include\WindowsConstants.au3", line 1:
    The directive '#include-once' is unknown or cannot be parsed. If you have a plugin for that directive, verify whether the .dll can be correctly loaded from the plugin-folder.

ERROR in "C:\Users\Admin\Desktop\Auoit\AutoIt_Interpreter_0.8.1803.7550\test.au3", line 5:
    The line or expression '$Form1 = GUICreate("Form1", 615, 438, 192, 124)' could not be processed due to the following error: Cannot access a disposed object..

If you believe that this is a bug, please report it to https://github.com/Unknown6656/AutoIt-Interpreter/issues/new?template=bug_report.md.
___________________________________________________________________________________________________
Exit code: -1     Time: 00:00:11.5634129 (Total), 00:00:01.2334809 (Script)

And finally here's the output on Windows 10 with latest release:

C:\Users\Admin\Desktop\Auoit\AutoIt-Interpreter_0.9.2146.8608>autoit3 test.au3
.--------------------------------------------------.
|                     WARNING!                     |
|                                                  |
| Your terminal does NOT support VT100/ANSI escape |
| sequences. This WILL lead to a severely degraded |
|      user experience. You have been warned.      |
'--------------------------------------------------'

(Press any key to continue)

ERROR in "C:\Users\Admin\Desktop\Auoit\AutoIt-Interpreter_0.9.2146.8608\test.au3", line 1:
    The script or include file 'ButtonConstants.au3' could not be resolved. Verify that the path is correct and the file in question is accessible. If you have an include resolver plugin, verify whether the .dll can be correctly loaded from the plugin-folder.
If you believe that this is a bug, please report it to https://github.com/Unknown6656/AutoIt-Interpreter/issues/new?template=bug_report.md.
[System.InvalidOperationException] "A task may only be disposed if it is in a completion state (RanToCompletion, Faulted or Canceled).":
   at System.Threading.Tasks.Task.Dispose(Boolean disposing)
   at System.Threading.Tasks.Task.Dispose()
   at Unknown6656.AutoIt3.Runtime.ExternalServices.ExternalServiceProvider`1.Run[T](String[] argv)

___________________________________________________________________________________________________
Exit code: 0     Time: 00:00:10.7544951 (Total), 00:00:00.1618247 (Script)

C:\Users\Admin\Desktop\Auoit\AutoIt-Interpreter_0.9.2146.8608>

Please note that both Windows I'm using are x64 based also the Windows 10 I'm using are a highly customized one so I'm not sure If this could cause any issues.

Thank you,
I'll be waiting for your updates.

@mast3rz3ro Thank you very much for your detailed report. I'll try and reproduce the error, however, it may take some time to fix it, as I'm not sure of its origin....

I'll try and o my best.

You are welcome, and thanks you for taking the maintaining this project.

Here's an example GUI that I'm trying to run it.
test_gui.au3:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 201, 101, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 8, 64, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 112, 64, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

	EndSwitch
WEnd

I'm hoping to see a simple GUI that are able to run on these three platforms (MacOS/Linux/Windows).

Sorry for repsonding this late. I was travelling a lot internationally due to work and wasn't able to look a lot into the matter.
I think I know where the issue might be coming from, but I'll have to do more experiments.

Please do note that (for now) no GUI method has been implemented yet, as I wasn't able to get consistent behavior across all three platforms. However, this is definitely high on my priority list.
(see #19 and #27)

Note that I resolved the following error in commit 70560e4:

ERROR in "C:\Users\Admin\Desktop\Auoit\AutoIt-Interpreter_0.9.2146.8608\test.au3", line 1:
The script or include file 'ButtonConstants.au3' could not be resolved.

That commit, however, does not resolve the issue of GUI-methods not yet being implemented.

closing this issue as the two underlying bugs have been resolved:

The remaining issue is covered by the following issues/PRs: