Jump to content
Sign in to follow this  
edthedestroyer

CUI Interface for use with CMD

Recommended Posts

edthedestroyer

I am trying to create a script that allows me to run and use it with CMD as the interface.

For example:

C:\>myscript

Enter PIN

: ****

Success

C:\>

This is the code I have so far...

#AutoIt3Wrapper_Change2CUI=y
ConsoleWrite("Enter PIN" & @CRLF & ":")

Local $input

While 1
$input &= ConsoleRead()
if StringInStr($input,@CRLF) <> 0 then ExitLoop
Wend

if $input = "1111" & @CRLF Then
ConsoleWrite("Success")
Else
ConsoleWrite("Failure")
ConsoleWrite($input)

EndIf

The problem is that after it writes Enter PIN: it will not accept input and gets stuck. After I close the script, all the input I typed shows up in cmd.

C:\>myscript

Enter PIN

:

;;;; get's stuck,closes script

C:\>1111

I want be able to run this script without opening another cmd window but I haven't been able to find relevant examples for creating a "console" application used through cmd.

Can anyone help me out?

Share this post


Link to post
Share on other sites
dany

unfortunately reading the console like that doesn't work.

Do a search on 'Console UDF', there are a few around and they might have solved this problem.


[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites
edthedestroyer

Yea that's what I'm looking at now. Not the end of the world I guess. Thanks.

Share this post


Link to post
Share on other sites
Mat

Since it hasn't been posted on the forum yet, you won't find mine: https://github.com/MattDiesel/au3-console

Example from _Console_Alloc: https://github.com/MattDiesel/au3-console/blob/master/Examples/_Console_Alloc.au3

This UDF is work in progress, but is pretty complete. Probably not the easiest to use as it is more of a direct wrapper over the windows api.

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  

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      Hi dear
      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
    • Simpel
      By Simpel
      Hi.
      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?
      Regards, Conrad
    • TheAutomator
      By TheAutomator
      A fullscreen console with custom commands!

      Introduction:
      Hi everyone!
      This funny project started as a question in the help section:
      https://www.autoitscript.com/forum/topic/174404-edit-detect-key-before-updating-content/
      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?  
      Thanks to:
      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
       
      Regards
      TheAutomator
    • Phil Viton
      By Phil Viton
      autoit3 under Win7 (x64)
      Here's a very simple script that reports the number
      of parameters it's called with:
      cmd_line_nparm.au3
      $nparm = $CmdLine[0] ; number of parameters
      MsgBox(0,"","nparm: " & $nparm)
      If I start a dos session and cd to the folder where
      this file is stored and run
      cmd_line_nparm.au3 abc def
      the response is nparm: 0 ; but if I provide the full
      path to the autoit exe file    I get the correct answer (2).
      Can anyone tell me what I need to do to avoid having to
      provide the full path? (Hopefully without needing to
      re-install autoit3)
      Thanks!
    • hcI
      By hcI
      Hello I would like to know if there is a way to return a sentence in cmd when I launch from it (because I add arguments).
      For example, diskpart.exe which help to manage the key and hdd connected, when you launch it with the parameter "/f" the app return a sentence saying that it don't recognize the parameter "/f" and it return the sentence in the cmd where i started the application, not a new one.
      That's what I want to do but I couldn't find anything that would solve my problem on internet and on AutoIt like ConsoleWrite / ConsoleWriteError (don't work).
       
      Thanks
×