AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

IfWinExist - case sensitivity

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
howartp



Joined: 14 Mar 2008
Posts: 5

PostPosted: Fri Mar 14, 2008 2:02 pm    Post subject: IfWinExist - case sensitivity Reply with quote

Hi,

I work in the IT support department in a school, and I'm trying to use AutoHotKey to help crack down on internet misuse. We have proxies and filters in place but there is no keyword searching, so I'm trying to write a small script which runs on the client workstations, watching for given search terms in the IE title bar.

My code is currently:

Code:
BadWords = msn,facebook,proxy

SetTimer, Alert1, 3000
return

Alert1:

Loop, parse, BadWords, `,
{
    IfWinExist, Google Search ahk_class IEFrame, %A_LoopField%
    winclose
    IfWinExist, Yahoo! Search Results ahk_class IEFrame, %A_LoopField%
    winclose
    IfWinExist, Live Search: ahk_class IEFrame, %A_LoopField%
    winclose
    IfWinExist, Dogpile Web Search ahk_class IEFrame, %A_LoopField%
    winclose
      ;SendInput ^{F4}
      Sleep 500
      ;return
}


However, because IfWinExist is case-sensitive (even with StringCaseSense Off), a student searching for 'MsN' will bypass the script.

Is there a) any way of making IfWinExist ignore the case, or b) a simple snippet of code which takes a word and expands/replaces it with all connotations of that word, eg msn,msN,mSn,mSN,Msn,MsN,MSn,MSN to save me having to write every connotation of every word I want to filter?

I've found a few references to case-sensitivity on these forums and the help file but none of them seem to apply to IfWinExist.

Thanks in advance,

Peter
Back to top
View user's profile Send private message
HugoV



Joined: 27 May 2007
Posts: 650

PostPosted: Fri Mar 14, 2008 2:14 pm    Post subject: Reply with quote

Why not:
- WinGetActiveTitle
- Loop, Parse a string
- use the case insensitive IfInString to see if any of the bad words occur in the title
Back to top
View user's profile Send private message
jaco0646



Joined: 07 Oct 2006
Posts: 666
Location: MN, USA

PostPosted: Fri Mar 14, 2008 2:21 pm    Post subject: Reply with quote

You could also use the RegEx option of SetTitleMatchMode, which is case insensitive and also provides more flexibility in your search terms.
_________________
http://autohotkey.net/~jaco0646/
Back to top
View user's profile Send private message Visit poster's website
howartp



Joined: 14 Mar 2008
Posts: 5

PostPosted: Sat Mar 15, 2008 10:27 pm    Post subject: Reply with quote

Thanks for those suggestions.

I'll have a look when I get back to work on Monday.

I might well be back... Smile

Cheers,

Peter
Back to top
View user's profile Send private message
howartp



Joined: 14 Mar 2008
Posts: 5

PostPosted: Mon Mar 17, 2008 9:46 am    Post subject: Reply with quote

Quote:
You could also use the RegEx option of SetTitleMatchMode, which is case insensitive and also provides more flexibility in your search terms.


Fantastic - that works great!

I'm not great on regex's - is it possible to generate this in regex:

f*c*b*k (ie facebook, but with the a, e and o replaced by wildcards?)

(Or, having just thought further - is that a valid regex? Or would it be something like:

f[a-z*]c[a-z*]b[a-z*]k

Once i've got that, I can probably work from it to generate the others such as proxy and myspace.

Cheers,

Peter
Back to top
View user's profile Send private message
Oberon



Joined: 18 Feb 2008
Posts: 453

PostPosted: Mon Mar 17, 2008 9:56 am    Post subject: Re: IfWinExist - case sensitivity Reply with quote

howartp wrote:
I work in the IT support department in a school, and I'm trying to use AutoHotKey to help crack down on internet misuse.
You're evil lol. This method isn't great because legitimate sites would also be blocked, for example if someone wanted to read something on the BBC news site about 'facebook' they'll be unfairly penalised.

howartp wrote:
f*c*b*k (ie facebook, but with the a, e and o replaced by wildcards?)
You can use \w or [a-z] followed by an * to indicate zero or more of the previous character class, e.g. f\w*c\w*b\w*k
Back to top
View user's profile Send private message
howartp



Joined: 14 Mar 2008
Posts: 5

PostPosted: Mon Mar 17, 2008 11:02 am    Post subject: Reply with quote

Quote:
You're evil lol.

I know...Very Happy but it is becoming an issue that needs dealing with somehow.
Quote:
This method isn't great because legitimate sites would also be blocked, for example if someone wanted to read something on the BBC news site about 'facebook' they'll be unfairly penalised.

Yeah, I've got a process in place to avoid this. The script reads a couple of text files from the network in which <those I choose to trust> can put exclusions by room or user. There's also a 'reload' keyboard shortcut in case we get a call mid-lesson. So if Mr Bloggs is doing a lesson on the dangers of social networking, or Mrs Smith wants 5 students to read a BBC page, we can allow that instantly.

Thanks for the regex code; I'll have a play.

Peter
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group