The main benefit of this script is to provide a quick and direct means of gathering system information when needed, making it easier to check system status and diagnose problems more quickly and accurately.
This Python script is designed to fetch system information and display it when a specific key combination (LCtrl + LAlt) is pressed. Here's a breakdown of the code:
1-Import necessary modules: subprocess: For running system commands. socket: For retrieving hostname and IP address. platform: For retrieving platform information. tkinter: For GUI (Graphical User Interface). pynput.keyboard: For monitoring keyboard events. 2-Define COMBINATION as the key combination to trigger system information retrieval.
3-Define on_press() function to handle key press events: When a key is pressed, if it matches the defined combination, it adds the key to the current set. If all keys in the combination are pressed, it calls the on_activate() function.
4-Define on_release() function to handle key release events: It removes the released key from the current set.
5-Define get_system_info() function to fetch system information:
It runs system commands using subprocess to retrieve:
Username (whoami)
Hostname (socket.gethostname())
IP Address (socket.gethostbyname_ex())
Windows Platform (platform.platform())
Serial Number (wmic bios get serialnumber)
It formats the gathered information into a string.
6-Define on_activate() function to display system information: It gets system information using get_system_info() function. Updates the label in the GUI (info_label) with the system information. Makes the GUI visible (root.deiconify()).
7-Define on_close() function to handle window close event:
It hides the GUI (root.withdraw()).
8-Set up the tkinter GUI: Create a root window with a title. Configure the root window's appearance. Create a label (info_label) to display information. Create a close button. Bind the on_close() function to the window close event.
9-Start listening for keyboard events using pynput.keyboard.Listener.
10-Start the tkinter event loop (root.mainloop()).