Damodara Posted November 22, 2012 Share Posted November 22, 2012 Hello,I am totally new to this, have a bit knowledge in c++ programing. But I was woundering if some could be kind to pint me to general direction.I want to achieve a simple goal:Detect if the windows user is not using a specific application for x minutes, and then pop a message to user (or notify a user in any other way with a message)Where should I start? Or maybe there is something like this already available? Link to comment Share on other sites More sharing options...
jmon Posted November 22, 2012 Share Posted November 22, 2012 (edited) try _Timer_GetIdleTime. It returns the idle time: #include <Timers.au3> ;Loop: While 1 ;Check if the idle time reached 15 minutes: If _Timer_GetIdleTime() >= 15 * 60 * 1000 Then MsgBox (0, "Time reached", "You have been idle for more than 15 minutes.") Exit EndIf ;Sleep for 10 seconds: Sleep(10 * 1000) WEnd but it's not specific to one application. Try this one for an application specific check: ;Create the Gui Global $GUI = GUICreate("Test", 800, 600) GUISetState() ;Declare the Timer: Global $TIMER = TimerInit() While 1 ;If this application is active then reset the timer: If WinActive($GUI) Then $TIMER = TimerInit() EndIf ;if the timer is more than 15 minutes then: If TimerDiff($TIMER) >= 15 * 60 * 1000 Then MsgBox (0, "Time reached", "You have been idle for more than 15 minutes.") Exit EndIf ;Sleep for 1 seconds before looping again: Sleep(1000) WEnd Edited November 22, 2012 by jmon [center]www.jmontserrat.comFile Sequence UDF - _StringExtractPaths - _StringTrimPattern - GuiCtrlSetOnTop - CalendarUDF[/center] Link to comment Share on other sites More sharing options...
stormbreaker Posted November 22, 2012 Share Posted November 22, 2012 jmon, he wants to check the user as well. This worked for me: poll_win() Func poll_win() Local $TIMER = TimerInit() While 1 Sleep(100) $WINHANDLE = WinActive('[TITLE:Untitled - Notepad2]') If $WINHANDLE then If _ProcessOwner(WinGetProcess($WINHANDLE)) = 'Administrator' then ExitLoop EndIf WEnd msgbox(64, 'Notice', 'The program has been used after ' & Int(TimerDiff($TIMER)/1000) & ' seconds.') EndFunc Func _ProcessOwner($pid=0,$hostname=".") $objWMIService = ObjGet("winmgmts://" & $hostname & "/root/cimv2") $colProcess = $objWMIService.ExecQuery("Select * from Win32_Process Where ProcessID ='" & $pid & "'") For $objProcess In $colProcess If $objProcess.ProcessID = $pid Then $usr = 0 $objProcess.GetOwner($usr) Return $usr EndIf Next EndFunc ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1 Link to comment Share on other sites More sharing options...
jmon Posted November 22, 2012 Share Posted November 22, 2012 Ah ok, you are trying to externally monitor an application usage with autoit? so then MKISH's example is what you need. [center]www.jmontserrat.comFile Sequence UDF - _StringExtractPaths - _StringTrimPattern - GuiCtrlSetOnTop - CalendarUDF[/center] Link to comment Share on other sites More sharing options...
guinness Posted November 22, 2012 Share Posted November 22, 2012 I was under the impression the user wanted to monitor an external application for how long it was idle for? I can't see MKISH's version doing that? UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
stormbreaker Posted November 22, 2012 Share Posted November 22, 2012 Detect if the windows user is not using a specific application for x minutesguinness, of course it doesn't do exactly what the OP wanted, but I preferred following the 'Teach a man to fish' method. The OP can start from my example.Regards,MKISH ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1 Link to comment Share on other sites More sharing options...
guinness Posted November 22, 2012 Share Posted November 22, 2012 but I preferred following the 'Teach a man to fish' method.OK, but I would have just pointed them to the help file with certain keywords if that was the case. But my point was to make it clear to Damodara that your example works but without the 'application idle time part.' I'm trying to avert the dreaded 'your example doesn't work for me, do it again scenario.' UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
stormbreaker Posted November 22, 2012 Share Posted November 22, 2012 But my point was to make it clear to Damodara that your example works but without the 'application idle time part.' I'm trying to avert the dreaded 'your example doesn't work for me, do it again scenario.' I truly agree to your point of pointing the OP to the help file. But then again, I think there is no function to get the user-name of the process (in the help file), thats what I believe. Also, what my example does, is tell that after how much time the Notepad2 window is activated. ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1 Link to comment Share on other sites More sharing options...
guinness Posted November 22, 2012 Share Posted November 22, 2012 (edited) I read your function wrong then. This will work for those that don't use Notepad2. Example() Func Example() ; Run Notepad Run("notepad.exe") ; Wait 5 seconds for the Notepad window to appear. Local $hWnd = WinWait('[CLASS:Notepad]', '', 5) WinSetState($hWnd, '', @SW_MINIMIZE) ; Monitor how long a particular window is not active for. WinActiveIdle($hWnd) EndFunc ;==>Example Func WinActiveIdle($sTitle, $sText = Default) ; See syntax for WinWait etc. If $sText = Default Then $sText = '' EndIf Local $hWnd= 0, $hTimer = TimerInit() While 1 Sleep(100) $hWnd = WinActive($sTitle, $sText) If $hWnd Then ; Add MKISH's function here. ExitLoop EndIf WEnd MsgBox(4096, '', 'The program was idle for ' & Int(TimerDiff($hTimer) / 1000) & ' seconds.') EndFunc ;==>WinActiveIdle Edited November 22, 2012 by guinness stormbreaker 1 UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
stormbreaker Posted November 22, 2012 Share Posted November 22, 2012 Well, I sort of feel honoured that an MVP of your level mentioned about me in his post. Thanks ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1 Link to comment Share on other sites More sharing options...
guinness Posted November 22, 2012 Share Posted November 22, 2012 Well, I sort of feel honoured that an MVP of your level mentioned about me in his post. ThanksHaha, that's cool. You've made my day MKISH. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Damodara Posted November 23, 2012 Author Share Posted November 23, 2012 Well thank you for the replies, I posted below what I managed on my own. I am offering some coffee money with paypal for someone to finish up this little script.Requirements:It must detect a process EFrame2.exe, determine that its idle, I mean a program window is not active, minimized etc.After 15 minutes it must show a message and keep running, delaying the message for 5 minutes, repeatedly showing the message until window becomes activeIt must work also on x64 windows (dont know if thats an issue )It must work on different users/computersI tried my best. But I am really out of my depth here. Messing around with what I understant I only managed this:Local $hWnd = WinWait('[TITLE:Untitled - Notepad]', '', 5);Declare the Timer:Global $TIMER = TimerInit()While 1 ;If this application is active then reset the timer: If WinActive($hWnd) Then $TIMER = TimerInit() EndIf ;if the timer is more than 15 minutes then: If TimerDiff($TIMER) >= 1 * 5 * 1000 Then TrayTip("Time reached", "You have been idle for more than 15 minutes.", 5, 1) EndIf ;Sleep for 1 seconds before looping again: Sleep(3000)WEnd Link to comment Share on other sites More sharing options...
stormbreaker Posted November 23, 2012 Share Posted November 23, 2012 We would be breaching the forum etiquette, if we accept paid requests here, try some other websites. We are here to help you write your script by yourself. ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1 Link to comment Share on other sites More sharing options...
Damodara Posted November 23, 2012 Author Share Posted November 23, 2012 (edited) We would be breaching the forum etiquette, if we accept paid requests here, try some other websites. We are here to help you write your script by yourself. Ok fine . Lets do it your way, the problem is I am not really sure, how to proceed further. The script below does exactly what I want, except I dont know how to detect the program. Local $hWnd = WinWait('[TITLE:Untitled - Notepad]', '', 5) ;Declare the Timer: Global $TIMER = TimerInit() While 1 ;If this application is active then reset the timer: If WinActive($hWnd) Then $TIMER = TimerInit() EndIf ;if the timer is more than 15 minutes then: If TimerDiff($TIMER) >= 1 * 5 * 1000 Then TrayTip("Time reached", "You have been idle for more than 15 minutes.", 5, 1) EndIf ;Sleep for 1 seconds before looping again: Sleep(3000) WEnd It works fine with the open program, but when its closed or not open its just spam the message... Edited November 23, 2012 by Damodara Link to comment Share on other sites More sharing options...
water Posted November 23, 2012 Share Posted November 23, 2012 Can you tell us why you need to monitor the application this way? In my company I would have a problem with the works council because such a script not only monitors the program but the user as well. Maybe there is a simpler way to achieve what you need to do. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki  Link to comment Share on other sites More sharing options...
Damodara Posted November 23, 2012 Author Share Posted November 23, 2012 Can you tell us why you need to monitor the application this way?In my company I would have a problem with the works council because such a script not only monitors the program but the user as well.Maybe there is a simpler way to achieve what you need to do.Its quite simple, we have a limited amount of licenses we can run at the same time, and users have log off before other can start using it. And its quite common for people to forget that they left the window open. So this would serve as a simple reminder to close that application. Link to comment Share on other sites More sharing options...
jmon Posted November 23, 2012 Share Posted November 23, 2012 (edited) except I dont know how to detect the program. In this case, what you need is to get the hWnd of the window from the process ID. You can get the process ID because you know the name of the program: "Eframe2.exe" Here is an example that returns the windows handles of a process, using _WinAPI_EnumProcessWindows from WinAPIEx.au3 : $iPid = ProcessExists("EFrame2.exe") If $iPid Then $aWindows = _WinAPI_EnumProcessWindows($iPid) If Not @error Then For $i = 1 To $aWindows[0][0] ;Here check if your window is active or not Next EndIf EndIf Edited November 23, 2012 by jmon [center]www.jmontserrat.comFile Sequence UDF - _StringExtractPaths - _StringTrimPattern - GuiCtrlSetOnTop - CalendarUDF[/center] Link to comment Share on other sites More sharing options...
Damodara Posted November 23, 2012 Author Share Posted November 23, 2012 In this case, what you need is to get the hWnd of the window from the process ID. You can get the process ID because you know the name of the program: "Eframe2.exe"Here is an example that returns the windows handles of a process, using _WinAPI_EnumProcessWindows from WinAPIEx.au3 :Ok thanks, but now I just get an error, so I am quessing I have to #include "_WinAPI_EnumProcessWindows from WinAPIEx.au3" this some how in my script? Any tips on how that works ? Link to comment Share on other sites More sharing options...
jmon Posted November 23, 2012 Share Posted November 23, 2012 yes, include that:#include "WinApiEx.au3"and download [center]www.jmontserrat.comFile Sequence UDF - _StringExtractPaths - _StringTrimPattern - GuiCtrlSetOnTop - CalendarUDF[/center] Link to comment Share on other sites More sharing options...
Damodara Posted November 23, 2012 Author Share Posted November 23, 2012 yes, include that: #include "WinApiEx.au3" and download Thats what I have so far, I only get this error: >Exit code: 0 Time: 6.421 Yeah I am total newb lol #include "WinApiEx.au3" Global $TIMER = TimerInit() $hWnd = ProcessExists("EFrame2.exe") If $hWnd Then $aWindows = _WinAPI_EnumProcessWindows($hWnd) If Not @error Then For $i = 1 To $aWindows[0][0] ;Here check if your window is active or not ;If this application is active then reset the timer: If WinActive($hWnd) Then $TIMER = TimerInit() EndIf ;if the timer is more than 15 minutes then: If TimerDiff($TIMER) >= 1 * 5 * 1000 Then TrayTip("Time reached", "You have been idle for more than 15 minutes.", 5, 1) EndIf ;Sleep for 1 seconds before looping again: Sleep(3000) Next EndIf EndIf 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