Jump to content

Recommended Posts

Posted

I am trying to make a program to block certain elements from opening and running. I will have to match the names of these elements. However I observed WinTitleMatchMode is case sensitive. If I specify Notepad to block, I can't block those with titles like NOTEPAD, NotePad, notepad. Anyway to overcome this?

Posted (edited)

Change it into upper case or lower case, then check it...

If StringUpper(WinGetTitle("")) = "NOTEPAD" Then
    MsgBox(0, "", "Notepad Window")
EndIf

or

If StringLower(WinGetTitle("")) = "notepad" Then
    MsgBox(0, "", "Notepad Window")
EndIf
Edited by stingjoel
Posted

Change it into upper case or lower case, then check it...

If StringUpper(WinGetTitle("")) = "NOTEPAD" Then
    MsgBox(0, "", "Notepad Window")
EndIf

or

If StringLower(WinGetTitle("")) = "notepad" Then
    MsgBox(0, "", "Notepad Window")
EndIf

<{POST_SNAPBACK}>

But winclose only goes for the exact name on the window, not the converted name.
Posted

Try this...

$WinTitle = WinGetTitle("")
If StringUpper($WinTitle) = "NOTEPAD" Then
   MsgBox(0, "", "Notepad window..." & @CRLF & "Click OK to close it!")
   WinClose($WinTitle, "")
EndIf
Posted

That only works on the currently active window. There is also a winlist function in the unstable that would show all the windows, and you can do a loop to see if one has notepad in the title.

Who else would I be?
Posted

Try this...

$WinTitle = WinGetTitle("")
If StringUpper($WinTitle) = "NOTEPAD" Then
   MsgBox(0, "", "Notepad window..." & @CRLF & "Click OK to close it!")
   WinClose($WinTitle, "")
EndIf

<{POST_SNAPBACK}>

I need it to work with Opt("WinTitleMatchMode", 2)
Posted

...And your point is?

<{POST_SNAPBACK}>

My point is, I need it to work with Opt("WinTitleMatchMode", 2) .

That option will catch all window titles regardless example: to close the windows Notepad will be closed with Note, pad, Notepads. But I can't close Notepad titles using notepad, notePad because of the case sensitive.

Posted

..still, your point is? You haven't even tried the code you have been submitted or you wouldn't be saying something like this.

<{POST_SNAPBACK}>

Those code doesn't even close my notepad windows.
Posted

As I said before, unless the currently active window is one with a title of notepad, then it won't work. Larry's script, however, will work on the latest unstable.

Who else would I be?
Posted

I don't see WinList documentations yet...

but, this works...

$array = WinList()

For $i = 1 to $array[0][0]
   If StringInStr(StringUpper($array[$i][0]),"NOTEPAD") Then _
          WinClose($array[$i][0])
Next

Lar.

<{POST_SNAPBACK}>

I got a winlist unknown function :)
Posted

No, means that the function names are unstable (can change function names from version to version)

<{POST_SNAPBACK}>

Thanks. will try that.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...