DJKMan Posted August 21, 2010 Share Posted August 21, 2010 I'm not sure if someone posted an example like mine already but feel free to let me know. I did search around and only found people using hacks to make it work. This is very simple and can be incorporated into any projects without an include. This is AutoIt with batch. As simple as I can get. Compile this into a Example.exe: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=Example.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;Consolewrite for GUI-Based Apps Example by DJKMan Local $sleep=3000 ConsoleWrite("echo Hello World!" & @LF) ;Echo first line. While 1 $randomnumber = Random(1, 5, 1) ConsoleWrite("echo Random Number: " & $randomnumber &@LF);Echo random number to console ConsoleWrite("echo ---Sleeping: "&$sleep&"---"&@LF) Sleep($sleep) WEnd Then save this as DevConsole.cmd and place it in the same directory as Example.exe: @echo off title Example System - Developer Console Prompt $G color 03 "Example.exe"|cmd.exe /Q Run DevConsole.cmd and that's all there is to it. Hope this helps you on your projects. Link to comment Share on other sites More sharing options...
wraithdu Posted August 21, 2010 Share Posted August 21, 2010 (edited) EDIT - better solution.Neat idea. Here's without the batch file. It gets a little funny if you're dealing with command line params, but you get the idea.#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=Example.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;Consolewrite for GUI-Based Apps Example by DJKMan Global $DEBUG = True If $DEBUG Then _ConsoleDebugRun() Func _ConsoleDebugRun() DllCall("kernel32.dll", "handle", "CreateMutexW", "ptr", 0, "bool", 1, "wstr", "AutoItDeveloperConsoleMutex") If @error Then Return SetError(1) Local $lastErr = DllCall("kernel32.dll", "dword", "GetLastError") If @error Then Return SetError(2) If $lastErr[0] <> 183 Then ; ERROR_ALREADY_EXISTS Run(@ComSpec & ' /c @echo off && title Example System - Developer Console && prompt $G && color 03 && "' & _ @ScriptFullPath & '" ' & $CmdLineRaw & ' | ' & @ComSpec & ' /Q') Sleep(3000) ; give time to launch child Exit EndIf EndFunc Local $sleep=3000 ConsoleWrite("echo Hello World!" & @LF) ;Echo first line. While 1 $randomnumber = Random(1, 5, 1) ConsoleWrite("echo Random Number: " & $randomnumber &@LF);Echo random number to console ConsoleWrite("echo ---Sleeping: "&$sleep&"---"&@LF) Sleep($sleep) WEnd Edited August 22, 2010 by wraithdu MuffettsMan 1 Link to comment Share on other sites More sharing options...
wraithdu Posted August 22, 2010 Share Posted August 22, 2010 I edited with a better solution using a mutex. No confusion with command line params this way. Link to comment Share on other sites More sharing options...
DJKMan Posted August 30, 2010 Author Share Posted August 30, 2010 Thank you! This is indeed a much better solution. 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