aphesia Posted February 17, 2009 Share Posted February 17, 2009 Opt("WinTitleMatchMode", 2) while 1 If WinActive("notepad") = 1 Then MsgBox(0, "", "Window is active") EndIf WEnd this should wait until any window which has anywhere in the name "notepad" is active. then gives a msgbox.. i run notepad.exe and dotn get any msgbox ?! i rly dont get the failure here Link to comment Share on other sites More sharing options...
JSThePatriot Posted February 17, 2009 Share Posted February 17, 2009 (edited) Have you tried without the "= 1" in the If statement?It would seem you're going to need the following... the = 1 is not needed, but not useful to remove either.Opt("WinTitleMatchMode", -2) ; Makes it case insensitive, but still substring While 1 If WinActive("notepad") Then MsgBox(0, "Test", "Window is Active") EndIf WEndEdit01: Added working code, and hopefully fixed the problem as =1 wasn't it.Jarvis Edited February 17, 2009 by JSThePatriot AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 17, 2009 Share Posted February 17, 2009 It is case-sensitive, you need "Notepad". .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
JSThePatriot Posted February 17, 2009 Share Posted February 17, 2009 It is case-sensitive, you need "Notepad".After a new look, I saw what you noted here, and was in my edit when you posted. Good job.Jarvis AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
aphesia Posted February 17, 2009 Author Share Posted February 17, 2009 ahh okay thanks.. maybe u can help me with another thing? i want to check if the windows is not active.. if its inactive, the script should do smth.. but instantly when the window gets active again it should stop with what it has done.. at the end i want a screensaver which starts when firefox & all media player are inactive.. and then waits 10 minutes.. if no acitivity -> monitor off.. if there is any activity it won´t turn of the display. if firefox gets active again it stops & resets everything and wait again until this windows are inactive. Link to comment Share on other sites More sharing options...
Envoi Posted February 17, 2009 Share Posted February 17, 2009 ahh okay thanks.. maybe u can help me with another thing?i want to check if the windows is not active.. if its inactive, the script should do smth.. but instantly when the window gets active again it should stop with what it has done..at the end i want a screensaver which starts when firefox & all media player are inactive.. and then waits 10 minutes.. if no acitivity -> monitor off.. if there is any activity it won´t turn of the display. if firefox gets active again it stops & resets everything and wait again until this windows are inactive.I'm thinking that you're not looking for the windows to be "inactive," but rather "idle." With the way you're describing it, if you click on your Firefox window (just so that the title bar is no longer "grayed out") it becomes "active." Your script would never run then, even if the Firefox window remained idle. Does this make sense? I'm not trying to confuse you here, but if you're looking in the AutoIt Help (which is awesome!) for "active" it's not necessarily referring to windows that are receiving mouse and keyboard input.I hope this maybe clears up the terminology for you and points you in the right direction.--Kris Link to comment Share on other sites More sharing options...
aphesia Posted February 17, 2009 Author Share Posted February 17, 2009 inactive = greyed out active = currently viewing or am i wrong? what i want to do is , only turn of display after 10 minutes inactivity if there is no firefox (watching dvd streams with it) or dvd player running. Link to comment Share on other sites More sharing options...
AlmarM Posted February 17, 2009 Share Posted February 17, 2009 What about 'Untitled - Notepad' AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Manjish Posted February 17, 2009 Share Posted February 17, 2009 Hey there aphesia.. why don't you look at WinActive and the Do until loop.. something like this: Do ;something Until winactive("Notepad","") [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 17, 2009 Share Posted February 17, 2009 To see if a certain window is active use WinActive() .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Envoi Posted February 17, 2009 Share Posted February 17, 2009 inactive = greyed out active = currently viewing or am i wrong? what i want to do is , only turn of display after 10 minutes inactivity if there is no firefox (watching dvd streams with it) or dvd player running. I got you now. That makes sense. Ok, then you're on the right track. Your pseudocode will be something like While 1 If WinActive("Firefox") and WinActive("Media Player") are false, then If _Timer_GetIdleTime() is > 10 minutes, then run your screen saver Sleep(500) Wend Does that help? --Kris Link to comment Share on other sites More sharing options...
aphesia Posted February 17, 2009 Author Share Posted February 17, 2009 yeye and i already have this script.. i just had the problem that it somehow didn´t found the active windows.. because i had the wrong Opt("WinTitleMatchMode", -x) thx Link to comment Share on other sites More sharing options...
aphesia Posted February 17, 2009 Author Share Posted February 17, 2009 so what i did:#include <idle-script.au3> ;same as Timers.au3Opt("WinTitleMatchMode", -2) ; Makes it case insensitive, but still substring$dvd = WinActive("dvd") = 0 or WinActive("firefox") = 0 or WinActive("player") = 0while 1 if $dvd Then Global $iIdleTime = _Timer_GetIdleTime() If $iIdleTime > "8000" Then if $dvd Then MsgBox(0,"lala","lala") EndIf EndIf Else sleep(500) EndIfWEndbut it doesnt work.. it gives me the pop up even if firefox window is active Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 17, 2009 Share Posted February 17, 2009 It should be more like this: (untested) #include <idle-script.au3>;same as Timers.au3 Opt("WinTitleMatchMode", -2); Makes it case insensitive, but still substring while 1 If _Timer_GetIdleTime() > "8000" Then if WinActive("dvd") = 0 And WinActive("firefox") = 0 And WinActive("player") = 0 Then MsgBox(0,"lala","lala") EndIf EndIf sleep(500) WEnd .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Manjish Posted February 17, 2009 Share Posted February 17, 2009 WinActive returns value as a boolean.. true or false.. So if u write $dvd = WinActive("dvd") = 0 or WinActive("firefox") = 0 or WinActive("player") = 0 It will never give u any correct result.. It shud be: $dvd = WinActive("dvd") or WinActive("firefox") or WinActive("player") [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
aphesia Posted February 17, 2009 Author Share Posted February 17, 2009 what admiralkalkex wrote works @manjish now i can realize a idea i hd for the lock programm thanks all 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