aeun01 Posted June 14, 2023 Share Posted June 14, 2023 (edited) Hello! Let me ask you a strange question. For example, can I text or interact with notepad while it is minimized? Thank you! Edited June 14, 2023 by aeun01 Link to comment Share on other sites More sharing options...
ioa747 Posted June 14, 2023 Share Posted June 14, 2023 (edited) check it Example() Func Example() ; Run Notepad Run("notepad.exe") ; Wait 10 seconds for the Notepad window to appear. Local $hWnd = WinWait("[CLASS:Notepad]", "", 10) ; Set the state of the Notepad window to minimize WinSetState($hWnd, "", @SW_MINIMIZE) ; Send a string of text to the edit control of Notepad. For $x = 1 to 50 ControlSend($hWnd, "", "Edit1", "This is some text in line:" & $x & @LF) Next ; Set the state of the Notepad window to restore WinSetState($hWnd, "", @SW_RESTORE) EndFunc ;==>Example So generally don't use Send() MouseClick() WinActivate() WinWaitActive() WinActive() etc. Instead use ControlSend() ControlSetText() ControlClick() WinWait() WinExists() WinMenuSelectItem() etc. Doing so allows you to interact with an application regardless of whether it is active or not. take a look at https://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F Edited June 14, 2023 by ioa747 aeun01 and SkysLastChance 1 1 I know that I know nothing Link to comment Share on other sites More sharing options...
aeun01 Posted June 14, 2023 Author Share Posted June 14, 2023 3 hours ago, ioa747 said: check it Example() Func Example() ; Run Notepad Run("notepad.exe") ; Wait 10 seconds for the Notepad window to appear. Local $hWnd = WinWait("[CLASS:Notepad]", "", 10) ; Set the state of the Notepad window to minimize WinSetState($hWnd, "", @SW_MINIMIZE) ; Send a string of text to the edit control of Notepad. For $x = 1 to 50 ControlSend($hWnd, "", "Edit1", "This is some text in line:" & $x & @LF) Next ; Set the state of the Notepad window to restore WinSetState($hWnd, "", @SW_RESTORE) EndFunc ;==>Example So generally don't use Send() MouseClick() WinActivate() WinWaitActive() WinActive() etc. Instead use ControlSend() ControlSetText() ControlClick() WinWait() WinExists() WinMenuSelectItem() etc. Doing so allows you to interact with an application regardless of whether it is active or not. take a look at https://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F Link to comment Share on other sites More sharing options...
aeun01 Posted June 14, 2023 Author Share Posted June 14, 2023 (edited) You save me! Thank you~ Is it possible to do the same in cmd? Edited June 14, 2023 by aeun01 Link to comment Share on other sites More sharing options...
ioa747 Posted June 14, 2023 Share Posted June 14, 2023 it doesn't even have to be visible To run DOS (console) commands, try Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE) ; don't forget " " before "/c" I know that I know nothing Link to comment Share on other sites More sharing options...
20Ice18 Posted June 15, 2023 Share Posted June 15, 2023 (edited) On 6/14/2023 at 11:55 AM, aeun01 said: Is it possible to do the same in cmd? Navigate to the directory where you want to create the text file. You can use the cd command to change directories. cd C:\Users\YourUsername\Documents Use the echo command followed by the text you want to write to the file, and then use the > symbol to redirect the output to a file. echo Hello, World! > output.txt Edited June 15, 2023 by 20Ice18 ❤️ 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