microbious Posted October 11, 2009 Share Posted October 11, 2009 can autoit make console applications such as basic xcopy or instsrv like those that if u just double click in them they would do nothign because they only accept command's given my CMD or batch files or such. Can u guys give me one example of show me link where those referenced to ? THanks in advance Link to comment Share on other sites More sharing options...
TurionAltec Posted October 11, 2009 Share Posted October 11, 2009 Search "Command Line Parameters" to see how to use $cmdline to read values passed from the commandline. See Consolewrite() to output to Stdout And add: #AutoIt3Wrapper_Change2CUI=y To the top of your script so that when compiled it will be read as a console application and dump Stdout to the console window that started it. Link to comment Share on other sites More sharing options...
microbious Posted October 11, 2009 Author Share Posted October 11, 2009 awesome thanks ill try it ASAP (as soon as i think of my first console app ) Link to comment Share on other sites More sharing options...
picaxe Posted October 11, 2009 Share Posted October 11, 2009 My version of a word count command line filter. Compile, run from a cmd window, see msgbox for instructions.#AutoIt3Wrapper_Change2CUI=y #include <Array.au3> $vCnt = 1 Do $aInp = StringRegExp(StringReplace(ConsoleRead(), Chr(0), ""), "(?i)(\b[a-z'?-?_]{2,}\b|\ba\b|\bi\b)", 3) $vCnt += UBound($aInp) -1 ConsoleWrite(_ArrayToString($aInp, @CRLF)) Until Not ConsoleRead(0, 1) Select Case Not IsArray($aInp) MsgBox(262144, @ScriptName, _ "No input file provided or no words found" & @LF & @LF _ & "List words to command line: " & @TAB & @ScriptName & " < somefile.ext" & @TAB & @LF _ & "Redirect to a file: " & @TAB & @TAB & @ScriptName & " < somefile.ext > output.txt" & @TAB & @LF _ & "List words with count: " & @TAB & @ScriptName & " < somefile.ext w" & @TAB) Case $cmdline[0] > 0 If $cmdline[1] = "w" Then ConsoleWrite(@CRLF & @CRLF & "Word count = " & $vCnt) MsgBox(262144, @ScriptName, "Word count = " & $vCnt) EndIf EndSelect Link to comment Share on other sites More sharing options...
Developers Jos Posted October 11, 2009 Developers Share Posted October 11, 2009 (edited) can autoit make console applications such as basic xcopy or instsrv like those that if u just double click in them they would do nothign because they only accept command's given my CMD or batch files or such.Can u guys give me one example of show me link where those referenced to ?THanks in advanceSince when will console applications not work when you double click them? The only reason some "seem" to do nothing is because they require command line parameters and will stop executing when they are omitted.JosPS: merged double posting Edited October 11, 2009 by Jos SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
microbious Posted October 11, 2009 Author Share Posted October 11, 2009 Since when will console applications not work when you double click them? most of them dont so i thought its kinda common thing for console apps so i wanted to get that covered. Link to comment Share on other sites More sharing options...
Developers Jos Posted October 11, 2009 Developers Share Posted October 11, 2009 most of them dont so i thought its kinda common thing for console apps so i wanted to get that covered.Seems like you are still convinced that console applications not run when you double click them?I do not know of any that doesn't run but plenty that will open a CMD window that very briefly displays an error and than close.Jos SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
monoceres Posted October 11, 2009 Share Posted October 11, 2009 Not running a console application from the command line makes absolutely no sense. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
microbious Posted October 11, 2009 Author Share Posted October 11, 2009 (edited) Seems like you are still convinced that console applications not run when you double click them?I do not know of any that doesn't run but plenty that will open a CMD window that very briefly displays an error and than close.Josno my point was that most of console apps i used if double clicked they just blink once and nothing happens until i give them a command with batch file or so, i kinda thought that was something i might have to look into (or not) . just in case i wanted to know that there is such option.For example console app called nircmdc.exe (NirCmd v2.20 Copyright © 2003 - 2008 Nir Sofer ) does nothing unless it receives a command like "help" so it would display list of supported commands (am sure u know what am talking about).In any case thanks for answers Edited October 11, 2009 by almostnotstupid Link to comment Share on other sites More sharing options...
TurionAltec Posted October 11, 2009 Share Posted October 11, 2009 Not running a console application from the command line makes absolutely no sense.If it's an interactive one, or one which doesn't immediately terminate and it could. Link to comment Share on other sites More sharing options...
Inverted Posted October 12, 2009 Share Posted October 12, 2009 @ almostnotstupid A console application can do pretty much whatever a normal GUI application can do. In fact a GUI application can also spawn a console. Most console applications are based on commandline parameter handling, so if you just run them they just show some info and exit. Now that I think about it, a console application can create a GUI, too (maybe not in AutoIt, but in a compiled language it should ? too tired to try it right now) Link to comment Share on other sites More sharing options...
TurionAltec Posted October 12, 2009 Share Posted October 12, 2009 Now that I think about it, a console application can create a GUI, too (maybe not in AutoIt, but in a compiled language it should ? too tired to try it right now) Sure you can! expandcollapse popup#AutoIt3Wrapper_Change2CUI=y #include <GUIConstants.au3> If $cmdline[0]=0 Then $title="Default Title" Else $title=$cmdline[1] EndIf $Form1 = GUICreate($title, 633, 454, 193, 125) $Button1 = GUICtrlCreateButton("Button1", 24, 224, 121, 49, 0) $Button2 = GUICtrlCreateButton("Button2", 152, 224, 121, 57, 0) $Button3 = GUICtrlCreateButton("Button3", 288, 224, 105, 33, 0) $Slider1 = GUICtrlCreateSlider(48, 32, 561, 33) GUISetState(@SW_SHOW) Opt("GUIOnEventMode",1) GUICtrlSetOnEvent ($Button1,"Button1") GUICtrlSetOnEvent ($Button2,"Button2") GUICtrlSetOnEvent ($Button3,"Button3") GUICtrlSetOnEvent ($Slider1,"Slider1") GUISetOnEvent($GUI_EVENT_CLOSE,"Close") While 1 sleep(1000) WEnd Func Button1() ConsoleWrite("Button1"&@CRLF) EndFunc Func Button2() ConsoleWrite("Button2"&@CRLF) EndFunc Func Button3() ConsoleWrite("Button3"&@CRLF) EndFunc Func slider1() ConsoleWrite("Slider: "&GUICtrlRead($Slider1)&@CRLF) EndFunc Func Close() Exit EndFunc The first commandline parameter passed will be the GUI title. The script will output to the console whenever a button is pressed, or the slider moved. Link to comment Share on other sites More sharing options...
Mat Posted October 12, 2009 Share Posted October 12, 2009 You are looking to try and make a traditional cin and cout console in autoit then? It is possible, but harder than in cpp etc. there is no "cin" function in autoit, however, if you search you'll find an example of how to use 'FileOpen ("con")' to read what has been written to the console. Thats the hardest bit of it. If you want more info on FileOpen ("con") then search google, I believe its an old VB trick. Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
trancexx Posted October 12, 2009 Share Posted October 12, 2009 (edited) You are looking to try and make a traditional cin and cout console in autoit then? It is possible, but harder than in cpp etc.there is no "cin" function in autoit, however, if you search you'll find an example of how to use 'FileOpen ("con")' to read what has been written to the console. Thats the hardest bit of it. If you want more info on FileOpen ("con") then search google, I believe its an old VB trick.MatThere are no tricks involved in that. It's a well documented parameter passed to CreateFile function (that is used by AutoIt for FileOpen() function) when you want to open console.CreateFile <- link, click and read. Edited October 12, 2009 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Mat Posted October 12, 2009 Share Posted October 12, 2009 Never knew that, though I thought it was documented somewhere. It's very useful to use, but in autoit its both shorter and easier to use inputboxs + other dialogs, so I have never really looked into it. AutoIt Project Listing Link to comment Share on other sites More sharing options...
TurionAltec Posted October 12, 2009 Share Posted October 12, 2009 It's a trick as compared to say ConsoleRead which you'd expect to work, but doesn't. Here's a thread about using the FileOpen("con") method in Autoit: http://www.autoitscript.com/forum/index.php?showtopic=79275&st=0&p=571658&#entry571658 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now