JockoDundee Posted May 24, 2021 Share Posted May 24, 2021 I understand the GUI/CUI issue. I’m just not understanding what compiling does to make ConsoleWrite work that the interpreter couldn’t do as well, based off the same or similar # directive the compiler uses. Like command line switch to the interpreter like /console. Or at the very worst, a separate executable. If the reason is, “that’s just the way it is”, I’m ok with it. Thoughts? Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Danp2 Posted May 25, 2021 Share Posted May 25, 2021 Have you tried launching the script outside of Scite? If so, how did that work? JockoDundee 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
jchd Posted May 25, 2021 Share Posted May 25, 2021 Maybe I don't understand your question, but doesn't the following code work in all use cases: GUI or CUI, compiled or not? CW("Hello world!" & @LF & "Μεγάλο πρόβλημα" & @LF & "Большая проблема" & @LF & "大问题" & @LF & "बड़ी समस्या" & @LF & "مشكلة كبيرة") Sleep(5000) Func CW($s = "") (@Compiled ? _CUI_ConsoleWrite : _ConsoleWrite)($s) EndFunc ;==>CW Func _CUI_ConsoleWrite(ByRef $s) Local Static $hDll = DllOpen("kernel32.dll") Local Static $hCon = __CUI_ConsoleInit($hDll) DllCall($hDll, "bool", "WriteConsoleW", "handle", $hCon, "wstr", $s & @LF, "dword", StringLen($s) + 1, "dword*", 0, "ptr", 0) Return EndFunc ;==>_CUI_ConsoleWrite ; internal use only Func __CUI_ConsoleInit(ByRef $hDll) DllCall($hDll, "bool", "AllocConsole") Return DllCall($hDll, "handle", "GetStdHandle", "int", -11)[0] EndFunc ;==>_CUI_ConsoleInit ; Unicode-aware ConsoleWrite Func _ConsoleWrite($s) ConsoleWrite(BinaryToString(StringToBinary($s & @LF, 4), 1)) EndFunc ;==>_ConsoleWrite Depending on the font settings for CUI and Scite console, some language may not display correctly. For instance Scite console displays everything correctly using Dejavu sans Mono. Ignore me if you're after something else. JockoDundee 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
TheXman Posted May 25, 2021 Share Posted May 25, 2021 (edited) When you compile your au3 scripts with aut2exe, if you have a CUI directive in your script, it adds and uses a CUI stub to execute the embedded script. So stdout goes directly to the console. AutoIt3.exe and AutoIt3_x64 are actually GUI apps. When you execute your au3 file using AutoIt3.exe or AutoIt3_x64.exe, you are actually executing it using GUI mode, regardless of the directive. Edited May 25, 2021 by TheXman Clarified that aut2exe adds a CUI stub if you have a CUI directive. Otherwise, it adds a GUI stub. JockoDundee 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
jchd Posted May 25, 2021 Share Posted May 25, 2021 Correct, but if you use my CW() function posted above, the output always gets sent to a console. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
TheXman Posted May 25, 2021 Share Posted May 25, 2021 (edited) How to write the output to the console was not the question. The question was why ... Edited May 25, 2021 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
jchd Posted May 25, 2021 Share Posted May 25, 2021 OK I didn't mention myself that AutoIt3 exes were GUI because it was granted in my view. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
JockoDundee Posted May 25, 2021 Author Share Posted May 25, 2021 1 minute ago, TheXman said: How to write the output to the console was not the question. The question was why ... This is true. Although, tbh, any reasonable way to write to the console from the interpreter is welcome information. But, yes, I was wondering why... And to your point that: 9 minutes ago, TheXman said: AutoIt3.exe and AutoIt3_x64 are actually GUI apps. When you execute your au3 file using AutoIt3.exe or AutoIt3_x64.exe, you are actually executing it using GUI mode, regardless of the directive. That's what I assumed, until I considered the case where you use a compiled exe to run a script in interpretive mode. In that case, even if the compiled script is compiled as a CUI, there is no console write output. Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Solution TheXman Posted May 25, 2021 Solution Share Posted May 25, 2021 23 minutes ago, JockoDundee said: That's what I assumed, until I considered the case where you use a compiled exe to run a script in interpretive mode. In that case, even if the compiled script is compiled as a CUI, there is no console write output. That's odd. I compiled a script that had the CUI=Y directive and the pragma that allows script execution. I then used that compiled script from a cmd console to execute an au3 file, using the /Autoit3ExecuteScript switch. The au3 file had several ConsoleWrites and all of them showed up in the cmd console. JockoDundee 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
JockoDundee Posted May 25, 2021 Author Share Posted May 25, 2021 34 minutes ago, TheXman said: That's odd. Really? That's definitely what I was hoping for before I started this discussion. Let me try again! Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
JockoDundee Posted May 25, 2021 Author Share Posted May 25, 2021 1 hour ago, TheXman said: I compiled a script that had the CUI=Y directive and the pragma that allows script execution. Yes, it works! Thanks everyone! Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
JockoDundee Posted May 25, 2021 Author Share Posted May 25, 2021 AutoIt3C.au3/.exe #pragma compile(Console, True) #pragma compile(AutoItExecuteAllowed, True) ConsoleWrite("Usage: AutoIt3C /AutoIt3ExecuteScript file [params...]" &@CRLF) Code hard, but don’t hard code... 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