Comments (3)
well im not quite happy with it yet... im still very new and the code is a mess. storing variables in a Dict is not ideal. had to make many workarounds due to that, i will learn to store them as objects and create a thread class also... but for now, this works (i can easily run 30+ oldschool runescape clients with a little mitm server intercepting the jav_config.ws http request to avoid advertisement errors... anyway, if you want to help me make this better... PLEASE DO
def getScreen (self, account):
#loop_time = time()
t = threading.currentThread()
while getattr(t, "loop", True):
if account in procDict and procDict[account]['hwnd']:
hwnd = procDict[account]['hwnd'][0]
screenshot = wincap.get_screenshot(hwnd)
if screenshot is not None:
cv.imshow(f'{account} screenshot', screenshot)
cv.waitKey(1)
#print('FPS {}'.format(1 / (time() - loop_time)))
#loop_time = time()
sleep(.1)
def cvLoop (self):
global cvLoop
while(cvLoop):
windowVal = "Not Found"
for account in list(procDict):
if account in procDict and procDict[account]['dur'] and procDict[account]['proc']:
pid = procDict[account]['proc'].pid
hwnd = findWin(pid)
procDict[account]['hwnd'] = hwnd
if hwnd:
windowVal = hwnd
if not win32gui.IsWindow(hwnd[0]) or not win32gui.IsWindowVisible(hwnd[0]):
print('fucked up')
procDict[account]['hwnd'] = None
else:
if not account in threadNames():
t = Thread(target=self.getScreen, args=(account, ), daemon=True)
t.name = account
t.start()
else:
for killThread in threading.enumerate():
if killThread.name == account:
killThread.loop = False
cv.destroyWindow(f'{account} screenshot')
for row in self.tv.treeview.get_children():
if self.tv.treeview.item(row,'text') == account:
self.tv.treeview.set(row, 'hwnd', windowVal)
sleep(.5)
from opencv_tutorials.
Thanks for the info Shane, I'll definitely check that out! Glad these videos have been helpful for you. And feel free to share that game window finder code when you're happy with it. I'm sure it could help somebody else out, too.
from opencv_tutorials.
def findWin (pid):
def callback (hwnd, hwnds):
if win32gui.IsWindowVisible (hwnd) and win32gui.IsWindowEnabled (hwnd):
_, found_pid = win32process.GetWindowThreadProcessId (hwnd)
if found_pid == pid:
hwnds.append(hwnd)
return True
hwnds = []
win32gui.EnumWindows (callback, hwnds)
return hwnds
from opencv_tutorials.
Related Issues (17)
- Screen shot is cached HOT 1
- Getting vscode window HOT 4
- Improvement mss
- res = cv2.matchTemplate
- win32ui DLLs Error
- MatchTemplate and Threading
- Windows Apps capturing a black screen HOT 4
- Cascade classifier can`t be trained
- No output after running command.
- Cropped image in opencv_annotation
- vision.py (ep 5) HOT 1
- Thread implementation HOT 2
- TypeError: argument for rectangle() given by name ('color') and position (3) HOT 1
- getting black screen only HOT 10
- win32ui.error: CreateCompatibleDC failed HOT 3
- please help me
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencv_tutorials.