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
#!/bin/bash | |
#region usage | |
function usage { | |
cat <<EOF | |
$(basename ${0}) by.もち: | |
ブログ投稿用に、画像・動画ファイルの一括リネームを行うスクリプト。 | |
引数で指定したディレクトリの直下にあるファイルのみが対象。 | |
各メディアファイルに対して次の処理を行う。 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
using System; | |
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
SampleUnion u = new SampleUnion { x = 0x01020304 }; | |
Console.WriteLine($"u = {u.x}"); |
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
using System.Runtime.InteropServices; | |
namespace ConsoleApp1 | |
{ | |
[StructLayout(LayoutKind.Explicit)] | |
struct SampleUnion | |
{ | |
[FieldOffset(0)] | |
public uint x; |
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
union SampleUnion | |
{ | |
unsigned int x; | |
unsigned char byte[4]; | |
}; |
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
NativeMethods.UnhookWindowsHookEx(_mouseHookId); | |
NativeMethods.UnhookWindowsHookEx(_keyboardHookId); |
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
using (Process currentProcess = Process.GetCurrentProcess ()) | |
using (ProcessModule currentModule = currentProcess.MainModule) { | |
// メソッドをマウスのイベントに紐づける。 | |
_mouseHookId = NativeMethods.SetWindowsHookEx ( | |
NativeMethods.HookType.WH_MOUSE_LL, | |
_mouseProc, | |
NativeMethods.GetModuleHandle (currentModule.ModuleName), | |
0 | |
); |
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
// デリゲート | |
private static readonly NativeMethods.LowLevelMouseKeyboardProc _mouseProc = MouseInputCallback; | |
private static readonly NativeMethods.LowLevelMouseKeyboardProc _keyboardProc = KeyboardInputCallback; | |
// メソッドを識別するID | |
private static IntPtr _mouseHookId = IntPtr.Zero; | |
private static IntPtr _keyboardHookId = IntPtr.Zero; |
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
// キーボード操作のイベントが発生したら実行されるメソッド | |
private static IntPtr KeyboardInputCallback (int nCode, IntPtr wParam, IntPtr lParam) { | |
if (nCode < 0) { | |
// キーボードのイベントに紐付けられた次のメソッドを実行する。メソッドがなければ処理終了。 | |
return NativeMethods.CallNextHookEx (_keyboardHookId, nCode, wParam, lParam); | |
} | |
// キーコードを取得する。 | |
KBDLLHOOKSTRUCT param = Marshal.PtrToStructure<KBDLLHOOKSTRUCT>(lParam); | |
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
// マウス操作のイベントが発生したら実行されるメソッド | |
private static IntPtr MouseInputCallback (int nCode, IntPtr wParam, IntPtr lParam) { | |
if (nCode < 0) { | |
// マウスのイベントに紐付けられた次のメソッドを実行する。メソッドがなければ処理終了。 | |
return NativeMethods.CallNextHookEx (_mouseHookId, nCode, wParam, lParam); | |
} | |
MSLLHOOKSTRUCT param = Marshal.PtrToStructure<MSLLHOOKSTRUCT> (lParam); | |
Win32Point mousePosition = new Win32Point { |