Last active
July 5, 2024 15:31
-
-
Save DinleyH/e222834ddb3533d59fd7cafccf612f07 to your computer and use it in GitHub Desktop.
Automatically close problematic dialog popups in sublime text 3.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This closes the popups instantly so you never see them and they dont effect indenting etc. Works on windows. | |
To install | |
1. open sublime | |
2. go to tools -> Developer -> New Plugin | |
3. paste the code into the document (replacing any existing code sublime includes in the document) | |
4. save the file using the default user plugin directory sublime suggests. | |
(on windows this is C:\Users\yourname\AppData\Roaming\Sublime Text\Packages\User) | |
5. Restart. | |
Now if a popup comes up itll instantly close. | |
Note: While this plugin does close the sublime and SFTP licence reminder popups, you should consider paying for the licence rather and supporting the developers. However money isnt always an option for some, and the pop-ups cause issues with indenting in sublime so this plugin is useful for people who wish to fix that issue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime_plugin | |
import ctypes | |
import time | |
TARGET_CLASS_NAME = "#32770" | |
class DialogBoxKiller(sublime_plugin.EventListener): | |
def close_dialog_boxes(self): | |
EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int)) | |
def get_window_class_name(hwnd): | |
buff = ctypes.create_unicode_buffer(256) # Assuming class name won't be longer than 256 characters | |
ctypes.windll.user32.GetClassNameW(hwnd, buff, len(buff)) | |
return buff.value | |
def enum_windows_callback(hwnd, lparam): | |
class_name = get_window_class_name(hwnd) | |
if class_name == TARGET_CLASS_NAME: | |
ctypes.windll.user32.SendMessageW(hwnd, 0x0010, 0, 0) # 0x0010 is WM_CLOSE | |
return True | |
ctypes.windll.user32.EnumWindows(EnumWindowsProc(enum_windows_callback), 0) | |
def on_pre_save_async(self, *args): | |
time.sleep(0.1) # Brief delay to ensure dialog has time to appear if it does | |
self.close_dialog_boxes() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice! was looking for a way to stop that for a while but gave up lol. Thank you.