Avoid Idle-Time Session

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
relativity
Posts: 13
Joined: 22 Nov 2019, 04:23

Avoid Idle-Time Session

Post by relativity » 08 Dec 2022, 07:40

Hello all,

I've got a problem with a computer session (citrix) with an idle time of 30 mins. I need to display the information 24/7, but the idle timer keeps disconnecting my session after 30 mins.
I cannot change the idle time at the moment. I've tried caffeine - which isn't working.

Furthermore, I've created several scripts which (for instance) checks the idle time (Idletime > 20mins) and moves the mouse and send a f15 key - what other ways do I have to simulate a user?

Code: Select all

SetTitleMatchMode, 2
VarsToSearch := ["Dynamics", "Rolcentrum", "Taakoverzicht"]

		SetTimer, CheckTime, 5000	; Time in miliseconds (1000 = 1s)

Code: Select all

CheckTime:
if (A_TimeIdle > 1200000) 
{
	; MsgBox, 0, , % A_TimeIdle, 2
	; Define the time
	TheTime := A_Hour A_Min

	; is day monday - friday?
	if A_WDay between 1 and 7
	{
		; Is the time between set variables
		If TheTime between 0530 and 2330 && !Ran)
		{
			; Create a loop
			Loop, 1
			{
				Sleep, 500
				; Display tooltip
				TrayTip, LZ, Searching for Dynamics NAV, 10, 17
				Sleep, 3000
				; Check if NAV Dynamics is running, else start it
				If WinExist("Dynamics")
				{
					HideTrayTip()
					Sleep, 1000
					TrayTip, LZ, Activating Dynamics NAV and simulating user input, 10, 17
					Sleep, 1000
					For Key, Value in VarsToSearch
					If WinExist(%Value%)
						{
						; Active Window in order of variables
						WinActivate, %Value%
						Sleep, 300
						MouseMove, 1, 1, 1, R
						Sleep 500
						MouseMove, -1, 1, 1, R
						Sleep, 300
						Send, {F15}
						}
					}
					Else
					{
				HideTrayTip()
				Sleep, 1000
				TrayTip, LZ, Dynamics NAV not found, 10, 17
				Goto Process
				}
			Ran := 1
			}
		}
	}
}
This is a screenshot from the message I get:
Image
Last edited by relativity on 15 Dec 2022, 05:03, edited 1 time in total.

User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: Avoid Idle-Time Session

Post by mikeyww » 08 Dec 2022, 09:50

No guarantees, but you may want to switch to A_TimeIdlePhysical as a start. You may need to click on something. If you click to activate a menu, you will at least be able to confirm that your script is doing something to interact with the remote system.

relativity
Posts: 13
Joined: 22 Nov 2019, 04:23

Re: Avoid Idle-Time Session

Post by relativity » 09 Dec 2022, 02:17

mikeyww wrote:
08 Dec 2022, 09:50
No guarantees, but you may want to switch to A_TimeIdlePhysical as a start. You may need to click on something. If you click to activate a menu, you will at least be able to confirm that your script is doing something to interact with the remote system.
Thanks

I already tried IdleTimePhysical, but the problem is that after that idle time has passed, it's starts the loop every time checktime is started (5 sec), because it needs physical input to restart the timer?

User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: Avoid Idle-Time Session

Post by mikeyww » 09 Dec 2022, 05:01

As a starting test, you could try a simpler script. Your goal is to determine whether you can send a click to the window that will reset the remote timer. You can do this in two lines. In the first line, sleep for 15 minutes. In the second line, issue a click that you think will activate a remote menu, or something like that. Run the script, wait 32 minutes, and see if the remote session timed out. You then have your answer. The total time required for this exercise is 34 minutes: two minutes to write the script, and 32 minutes to run it and wait. If you subtract 29 minutes to drink coffee, then it's only three minutes. :)

relativity
Posts: 13
Joined: 22 Nov 2019, 04:23

Re: Avoid Idle-Time Session

Post by relativity » 15 Dec 2022, 04:37

I created the following. The screen has a certain blue pixel. If this pixel is found then it will send an enter to the screen:

Code: Select all

CheckTime:
; Define the time
TheTime := A_Hour A_Min

; is day monday - friday?
if A_WDay between 2 and 5
{
	; Is the time between set variables
	If TheTime between 0530 and 2330 && !Ran)
	{
		; Create a loop
		Loop, 1
		{
			CoordMode, Pixel, Screen
			PixelSearch, FoundX, FoundY, 600, 500, 1300, 700, 0x0067B1, 0, Fast RGB
			Sleep, 5000
			If (ErrorLevel = 0)
			{
				FileAppend, %A_MM%-%A_DD% %A_Hour%:%A_Min% 0x0067B1`n, Found.log
				Send, {Enter}
				ControlSend, , {Enter}, ahk_exe CDViewer.exe
				Sleep, 1000
			}
			CoordMode, Pixel, Screen
			PixelSearch, FoundX, FoundY, 600, 500, 1300, 700, 0x0067B3, 0, Fast RGB
			Sleep, 5000
			If (ErrorLevel = 0)
			{
				FileAppend, %A_MM%-%A_DD% %A_Hour%:%A_Min% 0x0067B3`n, Found.log			
				Send, {Enter}
				ControlSend, , {Enter}, ahk_exe CDViewer.exe
				Sleep, 1000
			}
		Ran := 1
		}
	}
}
Return
Is it possible to create a loop when this pixel is found until pixel is not found anymore?


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: Avoid Idle-Time Session

Post by mikeyww » 15 Dec 2022, 07:10

Yes. When you want to leave the loop: :arrow: Break.
Exits (terminates) any type of loop statement.

just me
Posts: 9451
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Avoid Idle-Time Session

Post by just me » 15 Dec 2022, 08:48

That's just a session setting on the server. It can be changed.

Post Reply

Return to “Ask for Help (v1)”