Lobo65 Posted April 7 Posted April 7 Hi folks, I have a funny thing here, which I do not understand: running this code in a "standalone" script works perfectly fine AND without any flickering of a shell on the screen - just as expected (because of the @SW_Hide): $PID = Run(@ComSpec & " /c " & "wmic os get lastbootuptime","",@SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($PID) Now, if I put this code into an au3 file (as an include) and call that function from my script, it works except now there is a flickering of a shell. Any ideas why this now happens and what I can do to prevent the flickering shell ? Thanks guys :)
Developers Jos Posted April 7 Developers Posted April 7 Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team 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.
Developers Jos Posted April 7 Developers Posted April 7 How are you running the code in both occasions? 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.
Lobo65 Posted April 7 Author Posted April 7 Not sure if I get what you mean. I have a script, which I compile with the menioned code. I then log the output to a stream, which I later use to write it to a log file. Works fine. I now use the same code and placed it in an external file, which I include using the #external.au3 file. The answer is written just the same only the called shell now flickers. I am running AutoIt 3.3.16.1 on a Windows 11 24H2 The script is compiled to 64bit exe (in both cases). Apart: did you move this thread? Shall switch to the new location then?
Developers Jos Posted April 7 Developers Posted April 7 There is no difference using an #include or putting it in the master script! So, I need to understand how you run both instances. So the first one you compile and then run the generated exe ...right? How are you running the instance with the #include? Also compile and then execute the EXE or do you run it from SciTE with F5 or something? 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.
Lobo65 Posted April 7 Author Posted April 7 Ah...now I got you. Yes, I compile the script with the code internally and run it by double clicking the exe in explorer. Then, I move the code to the external include file, add the #include line with the proper name of the include, compile it and run it. It delivers the same output in the log, but it flickers the shell.
Nine Posted April 7 Posted April 7 (edited) Instead of relying on external program, you could use WMI object and be better served : #include <Constants.au3> MsgBox($MB_OK, "Last boot", GetLastBoot()) Func GetLastBoot() Local $oWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") Local $oItems = $oWMIService.ExecQuery('SELECT * FROM Win32_OperatingSystem') If Not IsObj($oItems) Then Exit MsgBox($MB_OK, "", "Not an object") If Not $oItems.count Then Exit MsgBox($MB_OK, "", "Not found") Return $oItems.ItemIndex(0).LastBootUpTime EndFunc Edited April 7 by Nine concision “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Developers Jos Posted April 7 Developers Posted April 7 1 hour ago, Lobo65 said: Then, I move the code to the external include file, add the #include line with the proper name of the include, compile it and run it. There should be no difference as the external script gets combined with the master at compilation time ending up as the same script as your first one. So there must be another difference somewhere. 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.
Lobo65 Posted April 7 Author Posted April 7 Hey MVPs, simply because I didn't knew how. I played around with the WMI a bit according some example I found here in the forum, but obviously, I didn't do it properly. Your example though does exactly, what I wanted! Thank you! Anyways... the flickering must be made by some other settings, because it still occurs... I will investigate that and report here or ask you guys for supporting me, if I don't find the reason. @Jos : sorry for leading you on the wrong track argumentum 1
Nine Posted April 7 Posted April 7 5 minutes ago, Lobo65 said: Hey MVPs, You can call me Nine 6 minutes ago, Lobo65 said: ask you guys for supporting me, if I don't find the reason Then please provide full runnable script, not just the 2 liners of the OP. Unless we can replicate your issue, it is very hard to find the real source of the problem. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Lobo65 Posted April 8 Author Posted April 8 Sorry Nine sure. Btw. I was talking about a cui program - no gui at all. Sorry for acting like a bloody newby - what I am .... Cheers
Solution Lobo65 Posted April 9 Author Solution Posted April 9 Ok now, looks like I found what's going on. Just as Jos said, it has nothing to do whether or not a function is ported to an include or not. I found, I had made (accidently) a change in compiler settings: ;#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UseX64=y ;#AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_Language=1031 #AutoIt3Wrapper_Res_Fileversion=0.0.0.0 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/sf /sv #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** That bold setting has made it's way into this somehow ...and if you remark it, no more flickering a shell appears. To get this story round: I am creating some cmdline tools, that need no gui (except some MsgBoxes every now and then) So sorry for crying wolf ... (what a word game ) Cheers Lobo
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