1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/usr/bin/env python3
from pynput import keyboard
from pynput.keyboard import Controller
import gi
from time import sleep
import sys
try:
option = sys.argv[1]
except IndexError:
print(f"Usage: python3 {sys.argv[0]} [paste]/[setip]")
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib
pastekey = Controller()
class EntryWindow(Gtk.Window):
def __init__(self):
super().__init__(title="Enter The IP Address.")
self.set_size_request(250, 47)
self.timeout_id = None
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
self.add(vbox)
self.entry = Gtk.Entry()
vbox.pack_start(self.entry, True, True, 0)
self.entry.connect("activate", self.onok)
hbox = Gtk.Box(spacing=6)
vbox.pack_start(hbox, True, True, 0)
def onok(self, widget):
global currentip
with open("/tmp/tempaddr", "w") as h:
h.write(widget.get_text())
self.destroy()
def prompt():
win = EntryWindow()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()
def paste(text):
pastekey.type(text)
def main():
if option == "paste":
try:
with open("/tmp/tempaddr", "r") as h:
paste(h.read().strip())
except:
pass
elif option == "setip":
prompt()
if __name__ == "__main__":
try:
main()
except:
pass
|