Coder Social home page Coder Social logo

obs-zoom-and-follow's Introduction

This script is not being actively maintained. Please contact me if you want to take over maintenance.

I no longer stream regularly and do not find myself with the free time to do the necessary refactor to address existing issues. Please use BlankSourceCode's lua script to achieve similar functionality. It only supports desktop capture, but works cross-platform, has basic dual machine support, and does not require you to setup Python or any dependencies.


Zoom and Follow

Have you ever needed to zoom in on your screen to show some fine detail work, or to make your large 4k/ultrawide monitor appear less daunting on stream? Zoom and Follow for OBS Studio does exactly that, zooms in on your mouse and follows it around. Configurable and low-impact, you can now do old school Camtasia zoom live!

Maintained for the current release version of OBS

Built using Python 3.10

Inspired by caharkness's Magic Window

Last updated: 2023 September 14

Dependencies

Install

  • Install Python 3

    Make sure that you configure the correct version of Python within OBS in the "Scripts" window > "Python Settings" tab

  • Install requirements

    python -m pip install -r requirements.txt

    or

    python3 -m pip install -r requirements.txt

  • Add zoom_and_follow_mouse.py as an OBS script

Note: I will not provide support on how to install Python or any dependencies as each system and platform is different. I am only set up to test on the current versions of Windows 11 and Apple Silicon-based macOS and can only guarantee compatibility with the latest version of OBS on the latest version of each OS.

How to Use

  1. In the "Tools > Scripts" Menu of OBS
    • Select a source to zoom into as part of the script settings
    • Configure the size of the zoom window
    • Change any of the other settings to adjust the zoom and follow behavior (Optional)
  2. In the "Settings > Hotkeys" Menu of OBS
    • Setup a hotkey for Enable/Disable Mouse Zoom
    • Setup a hotkey for Enable/Disable Mouse Follow
  3. Use Zoom hotkey to zoom in and out of the source
    • Optionally, use the Follow hotkey to toggle mouse tracking
  4. Adjust Source Bounding Box Type, Alignment, and Size to preference

Setting up zoom control for multiple sources

Duplicate and rename zoom_and_follow_mouse.py, and repeat the Install and How to Use sections with the duplicate copy.

To Do

  • Only track windows/games when they are the active window
  • Re-implement window tracking on macOS
  • Proper testing on Linux (X11/Wayland/etc.) Looking for Linux maintainers

obs-zoom-and-follow's People

Contributors

basnetsagar0 avatar bpatram avatar conner-pys avatar gnu-lorien avatar marckopop avatar riyasvaliyadan avatar rvillani avatar tryptech avatar upgradeq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

obs-zoom-and-follow's Issues

Mouse movement being picked from incorrect monitor

After I had reported #54 and you provided the update, I verified that everything was working as expected, and then didn't really get a chance to use it. Today when attempting to use the feature, I ran into some very strange behavior.

Zoom works perfectly fine with the custom monitor dimensions I provided but when it comes to follow, nothing happens while I'm moving the mouse on the screen being shared, which is my external monitor. However, I discovered this by accident as I moved my mouse cursor to the primary monitor: moving the mouse there within the dimensions specified in the plugin's settings as custom resolution does trigger the follow.

I have tried unloading the script, deleting the monitor source altogether, creating the source again, loading and configuring the script again, but to no avail. And what's most strange about this is I hadn't changed anything in the screen scene, the display capture source, or the script's settings in OBS since last verifying that it worked. The only changes I had made were in other scenes.

To reiterate briefly: The display source being captured is display B, and the script is set to use display B as well, but follow happens when I move my mouse on display A, and not when I move the mouse on display B.

I'm stumped at what might be causing such behavior.

multiscreem issue

hi! i have two monitors (left and right) and a issue when i use the left monitor.
When i use the script on left monitor, the zoom effect follow the mouse when i move left, up and down.
But when i move to right -->the zoom stop following the mouse
I have no problem with the right monitor

Unable to Launch Script

I am getting the following when I try to load the script into OBS

[zoom_and_follow_mouse.py] File "D:/BACKUP-2020/Projects/Twitch/obs-zoom-and-follow-master\zoom_and_follow_mouse.py", line 2, in
[zoom_and_follow_mouse.py] import pywinctl as pwc # version >=0.0.30
[zoom_and_follow_mouse.py] ModuleNotFoundError: No module named 'pywinctl'

I have run the pip to install this as well as installed the newest .whl file and I get the same error whenever I choose the scrpt.

don't work

hi, i just install zoom and follow and showed me this error

[zoom_and_follow_mouse.py] {}
[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py] File "C:\Users\pedrinj66\OneDrive\Desktop\stream downloads\OBS PYTHON\zoom_and_follow_mouse.py", line 371, in toggle_zoom
[zoom_and_follow_mouse.py] zoom.update_source_size()
[zoom_and_follow_mouse.py] File "C:\Users\pedrinj66\OneDrive\Desktop\stream downloads\OBS PYTHON\zoom_and_follow_mouse.py", line 66, in update_source_size
[zoom_and_follow_mouse.py] data = loads(data)['monitor']
[zoom_and_follow_mouse.py] KeyError: 'monitor'

Zoom in option

On the script setting, Can you add a option like 2x zoom, 5x zoom, 10x zoom Instead of entering the width & height manually.

It would nice to auto detect screen resolution & 2x zoom or so...

Active Border above 0.16 causes flicker

Hello!! I have a 1080p OBS canvas, I use a 4K monitor scaled down. Everything working great, with this one caveat mentioned in the title.

Here are my Transform settings and here are my script settings below.

{550AE9BA-97C1-44C8-8DE0-4CB976EE93A9}
{8F4D6149-FAA4-4667-893A-5F60DEF4A2A7}

There's no flicker when active border is set at 0.16 and lower. Also, when set above 0.16, there is no flicker if we are at a screen edge.

If there's anything else I can provide, I will be happy to.

Zoom working but no mouse follow

I love the idea of this plugin. I got it all installed in OBS, I’m able to input and adjust settings, but when I activate it it does a single zoom in to a part of the screen and remains locked on that zoom, ie, nothing happens when I move mouse, no zoom following the mouse. I’m using Python version 3.6.8 as described, installed everything else as described, etc, and all installed ok. I am using OBS 27 RC3. Can you help me troubleshoot? I’d love to get this working as I think it’s a wonderful opportunity to improve my tutorials. Thanks for all your work on this...really nice idea.

Error on startup of OBS when this script is installed

Hi,

I've been trying to get this OBS plugin to work.

But after including the script into OBS, and then starting up OBS, it gives me the following message on Linux Mint 20.1 Xfce:

[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py]   File "/home/username/.config/obs-studio/scripts/obs-zoom-and-follow-master/zoom_and_follow_mouse.py", line 19, in <module>
[zoom_and_follow_mouse.py]     class CursorWindow:
[zoom_and_follow_mouse.py]   File "/home/username/.config/obs-studio/scripts/obs-zoom-and-follow-master/zoom_and_follow_mouse.py", line 26, in CursorWindow
[zoom_and_follow_mouse.py]     d_w = get_monitors()[monitor_idx].width
[zoom_and_follow_mouse.py]   File "/home/username/.local/lib/python3.8/site-packages/screeninfo/screeninfo.py", line 37, in get_monitors
[zoom_and_follow_mouse.py]     raise ScreenInfoError("No enumerators available")
[zoom_and_follow_mouse.py] screeninfo.common.ScreenInfoError: No enumerators available

We've already been discussing the problem with the maintainer of screeninfo here:
https://github.com/rr-/screeninfo/issues/48

They asked to create a parallel bug report here, so you can coordinate.

@tryptech
/cc @rr-

Zoom source empty list

I have problem on newest OBS on Macbook Pro M1 with "Zoom source" list is empty even after Refresh lis of sources.
Screenshot:
Screenshot 2022-09-22 at 09 42 32

Could you help?

Not working after restarting OBS (2560x1440 dual monitors stacked vertically)

Hi, I have installed the script in Windows 11, OBS 27.2.4 (64 bit), I use 2 monitors in 2560x1440 landscape stacked vertically one on top of the other, with my main monitor being the one on the bottom. I have a scene with Display Capture, and I use that in the script, with zoom configured to the default 1280x720 values. Everything works as expected until I close OBS, and the next time I open it the zoom shortcut produces a strange behaviour, like it zooms to the top left point (infinite zoom?) and the screen capture turns black. Unzooming just leaves the screen at the 1280x720 zoomed in level. So after that initial zoom, the script seems to behave as if the normal level was the zoomed in level (1280x720) and the zoomed level was an infinite zoom on the top left pixel, and there's no way of seeing my entire screen in the 2560x1440 resolution.

My workaround currently is to uninstall the script, and add it back each time I open OBS, which works but is not ideal.

Sorry if this description is not good enough, let me know how I can provide more useful information for debugging the issue.

Trigger from One Zoom Level to Another

I'd like to be able to start with, say a zoom level of 1280x720 (150%, based on a 1920x1080 screen), then instead of having to first toggle back up to 1920x180, before I can then use the separate hotkey for zooming to 960x540 (200%), then only being able to use THAT key to toggle to 100% (1920x1080).

Perhaps being able to assign a hotkey that simply toggles zoom, regardless of which level currently zoomed into.

Then a 2nd key that let's you toggle between different zoom levels. (I have seen other hotkeys behave such that if you assign the same keystroke for multiple actions, repeatedly pressing that hotkey switches from one to the other to the other.)

KeyError: 1 in update_monitor_dim

I'm using OBS 27.2.4 on a Mac with MacOS 12.5, and /Library/Frameworks/Python.framework/Versions/3.9

I setup a hotkey of Command+Z, and when I press it, I get the following error in a popup:

[zoom_and_follow_mouse.py] Source Type: display_capture
[zoom_and_follow_mouse.py] Retrieving monitor 1
[zoom_and_follow_mouse.py] Updating stored dimensions to match selected monitor's dimensions
[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py] File "/Users/ngriffin/Projects/sales-engineering/screencasts/python-scripts/zoom_and_follow_mouse.py", line 668, in toggle_zoom
[zoom_and_follow_mouse.py] zoom.update_source_size()
[zoom_and_follow_mouse.py] File "/Users/ngriffin/Projects/sales-engineering/screencasts/python-scripts/zoom_and_follow_mouse.py", line 221, in update_source_size
[zoom_and_follow_mouse.py] self.update_monitor_dim(self.monitors[self.monitors_key[monitor_index]])
[zoom_and_follow_mouse.py] File "/Users/ngriffin/Projects/sales-engineering/screencasts/python-scripts/zoom_and_follow_mouse.py", line 84, in update_monitor_dim
[zoom_and_follow_mouse.py] if self.source_w != monitor[1]['size'].width or self.source_h != monitor[1]['size'].height or self.source_x != monitor[1]['pos'].x or self.source_y != monitor[1]['pos'].y:
[zoom_and_follow_mouse.py] KeyError: 1

I'd be much obliged if you think it's a bug, or if there might be a way to wokraround the problem.

Thank you, Neil

Won't follow mouse in a different Monitor

I have 2 monitors, one is 1920 x 1080, setted in source "Monitor [Capture]", and the other one is 1280 x 800, setted in source "TV [Capture]. I've created 2 different scripts for each one of the monitors ("zoom_and_follow_mouse_1.py" and "zoom_and_follow_mouse_2.py") so I can use the zoom in both of them, yet in the second monitor it just won't work. Even that it will zoom in the right source, "TV [Capture]", the zoom will follow my mouse in the 1920 x 1080 monitor and not in the 1280 x 800 monitor as intended even choosing \. \DISPLAY2 it won't track in the right monitor.

Master + hotfix not working with OBS 27.2.4

I was never able to get master to work, hotfix worked for me a couple weeks ago. I would however have to reinstall and configure the settings every time I opened OBS.

OBS updated and now it doesnt work at all. I am able to load up the settings and configure it. It's just when I set the hotkey and press it that nothing happens.

I wish I could offer something more helpful here like error codes.

ModuleNotFoundError: No module named 'pywinctl'

I have Python 3.6.8 installed and in cmd I installed the PyWinCtl module with:

pip install pywinctl==0.0.38

However OBS is still spitting out the error:

Traceback (most recent call last):
[zoom_and_follow_mouse.py]   File "C:/Program Files/obs-studio/data/obs-plugins/frontend-tools/scripts\zoom_and_follow_mouse.py", line 2, in <module>
[zoom_and_follow_mouse.py]     import pywinctl as pwc # version >=0.0.30
[zoom_and_follow_mouse.py] ModuleNotFoundError: No module named 'pywinctl'

I have tried restarting OBS, reinstalling different pywinctl versions >0.0.30, however I still dont see the Python script settings.

Syntax error: Line 7

I've recently reset my OBS install and when I add the script into OBS I get the following error

[zoom_and_follow_mouse.py]   File "%USERPROFILE%/OneDrive/Software/Streaming/OBS/plugins\zoom_and_follow_mouse.py", line 7
[zoom_and_follow_mouse.py]     <!DOCTYPE html>
[zoom_and_follow_mouse.py]     ^
[zoom_and_follow_mouse.py] SyntaxError: invalid syntax

I have installed Python 3.6 and changed the python path to the correct location and also installed pynput and screeninfo.

script on Linux openSUSE Tumbleweed

[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py] File "/usr/share/obs/obs-plugins/frontend-tools/scripts/obs-zoom-and-follow-master/zoom_and_follow_mouse.py", line 20, in
[zoom_and_follow_mouse.py] class CursorWindow:
[zoom_and_follow_mouse.py] File "/usr/share/obs/obs-plugins/frontend-tools/scripts/obs-zoom-and-follow-master/zoom_and_follow_mouse.py", line 28, in CursorWindow
[zoom_and_follow_mouse.py] monitors = pwc.getAllScreens()
[zoom_and_follow_mouse.py] File "/home/ivo/.local/lib/python3.8/site-packages/pywinctl/_pywinctl_linux.py", line 881, in getAllScreens
[zoom_and_follow_mouse.py] 'workarea': Rect(crtc.x + wa[0], crtc.y + wa[1], crtc.x + crtc.width - (SCREEN.width_in_pixels - wa[2] - wa[0]), crtc.y + crtc.height - (SCREEN.height_in_pixels - wa[3] - wa[1])),
[zoom_and_follow_mouse.py] TypeError: 'NoneType' object is not subscriptable

obs_hotkey_save issue

I got an issue when it tries to save the hotkey_

OBS 28.0.1
Python 3.10.7

Py log:
[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py] File "C:\OBSfiles/obs-zoom-and-follow-master\zoom_and_follow_mouse.py", line 797, in script_save
[zoom_and_follow_mouse.py] hotkey_save_array = obs.obs_hotkey_save(zoom_id_tog)
[zoom_and_follow_mouse.py] File "C:\Program Files\obs-studio\data\obs-scripting\64bit\obspython.py", line 2615, in obs_hotkey_save
[zoom_and_follow_mouse.py] return _obspython.obs_hotkey_save(id)
[zoom_and_follow_mouse.py] TypeError: in method 'obs_hotkey_save', argument 1 of type 'obs_hotkey_id'

AttributeError: module 'obspython' has no attribute 'obs_get_frame_interval_ns'

Python 3.6.8 isn't in PATH, a higher version is.

Dependencies Installed

Python 3.6.8
pywin32 304
PyWinCtl 0.0.38
win32core 221.36
win32gui 221.6

OBS Python Install Path: C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64
OBS 21.1.0 (64bit, windows)

Script Log

[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py]   File "D:/Folder\zoom_and_follow_mouse.py", line 20, in <module>
[zoom_and_follow_mouse.py]     class CursorWindow:
[zoom_and_follow_mouse.py]   File "D:/Folder\zoom_and_follow_mouse.py", line 39, in CursorWindow
[zoom_and_follow_mouse.py]     refresh_rate = int(obs.obs_get_frame_interval_ns()/1000000)
[zoom_and_follow_mouse.py] AttributeError: module 'obspython' has no attribute 'obs_get_frame_interval_ns'

It zooms to upper left corner & It does not follow cursor

Hello, I have downloaded this and followed all the instructions both in the Github and a tutorial video. However, It zooms to the upper left corner until I can see only a few pixels and it doesn't follow the cursor.

  • downloaded python and script
  • selected source
  • edited script settings
  • added hotkeys
  • edited transform edit

It is my first time downloading a script. Have I missed anything or is there anything missing / broken?

No properties available

Hi, first of all, thank you for this plugin. I've heard good things.

Getting to the point, I'm having difficulty getting this to work. At the point of adding the script to OBS, the window displays a message saying No properties available. I've provided screenshots, below. Also, clicking Script Log shows an empty log window.

My environment

  • MacOS 12.6 (x64).
  • OBS version 28.0.2.
  • pywinctl version 0.0.38.
  • The version of your script as of today (commit 1d17b5d).

Screenshots

The issue

Screenshot 2022-09-25 at 9 54 59 PM

Python path

Screenshot 2022-09-25 at 9 54 07 PM

pywinctl version

Screenshot 2022-09-25 at 9 54 22 PM

Is available for Linux too?

I'm trying to set up your plugin but I'm struggling, is this supported for Linux also?

[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py]   File "/usr/share/obs/obs-plugins/frontend-tools/scripts/zoom_and_follow_mouse.py", line 19, in <module>
[zoom_and_follow_mouse.py]     class CursorWindow:
[zoom_and_follow_mouse.py]   File "/usr/share/obs/obs-plugins/frontend-tools/scripts/zoom_and_follow_mouse.py", line 26, in CursorWindow
[zoom_and_follow_mouse.py]     d_w = get_monitors()[monitor_idx].width
[zoom_and_follow_mouse.py]   File "/home/zipus/.local/lib/python3.8/site-packages/screeninfo/screeninfo.py", line 37, in get_monitors
[zoom_and_follow_mouse.py]     raise ScreenInfoError("No enumerators available")
[zoom_and_follow_mouse.py] screeninfo.common.ScreenInfoError: No enumerators available
[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py]   File "/usr/share/obs/obs-plugins/frontend-tools/scripts/zoom_and_follow_mouse.py", line 19, in <module>
[zoom_and_follow_mouse.py]     class CursorWindow:
[zoom_and_follow_mouse.py]   File "/usr/share/obs/obs-plugins/frontend-tools/scripts/zoom_and_follow_mouse.py", line 26, in CursorWindow
[zoom_and_follow_mouse.py]     d_w = get_monitors()[monitor_idx].width
[zoom_and_follow_mouse.py]   File "/home/zipus/.local/lib/python3.8/site-packages/screeninfo/screeninfo.py", line 37, in get_monitors
[zoom_and_follow_mouse.py]     raise ScreenInfoError("No enumerators available")
[zoom_and_follow_mouse.py] screeninfo.common.ScreenInfoError: No enumerators available
[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py]   File "/usr/share/obs/obs-plugins/frontend-tools/scripts/zoom_and_follow_mouse.py", line 19, in <module>
[zoom_and_follow_mouse.py]     class CursorWindow:
[zoom_and_follow_mouse.py]   File "/usr/share/obs/obs-plugins/frontend-tools/scripts/zoom_and_follow_mouse.py", line 26, in CursorWindow
[zoom_and_follow_mouse.py]     d_w = get_monitors()[monitor_idx].width
[zoom_and_follow_mouse.py]   File "/home/zipus/.local/lib/python3.8/site-packages/screeninfo/screeninfo.py", line 37, in get_monitors
[zoom_and_follow_mouse.py]     raise ScreenInfoError("No enumerators available")
[zoom_and_follow_mouse.py] screeninfo.common.ScreenInfoError: No enumerators available
[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py]   File "/usr/share/obs/obs-plugins/frontend-tools/scripts/zoom_and_follow_mouse.py", line 19, in <module>
[zoom_and_follow_mouse.py]     class CursorWindow:
[zoom_and_follow_mouse.py]   File "/usr/share/obs/obs-plugins/frontend-tools/scripts/zoom_and_follow_mouse.py", line 26, in CursorWindow
[zoom_and_follow_mouse.py]     d_w = get_monitors()[monitor_idx].width
[zoom_and_follow_mouse.py]   File "/home/zipus/.local/lib/python3.8/site-packages/screeninfo/screeninfo.py", line 37, in get_monitors
[zoom_and_follow_mouse.py]     raise ScreenInfoError("No enumerators available")
[zoom_and_follow_mouse.py] screeninfo.common.ScreenInfoError: No enumerators available

Captura de pantalla de 2021-02-08 01-34-30

Also I can't find the field you mention on How To to save the shortcut.
I've Python 3.8.5 and I just installed pynput and screeninfo as global and added you script to Scripts Panel.

active border

hi, i want the cursor to be ALWAYS in the center, even if it means i get black bars if i move my mouse to the corners of the monitor, is there anyway i can do that? (its necessary)

Zoom in the upper left corner after pressing hotkey and zooms further in when pressing again

Hello,

I spend a couple of hours on this, but I still have the same problem.
I have 3 connected monitors and the monitor that I would like to have the function work is a 4k (3840 x 2160) monitor.

I tried the hotfix a bit earlier made; but the problem remains the same.

After using the hotkey it zooms in in the top left corner and when I press it again it zooms further into; until I can't see anything. After pressing it again it goes back to the top left corner (not the full screen). Also the mouse follow doesn't work.

OBS 27.2.4 (64 bit)
Python 3.6 (64 bit)
Windows 11 Pro
OS Build 22000.795

Problem Trying to get monitor capture

[zoom_and_follow_mouse.py] {}
[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py]   File "C:\Program Files\obs-studio\OBS PYTHON\zoom_and_follow_mouse.py", line 371, in toggle_zoom
[zoom_and_follow_mouse.py]     zoom.update_source_size()
[zoom_and_follow_mouse.py]   File "C:\Program Files\obs-studio\OBS PYTHON\zoom_and_follow_mouse.py", line 66, in update_source_size
[zoom_and_follow_mouse.py]     data = loads(data)['monitor']
[zoom_and_follow_mouse.py] KeyError: 'monitor'

it supports only Window Capture

settings don't show up on obs

after installing the python modules and adding the file to the obs scripts i cannot find a hot key option on the hotkey section of the settings

Can this package work with latest 3.10.6 python?

I'm struggling to get this to work. The 3.6.x python is at end of life and not downloadable from python as an exe...
Is this pilot error or is 3.10.6 really incompatitable with 3.6.x.. This script seems to great but yeah not showing props on obs

image

After restart script isnt working anymore

hey, after restart only the zoom effect is working, its not following the mouse anymore. the only solution is to change the zoom source, then press hotkey, a error occurs, then changing the zoom source again to the screen capture, then its working again. thats a lil bit annoying to do everytime :(

How to make it work with OBS Flatpak?

It's working fine with the OBS RPM, but I need to use OBS Flatpak.
pywinctl is installed, but it's not detected by OBS Flatpak!

[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py]   File "/home/mbesar/Apps/obs/scripts/zoom_and_follow_mouse.py", line 2, in <module>
[zoom_and_follow_mouse.py]     import pywinctl as pwc # version >=0.0.30
[zoom_and_follow_mouse.py] ModuleNotFoundError: No module named 'pywinctl'

OS: Fedora 36.
OBS: 27.2.4 Official Flatpak.

Fails on window capture, type browser

If you window capture a browser, the window title can change - notably every time you navigate. This causes an indexoutofrange exception when enumerating the windows upon script triggering. Would it be an option to capture the PID of the HWND when you select the source in the script settings and use that rather than the window title?

funky behavior for retina

I have a 16-inch (3072 × 1920) with retina display.

When it auto detects, it appears to auto-detect the base canvas resolution as 3584x2240.
It also gave an output resolution that did not match the same aspect ratio. Since the above showed as 16:10, I manually changed the output to 1792x1120 (also 16:10).

Then I configured the script settings:
At this time, display source isn't auto-populating. But I found that I could just type in the video capture source I was using.
I don't recall there ever being anything in the drop-down for select monitor to use base for zooming except for manual monitor size.

I set the manual monitor width to 3584 and the height to 2240, and the zoom to 1280x768, respectively. The rest I leave at default. I set a hot-key for the zoom, and a different one to follow the mouse.

Then, when I press the zoom key, it zooms in. Pressing the key again zooms back out, filling the bounds again, as expected.

Editing the transform to position in center and stretch to the bounds shows some movement, but it looks like the cursor drops off the screen about 1/3 of the way across. It then becomes apparent that it wasn't following the cursor, exactly.

One other thing that I've noticed is that screeninfo is not returning the same dimensions reported by the about mac dialog, or that the auto-detect calculates:

>>> from screeninfo import get_monitors
>>> get_monitors()
[Monitor(x=0, y=0, width=1792, height=1120, width_mm=None, height_mm=None, name=None)]

I did try forcing the base canvas to match that height and width, but that didn't really seem to help.
I did determine that if I put in 3584x2240 for the ZoomCrop filter dimensions that it scaled back out to expected size. Until I hit the hot-key again.

... almost suggesting that the something about how the filter behaves is somehow unique.

... Any ideas? I'm pretty much out.

Allow setting custom screen dimensions

Thank you for this script - it works flawlessly for most use cases. However, I have an edge case where I'm using a 5120x1440p monitor and I only want to share the first half of its screen i.e. 2560x1440p. After adding the source, I have cropped 2560p from its right side, and then resized it to 1920x1080p, which is my canvas size. However, upon using your script, each time it zooms out, it resets the crop to 5120x1440p using a filter, and I don't see an option in the script's settings to specify a custom value for those dimensions (which in my case would be 2560x1440).

Can you please add the option to use custom values for these in the script's settings? (You could still default to getting these values from the monitor's default resolution, but provide a check box for those with a use case like me to override those default values.)

Script failed to load Ubuntu 22.04

Error using script

Unable to use the script in OBS using Ubuntu OS

How it happen

After following the github instruction, I had the script in OBS and this error code appears in a pop-up

OS version

image

Error from OBS

[OBS Mouse Follower.py] Traceback (most recent call last): [OBS Mouse Follower.py] File "/run/user/1000/doc/83dd53b/OBS Mouse Follower.py", line 3, in <module> [OBS Mouse Follower.py] from ctypes import windll, Structure, c_long, byref [OBS Mouse Follower.py] File "/usr/lib/python3.8/ctypes/__init__.py", line 7, in <module> [OBS Mouse Follower.py] from _ctypes import Union, Structure, Array [OBS Mouse Follower.py] ImportError: /usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so: undefined symbol: PyFloat_Type [OBS Mouse Follower.py] Traceback (most recent call last): [OBS Mouse Follower.py] File "/run/user/1000/doc/83dd53b/OBS Mouse Follower.py", line 3, in <module> [OBS Mouse Follower.py] from ctypes import windll, Structure, c_long, byref [OBS Mouse Follower.py] File "/usr/lib/python3.8/ctypes/__init__.py", line 7, in <module> [OBS Mouse Follower.py] from _ctypes import Union, Structure, Array [OBS Mouse Follower.py] ImportError: /usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so: undefined symbol: PyFloat_Type [OBS Mouse Follower.py] Traceback (most recent call last): [OBS Mouse Follower.py] File "/run/user/1000/doc/83dd53b/OBS Mouse Follower.py", line 3, in <module> [OBS Mouse Follower.py] from ctypes import windll, Structure, c_long, byref [OBS Mouse Follower.py] File "/usr/lib/python3.8/ctypes/__init__.py", line 7, in <module> [OBS Mouse Follower.py] from _ctypes import Union, Structure, Array [OBS Mouse Follower.py] ImportError: /usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so: undefined symbol: PyFloat_Type [OBS Mouse Follower.py] Traceback (most recent call last): [OBS Mouse Follower.py] File "/run/user/1000/doc/83dd53b/OBS Mouse Follower.py", line 3, in <module> [OBS Mouse Follower.py] from ctypes import windll, Structure, c_long, byref [OBS Mouse Follower.py] File "/usr/lib/python3.8/ctypes/__init__.py", line 7, in <module> [OBS Mouse Follower.py] from _ctypes import Union, Structure, Array [OBS Mouse Follower.py] ImportError: /usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so: undefined symbol: PyFloat_Type

Error log. No zoom or follow.

[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py] File "C:\Program Files\obs-studio\data\obs-scripting\64bit\OBS PYTHON\zoom_and_follow_mouse.py", line 371, in toggle_zoom
[zoom_and_follow_mouse.py] zoom.update_source_size()
[zoom_and_follow_mouse.py] File "C:\Program Files\obs-studio\data\obs-scripting\64bit\OBS PYTHON\zoom_and_follow_mouse.py", line 58, in update_source_size
[zoom_and_follow_mouse.py] window = pwc.getWindowsWithTitle(data[0])[0]
[zoom_and_follow_mouse.py] IndexError: list index out of range

Moves screen but fails to zoom in

Hi there. Looking to make some tutorials but the zoom feature is important to me, this looks great but I'm running into some issues

Python 3.6.8
OBS 26.1.1

Installed the two required modules. Settings show up as expected.

image

And here it is in use but failing to zoom after resize

bar

Thanks for your efforts

Not working with OBS 28 (64-bit) on Windows 11 with Python 3.10

(Thank you VERY much -- I have been using zoom-and-follow reliably for several years--through many upgrades of OBS--but it is not working for me now....)
System: Windows 11 64-bit kept up-to-date with Windows Updates
OBS Studio: 28.0.0 (64 bit)
Python: 3.10.6 (64-bit)
[... ran installer with pip installed to: C:\Program Files\obs-studio\py\python310]
PyWinCtl: 0.0.38
[... executed the following in Python directory (with Admin privs)> .\python.exe -m pip install pywinctl]
Configured OBS Studio: Tools --> Scripts
Python Install Path: C:\Program Files\obs-studio\py\python310
Script: C:\Program Files\obs-studio\py\src\zoom_and_follow_mouse.py

When I launch OBS Studio, the Script Log opens with these messages:
[zoom_and_follow_mouse.py]
C:\Program Files/obs-studio/py/src\zoom_and_follow_mouse.py:566: SyntaxWarning: "is" with a literal. Did you mean "=="?
if source_string is "":

Non-initial update
Source 'Display Capture' not found.
None
Source Name:

NOTE: My Source is: "Display Capture"

When I open Settings --> Hotkeys, I enter my usual keys, and they do NOT work for me: No zoom.

Here is a part of my Script Log:
[zoom_and_follow_mouse.py] Zoom: True
[zoom_and_follow_mouse.py] Mouse position: [-1573, 236]
[zoom_and_follow_mouse.py] Zoom: True
[zoom_and_follow_mouse.py] Mouse position: [-1589, 351]
[zoom_and_follow_mouse.py] Zoom: True
[zoom_and_follow_mouse.py] Mouse position: [-1589, 351]
[zoom_and_follow_mouse.py] Tracking: True
[zoom_and_follow_mouse.py] Tracking: False

It seems to me that the Zoom Hotkey is being received by the script, but it is not "toggling" from True to False (and it is NOT having the zoom effect either). However, the mouse tracking seems to be toggling from on to off.

Again: Thank you VERY much.

PS: At the very top of the script, please consider adding a DOCSTRING like:
"""\
This script is written to be called from OBS Studio. It allows users to zoom and follow the mouse. For more information, please visit the project: https://github.com/tryptech/obs-zoom-and-follow
"""

No mouse follow after zoom.

I encountered a weird issue: I have one monitor 3440x1440 and the second 2560x1080 above. When I initially installed the script it behave exactly the same as motioned above BUT as soon as I switched the capture source to the second screen, it started zooming as Intended even after switching to the primary screen, although the mouse tracking is not working at all.
Here is a recording of said behavior:
https://drive.google.com/file/d/1jyAq9-3SmDxRVsMse5RL7HQWQbztt8hs/view

Zoom Fails to run in a Scene Collection

When using the script in the "All Scenes" section of OBS it works as expected and zooms into the two monitors I select in the Zoom Source setting.

I have created a Scene Collection that consists of a single display source (with a unique name across all scenes and collections) when attempting to run the script using the same settings, with the "Zoom Source" set to the display source for the current Scene Collection the script log pops up with the following error text:

[zoom_and_follow_mouse.py] {}
[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py]   File "D:\XXXX\OBS\Scripts\OBS PYTHON\zoom_and_follow_mouse.py", line 371, in toggle_zoom
[zoom_and_follow_mouse.py]     zoom.update_source_size()
[zoom_and_follow_mouse.py]   File "D:\XXXX\OBS\Scripts\OBS PYTHON\zoom_and_follow_mouse.py", line 66, in update_source_size
[zoom_and_follow_mouse.py]     data = loads(data)['monitor']
[zoom_and_follow_mouse.py] KeyError: 'monitor'

The monitor is set up exactly the same as those not in a scene collection and the script has the same settings as well, the only difference is that the display source is now part of a collection.

Can the script not be run within a scene collection or is this something that could perhaps be looked at?

OBS Version: 27.2.4 (Windows 11 64 Bit)
Python Version: 3.6.7 (from Mushiiies Portable Python)
Monitor Resolution: 1920x1080

Whenever I zoom in all I see is a blurry white square

Ok so, whenever I try to zoom in it looks like a blurry square, and then I checked the source that gets resized with the zoom cropped.
When I click the keybind I have for zoom and follow the resolution changes to 0 on width and 0 on height.
I dunno if it's an error with the version I'm running of pywinctl (0.0.36 - Which dropped the dependecy of numpy) but the only thing that pops up whenever I check the log is:

[zoom_and_follow_mouse.py] Key 'monitor' does not exist in data

Getting this when using with Ubuntu 21.10

[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py] File "/home/wumbl3/Documents/obs-zoom-and-follow-master/zoom_and_follow_mouse.py", line 19, in
[zoom_and_follow_mouse.py] class CursorWindow:
[zoom_and_follow_mouse.py] File "/home/wumbl3/Documents/obs-zoom-and-follow-master/zoom_and_follow_mouse.py", line 26, in CursorWindow
[zoom_and_follow_mouse.py] d_w = get_monitors()[monitor_idx].width
[zoom_and_follow_mouse.py] File "/home/wumbl3/.local/lib/python3.9/site-packages/screeninfo/screeninfo.py", line 32, in get_monitors
[zoom_and_follow_mouse.py] raise ScreenInfoError("No enumerators available")
[zoom_and_follow_mouse.py] screeninfo.common.ScreenInfoError: No enumerators available

Any ideas?

Issue with KeyError: 'source'

Hello To the Forum,

I am new and not very good in IT or programming things.

But I have an issue with the script of the mouse zoom and following.

I have installed python. It is on version 3.6.8
For that I did first: python -m pip install pynput
Worked well no errors.
Then I did: python -m pip install screeninfo
Worked well too. No errors.

I downloaded the zip file from github and extracted it to my C: folder.
I opened OBS went to scripts. I added "mouse zoom and follow".
When I do that I get a message:

[zoom_and_follow_mouse.py] Source update
[zoom_and_follow_mouse.py] Source Name: Bildschirmaufnahme
[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py] File "C:/Program Files/obs-zoom-and-follow-master\zoom_and_follow_mouse.py", line 797, in script_save
[zoom_and_follow_mouse.py] hotkey_save_array = obs.obs_hotkey_save(zoom_id_tog)
[zoom_and_follow_mouse.py] TypeError: in method 'obs_hotkey_save', argument 1 of type 'obs_hotkey_id'
[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py] File "C:/Program Files/obs-zoom-and-follow-master\zoom_and_follow_mouse.py", line 770, in script_load
[zoom_and_follow_mouse.py] [source, source_type] = load_settings['source'].split("||")
[zoom_and_follow_mouse.py] KeyError: 'source'
[zoom_and_fo
OBS_crash_message
llow_mouse.py] Updating Source List
[zoom_and_follow_mouse.py] New source: True
[zoom_and_follow_mouse.py] Updating Monitor List
[zoom_and_follow_mouse.py] Monitor override list updated
[zoom_and_follow_mouse.py] Updating Source List
[zoom_and_follow_mouse.py] New source: True
[zoom_and_follow_mouse.py] Updating Monitor List
[zoom_and_follow_mouse.py] Monitor override list updated
To me it looks good so far.

But when I go to the settings and Hotkeys, I cannot find anything related to the script.
But instead I get an error message and now I don't know what to do:

[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py] File "C:/Program Files/obs-zoom-and-follow-master\zoom_and_follow_mouse.py", line 797, in script_save
[zoom_and_follow_mouse.py] hotkey_save_array = obs.obs_hotkey_save(zoom_id_tog)
[zoom_and_follow_mouse.py] TypeError: in method 'obs_hotkey_save', argument 1 of type 'obs_hotkey_id'

If it helps, I work with OBS 27.2.4 (64-bit, windows)

When I close OBS it crashes and gives the error message enclosed in the png.

When I reopen OBS, I get this message:
[zoom_and_follow_mouse.py] Traceback (most recent call last):
[zoom_and_follow_mouse.py] File "C:/Program Files/obs-zoom-and-follow-master\zoom_and_follow_mouse.py", line 770, in script_load
[zoom_and_follow_mouse.py] [source, source_type] = load_settings['source'].split("||")
[zoom_and_follow_mouse.py] KeyError: 'source'

Does anyone knows what I can do to fix this?

Thank you so much for your help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.