rmassip Posted February 2, 2021 Share Posted February 2, 2021 Hi all, I would like to know if it is possible to manage a program in the background, that is, the same actions (click, send, ...) that you would do with AutoIt, but without the user seeing it. I have seen that with the "Run" function you can indicate the flag @SW_HIDE so that the process is not shown. I have made a POC with the 'notepad' example. Without adding the @SW_HIDE flag (in second line) it works correctly: 1) open notepad 2) write text 3) save it to a file But adding the @SW_HIDE, it waits for the notepad screen (obviously), in the line 5, WinWaitActive ("[CLASS: Notepad]"). Is there a way to interact with an open program in @SW_HIDE? thank you very much!! ; Run Notepad Local $iPID = Run("notepad.exe","" ), @SW_HIDE ) ; Wait for the Notepad to become active. The classname "Notepad" is monitored instead of the window title WinWaitActive("[CLASS:Notepad]") ; Now that the Notepad window is active type some special characters Send("Sending some special characters:{ENTER 2}") ; Do it the first way Send("First way: ") Send("{!}{^}{+}{#}") Send("{ENTER}") ; Do it the second way (RAW mode, notice the second parameter of Send is 1) Send("Second way: ") Send("!^+#", 1) Send("{ENTER}{ENTER}Finished") ; Finished! ; Save File Send("!A{DOWN}G{ENTER}") Sleep(500) Send("file.txt{ENTER}") Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 2, 2021 Moderators Share Posted February 2, 2021 Welcome to the forum. Take a look at the Control* Commands in the Help File. If you grab the element that you want to interact with on the GUI, and use ControlClick, ControlSend, etc. rather than just clicks and sends, it won't matter if the window is visible or not. rmassip 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
JockoDundee Posted February 2, 2021 Share Posted February 2, 2021 1 hour ago, rmassip said: Is there a way to interact with an open program in @SW_HIDE? Not that I’m aware of. What I do is this: rmassip 1 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
rmassip Posted February 2, 2021 Author Share Posted February 2, 2021 Thank you very much for the answers! 😄 I have tried @JLogan3o13 's solution, and it works roughly. I have managed to send invisible notepad, the problem is the applications that do not have clear controls hehe I leave the code here in case it works for someone: expandcollapse popup#include <AutoItConstants.au3> ; Run Notepad ;Local $iPID = Run("notepad.exe","") Local $iPID = Run("notepad.exe","", @SW_HIDE ) ; Wait for the Notepad to become active. The classname "Notepad" is monitored instead of the window title ;WinWaitActive("[CLASS:Notepad]") Local $hWnd = WinWait("[CLASS:Notepad]") ConsoleWrite("*** Handler: " & $hWnd) ; Now that the Notepad window is active type some special characters ControlSend($hWnd, "", "Edit1", "Sending some special characters:{ENTER 2}") ; Do it the first way ControlSend($hWnd, "", "Edit1", "First way: ") ControlSend($hWnd, "", "Edit1", "{!}{^}{+}{#}") ControlSend($hWnd, "", "Edit1", "{ENTER}") ; Do it the second way (RAW mode, notice the second parameter of Send is 1) ControlSend($hWnd, "", "Edit1", "Second way: ") ControlSend($hWnd, "", "Edit1", "!^+#", 1) ControlSend($hWnd, "", "Edit1", "{ENTER}{ENTER}Finished") ; Finished! ; Save File ControlSend($hWnd, "", "Edit1", "!A{DOWN}G{DOWN}{ENTER}") ;Menú navigate (spanish letters, english maybe F-S) Sleep(2000) Local $hWndSave = WinWait("[CLASS:#32770]") ;Save As Diaglog class Win10 Sleep(2000) ControlSend($hWndSave, "", "Edit1","file_9.txt{ENTER}") ;Close WinClose("[CLASS:Notepad]") Thanks also to @JockoDundee for this idea, it is very original! I have to do something similar, because when I load data, a "PD" (pending) appears in the application within a yellow box. Currently I am solving it with a PixelSearch in a bucle, but if I make the windows invisible, I am afraid that it will not work for me, so your idea even being a "workaround" may work for me hehe Local $ aCoord = PixelSearch (0, 300, 20, 320, 0xFFFF00, "", "", $ hWnd) ;PD Yellow Thanks for the help! I'm still rookie but I already have my first scripts, AutoIt looks very good 🤓 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