kylomas Posted March 26, 2017 Share Posted March 26, 2017 M23, Thank you, interesting thread (even though the OP was a bit vague). kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
InunoTaishou Posted March 26, 2017 Share Posted March 26, 2017 Maybe this will help too. Get you the next/last visible (*, because _WinApi_GetWindow will just return the next/prev window, regardless of it's state) window, so you can send data to it expandcollapse popup#include <GUIConstants.au3> #include <WinAPI.au3> Global Const $WIN_STATE_VISIBLE = 2 If (Not WinExists("Untitled - Notepad")) Then Run("notepad.exe", @SystemDir) WinWait("Untitled - Notepad") EndIf Global $hMain = GUICreate("Test", 400, 335) Global $edtData = GUICtrlCreateEdit("This is a test{enter}", 10, 10, 380, 280) Global $btnSend = GUICtrlCreateButton("Send Data to last window", 10, 300, 380, 25) GUISetState(@SW_SHOW, $hMain) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE Exit 0 * ProcessClose("notepad.exe") Case $btnSend If (SendData(GetVisibleWindow($hMain, $GW_HWNDNEXT), "Edit1", GUICtrlRead($edtData))) Then GUICtrlSetData($edtData, "") EndIf EndSwitch WEnd Func SendData(Const $hWnd, Const $iCtrlId, Const $sData) If (WinExists($hWnd) = False) Then Return SetError(1, 0, "") If (StringLen($sData) = 0) Then Return SetError(2, 0, "") Return ControlSend($hWnd, "", $iCtrlId, $sData) EndFunc ;==>SendData Func GetVisibleWindow(Const $hWnd, Const $iCmd) If (Not WinExists($hWnd)) Then Return SetError(1, 0, 0) Local $hReturn = $hWnd While (True) $hReturn = _WinAPI_GetWindow($hReturn, $iCmd) If ($hReturn = 0) Then Return SetError(_WinAPI_GetLastError(), 0, 0) ElseIf (BitAND(WinGetState($hReturn), $WIN_STATE_VISIBLE)) Then Return $hReturn EndIf WEnd EndFunc ;==>GetVisibleWindow Although I think Melba's virtual keyboard would probably work better. ControlSend relies on the control id to send to. Mine could work if you know the control to send to. Mine would also work if you use WinActivate and then Send, instead of controlsend. But still, Melba's would be better lol 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