Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How to activate specific window when certain amount of time passes without any activity only in that window?


  • Please log in to reply
8 replies to this topic
manoj aggarwal
  • Members
  • 72 posts
  • Last active: Nov 13 2015 10:03 AM
  • Joined: 12 Oct 2014
Friends I want that when a specific window is idle for 10 minutes then it should first activate that window and then send f4 key. I work on some online software and it logs out when that software is idle or inactive for 10 minutes and to log in again is very cumbersome and hectic work, so I want when 10 minutes pass without any activity (only on that window) then that window should be activated and f4 key should be sent automatically. That windows title as shown in window spy is this- Finacle - Microsoft Internet Explorer ahk_class IEFrame ahk_exe IEXPLORE.EXE Please help… THANKS

Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Loop
{
WinWaitActive, Finacle - Microsoft Internet Explorer ahk_class IEFrame ahk_exe IEXPLORE.EXE,, 600 ;seconds
If ErrorLevel ; if it timed out
   {
   WinActivate, Finacle - Microsoft Internet Explorer ahk_class IEFrame ahk_exe IEXPLORE.EXE
   Send {F4}
   }
WinWaitNotActive, Finacle - Microsoft Internet Explorer ahk_class IEFrame ahk_exe
}

 

I'm actually not entirely sure how well using a SetTimer would work on this, so I've opted for the loop.



manoj aggarwal
  • Members
  • 72 posts
  • Last active: Nov 13 2015 10:03 AM
  • Joined: 12 Oct 2014
 

Loop{WinWaitActive, Finacle - Microsoft Internet Explorer ahk_class IEFrame ahk_exe IEXPLORE.EXE,, 600 ;secondsIf ErrorLevel ; if it timed out   {   WinActivate, Finacle - Microsoft Internet Explorer ahk_class IEFrame ahk_exe IEXPLORE.EXE   Send {F4}   }WinWaitNotActive, Finacle - Microsoft Internet Explorer ahk_class IEFrame ahk_exe}
 
I'm actually not entirely sure how well using a SetTimer would work on this, so I've opted for the loop.
 



THANKS DEAR Exaskryz for helping me....
the codes suggested by you are working fine....
One more thing i wish to bring in your kind notice is that-
they are also reducing the speed of system. I think the loop is Continuously finding for the specific window, that is why it is affecting the speed of system. Is there any other way to do this or this can happen that this loop should start after 1 minute in stead of Continuously finding the specific window. In other words it should start finding the specific window only after 1 minute of previous attempt. PLEASE HELP. THANKS

Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

That code shouldn't be slowing down your system. I expec WinWaitActive and WinWaitNotActive are not be polling windows every millisecond, but listening for some kind of change of the active window in the windows environment and then checking what the title is. I am not an AHK developer so I might be wrong.



manoj aggarwal
  • Members
  • 72 posts
  • Last active: Nov 13 2015 10:03 AM
  • Joined: 12 Oct 2014

That code shouldn't be slowing down your system. I expec WinWaitActive and WinWaitNotActive are not be polling windows every millisecond, but listening for some kind of change of the active window in the windows environment and then checking what the title is. I am not an AHK developer so I might be wrong.

 

 

Thanks Exaskryz for your good answer once again. Dear Exaskryz, one more thing i wish to tell you, that if 10 minutes pass to the last f4 or f10 keystroke in that window then that window logs out. So i want that before passing 10 minutes to f4 or f10 keystroke in that window, it should automatically send these keystroke in that window. Please help. Thanks



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

You can use a timeout of less than 600 seconds. Try 9 minutes, which is 540 seconds.



manoj aggarwal
  • Members
  • 72 posts
  • Last active: Nov 13 2015 10:03 AM
  • Joined: 12 Oct 2014

You can use a timeout of less than 600 seconds. Try 9 minutes, which is 540 seconds.

 

Ok sir. Thanks for your help.

Sir Could you please tell me how should i set f4 and f10 keys for that specific window, So that it can send f4 or f10 keys in that specific window before passing 10 minutes to the last keystroke of f4 or f10 in that window. The codes suggested by you only activate that specific window if it is not activated for last 10 minutes, but if the window is activated and is idle for 10 minutes namely keeping the window activated, i do not send f4 or f10 keys in that window for 10 minutes, then it is also logged out. so i want that it should track whether f4 or f10 key has been sent in that specific window for last 10 minutes or not. If f4 or f10 key is not sent in that window for last 10 minutes then only it should send f4 key in that window. Please tell me how to do that. I will be highly obliged to you. Thanks a lot sir...



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Oh, yeah, now I see the problem. Sorry for the misunderstanding. Set a time limit on WinWaitNotActive as well of 540 seconds. If it times out, it'll go back to the top of the loop, and the WinWaitActive must instantly be true. That would ensure that while your are not at your computer the script will still work.

 

But now it is trickier if you can manually activate it. Here's what I would do.

 

SetTimer, forFinacle, 10000 ; check every 10 seconds
#IfWinActive, Finacle - Microsoft Internet Explorer ahk_class IEFrame ahk_exe IEXPLORE.EXE
~F4::timeF4:=A_TickCount
~F10::timeF10:=A_TickCount
 
forFinacle:
If (A_TickCount-timeF4 > 600000) && (A_TickCount-timeF10 > 600000)
{
WinActivate Finacle - Microsoft Internet Explorer ahk_class IEFrame ahk_exe IEXPLORE.EXE
Send {F4}
timeF4:=A_TickCount
}
return

 

This will keep track of your actual keyboard presses of F4 and F10 to the window. Once the script notices you have gone longer than 10 minutes without pressing F4 or F10, it will send an {F4} keystroke to your window.

 

You may be able to use ControlSend here to avoid activating the window and disrupting your work. I just don't know what control you'd target in IE.



manoj aggarwal
  • Members
  • 72 posts
  • Last active: Nov 13 2015 10:03 AM
  • Joined: 12 Oct 2014
 

Oh, yeah, now I see the problem. Sorry for the misunderstanding. Set a time limit on WinWaitNotActive as well of 540 seconds. If it times out, it'll go back to the top of the loop, and the WinWaitActive must instantly be true. That would ensure that while your are not at your computer the script will still work.
 
But now it is trickier if you can manually activate it. Here's what I would do.
 

SetTimer, forFinacle, 10000 ; check every 10 seconds#IfWinActive, Finacle - Microsoft Internet Explorer ahk_class IEFrame ahk_exe IEXPLORE.EXE~F4::timeF4:=A_TickCount~F10::timeF10:=A_TickCount forFinacle:If (A_TickCount-timeF4 > 600000) && (A_TickCount-timeF10 > 600000){WinActivate Finacle - Microsoft Internet Explorer ahk_class IEFrame ahk_exe IEXPLORE.EXESend {F4}timeF4:=A_TickCount}return
 

This will keep track of your actual keyboard presses of F4 and F10 to the window. Once the script notices you have gone longer than 10 minutes without pressing F4 or F10, it will send an {F4} keystroke to your window.
 
You may be able to use ControlSend here to avoid activating the window and disrupting your work. I just don't know what control you'd target in IE.
 








Thanks a lot dear Exaskryz...
Now the script is working great...
You are really expert at autohotkey dear Exaskryz...
I appreciate your skills...
Thank you very much once again...