Jump to content

just dont get what is wrong here


aphesia
 Share

Recommended Posts

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

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
WEnd

Edit01: Added working code, and hopefully fixed the problem as =1 wasn't it.

Jarvis

Edited 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

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

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

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

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

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

so what i did:

#include <idle-script.au3> ;same as Timers.au3

Opt("WinTitleMatchMode", -2) ; Makes it case insensitive, but still substring

$dvd = WinActive("dvd") = 0 or WinActive("firefox") = 0 or WinActive("player") = 0

while 1

if $dvd Then

Global $iIdleTime = _Timer_GetIdleTime()

If $iIdleTime > "8000" Then

if $dvd Then

MsgBox(0,"lala","lala")

EndIf

EndIf

Else

sleep(500)

EndIf

WEnd

but it doesnt work.. it gives me the pop up even if firefox window is active :)

Link to comment
Share on other sites

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

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

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