Sign in to follow this  
Followers 0
Killer

How to make case unsensitive?

16 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Try this...

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

...And your point is?


Who else would I be?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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


Who else would I be?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

Read Above^


Who else would I be?

Share this post


Link to post
Share on other sites

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


Who else would I be?

Share this post


Link to post
Share on other sites

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

<{POST_SNAPBACK}>

Thanks. will try that.

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  
Followers 0