def checkforbrowser(): ''' Check whether the input is mozilla, and returns True if so. ''' current_window_id = GetForegroundWindow() pid = GetWindowThreadProcessId(current_window_id) application_name = Process(pid[-1]).name() application_name = application_name.replace(".exe", "") if ((application_name == 'firefox') or (application_name == 'chrome')) or (application_name == 'iexplore'): return True else: return False
if len(url_string) > 2: return (url_string[2]) elif len(url_string) == 2: return (url_string[1]) else: return (url_string[0]) # Defining dictionary for storing values app_dictionary = {} start = time.time() last_window_id = GetForegroundWindow() pid = GetWindowThreadProcessId(last_window_id) application_name = Process(pid[-1]).name() application_name = application_name.replace(".exe", "") print(application_name) while True: current_window_id = GetForegroundWindow() if (current_window_id != last_window_id) & (len( GetWindowText(current_window_id)) != 0): end = time.time() duration, time_tuple = printTime(end - start) #print(current_window_id) #print(len(GetWindowText(current_window_id))) if round(end - start) != 0: print(duration) try: app_dictionary[application_name] = tuple(