tbwalker Posted November 19, 2019 Posted November 19, 2019 I'm trying to build a script that will eventually create a log with time stamps of the active windows used on a workstation throughout the day, but I'm having a problem figuring out how to actually get this information. For example, if someone has Microsoft Word open, I'd like to be able to pop-up/log "word.exe" along with the full path to that file if at all possible (sort of like seeing the application DETAILS name in Windows Task Manager and being able to right-click on the name and choose "Open FIle Location" to get the full path to the file). Is what I'm asking even possible within the realm of AutoIt? I have the below script as a test that gets me the current active window handle and title in a message box every 6 seconds, but for the life of me, I don't know what code I need to use to get the actual .EXE name/path of the active window. #include <MsgBoxConstants.au3> Local $i = 0 Do Global $handle = WinGetHandle("[ACTIVE]") Global $title = WinGetTitle("[ACTIVE]") MsgBox(0,"Active Handle & Title",$handle & " - " & $title, 3) $i = $i + 1 Sleep(3000) Until $i = 100 Any help or suggestions would be greatly appreciated. I don't mind figuring out the code myself, if someone could just point me in the right direction. Thanks, TBWalker
seadoggie01 Posted November 19, 2019 Posted November 19, 2019 (edited) Basically, use WinGetProcess --> PID and match that in ProcessList to get the process name Edited November 19, 2019 by seadoggie01 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
Danp2 Posted November 19, 2019 Posted November 19, 2019 There's also _WinAPI_GetProcessName. Latest Webdriver UDF Release Webdriver Wiki FAQs
Developers Jos Posted November 19, 2019 Developers Posted November 19, 2019 (edited) -or- ; Retrieve the handle of the Notepad window using the classname of Notepad. Local $hWnd = WinGetHandle("[ACTIVE]") ; Retrieve the identifier of the thread and pass a variable to the $iPID parameter to store the PID. Local $iPID = 0 Local $iThread = _WinAPI_GetWindowThreadProcessId($hWnd, $iPID) ; Display the process thread, PIDof, processname and processfilename ConsoleWrite(' Process thread:' & $iThread & ' Process ID (PID): ' & $iPID & " Processname:" & _WinAPI_GetProcessName($iPID) & " filename:" & _WinAPI_GetProcessFileName($iPID) & @CRLF) Jos Edited November 19, 2019 by Jos seadoggie01, Professor_Bernd and KaFu 2 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
tbwalker Posted November 20, 2019 Author Posted November 20, 2019 Thank you all! I will give your tips a try. I really appreciate it.
Developers Jos Posted November 20, 2019 Developers Posted November 20, 2019 So how exactly will you be using this as it has a bit of a "big brother is watching you" ring to it? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
tbwalker Posted November 20, 2019 Author Posted November 20, 2019 (edited) I work for a global manufacturing company that is trying to come up with cost savings. We use a lot of Microsoft O365, Adobe and AutoDesk AutoCAD Products, purchasing a large number of licenses for each on an annual subscription. We want to make sure that we aren't issuing licenses for applications, such as Adobe Acrobat DC, When users rarely, if ever, actually launch and use the applications. Since this is a cost savings initiative, the company doesn’t actually want to spend a whole lot of money on methods of auditing, so I thought I would come up with a cheap method that would log to a text file whenever a specific application was used. I would program it to look specifically for the Adobe, Microsoft, and AutoCAD applications we are paying mega bucks on licensing, then after 30 days we would collect the log files from all of the computers globally (probably have each computer automatically write the log files to a location on the domain controller when they connect to our network), And simply do a plain English windows search including content of the text log files to see which files contain activity for specific licenses. Text files with license activity would be put in a separate folder, and those text files with no license activity would be put in the folder for us to contact the users and verify directly that they are not using the application, therefore allowing us to recover license so we do not over purchase. I don’t know if this is going to work out, but it sort of the basic plan. Thanks again for your assistance Edited November 20, 2019 by tbwalker
Developers Jos Posted November 20, 2019 Developers Posted November 20, 2019 Understood, but there is a thin line between monitoring for efficiency and invading employees privacy, so I guess/hope this is made known to them and won't be running hidden. Jos seadoggie01 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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