Sign in to follow this  
Followers 0
wraithdu

Odd Console (CUI) Behavior in Win 8

9 posts in this topic

#1 ·  Posted (edited)

I'm not sure whether to classify this as a bug or not yet, but this simple script no longer seems to work in Win 8 when compiled as CUI. It should pause and wait for input as it does on Win 7, but it just exits immediately. You can still see that the 'pause' command prints its text however. Any ideas, or go with bug and I'll open a ticket?

#NoTrayIcon
#AutoIt3Wrapper_Change2CUI=y

RunWait(@ComSpec & " /c pause", "", Default, 0x10)

It's strange that something as basic as this would change from Win 7 to 8.

Edited by wraithdu

Share this post


Link to post
Share on other sites



What happens if you were to run that command line yourself in the prompt?

Share this post


Link to post
Share on other sites

Normal behavior, just like a .bat file.

Share this post


Link to post
Share on other sites

Ok. Couple questions on the code.

Why are you passing the default keyword for window state? That results in a hidden window which seems like it would cause issues when you want it to share the CUI. I don't imagine that's the problem though.

Second, what's this 0x10 flag? I don't see that documented anywhere.

Share this post


Link to post
Share on other sites

From looking at the help file for RunWait, using 0x10000 in the last parameter spawns a new console window, but you're hiding it by using the Default keyword.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

The show state is irrelevant. The 0x10 flag means to use the existing console window (as opposed to creating a new window, see the Run() command), which is visible by default since it is compiled as a CUI. So the command runs in the context of the existing console window. Try it on Win7, it works as it should. The diff on Win8 is that it doesn't pause and wait for input, it just blows right through and exits.

You really think I'd post non-working code without testing it... gimme a little credit here ;)

Edited by wraithdu

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

No offence intended, I just confused 0x10 and 0x10000 in my head.

Perhaps when that value ($STDIO_INHERIT_PARENT = 0x10) was added to the Runxxx commands something was done incorrectly and it took Windows 8 to discover it.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I think you're probably right about the flags param. There was some other weirdness I remember as well when trying to read console input using Mat's console UDF (ReadConsole API function). Here's the addition and note I made:

; ugly fix for input handle when script is compiled as CUI, otherwise reading input fails
_WinAPI_CreateFile("CONIN$", 2, 6, 6)

So I definitely think that console mode and IO streams needs to be revisited.

Edited by wraithdu

Share this post


Link to post
Share on other sites

I never said it was invalid, only that I didn't see it documented anywhere.

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  
Followers 0