Jump to content

If application is idle for 15 minutes, show a pup up message


Damodara
 Share

Recommended Posts

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

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 by jmon
Link to comment
Share on other sites

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

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

Detect if the windows user is not using a specific application for x minutes

guinness, 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

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

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.'

:guitar: 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

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 by guinness

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

:graduated: 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

:graduated: Well, I sort of feel honoured that an MVP of your level mentioned about me in his post. Thanks

Haha, 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

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 active
  • It must work also on x64 windows (dont know if thats an issue :) )
  • It must work on different users/computers

I 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

:guitar: 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

:guitar: 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 :P . 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 by Damodara
Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.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 (NEW 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

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

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 by jmon
Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...