Briandr Posted January 8, 2015 Share Posted January 8, 2015 I used the Autoit recorder to capture some mouse and keystrokes. Got the desired results. I tried adding several code examples I found to kill an existing process by PID or by name. Either the PID or process is taking longer to expected to close as the code captured by the recorder seems to be hitting the same one I am trying to start. What would be best example of way to kill the process? I do have one other question about SW_HIDE. Do I need to use it under each _WinWaitActivate line to hide the whole recording? expandcollapse popup#region --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000409) --- #region --- Internal functions Au3Recorder Start --- #include <Process.au3> _ProcessCloseTree("6256") Func _ProcessCloseTree($iPID) If IsString($iPID) Then $iPID = ProcessExists($iPID) ;To get PID If Not $iPID Then Return SetError(1, 0, 0) Local $aProc_List = ProcessList() For $i = 1 To $aProc_List[0][0] If _ProcessGetParent($aProc_List[$i][1]) = $iPID Then ProcessClose($aProc_List[$i][1]) Next ProcessClose($iPID) EndFunc Func _ProcessGetParent($iPID) Local $wbemFlagReturnImmediately = 0x10 Local $wbemFlagForwardOnly = 0x20 Local $colItems = "" Local $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $objItem.ProcessID = $iPID Then Return $objItem.ParentProcessID Next Endif Return SetError(1, 0, 0) EndFunc Func _Au3RecordSetup() Opt('WinWaitDelay',100) Opt('WinDetectHiddenText',1) Opt('MouseCoordMode',0) Local $aResult = DllCall('User32.dll', 'int', 'GetKeyboardLayoutNameW', 'wstr', '') If $aResult[1] <> '00000409' Then MsgBox(64, 'Warning', 'Recording has been done under a different Keyboard layout' & @CRLF & '(00000409->' & $aResult[1] & ')') EndIf EndFunc Func _WinWaitActivate($title,$text,$timeout=0) WinWait($title,$text,$timeout) If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) EndFunc _AU3RecordSetup() #endregion --- Internal functions Au3Recorder End --- Run('C:\Program Files (x86)\Hewlett-Packard\HP Connection Manager\HPConnectionManager.exe') _WinWaitActivate("HP Connection Manager","") Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}") _WinWaitActivate("Preferences","") Send("{TAB}{TAB}{DOWN}{TAB}{TAB}{SPACE}{TAB}{SPACE}{TAB}{SPACE}{TAB}{SPACE}{TAB}{SPACE}{TAB}{ENTER}") _WinWaitActivate("HP Connection Manager","") Send("{ALTDOWN}{F4}{ALTUP}{TAB}{ENTER}") #endregion --- Au3Recorder generated code End --- Link to comment Share on other sites More sharing options...
aleph01 Posted January 8, 2015 Share Posted January 8, 2015 Why not keep it simple with a While loop? Substitute process name with PID if desired.While ProcessExists ("notepad.exe") <> 0ProcessClose ("notepad.exe")Sleep (101)WEndNote: Code button is ignoring me. I don't need that, I can get that at home._aleph_ Meds. They're not just for breakfast anymore. Link to comment Share on other sites More sharing options...
aleph01 Posted January 8, 2015 Share Posted January 8, 2015 (edited) I'm using version 3.3.12.0 and I don't see any WinWaitActivate in the help file. Perhaps you need WinWait followed by WinActivate perhaps then followed by a WinWaitActive if necessary?_aleph_ Edited January 8, 2015 by aleph01 Meds. They're not just for breakfast anymore. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 9, 2015 Moderators Share Posted January 9, 2015 WinWaitActivate is a custom function generated when using Au3Recorder "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
aleph01 Posted January 9, 2015 Share Posted January 9, 2015 Ah! I have never used Au3Recorder. Maybe it's time to expand my horizons..._aleph_ Meds. They're not just for breakfast anymore. Link to comment Share on other sites More sharing options...
kylomas Posted January 9, 2015 Share Posted January 9, 2015 Briandr, Do you want to run the stuff recorded and then kill the process created by the Run command? 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...
Briandr Posted January 9, 2015 Author Share Posted January 9, 2015 (edited) Hi and thanks to all. No I recorded the process as if it was not running then had the recorder track all the keystrokes and mouse movements to deselect things. What I want prior to deployment is kill the process (it will be running on client computers) as the recorder starts by launcing the process. Maybe not best approach. Edited January 9, 2015 by Briandr Link to comment Share on other sites More sharing options...
Briandr Posted January 9, 2015 Author Share Posted January 9, 2015 Any ideas as to why this is not working. It was working fine yesterday. The two lines in the code window are not doing anything. Tried on more than one computer. Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}") _WinWaitActivate("Preferences","") When I check task manager the script is paused. It does not appear the tabs and enter are being sent. If I send the tabs manually the script is able to resume just fine. Ideally I'd like to send mouse clicks, but the recorder is not seeing my mouse clicks. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 9, 2015 Moderators Share Posted January 9, 2015 Can you please explain what you are trying to do in the section with all the Sends? There has to be a better way... "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Briandr Posted January 9, 2015 Author Share Posted January 9, 2015 (edited) App opens and I am trying to send enter to 'Preferences' buttonn. App has three tabs. So presumably with the window in focus I am tabbing down six times so I can send an enter to the button. I counted my tabs and it was six. App does not appear to have any valid key combs to get me to the button without all the tabbing Edited January 9, 2015 by Briandr Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 9, 2015 Moderators Share Posted January 9, 2015 Ok, like pulling teeth...What is the application? Is it something that can be done programmatically? How about a screenshot? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Briandr Posted January 9, 2015 Author Share Posted January 9, 2015 (edited) Screenshot in attachment Now the darn thing is putting egg on my face. Its working now with the original code created by the Autoit recorder. Not sure if the app necessarily needed to be closed or maybe it was having trouble finding it (have multiple monitors), but if there is an easy way to streamline I'd like to. Thank you. HPConnMgr.docx Edited January 9, 2015 by Briandr 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