Jump to content

Func processclose for web browsers


Recommended Posts

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 by bordomavi
Link to comment
Share on other sites

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

Global $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

?

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

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 by Danp2
Link to comment
Share on other sites

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

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 by bordomavi
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...