Q:

Minimizing the CMD window during code execution

Attaching the snippet of my code.
Objective: I am trying to ping a website for certain interval of time (User defined). If the URL works, it will open the webpage in the default browser. If not it will keep pinging until the user defined time interval expires.
Issue: Code works perfectly but at instruction
response = os.system("ping " + url)
it pops up the cmd window on screen and I need to minimize it every time. It is irritating to do it manually all the time. Is there any way I can resize the terminal window or make it minimize all the time until the code expires?
A little manual study of OS lands me to os.get_terminal_size() but nothing much. I also looked into some other libraries that can resolve the issue but does not get any information 
import os, time, webbrowser

#Enter URL that need to check. Add input()
url = "167.6.2.200"
input_time = float(input("How long ping should work: "))

current_time = time.time()   #note current time
actual_time = 0
isHostOn=0

#r = (os.get_terminal_size())
response =0 

#Execute the loop till the time expires entered by User
while((input_time + current_time) > actual_time): 
    response = os.system("ping " + url)
    if response ==0:
        webbrowser.open_new_tab("https://167.6.2.200:446/")
        break;
    else:
        #add Exception if any
        #print("no")
        pass # do nothing

    actual_time = time.time()
    #time.sleep(5)

Is there any possibility that I can resize/minimize the cmd window open everytime? Any change to execute the command in background.
P.S: I am using Window 10 OS

A:

(With Windows 10)
Consider using the subprocess module, like so:
>>> import os, subprocess
>>> startupinfo = subprocess.STARTUPINFO()
>>> startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
>>> with subprocess.Popen("ping 192.168.1.1", startupinfo=startupinfo, text=True, stdout=subprocess.PIPE) as p:
    for line in p.stdout:
        print(line, end="")

Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.1.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms
>>> with subprocess.Popen("ping 10.1.10.1", startupinfo=startupinfo, text=True, stdout=subprocess.PIPE) as p:
    for line in p.stdout:
        print(line, end="")

Pinging 10.1.10.1 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 10.1.10.1:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

Iterate over p.stdout to get each line of the results as a string. Obviously you can ignore this if you want, in which case the text and stdout arguments can be removed.
Use p.returncode to get the return code.

On my Windows 10 machine, ping returns 0 if it receives a reply, and 1 if there's an error. Note that it returns 0 when I receive a Destination host unreachable response after trying to ping an address on my LAN that doesn't exist. Though I doubt it'll be an issue for your use case.
p.returncode will return None if you access it before the process has ended. 
You can wait for the process to end by calling the p.wait() method, like so:
with subprocess.Popen("ping 192.168.1.1", startupinfo=startupinfo, text=True, stdout=subprocess.PIPE) as p:
    p.wait()
    print("Return code for 192.168.1.1:", p.returncode)
    for line in p.stdout:
        print(line, end="") # This will now all print immediately, after waiting for the process to finish

Output:
Return code for 192.168.1.1: 0

Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.1: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.1.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

Or you can access p.returncode after the with statement, like so:
with subprocess.Popen("ping 10.1.10.1", startupinfo=startupinfo, text=True, stdout=subprocess.PIPE) as p:
    for line in p.stdout:
        print(line, end="")
print("Return code for 10.1.10.1:", p.returncode)

Output:
Pinging 10.1.10.1 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 10.1.10.1:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
Return code for 10.1.10.1: 1

Pinging a non-existant address on my LAN returns 0:
with subprocess.Popen("ping 192.168.1.99", startupinfo=startupinfo, text=True, stdout=subprocess.PIPE) as p:
    for line in p.stdout:
        print(line, end="")
print("Return code for 192.168.1.99:", p.returncode)

Output:
Pinging 192.168.1.99 with 32 bytes of data:
Reply from 192.168.1.105: Destination host unreachable.
Reply from 192.168.1.105: Destination host unreachable.
Reply from 192.168.1.105: Destination host unreachable.
Reply from 192.168.1.105: Destination host unreachable.

Ping statistics for 192.168.1.99:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Return code for 192.168.1.99: 0

Pinging an invalid URL returns 1:
with subprocess.Popen("ping www..com", startupinfo=startupinfo, text=True, stdout=subprocess.PIPE) as p:
    for line in p.stdout:
        print(line, end="")
print("Return code for www..com:", p.returncode)

Output:
Ping request could not find host www..com. Please check the name and try again.
Return code for www..com: 1

