Jump to content
Sign in to follow this  
Nova

Wait for text ? Then do !

Recommended Posts

Nova

Hi I had an idea for a script and I was woundering if anyone could tell me if it possible to do.

Here is a very basic idea of what Id need to start !

I want an autoit script to wait for a certain word or words to be written on an open msword document and once that word has been typed to do a preset action corrosponding to that word.

Like for example if the word "ring" is typed into the open msword page a sound effect (ring.wav) would be played ?

Can anyone explain to me how this could be done ?

Share this post


Link to post
Share on other sites
konan

this is a example. in a NotePad windows,when you type "ring", it will send("ok"). If the times of "ring" is over 10 , the script is over.

winactivate("Untitled - Notepad")
$site=0
$flag=0
$tm=1
do
   $txt=controlgettext("Untitled - Notepad","","Edit1")
   $inw=stringinstr($txt,"ring",0,$tm)
   if $inw>$site then
      $tm=$tm+1
      $site=$inw
      send("ok")
   endif
   if $tm>10 then
      $flag=1
   endif
   sleep(100)
until $flag=1

Share this post


Link to post
Share on other sites
konan

AutoIt cannot read the text in word. Word uses a "custom" control.

Lar.

<{POST_SNAPBACK}>

Yeah,AutoIt can't do with custon control, so you can use NotePad instead it.

Share this post


Link to post
Share on other sites
Nova

anyideas why this wont work then ?

winactivate("Untitled - Notepad")

   $txt=controlgettext("Untitled - Notepad","","Edit1")
   $check=stringinstr($txt,"ring",0)
   
   If $check=0 Then
   send("ok")   
   else 
   Run('C:\Program Files\iTunes\iTunes.exe "' & 'C:\My Music\soundeffects\ring.wav"')  
   endif


while 1
 sleep(10) 
wend

Share this post


Link to post
Share on other sites
Jos

anyideas why this wont work then ?

<{POST_SNAPBACK}>

Do you want to wait till the text contains "ring" and then Beep ?

WinActivate("Untitled - Notepad")

While 1
   $TXT = ControlGetText("Untitled - Notepad", "", "Edit1")
   $CHECK = StringInStr($TXT, "ring", 0)
   If $CHECK = 0 Then
     ;Send("ok")   
   Else 
      Run('C:\Program Files\iTunes\iTunes.exe "' & 'C:\My Music\soundeffects\ring.wav"')  
      ExitLoop
   EndIf
   Sleep(10) 
Wend

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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  

×