Jump to content

Can you send stuff to minimized programs with Hwnd?


Zamp
 Share

Recommended Posts

Earlier I was playing around with the Hwnd thing, and found out you can use it to send stuff to notepad as long as it's the active window. This is what I used to make it do that:

Func _p()
    $p = Not $p
    While $p
        Run("notepad.exe")
        WinWait("Untitled - Notepad")
        Local $hWnd = WinGetHandle("Untitled - Notepad")
        Local $sHWND = String($hWnd)   ; Convert to a string
        ControlSend(HWnd($HWND), "", HWnd($HWND), "blah")
        Send("p")
    WEnd
EndFunc

So that made it open notepad and type blah in it. After I got it to do that I made it so it would minimize notepad then do controlsend, but it didn't work. So is there a way to make it send stuff to minimized programs? I know there is an easier way to do this then what I'm trying to do, but I just want to know if it's possible or not.

Link to comment
Share on other sites

Earlier I was playing around with the Hwnd thing, and found out you can use it to send stuff to notepad as long as it's the active window. This is what I used to make it do that:

Func _p()
    $p = Not $p
    While $p
        Run("notepad.exe")
        WinWait("Untitled - Notepad")
        Local $hWnd = WinGetHandle("Untitled - Notepad")
        Local $sHWND = String($hWnd)  ; Convert to a string
        ControlSend(HWnd($HWND), "", HWnd($HWND), "blah")
        Send("p")
    WEnd
EndFunc

So that made it open notepad and type blah in it. After I got it to do that I made it so it would minimize notepad then do controlsend, but it didn't work. So is there a way to make it send stuff to minimized programs? I know there is an easier way to do this then what I'm trying to do, but I just want to know if it's possible or not.

You can send to minimized applications. Try this

Run("notepad.exe")
        WinWait("Untitled - Notepad")
    ControlSend("Untitled - Notepad", "","Edit1", "first line sent while window visible" & @CR)
    WinSetState("Untitled - Notepad",'',@SW_MINIMIZE)
    sleep(2000);
        ControlSend("Untitled - Notepad", "","Edit1", "Second line sent while minimised" & @CR)
    sleep(500)
        WinSetState("Untitled - Notepad",'',@SW_MAXIMIZE)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I know you can do it like that, but is there a way to do it using Hwnd? I'm not really trying to make anything right now, I just want to know this just for the fun of it :whistle:

It's the same thing -

Run("notepad.exe")
    WinWait("Untitled - Notepad")
    $hWnd = WinGetHandle("Untitled - Notepad")
    ControlSend($hWnd, "","Edit1", "first line sent while window visible" & @CR)
    WinSetState("Untitled - Notepad",'',@SW_MINIMIZE)
    sleep(2000);
    ControlSend($hWnd, "","Edit1", "Second line sent while minimised" & @CR)
    sleep(500)
    WinSetState($hWnd,'',@SW_MAXIMIZE)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Ok thanks martin.

Also, how do you use the mouseclickplus thing? I tried using it before by copying that whole thing into my autoit script, then putting in the _Mouseclickplus(blahblahblah) but it didn't do the clicking it should have.

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

  • Recently Browsing   0 members

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