Giulio

Script stops when running a program

26 posts in this topic

#1 ·  Posted

Hi guys, just for fun I wanted to make a script to log in my ts3 server automatically

this to open the ts3 client

ShellExecute( "C:\Program Files\TeamSpeak 3 Client\ts3client_win64.exe" )

then insert the comination CTRL+S to open the window with the server details

Send("^s")

 but I noticed that the script complitely stops when the client runs up (without any error from AutoIt).

To have a confirm I replaced the last string with

MouseClick("left", 43, 34, 1, 100)

(the button "connect").

Indeed, once the client is opened, the mouse stopped at the middle of the sceen instead of going at the button.

Any solution to this?

Share this post


Link to post
Share on other sites



#2 ·  Posted

Hello Giulio :)

Did you try to check if the Window lost focus?

Can you please post the script?

 


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#3 ·  Posted

3 hours ago, FrancescoDiMuro said:

Can you please post the script?

ShellExecute( "C:\Program Files\TeamSpeak 3 Client\ts3client_win64.exe" )
Sleep(3000)
Send("^s")
Sleep(500)
Send("{ENTER}")

But when the client opens nothing happens 

 

3 hours ago, FrancescoDiMuro said:

Did you try to check if the Window lost focus?

yes I put Sleep(3000) to let him wait 3 seconds but my pc opens the client in 1 second, during the remaining 2 seconds I tried to click manually on the top on the window to make me sure that the window had focus on

 

So I tried to replace the send() and sleep() with the MouseClick("left", 43, 34, 1, 100) and I noticed that the mouse (with speed at 100) stopped in the middle of the screen instead of going to the 43, 34 button, when the client was fully loaded

Share this post


Link to post
Share on other sites

#4 ·  Posted

3 minutes ago, Giulio said:
ShellExecute( "C:\Program Files\TeamSpeak 3 Client\ts3client_win64.exe" )
Sleep(3000)
Send("^s")
Sleep(500)
Send("{ENTER}")

But when the client opens nothing happens 

 

yes I put Sleep(3000) to let him wait 3 seconds but my pc opens the client in 1 second, during the remaining 2 seconds I tried to click manually on the top on the window to make me sure that the window had focus on

 

So I tried to replace the send() and sleep() with the MouseClick("left", 43, 34, 1, 100) and I noticed that the mouse (with speed at 100) stopped in the middle of the screen instead of going to the 43, 34 button, when the client was fully loaded

I googled "automate teamspeak login", and I found this:

http://forum.teamspeak.com/threads/66422-Auto-Login

Maybe could help you :)

 


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#6 ·  Posted

Try to move the mouse in another area... It's awkward that the mouse stops in the middle of the screen.

And, you could try another thing: instead of moveing the mouse, could you arrive at the Server Details with keyboard?

If so, you could use 

; Use $n for specify the number of times the key has to be sent

Local $n = 3

Send("{TAB $n}")

to "arrive" to Server Details ( maybe )

Hope that helps :) 


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#7 ·  Posted

13 minutes ago, FrancescoDiMuro said:

And, you could try another thing: instead of moveing the mouse, could you arrive at the Server Details with keyboard?

Yes it's CTRL+S and it doesn't work

 

14 minutes ago, FrancescoDiMuro said:

Try to move the mouse in another area... It's awkward that the mouse stops in the middle of the screen.

Everywhere I chose the mouse to go it stops when the client finish' to open

Share this post


Link to post
Share on other sites

#8 ·  Posted

Just now, Giulio said:

Yes it's CTRL+S and it doesn't work

(works manually)

Share this post


Link to post
Share on other sites

#9 ·  Posted

ShellExecute( "C:\Program Files\TeamSpeak 3 Client\ts3client_win64.exe")
WinActivate("Here goes the Title of TeamSpeak")
Sleep(3000)
Send("^s")
Sleep(500)
Send("{ENTER}")

or

Run("C:\Program Files\TeamSpeak 3 Client\ts3client_win64.exe")
Sleep(1000)
WinActivate("Here goes the Title of TeamSpeak")
Sleep(1000)
Send("^s")
Sleep(500)
Send("{ENTER}")

 


ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Share this post


Link to post
Share on other sites

#10 ·  Posted

31 minutes ago, 232showtime said:
ShellExecute( "C:\Program Files\TeamSpeak 3 Client\ts3client_win64.exe")
WinActivate("Here goes the Title of TeamSpeak")
Sleep(3000)
Send("^s")
Sleep(500)
Send("{ENTER}")

 

the script still blocks when the client is loaded

 

32 minutes ago, 232showtime said:

 

Run("C:\Program Files\TeamSpeak 3 Client\ts3client_win64.exe")
Sleep(1000)
WinActivate("Here goes the Title of TeamSpeak")
Sleep(1000)
Send("^s")
Sleep(500)
Send("{ENTER}")

 

with Run() it doesn't open the client neither ( I had already tried before putting ShellExecute() )

Share this post


Link to post
Share on other sites

#11 ·  Posted

@Giulio 

Can you do what I've suggested before? Instead of clicking function, can you go to Server Details with TABs? :) 


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#12 ·  Posted

2 minutes ago, FrancescoDiMuro said:

@Giulio 

Can you do what I've suggested before? Instead of clicking function, can you go to Server Details with TABs? :) 

It's with CTRL+S

Share this post


Link to post
Share on other sites

#13 ·  Posted

Just add #RequireAdmin at the top of your script it will open the server properties after that, well it does for me anyway.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

27 minutes ago, Giulio said:

It's with CTRL+S

Fixed buddy :)

#include <MsgBoxConstants.au3>

; Name of the process you want to launch
Local $sProcess = StringReplace(@AppDataDir, "Roaming", "Local") & "\TeamSpeak 3 Client\ts3client_win64.exe"

; Store the PID of the process to launch
Local $iPID = ShellExecute($sProcess, "", "", "", @SW_SHOW)

; Retrieve the list of the windows opened, hide...
Local $aWinList = WinList()

; Hwnd of the process
Local $hProcess = ""

Do
    For $i = 1 To $aWinList[0][0]
        If $aWinList[$i][0] <> "" Then
            ; If the Process stored in $aWinList[$i][1] is equals to $iPID, then, assign the hWnd of the $aWinList[$i][1] to $hProcess, and ExitLoop
            If WinGetProcess($aWinList[$i][1]) = $iPID Then
                $hProcess = $aWinList[$i][1]
                ExitLoop
            EndIf
        EndIf
    Next
Until $hProcess = ""

; Activate the window ( TeamSpeak 3 )

WinActivate($hProcess, "TeamSpeak 3")

; Send TAB before doing anything else

Send("{TAB}", 0)

; Send CTRL + s to open Server Details, and do whatever you want :)

Send("^s", 0)

Hope that helps :) 

 

 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#15 ·  Posted

13 minutes ago, FrancescoDiMuro said:

Fixed buddy :)

#include <MsgBoxConstants.au3>

; Name of the process you want to launch
Local $sProcess = StringReplace(@AppDataDir, "Roaming", "Local") & "\TeamSpeak 3 Client\ts3client_win64.exe"

; Store the PID of the process to launch
Local $iPID = ShellExecute($sProcess, "", "", "", @SW_SHOW)

; Retrieve the list of the windows opened, hide...
Local $aWinList = WinList()

; Hwnd of the process
Local $hProcess = ""

Do
    For $i = 1 To $aWinList[0][0]
        If $aWinList[$i][0] <> "" Then
            ; If the Process stored in $aWinList[$i][1] is equals to $iPID, then, assign the hWnd of the $aWinList[$i][1] to $hProcess, and ExitLoop
            If WinGetProcess($aWinList[$i][1]) = $iPID Then
                $hProcess = $aWinList[$i][1]
                ExitLoop
            EndIf
        EndIf
    Next
Until $hProcess = ""

; Activate the window ( TeamSpeak 3 )

WinActivate($hProcess, "TeamSpeak 3")

; Send TAB before doing anything else

Send("{TAB}", 0)

; Send CTRL + s to open Server Details, and do whatever you want :)

Send("^s", 0)

Hope that helps :) 

Ok. I can't understand this.

By the way he can't find the file

 

 

Share this post


Link to post
Share on other sites

#16 ·  Posted

@FrancescoDiMuro - Doesn't work for me unless I add #RequireAdmin to the top of your script.

The following code works for me, prefer to use ControlSend then Send:

#RequireAdmin
ShellExecute( "C:\Program Files\TeamSpeak 3 Client\ts3client_win64.exe" )
Local $hWnd = WinWait('TeamSpeak 3', '')
ControlSend($hWnd, "", "", "^s")
ControlSend($hWnd, "", "", "{ENTER}")

 

Share this post


Link to post
Share on other sites

#17 ·  Posted

Just now, Subz said:

@FrancescoDiMuro - Doesn't work for me unless I add #RequireAdmin to the top of your script.

The following code works for me, prefer to use ControlSend then Send:

#RequireAdmin
ShellExecute( "C:\Program Files\TeamSpeak 3 Client\ts3client_win64.exe" )
Local $hWnd = WinWait('TeamSpeak 3', '')
ControlSend($hWnd, "", "", "^s")
ControlSend($hWnd, "", "", "{ENTER}")

 

This work for me, without #RequireAdmin.


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#19 ·  Posted

3 minutes ago, Giulio said:

 

@Giulio

Replace this:

Quote
; Name of the process you want to launch
Local $sProcess = StringReplace(@AppDataDir, "Roaming", "Local") & "\TeamSpeak 3 Client\ts3client_win64.exe"

with this:

Quote
; Name of the process you want to launch
Local $sProcess = "C:\Program Files\TeamSpeak 3 Client\ts3client_win64.exe"

 

 


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#20 ·  Posted

3 minutes ago, FrancescoDiMuro said:

@Giulio

Replace this:

with this:

 

tried but the script still blocks when the client is open, even with #requireadmin

 

9 minutes ago, Subz said:

 

#RequireAdmin
ShellExecute( "C:\Program Files\TeamSpeak 3 Client\ts3client_win64.exe" )
Local $hWnd = WinWait('TeamSpeak 3', '')
ControlSend($hWnd, "", "", "^s")
ControlSend($hWnd, "", "", "{ENTER}")

 

this works for me

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