Skip to content

Instantly share code, notes, and snippets.

@evilwk
evilwk / PostKey.cpp
Last active April 26, 2019 01:38
Post按键 #Cpp
#define MAKE_DOWN_LPARAM(key) (LPARAM)(0x1 | (MapVirtualKey(key, MAPVK_VK_TO_VSC) << 16))
#define MAKE_UP_LPARAM(key) (LPARAM)(0x1 | (KF_REPEAT | KF_UP | MapVirtualKey(key, MAPVK_VK_TO_VSC) << 16))
void PostKey(HWND hWnd, UINT vKey)
{
if (hWnd == NULL)
return;
::PostMessage(hWnd, WM_KEYDOWN, vKey, MAKE_DOWN_LPARAM(vKey));
Sleep(100);
@evilwk
evilwk / LuaMgr.h
Last active April 26, 2019 01:39
Lua扩展函数 #Cpp #Lua
#pragma once
#define LUA_REGISTRYINDEX (10000)
#define LUA_ENVIRONINDEX (10001)
#define LUA_GLOBALSINDEX (10002)
#define lua_upvalueindex(i) (LUA_GLOBALSINDEX(i))
typedef struct lua_State lua_State;
typedef double lua_Number;
typedef int (*lua_CFunction) (lua_State *L);
@evilwk
evilwk / HtmlFragment.cs
Last active April 26, 2019 01:40
复制Html到剪贴板 #C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Utils
{
public class HtmlFragment
{
@evilwk
evilwk / ShadowLayout.java
Last active April 26, 2019 01:37
阴影布局 #Android
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
@evilwk
evilwk / PolygonImageView.java
Last active April 26, 2019 06:10
多边形图片 #Android
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
@evilwk
evilwk / rpn.lua
Last active April 26, 2019 01:39
逆波兰式算法 #Lua
local function IsString(ch)
return string.match(ch, "[^\t%s%d%+%-%*/%%%(%)]")
end
local function GetString(szExpression, nIndex)
return string.find(szExpression, "^([^\t%s%d%+-%*/%%%(%)]+)", nIndex)
end
local function IsNumber(ch)
return string.match(ch, "[%d%.]+")
@evilwk
evilwk / var2str.lua
Last active April 26, 2019 01:36
变量转字符串 #Lua
function var2str(var, szIndent)
local szType = type(var)
if szType == "nil" then
return "nil"
elseif szType == "number" then
return tostring(var)
elseif szType == "string" then
return string.format("%q", var)
elseif szType == "function" then
local szCode = string.dump(var)
@evilwk
evilwk / ZipUtil.java
Last active April 26, 2019 01:39
Zip文件解压 #Java
package com.mcelf.TutorialMap.util;
import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/**
* @author evilwk <evilwk@gmail.com> on 2016/8/6 0006
*/
@SuppressWarnings("ResultOfMethodCallIgnored")