ShiftyGypsy Posted July 3, 2007 Posted July 3, 2007 try this script with various versions of autoit... Global $pid1,$pid2,$hwnd1,$hwnd2,$time $time = TimerInit() $pid1 = Run("notepad") $pid2 = Run("cmd") ;replace cmd /\ with program of your choice... Do $hwnd1 = ProcessGetHwnd($pid1) $hwnd2 = ProcessGetHwnd($pid2) Sleep(100) If TimerDiff($time) > 10000 Then Exit Until $hwnd1 <> 0 And $hwnd2 <> 0 WinActivate($hwnd1) Sleep(1000) ControlSend($hwnd2,"","","tEsT") MsgBox(4096,"","tEsT in the CMD (or your app) window means success") Func ProcessGetHwnd(ByRef $process) Local $n Local $list = WinList() For $n = 1 to $list[0][0] If WinGetProcess($list[$n][1]) = $process Then Return $list[$n][1] Next Return 0 EndFunc (got this from the bug forum -- please disregard my post there) is there a way to use controlclick on a control in an inactive window like controlsend above?
PsaltyDS Posted July 4, 2007 Posted July 4, 2007 (got this from the bug forum -- please disregard my post there) is there a way to use controlclick on a control in an inactive window like controlsend above? Works if you give it focus first: #include <guiconstants.au3> Opt("GuiOnEventMode", 1) $hGui = GUICreate("Test", 200, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") $Label = GUICtrlCreateLabel("", 10, 10, 180, 20) $Button = GUICtrlCreateButton("Mark", 50, 40, 100, 50) GUICtrlSetOnEvent(-1, "_ButtonHit") GUISetState() $pid1 = Run("notepad") Sleep(2000) ControlFocus("Test", "", $Button) ControlClick("Test", "", $Button) While 1 Sleep(20) WEnd Func _Quit() Exit EndFunc Func _ButtonHit() GUICtrlSetData($Label, "Button hit at: " & @HOUR & ":" & @MIN & ":" & @SEC) EndFunc Comment out the ControlFocus() and it doesn't work anymore for me. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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