bordomavi Posted August 7, 2014 Share Posted August 7, 2014 (edited) i created this code but not working. and if 2 browsers are runnig what can i do? Func _browser() If ProcessExists("firefox.exe") Then $name = "FireFox" And $exe = "Firefox.exe" If ProcessExists("palemoon.exe") Then $name = "PaleMoon" And $exe = "palemoon.exe" If ProcessExists("opera.exe") Then $name = "Opera" And $exe = "Opera.exe" If ProcessExists("safari.exe") Then $name = "Safari" And $exe = "Safari.exe" If ProcessExists("waterfox.exe") Then $name = "WaterFox" And $exe = "waterfox.exe" If ProcessExists("cyberfox.exe") Then $name = "CyberFox" And $exe = "cyberfox.exe" If ProcessExists("iexplore.exe") Then $name = "Internet Explorer" And $exe = "iexplore.exe" If ProcessExists("yandex.exe") Then $name = "Yandex" And $exe = "yandex.exe" If ProcessExists("maxthon.exe") Then $name = "Maxthon" And $exe = "maxthon.exe" If ProcessExists("dragon.exe") Then $name = "Comodo Dragon" And $exe = "dragon.exe" If ProcessExists("IceDragon.exe") Then $name = "Comodo Dragon" And $exe = "IceDragon.exe" If ProcessExists("chrome.exe") Then $name = "Chrome" And $exe = "Chrome.exe" EndFunc If ProcessExists($exe) Then If MsgBox(4, "Warning !", $name & "browser is running. Do you want close it ?") = 6 Then ProcessClose($exe) Else Exit EndIf EndIf Edited August 7, 2014 by bordomavi Link to comment Share on other sites More sharing options...
Muzaiyan Posted August 7, 2014 Share Posted August 7, 2014 Actually i was working on a project and there i used a function similar to this i just edit your script hope i did the right. . .Tell me if i am expandcollapse popupGlobal $exe = "", $name = "" _Browser_Processes() Func _Browser_Processes() If ProcessExists("firefox.exe") Then $name &= "FireFox|" $exe &= "Firefox.exe|" EndIf If ProcessExists("palemoon.exe") Then $name &= "PaleMoon|" $exe &= "palemoon.exe|" EndIf If ProcessExists("opera.exe") Then $name &= "Opera|" $exe &= "Opera.exe|" EndIf If ProcessExists("safari.exe") Then $name &= "Safari|" $exe &= "Safari.exe|" EndIf If ProcessExists("waterfox.exe") Then $name &= "WaterFox|" $exe &= "waterfox.exe|" EndIf If ProcessExists("cyberfox.exe") Then $name &= "CyberFox|" $exe &= "cyberfox.exe|" EndIf If ProcessExists("iexplore.exe") Then $name &= "Internet Explorer|" $exe &= "iexplore.exe|" EndIf If ProcessExists("yandex.exe") Then $name &= "Yandex|" $exe &= "yandex.exe|" EndIf If ProcessExists("maxthon.exe") Then $name &= "Maxthon|" $exe &= "maxthon.exe|" EndIf If ProcessExists("dragon.exe") Then $name &= "Comodo Dragon|" $exe &= "dragon.exe|" EndIf If ProcessExists("IceDragon.exe") Then $name &= "Comodo Dragon|" $exe &= "IceDragon.exe|" EndIf If ProcessExists("chrome.exe") Then $name &= "Chrome|" $exe &= "Chrome.exe|" EndIf If StringRight($name, 1) = "|" Then $name = StringTrimRight($name, 1) If StringRight($exe, 1) = "|" Then $exe = StringTrimRight($exe, 1) If StringInStr($name, "|") Or StringInStr($exe, "|") Then $name = StringSplit($name, "|") $exe = StringSplit($exe, "|") EndIf EndFunc ;==>_Browser_Processes #include <Array.au3> _ArrayDisplay($name, "Browsers") _ArrayDisplay($exe, "Processes") ;~ If ProcessExists($exe) Then ;~ If MsgBox(4, "Warning !", $name & "browser is running. Do you want close it ?") = 6 Then ;~ ProcessClose($exe) ;~ Else ;~ Exit ;~ EndIf ;~ EndIf Link to comment Share on other sites More sharing options...
mikell Posted August 7, 2014 Share Posted August 7, 2014 ? Local $array[3][2] = [ _ ["firefox.exe", "FireFox"], _ ["iexplore.exe", "Internet Explorer"], _ ["chrome.exe", "Google Chrome"] ] For $i = 0 to 2 If ProcessExists($array[$i][0]) Then If MsgBox(4, "Warning !", $array[$i][1] & "browser is running. Do you want close it ?") = 6 Then _ ProcessClose($array[$i][0]) EndIf Next Link to comment Share on other sites More sharing options...
Danp2 Posted August 7, 2014 Share Posted August 7, 2014 (edited) Local $aBrowsers[12][2] = [["firefox.exe", "Firefox"], _ ["palemoon.exe", "PaleMoon"], _ ["opera.exe", "Opera"], _ ["safari.exe", "Safari"], _ ["waterfox.exe", "WaterFox"], _ ["cyberfox.exe", "CyberFox"], _ ["iexplore.exe", "Internet Explorer"], _ ["yandex.exe", "Yandex"], _ ["maxthon.exe", "Maxthon"], _ ["dragon.exe", "Comodo Dragon"], _ ["IceDragon.exe", "Comodo Dragon"], _ ["chrome.exe", "Chrome"]] For $i = 0 To UBound($aBrowsers) - 1 If ProcessExists($aBrowsers[$i][0]) Then If MsgBox(4, "Warning !", $aBrowsers[$i][1] & " browser is running. Do you want close it ?") = 6 Then ProcessClose($aBrowsers[$i][0]) EndIf EndIf Next Edited August 7, 2014 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mikell Posted August 7, 2014 Share Posted August 7, 2014 (edited) Danp2, Amazing... exactly the same idea at the same time Edit except for the ProcessClose Edited August 7, 2014 by mikell Link to comment Share on other sites More sharing options...
bordomavi Posted August 7, 2014 Author Share Posted August 7, 2014 Local $aBrowsers[12][2] = [["firefox.exe", "Firefox"], _ ["palemoon.exe", "PaleMoon"], _ ["opera.exe", "Opera"], _ ["safari.exe", "Safari"], _ ["waterfox.exe", "WaterFox"], _ ["cyberfox.exe", "CyberFox"], _ ["iexplore.exe", "Internet Explorer"], _ ["yandex.exe", "Yandex"], _ ["maxthon.exe", "Maxthon"], _ ["dragon.exe", "Comodo Dragon"], _ ["IceDragon.exe", "Comodo Dragon"], _ ["chrome.exe", "Chrome"]] For $i = 0 To UBound($aBrowsers) If ProcessExists($aBrowsers[$i][0]) Then If MsgBox(4, "Warning !", $aBrowsers[$i][1] & " browser is running. Do you want close it ?") = 6 Then ProcessClose($aBrowsers[$i][1]) EndIf EndIf Next if 2 browsers are running in same time does this script work? Link to comment Share on other sites More sharing options...
mikell Posted August 7, 2014 Share Posted August 7, 2014 Did you try the script before asking ? Link to comment Share on other sites More sharing options...
bordomavi Posted August 7, 2014 Author Share Posted August 7, 2014 Did you try the script before asking ? lol no i have 1 browser Link to comment Share on other sites More sharing options...
mikell Posted August 7, 2014 Share Posted August 7, 2014 Haha I see So believe me : it works , assuming you first corrected ProcessClose($array[$i][1]) to ProcessClose($array[$i][0]) Link to comment Share on other sites More sharing options...
bordomavi Posted August 7, 2014 Author Share Posted August 7, 2014 ok thanks Link to comment Share on other sites More sharing options...
bordomavi Posted August 7, 2014 Author Share Posted August 7, 2014 i tried it doesn't work. doesn't close .exe Link to comment Share on other sites More sharing options...
mikell Posted August 7, 2014 Share Posted August 7, 2014 Did you replace in the code ProcessClose($Browsers[$i][1]) by ProcessClose($Browsers[$i][0]) ? Link to comment Share on other sites More sharing options...
bordomavi Posted August 7, 2014 Author Share Posted August 7, 2014 i didn't see sory. now working thanks. Link to comment Share on other sites More sharing options...
bordomavi Posted August 7, 2014 Author Share Posted August 7, 2014 (edited) but i dont understand why this script doesnt read other lines ? for example : Local $aBrowsers[12][2] = [["firefox.exe", "Firefox"], _ ["palemoon.exe", "PaleMoon"], _ ["opera.exe", "Opera"], _ ["safari.exe", "Safari"], _ ["waterfox.exe", "WaterFox"], _ ["cyberfox.exe", "CyberFox"], _ ["iexplore.exe", "Internet Explorer"], _ ["yandex.exe", "Yandex"], _ ["maxthon.exe", "Maxthon"], _ ["dragon.exe", "Comodo Dragon"], _ ["IceDragon.exe", "Comodo Dragon"], _ ["chrome.exe", "Chrome"]] For $i = 0 To UBound($aBrowsers) If ProcessExists($aBrowsers[$i][0]) Then If MsgBox(4, "Warning !", $aBrowsers[$i][1] & " browser is running. Do you want close it ?") = 6 Then ProcessClose($aBrowsers[$i][0]) EndIf EndIf Next MsgBox(0, ":) !", "Hello world") Edited August 7, 2014 by bordomavi Link to comment Share on other sites More sharing options...
mikell Posted August 7, 2014 Share Posted August 7, 2014 Because there is an other error in the script For $i = 0 To UBound($aBrowsers) - 1 Link to comment Share on other sites More sharing options...
Danp2 Posted August 7, 2014 Share Posted August 7, 2014 except for the ProcessClose Edit Fixed. ;-) Latest Webdriver UDF Release Webdriver Wiki FAQs 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