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

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

Closed
mast3rz3ro opened this issue Feb 27, 2024 · 9 comments
Assignees
Labels
area: CLI command line interface bug Something isn't working
Projects

Comments

@mast3rz3ro
Copy link

mast3rz3ro commented Feb 27, 2024

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

@Unknown6656 Unknown6656 self-assigned this Mar 3, 2024
@Unknown6656 Unknown6656 added the bug Something isn't working label Mar 3, 2024
@Unknown6656
Copy link
Owner

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.

@Unknown6656
Copy link
Owner

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.

Unknown6656 added a commit to Unknown6656/Unknown6656.Core that referenced this issue Mar 3, 2024
@Unknown6656
Copy link
Owner

Unknown6656 commented Mar 4, 2024

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.

@mast3rz3ro
Copy link
Author

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.

@Unknown6656 Unknown6656 reopened this Mar 11, 2024
@Unknown6656
Copy link
Owner

@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.

@mast3rz3ro
Copy link
Author

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).

@Unknown6656
Copy link
Owner

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)

@Unknown6656 Unknown6656 added the area: CLI command line interface label Mar 27, 2024
@Unknown6656 Unknown6656 added this to ToDo - Backlog in FEATURES via automation Mar 27, 2024
@Unknown6656 Unknown6656 moved this from ToDo - Backlog to ToDo - Soon in FEATURES Mar 29, 2024
@Unknown6656 Unknown6656 added the urgent ! THIS IS URGENT ! label Mar 29, 2024
@Unknown6656
Copy link
Owner

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.

@Unknown6656 Unknown6656 removed the urgent ! THIS IS URGENT ! label Mar 30, 2024
@Unknown6656
Copy link
Owner

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

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

FEATURES automation moved this from ToDo - Soon to Done Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: CLI command line interface bug Something isn't working
Projects
Status: Done
FEATURES
  
Done
Development

No branches or pull requests

2 participants