VAN0 Posted 2 hours ago Share Posted 2 hours ago I'm trying make my compiled script as CUI to be shown on screen when ran (task scheduler or from explorer), but not taking focus. My initial idea was to relaunch itself with Run() and use @SW_SHOWNOACTIVATE flag, but it didn't work, it still showed focused console window. Any ideas how it can be achieved? Thank you. Link to comment Share on other sites More sharing options...
ioa747 Posted 1 hour ago Share Posted 1 hour ago (edited) before starting the CUI , check which window has the focus $hWndActive = WinGetHandle("[ACTIVE]"), and after opening your CUI , return the focus to where it was WinActivate($hWndActive ) Edited 1 hour ago by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
VAN0 Posted 1 hour ago Author Share Posted 1 hour ago CUI is being launched either by the task scheduler (aka system) or by explorer (aka user) Link to comment Share on other sites More sharing options...
ioa747 Posted 59 minutes ago Share Posted 59 minutes ago put Send("!{TAB}") on start I know that I know nothing Link to comment Share on other sites More sharing options...
Nine Posted 59 minutes ago Share Posted 59 minutes ago Show a runable script where we can actually see the issue. “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
VAN0 Posted 47 minutes ago Author Share Posted 47 minutes ago (edited) @ioa747 Thanks, it works, but very unreliable. Sometimes it switches to totally different application.. 14 minutes ago, Nine said: Show a runable script where we can actually see the issue. Sure #AutoIt3Wrapper_Change2CUI=y sleep(60000) Compile it and run from explorer. The opened console window will be in focus. The expected result: explorer window remains in focus, while console window remains visible on screen Note, as I mentioned before, this may be run by task scheduler, so any application can be in focus when it's launched. Edited 43 minutes ago by VAN0 Link to comment Share on other sites More sharing options...
VAN0 Posted 38 minutes ago Author Share Posted 38 minutes ago Here is a somewhat working attempt relaunch itself as non-active window: #AutoIt3Wrapper_Change2CUI=y If $CmdLine[0] = 0 Then Run(@ScriptFullPath & ' 1', @WorkingDir, @SW_SHOWNOACTIVATE, 0x10000) Exit EndIf ConsoleWrite("Should start NOT focused") Sleep(60000) Unfortunately, it still steals focus for a moment Link to comment Share on other sites More sharing options...
ioa747 Posted 15 minutes ago Share Posted 15 minutes ago (edited) make a separate launcher script so it's not a CUI ;~ launcher.exe Local $hWndActive $hWndActive = WinGetHandle("[ACTIVE]") ShellExecute(@ScriptDir & "\MyCUI.exe") WinActivate($hWndActive) Edited 1 minute ago by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
VAN0 Posted 9 minutes ago Author Share Posted 9 minutes ago That would do it, but I'm trying find a way to do it within same script if possible. For example, I probably could do something if I could figure out how to get hwnd of the console window. 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