lairdb Posted April 10, 2008 Share Posted April 10, 2008 I finally decided this wasn't a bug, but it's an odd behaviour, and I'm looking for advice on whether there's a better way to solve it. I'm using the GetLastInputInfo API to determine whether a session is idle; if it is idle for long enough, then my script interacts with the session. Here's my first step test app: Do sleep(500) $j = _TicksSinceLastInput() traytip(@ScriptName,"Idle for "&$j&".",10,1) if ($j > 10000) then controlclick("","Running Applications","[CLASS:Button; Text:start]") EndIf until False Func _TicksSinceLastInput() local $struct = DllStructCreate("uint;dword"); DllStructSetData($struct, 1, DllStructGetSize($struct)); DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($struct)) local $systick = DllCall("kernel32.dll", "dword", "GetTickCount") return $systick[0] - DllStructGetData($struct, 2) EndFuncoÝ÷ ÙhZ´b±Ê/z·ËajШÚè)brFÝ¡ë'¢ÚÞ±ënØ^zn¶Ø¦z´áy"¢ëm+uç"uçm«pjƯjX{^®Þµ«b¢vî¶z-Â#§µçR¡«¢+Ù¼(%ͱÀ ÔÀÀ¤($ÀÌØí¨ô}Q¥ÍM¥¹1ÍÑ%¹ÁÕÐ ¤(%ÑÉåÑ¥À¡MÉ¥ÁÑ9µ°ÅÕ½Ðí%±½ÈÅÕ½ÐìµÀìÀÌØí¨µÀìÅÕ½Ðì¸ÅÕ½Ðì°ÄÀ°Ä¤(%¥ ÀÌØí¨ÐìÄÀÀÀÀ¤Ñ¡¸($$íÕ¹½µµ¹ÐÝ¡¥¡Ùȱ¥¹å½ÔݹÐѼÑÍи($$íµ½Õ͵½Ù ÈÀÀ°ÈÀÀ°ÌÀ¤ìÑ¡¥ÌÝ¥±°ÉÍÐÑ¡¥±½Õ¹ÑÈ($$í½¹Ñɽ±±¥¬ ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíIÕ¹¹¥¹ÁÁ±¥Ñ¥½¹ÌÅÕ½Ðì°ÅÕ½Ðím 1MLé ÕÑѽ¸ìQáÐéÍÑÉÑtÅÕ½Ðì¤ìÑ¡¥ÌÝ¥±°9=PÉÍÐÑ¡¥±½Õ¹ÑÈ($%µ½Õͽ¹Ñɽ±±¥¬ ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíIÕ¹¹¥¹ÁÁ±¥Ñ¥½¹ÌÅÕ½Ðì°ÅÕ½Ðím 1MLé ÕÑѽ¸ìQáÐéÍÑÉÑtÅÕ½Ðì¤ìÑ¡¥ÌÝ¥±°ÉÍÐÑ¡¥±½Õ¹ÑÈ($%¹%(%չѥ°±Í(((()Õ¹}Q¥ÍM¥¹1ÍÑ%¹ÁÕÐ ¤(%±½°ÀÌØíÍÑÉÕÐô±±MÑÉÕÑ ÉÑ ÅÕ½ÐíÕ¥¹ÐíݽÉÅÕ½Ðì¤ì(±±MÑÉÕÑMÑÑ ÀÌØíÍÑÉÕаݱ±MÑÉÕÑÑM¥é ÀÌØíÍÑÉÕФ¤ì(±± ±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíÑ1ÍÑ%¹ÁÕÑ%¹¼ÅÕ½Ðì°ÅÕ½ÐíÁÑÈÅÕ½Ðì°±±MÑÉÕÑÑAÑÈ ÀÌØíÍÑÉÕФ¤(±½°ÀÌØíÍåÍÑ¥¬ô±± ±° ÅÕ½Ðíɹ°Ìȹ±°ÅÕ½Ðì°ÅÕ½ÐíݽÉÅÕ½Ðì°ÅÕ½ÐíÑQ¥ ½Õ¹ÐÅÕ½Ðì¤(%ÉÑÕɸÀÌØíÍåÍÑ¥lÁt´±±MÑÉÕÑÑÑ ÀÌØíÍÑÉÕаȤ)¹Õ¹()Õ¹5½ÕÍ ½¹Ñɽ± ±¥¬ ÀÌØíÝ¥¹Q¥Ñ±°ÀÌØíÝ¥¹QáаÀÌØíÝ¥¹ ½¹Ñɽ±%¤(%±½°ÀÌØíÝ¥¹Á½ÌôÝ¥¹ÑÁ½Ì ÀÌØíÝ¥¹Ñ¥Ñ±°ÀÌØíÝ¥¹ÑáФ(%¥¡ÉɽÈôĤѡ¸ÉÑÕɸÀ(%±½°ÀÌØí½¹Ñɽ±Á½Ìô½¹Ñɽ±ÑÁ½Ì ÀÌØíÝ¥¹Q¥Ñ±°ÀÌØíÝ¥¹QáаÀÌØíÝ¥¹ ½¹Ñɽ±%¤(%¥¡ÉɽÈôĤѡ¸ÉÑÕɸÀ(%ÉÑÕɸµ½Õͱ¥¬ ÅÕ½Ðí±ÐÅÕ½Ðì°ÀÌØíÝ¥¹Á½ÍlÁt¬ ÀÌØí½¹Ñɽ±Á½ÍlÁt¥¹Ð ÀÌØí½¹Ñɽ±Á½ÍlÉt¼È¤¤°ÀÌØíÝ¥¹Á½ÍlÅt¬ ÀÌØí½¹Ñɽ±Á½ÍlÅt¥¹Ð ÀÌØí½¹Ñɽ±Á½ÍlÍt¼È¤¤°Ä°È¤)¹Õ¹ I discovered that MouseMove and MouseClick both do count as user input, so I ended up writing MouseControlClick, which takes the control identification, finds the window and control, and does an actual mouseclick in the location. Any holes; any better way to approach? Thanks. Link to comment Share on other sites More sharing options...
weaponx Posted April 10, 2008 Share Posted April 10, 2008 (edited) Just perform a random mouseclick before the controlclick. Edited April 10, 2008 by weaponx Link to comment Share on other sites More sharing options...
martin Posted April 10, 2008 Share Posted April 10, 2008 Welcome to the AUtoIt forums! Looks fine to me. I prefer your first approach because it's simpler. To create some 'user' action you could just say something like Send("{LCTRL}") which would only add one line. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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