Sign in to follow this  
Followers 0
MarkJoel60

Strangeness with AutoIt and GoogleTalk

11 posts in this topic

#1 ·  Posted (edited)

Hello All. I am creating a little script that will fire and alert me, using my GoogleTalk Chat. I got something to work, but I had to do a really strange kludge, and I am wondering if someone has a better way of doing this.

So, I want to login to GoogleTalk, and send a message to myself. But, Google Talk has no buttons or control codes to initiate a chat. The only way I can see to do it is search for a contact. The problem is that there is a lag until GoogleTalk is active (while it logs in). Waiting until Active on the window does not work, since the window is ACTIVE, it's just the server is busy. I even search the screen text for information (which you can see in the script) but this is apparently active before the log-in is complete, so that doesn't help.

I thought to put a sleep command in, but when I do that, GoogleTalk sleeps as well!

It takes a mouse click to start things back up again. So, I sleep, then move the mouse into the GoogleTalk Window, and then click, and this works -- 99% of the time.

Anyone have any ideas? (BTW, you can see the strangeness I am talking about it you comment out the line right after Sleep(3000)

Here is the script. This assumes there is a person in your contacts whose name can be found by using the string: "Mark".

Run("C:\Program Files\Google\Google Talk\googletalk.exe")
WinWaitActive("Google")
$loggedIn = False
AutoItSetOption("WinDetectHiddenText", 1)
$location = 0
while $loggedIn == false
     $res = WinGetText("Google")
     $location = StringInStr($res, "Search All Contacts",0)
        if $location > 0 Then
            $loggedIn = True
        EndIf
WEnd
    
Sleep(3000) 
MouseClick("left",1175,388)

ControlSend("Google", "", "[CLASS:RichEdit20W; INSTANCE:3]", "Mark{ENTER}") 

;WinWaitActive("Mark")
Send("Message from AutoIt{ENTER}")
Edited by MarkJoel60

Share this post


Link to post
Share on other sites



GoogleTak hasn't seen any improvements for a while. Google actually needs to release a new version with many enhancements. Tons of users have complained/asked for things and GoogleTalk hasn't changed in years. It even still says beta on it.

What exactly are you trying to do? I'm sure there are other ways you can send messages to yourself that don't include buggy non-standard software.

Share this post


Link to post
Share on other sites

Why dont you try using tcp commands since you obviously are on 2 different computers? This will stop you from having to try using google talk and you can make the alert as big or as small as you want.

Share this post


Link to post
Share on other sites

Sorry about double post but cant edit for some reason button doesnt work, its prob the same problem but have you tried doing a loop with a counter and a much smaller sleep till counter hits a amount to see if google will have the same effect?

Share this post


Link to post
Share on other sites

Hey, thanks for the replies...

Well, what I am trying to do is set up an automated program that runs different tests and things and if it hits an event, it messages me (or someone else if they want). I want to be able to push the message out to a handheld device. There aren't many choices on those things for messaging software. You have AIM, Yahoo (maybe) Skype and Google. Ideally, the routine could send it to any of them.

The reason I wanted to use GoogleTalk was I was testing on a Nokia 810N, and it has GoogleTalk. The box says it has Skype, but it doesn't ... long story.

I found a program called Pidgeon, and it will send messages to GoogleTalk. But I was hoping my routine would be versatile enouh to use virtually any chat software for the alerts.

The TCP messages sound like a good idea, but I think I need to be able to install software on the handheld then, right? I don' think I have access to the handhelds for that...

The thing is that my problem seems to be in Auto It, not Google. I could be wrong. But it seems like something weird is happening during the Auto It Sleep() function....

I guess from what I'm hearing thoguh, I'd be better off using Pidgeon than GoogleTalk to send, eh?

Share this post


Link to post
Share on other sites

Google's GoogleTalk has issues. I can verify that and so can many others.

Using Pidgin is a good suggestion. It uses standard controls and can easily be automated. I've had it connect to GoogleTalk without any problems.

Share this post


Link to post
Share on other sites

Google's GoogleTalk has issues. I can verify that and so can many others.

Using Pidgin is a good suggestion. It uses standard controls and can easily be automated. I've had it connect to GoogleTalk without any problems.

OK.. thanks for the advice... I guess I'll go that route then...

Share this post


Link to post
Share on other sites

Google's GoogleTalk has issues. I can verify that and so can many others.

Using Pidgin is a good suggestion. It uses standard controls and can easily be automated. I've had it connect to GoogleTalk without any problems.

Richard (or anyone), I was wondering how well you know Pidgin... I have it working, but a preference option will kill the script (and I hate that).

Pidgin has a setting in preferences called:

"Show System Tray Icon" If it is set to "ALWAYS" then when you first kick off Pidgin, it is minimized to the system tray. None of the calls I make (ie WinActivate) seem to work.

Strangely, if it is already running and minimized, then everything is fine. The First call to Pidgin will make it the active window, and everything works from there. But, if I kick off the new Pidgin session, then it will NOT activate the window, and I am screwed.

So, I can either make sure that the option to start as a System tray is turned off, or I can always make sure Pidgin is running before my script is called, but I would rather have the system be more bullet-proof than that.

Here is my script (Again, the code setting the $ContactName variable has to be someone in your list):

Any ideas?

If $CmdLine[0] = 0 Then 
    $ContactName = "markjoel60@MYEMAIL.COM{ENTER}"
Else
  $ContactName = $CmdLine[1] & "{ENTER}"
EndIf
  


if WinExists("Buddy List") Then
    Run("C:\Program Files\Pidgin\Pidgin.exe")
    WinActivate("Buddy List")
    WinWaitActive("Buddy List")
Else
  ;*********
  ; This doesn't work if Pidgin is minimize to tray!
  ;*************************************************   
    Run("C:\Program Files\Pidgin\Pidgin.exe")
    WinActivate("Buddy List")
;   WinWaitActive("Buddy List")
    
Sleep(2000) 

EndIf

$size = WinGetPos("[active]")
MouseClick("Left", $size[0] + 35, $size[1] + 39)   ; hit buddies drop down list
MouseClick("Left", $size[0] + 71, $size[1] + 64)    ; hit Send IM option

Send($ContactName)
$CNLen = StringLen($ContactName)
$CNLen -= 7 ; get rid of the {ENTER} suffix
$winName = StringLeft($ContactName, $CNLen)
WinWaitActive($winName)
Send("Message from AutoIt{ENTER}")
Send("{ESCAPE}")
MouseClick("Left", $size[0] + 241, $size[1] + 18)

Share this post


Link to post
Share on other sites

I suggest just don't minimize to tray. You could also mess with some tray UDFs and activate the window again from the tray icon.

Share this post


Link to post
Share on other sites

I suggest just don't minimize to tray. You could also mess with some tray UDFs and activate the window again from the tray icon.

Yeah, but I want to be bullet proof in case my user does something unpredictable...

Anyway, I have a kludge that works. Bascially, I call Pidgin, and then sleep, and call it again. This seems to work OK... so I'm good for now.

Thanks for the advice!

if WinExists("Buddy List") Then
    Run("C:\Program Files\Pidgin\Pidgin.exe")
    WinActivate("Buddy List")
    WinWaitActive("Buddy List")
Else
  ;*********
  ; This doesn't work if Pidgin is minimize to tray!
  ;*************************************************   
    Run("C:\Program Files\Pidgin\Pidgin.exe")
    WinActivate("Buddy List")
    Sleep(2000)
    Run("C:\Program Files\Pidgin\Pidgin.exe")   
    Sleep(1000)
    

EndIf

Share this post


Link to post
Share on other sites

That's why I suggested you try some tray manipulation. I've never worked with it, so I don't know what the necessary UDFs are.

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