Jump to content

Script stops when running a program


Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

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

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

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

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...