forked from Answeror/lit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoto.py
54 lines (43 loc) · 1.07 KB
/
goto.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import windows
import socket
ENCODING = 'utf-8'
PORT = 50007
def main(argv):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('', PORT))
s.listen(1)
conn, addr = s.accept()
while True:
line = conn.recv(1024).decode(ENCODING)
if line == 'exit':
break
elif line == 'all':
print(windows.top_level_windows())
else:
windows.goto(int(line))
print(line)
if __name__ == '__main__':
import sys
main(sys.argv[1:])
else:
import subprocess as sp
import sys
import os
import logging
root = r'C:\Program Files (x86)\lit'
p = sp.Popen([
os.path.join(root, 'ele', 'elevate.cmd'),
os.path.join(root, 'goto.exe')
])
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
while True:
try:
s.connect((socket.gethostname(), PORT))
except:
pass
else:
break
def goto(hwnd):
s.sendall(('%d\n' % hwnd).encode(ENCODING))