Ascer Posted March 13, 2017 Share Posted March 13, 2017 Hello! My proces list is full of Notepad.exe, all of these open windows have this same ProcessName and ProcessClass. I editing example Notepad.exe (3) After edit i go to AutoIt and run script. Script need to know what was last processID of editing Notepad.exe. Script cant be runned while i edit my notepad. There is any way to return proces list by last usage or something similar? @Melba23 Regards! Ascer Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2017 Moderators Share Posted March 13, 2017 Ascer, Assuming that the Notepad window is still active then you can use this: $iPID = WinGetProcess("[ACTIVE]") to get the PID. If the window is no longer active then you will have to get a bit more complicated and store the PID of the last active Notepad window which you get using the code above. And just for interest, why do you need the PID? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Ascer Posted March 13, 2017 Author Share Posted March 13, 2017 (edited) Thanks for request @Melba23! Notepad.exe list was only example. My proces list cannot store information about last $pid or $hwnd in main window. What i properly do: Open proces.exe -> Go to Deskop -> Open Folder called Data -> run AutoIt compiled script. How to get $pid or $hwnd of proces.exe while i have more than one opened? The class and Title is this same. Edited March 13, 2017 by Ascer Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2017 Moderators Share Posted March 13, 2017 Ascer, Not too hard to do - this works for me with 3 Notepads open: expandcollapse popup#include <Array.au3> HotKeySet("{ESC}", "_Exit") ; Class of multiple windows $sClass = "Notepad" ; Get list of these windows $aNotepadList = WinList("[CLASS:" & $sClass & "]") ; And display it just for interest _ArrayDisplay($aNotepadList, "", Default, 8) ; Declare variables Global $hLastActiveNotepad = 0, $iLastNotepadPID While 1 ; Get handle of active GUI $hHandle = WinGetHandle("[ACTIVE]") ; Check if it is a Notepad For $i = 1 To $aNotepadList[0][0] If $aNotepadList[$i][1] = $hHandle Then ; if it is not the same instance as the last active Notepad If $hHandle <> $hLastActiveNotepad Then ; Store new handle $hLastActiveNotepad = $hHandle ; Determine PID $iLastNotepadPID = WinGetProcess("[ACTIVE]") ConsoleWrite($iLastNotepadPID & @CRLF) EndIf ExitLoop EndIf Next WEnd Func _Exit() Exit EndFunc But I am still intrigued as to why you need the PID..... M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Ascer Posted March 13, 2017 Author Share Posted March 13, 2017 6 minutes ago, Melba23 said: Ascer, Not too hard to do - this works for me with 3 Notepads open: expandcollapse popup#include <Array.au3> HotKeySet("{ESC}", "_Exit") ; Class of multiple windows $sClass = "Notepad" ; Get list of these windows $aNotepadList = WinList("[CLASS:" & $sClass & "]") ; And display it just for interest _ArrayDisplay($aNotepadList, "", Default, 8) ; Declare variables Global $hLastActiveNotepad = 0, $iLastNotepadPID While 1 ; Get handle of active GUI $hHandle = WinGetHandle("[ACTIVE]") ; Check if it is a Notepad For $i = 1 To $aNotepadList[0][0] If $aNotepadList[$i][1] = $hHandle Then ; if it is not the same instance as the last active Notepad If $hHandle <> $hLastActiveNotepad Then ; Store new handle $hLastActiveNotepad = $hHandle ; Determine PID $iLastNotepadPID = WinGetProcess("[ACTIVE]") ConsoleWrite($iLastNotepadPID & @CRLF) EndIf ExitLoop EndIf Next WEnd Func _Exit() Exit EndFunc But I am still intrigued as to why you need the PID..... M23 Thanks for time spent on writing code but it's useless for me. Script need to know $pid or $handle just at start. I cant run script, do my things and script find last active $pid. So there is any function to return $process list by last usage/active? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2017 Moderators Share Posted March 13, 2017 Ascer, Firstly, when you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily. Secondly, the code might well be useless for you - but you had not specified your precise requirements earlier in the thread, so how I am I supposed to guess precisely what you need unless you tell me? Finally, you have the basis of what you require in that script - so unless you offer a lot more information on what exactly you are trying to do and just what these multiple processes actually are, I am out of here. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Ascer Posted March 13, 2017 Author Share Posted March 13, 2017 PIC NR 1. PIC NR 2. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2017 Moderators Share Posted March 13, 2017 Ascer, I already pointed you to the Forum rules when I locked your first thread - and specifically mentioned the "no gaming" rule - and yet here you are again asking about game interaction. So the thread gets locked again - we take our rules seriously and enforce them rigidly. And you have used up the final element of flex we were prepared to show you. Either follow the rules in future or leave the community - and we will force your departure if necessary. Your choice - please choose wisely. M23 water 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts