Jump to content

Open window, input text, then minimize


llssff
 Share

Recommended Posts

My current script:

```

$notepadWindow = RunWait('notepad.exe')

ControlSend($notepadWindow, "Edit1", "", "abcde")

WinSetState($notepadWindow, "", @SW_MINIMIZE)

```

I can't seem to get these three lines to work. Its supposed to run a notepad window, then enter "abcde", followed by minimizing it. 

Currently it just opens and nothing happens.

What am I doing wrong here?

 

 

 

Link to comment
Share on other sites

You could use something like:

Global $g_hWnd
Global $g_iPID = Run("notepad.exe")
    ProcessWait($g_iPID, 5)
Global $g_hWnd = _GetProcessHandle("[CLASS:Notepad]")
    If @error Then Exit MsgBox(4096, "Error", $g_hWnd)
ControlSend($g_hWnd, "", "Edit1", "abcde")
WinSetState($g_hWnd, "", @SW_MINIMIZE)

Func _GetProcessHandle($_vWinTitle = "", $_sWinText = "")
    Local $aWinlist = WinList($_vWinTitle, $_sWinText)
        If @error Then Return
    For $i = 1 To $aWinlist[0][0]
        If WinGetProcess($aWinlist[$i][0], "") = $g_iPID Then Return SetError(0, 0, $aWinlist[$i][1])
    Next
    Return SetError(1, 0, "No handle found")
EndFunc

 

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...