Skip to content

Instantly share code, notes, and snippets.

@mo-han
mo-han / nt_clipboard.py
Last active June 11, 2020 05:31
simple class for using clipboard in NT OS (Windows), supporting copied files (paths)
class Clipboard:
import win32clipboard as wcb
cf_dict = {n.lstrip('CF_'): m for n, m in inspect.getmembers(wcb) if n.startswith('CF_')}
def __enter__(self):
self.open()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.close()
@echo off & pushd %TEMP%
mode con cols=78 lines=3
title KMS ^& KMS 2038 ^& Digital ^& Online Activation Suite %ver% by mephistooo2 - TNCTR.com
set ver=v8.7
echo.
whoami /user|findstr "S-1-5-18">nul || (call :runasTI 1 cmd.exe /c "%~f0" &echo TRUSTED INSTALLER RIGHTS ENABLED... &echo Please wait... &TIMEOUT /T 3 >nul &exit)
echo.
echo Files extracting , please wait...
if exist "%TEMP%\KMS_Suite" @RD /S /Q "%TEMP%\KMS_Suite" >nul
powershell -noprofile -c "$f=[io.file]::ReadAllText('%~f0') -split ':bat2file\:.*';iex ($f[1]);X 1;" >nul
@mo-han
mo-han / traitsui_large_image_button_fail.py
Last active February 5, 2021 04:54
traitsui large icon button test
from mylib.traitsui_helper.import_10_qt import * # mylib: https://github.com/mo-han/mo-han-toolbox/tree/master/mylib
i = ImageResource(r'scpi_shell\icon.png')
TestAction = Action(
name="&Test", action="test_clicked", tooltip="Click to test", image=i, height=-1280
)
class DialogWithToolbar(HasTraits):
@mo-han
mo-han / path_check.py
Created March 4, 2021 04:10
python validate path str
#!/usr/bin/env python3
import errno
import os
import pathlib
import tempfile
# The code below is based on or copy from an answer by Cecil Curry at:
# https://stackoverflow.com/questions/9532499/check-whether-a-path-is-valid-in-python-without-creating-a-file-at-the-paths-ta/34102855#34102855
# -*- CODE BLOCK BEGIN -*-