Jump to content

Recommended Posts

Posted (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 by aeun01
  • aeun01 changed the title to Can I work without activating program?
Posted (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 by ioa747

I know that I know nothing

Posted
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

 

Posted

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

Posted (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 by 20Ice18

❤️

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...