Jump to content
Sign in to follow this  
Skrip

Partial "Win" name

Recommended Posts

Skrip

could a partial window name work, in any way?

$win_name = "PARTIAL NAME"


While 1
    sleep(100)

if WinExists($win_name) Then
    MsgBox(64,"Alert", "IF <NAME> EXISTS MESSAGE HERE")
EndIf

WEnd

could something like that work?


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
Valuater

Maybe this

$win_name = "PARTIAL NAME"


While 1
    sleep(100)

if WinExists($win_name) Then
    MsgBox(64,"Alert", "IF " & $win_name" & " EXISTS MESSAGE HERE")
EndIf

WEnd

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Skrip

Thanks alot!

(by the way you missed a ")

$win_name = "PARTIAL NAME"

While 1

sleep(100)

if WinExists($win_name) Then

MsgBox(64,"Alert", "IF " & "$win_name" & " EXISTS MESSAGE HERE")

EndIf

WEnd

but thanks for help

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
Shinies

Would the uhmmm, whats it called.... o ya

Opt("WinSetTitleMatch", 1) or something like that, i forget wat its called.

Share this post


Link to post
Share on other sites
Skrip

oh sorry, I didn't see that code in the documentation


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
herewasplato

Actually, there was one extra quote in Valuater's very fast reply.

MsgBox(64,"Alert", "IF " & $win_name" & " EXISTS MESSAGE HERE")

You did thank him - but you seem to have "corrected his code" by adding another extra quote:

(by the way you missed a ")

...

MsgBox(64,"Alert", "IF " & "$win_name" & " EXISTS MESSAGE HERE")

I think that is should be like this:

MsgBox(64,"Alert", "IF " & $win_name & " EXISTS MESSAGE HERE")

There should not be quotes around the variable during concatenation...

...unless you were going for msg text like this for some reason:

IF $win_name EXISTS MESSAGE HERE

then you can stick with:

MsgBox(64,"Alert", "IF " & "$win_name" & " EXISTS MESSAGE HERE") ....or just

MsgBox(64,"Alert", "IF $win_name EXISTS MESSAGE HERE")

Both of those will not display the value of the variable.

...but the OPT setting is all you needed.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
Skrip

Yes but I added some more to it but its giving me an error (ya i did try it like this

MsgBox(64,"Alert", "IF " & $win_name" & " EXISTS MESSAGE HERE")
and this
MsgBox(64,"Alert", "IF " & $win_name & " EXISTS MESSAGE HERE")
and so far i've got this

$win_name = "MSN"


While 1
    sleep(100)

if WinExists($win_name) Then
    MsgBox(64,"Alert", "Alert")
if WinExists($win_name) Then
    WinClose("$win_name", "")
EndIf


WEnd

Im using MSN as a test page (msn.com)

I want the script to give the alert then close the "$win_name" or the page its alerting from

when i open it, it says WEnd is not a command, and when i remove it, it says EndIf is not finished without WEnd

please help

heres the error

Line 14 (File "C:\Autoit3\testwin.au3"):

WEnd

Error: "Wend" statement with no matching "While" statement.
Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
herewasplato

try:

AutoItSetOption("WinTitleMatchMode", 2)
$win_name = "MSN"

While 1
    Sleep(100)
    If WinExists($win_name) Then
        MsgBox(64, "Alert", "Alert")
        WinClose("$win_name", "")
    EndIf
WEnd


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
Skrip

Thanks that worked but is there a way to make the window close when the alert thing pops up?

EDIT: I just found the WinClose thing but its not working... please fix

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
MSLx Fanboy

MsgBox pauses script execution. That means that the windows won't close until a message box button is clicked.

Try putting WinClose before the MsgBox


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites
Skrip

didn't work

AutoItSetOption("WinTitleMatchMode", 2)
$win_name = "MSN"

While 1
    Sleep(100)
    If WinExists($win_name) Then
    WinClose("$win_name", "")
        MsgBox(64, "Alert", "Alert")
    EndIf
WEnd

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
MSLx Fanboy

It should be:

WinClose($win_name)

What you have right now, it's looking for a window title that is really "$win_name" (not "MSN")


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites
Skrip

ya, thanks that worked


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
herewasplato

It should be:

WinClose($win_name)

What you have right now, it's looking for a window title that is really "$win_name" (not "MSN")

Thanks for correcting that - I had to leave for a while right after I posted that quick copy/paste/sloppy edit/error!

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.