Gleep5 Posted August 2, 2015 Share Posted August 2, 2015 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 WEndScript 2:Local $tvHandle = 0 while True $tvHandle = WinWaitActive("Commercial use suspected") if Not ($tvHandle = 0) Then Send("!+{F4}",0) EndIf WEndScript 3:Local $tvHandle = 0 while True $tvHandle = WinWaitActive("Reconnect to partner") if Not ($tvHandle = 0) Then Send("{Tab}") Send("{Enter}") EndIf WEndScript 4:Local $tvHandle = 0 while True $tvHandle = WinWaitActive("Wait for partner") if Not ($tvHandle = 0) Then Send("{Tab}") Send("{Enter}") EndIf WEndAnyone able to throw this together into one script? Thanks if you can! Link to comment Share on other sites More sharing options...
kylomas Posted August 2, 2015 Share Posted August 2, 2015 Gleep5,Welcome to the forum! Neber having used TeamViewer thisCommercial use suspectedmake 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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 2, 2015 Moderators Share Posted August 2, 2015 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
mikell Posted August 2, 2015 Share Posted August 2, 2015 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 Link to comment Share on other sites More sharing options...
Gleep5 Posted August 2, 2015 Author Share Posted August 2, 2015 Gleep5,Welcome to the forum! Neber having used TeamViewer thismake 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. Link to comment Share on other sites More sharing options...
Gleep5 Posted August 2, 2015 Author Share Posted August 2, 2015 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.M23Yes, 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. Link to comment Share on other sites More sharing options...
Gleep5 Posted August 2, 2015 Author Share Posted August 2, 2015 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! Link to comment Share on other sites More sharing options...
mikell Posted August 2, 2015 Share Posted August 2, 2015 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 commandHave a look at the help file and use the Windows Info Tool (Au3Info.exe) Link to comment Share on other sites More sharing options...
JohnOne Posted August 2, 2015 Share Posted August 2, 2015 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now