Gleep5

Help combining scripts...

9 posts in this topic

I have four scripts I would like to combine, but my skills in coding are beyond subpar with autoit.  Can someone help me combine these into one script?  I have all four running right now seperately, but the CPU usage is around 2% for each one... seems pretty overkill considering what their task is.  Each script kills a popup from Teamviewer.

Script 1:

Local $tvHandle = 0
while True
$tvHandle = WinWaitActive("Sponsored session")
if Not ($tvHandle = 0) Then
Send("{Enter}")
EndIf
WEnd

Script 2:

Local $tvHandle = 0
while True
$tvHandle = WinWaitActive("Commercial use suspected")
if Not ($tvHandle = 0) Then
Send("!+{F4}",0)
EndIf
WEnd

Script 3:

Local $tvHandle = 0
while True
$tvHandle = WinWaitActive("Reconnect to partner")
if Not ($tvHandle = 0) Then
Send("{Tab}")
Send("{Enter}")
EndIf
WEnd

Script 4:

Local $tvHandle = 0
while True
$tvHandle = WinWaitActive("Wait for partner")
if Not ($tvHandle = 0) Then
Send("{Tab}")
Send("{Enter}")
EndIf
WEnd

Anyone able to throw this together into one script?  Thanks if you can!

Share this post


Link to post
Share on other sites



Gleep5,

Welcome to the forum!  Neber having used TeamViewer this

Commercial use suspected

make me suspicious of a violation of forum rules.  Please read them.  I will point out that if you look n the Help file for WinWaitActive you will see that combining these scripts will not work.

Probably overly cautious but will wait for a MOD to weigh in.

kylomas

 


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Hi,

From what I can see on the TeamViewer forum they are happy with the use of such scripts - as a result, so am I.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

You can't use WinWait* if checking several windows...
This should work (Untested)

Local $aTitles[5] = [4, "Sponsored session", "Commercial use suspected", "Reconnect to partner", "Wait for partner"]
While 1
    For $i = 1 to $aTitles[0]     ; loop throught the titles array
       If WinExists($aTitles[$i]) Then   ; if window exists then
            WinActivate($aTitles[$i])   ; activate it
             Switch $i    ; check the title index in the array
                Case 1
                      Send("{Enter}")   
                Case 2
                      Send("!+{F4}",0)
                Case 3, 4
                     Send("{Tab}")
                     Send("{Enter}")
             EndSwitch
         EndIf
    Next
    Sleep(10)   ; spare the cpu
Wend

 

Share this post


Link to post
Share on other sites

Gleep5,

Welcome to the forum!  Neber having used TeamViewer this

make me suspicious of a violation of forum rules.  Please read them.  I will point out that if you look n the Help file for WinWaitActive you will see that combining these scripts will not work.

Probably overly cautious but will wait for a MOD to weigh in.

kylomas

 

I contacted them to see if I could buy some type of "home" user license since paying 1500 dollars is a bit absurd for the 13 computers I control.  I think there is a limit of 10 or 12 before the "commercial use suspected" window appears... I have one computer too many I guess.  :/  They apologized but politely pointed out that dishonest companies would take advantage of that as well... paraphrasing of course. 

Share this post


Link to post
Share on other sites

Hi,

From what I can see on the TeamViewer forum they are happy with the use of such scripts - as a result, so am I.

M23

Yes, they already have a couple threads on their forums discussing how to close the nagware - they are cool with it.  They just didn't have any combined scripts that I saw and I figured I'd get more expert help using AutoIT here.

Share this post


Link to post
Share on other sites

You can't use WinWait* if checking several windows...
This should work (Untested)

Local $aTitles[5] = [4, "Sponsored session", "Commercial use suspected", "Reconnect to partner", "Wait for partner"]
While 1
    For $i = 1 to $aTitles[0]     ; loop throught the titles array
       If WinExists($aTitles[$i]) Then   ; if window exists then
            WinActivate($aTitles[$i])   ; activate it
             Switch $i    ; check the title index in the array
                Case 1
                      Send("{Enter}")   
                Case 2
                      Send("!+{F4}",0)
                Case 3, 4
                     Send("{Tab}")
                     Send("{Enter}")
             EndSwitch
         EndIf
    Next
    Sleep(10)   ; spare the cpu
Wend

 

This appears to work!  At least it closed the "Like" window already... haven't tested the others yet.  :)  CPU usage is only 3.1% instead of four processes at 2 - I say that's a total win! :)  Thanks so much!

Share this post


Link to post
Share on other sites

Glad I could help  :)

BTW it would be much cleaner to use ControlSend() instead of Send()

ControlSend($aTitles[$i], "", $control, "{Enter}")   ; $control = the button to command

Have a look at the help file and use the Windows Info Tool (Au3Info.exe)

Share this post


Link to post
Share on other sites

I'd put more sleep than that...

While 1
    For $i = 1 to $aTitles[0]     ; loop throught the titles array
       If WinExists($aTitles[$i]) Then   ; if window exists then
            WinActivate($aTitles[$i])   ; activate it
             Switch $i    ; check the title index in the array
                Case 1
                      Send("{Enter}")   
                Case 2
                      Send("!+{F4}",0)
                Case 3, 4
                     Send("{Tab}")
                     Send("{Enter}")
             EndSwitch
         EndIf
         Sleep(10)
    Next
    Sleep(100)   ; spare the cpu
Wend

 


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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