備忘録

備忘録

C#

C# GmailのメールをIMAPを使って受信する

C#

■必要なもの ・NuGetから「 S22.Imap Imap Library COmponent 」を入手する。■プログラム using (ImapClient client = new ImapClient("imap.gmail.com", 993, "***@gmail.com", "password", AuthMethod.Login, true)) { // 未読メールのみ IEnumerable<uint> uids</uint>…

C#で整数の乱数を作る方法

C#

Ⅰ. はじめに タイトルの通り「C#で整数の乱数を作る方法」です。 Ⅱ. やり方 // .NET 6以上 // var random = new Random(BitConverter.ToInt32(RandomNumberGenerator.GetBytes(4))); var random = new Random((int)DateTime.Now.Ticks & 0x0000FFFF); // 0〜…

C# WPF focusする

textboxなどをfocusするときに使う。また、以下の方法だとfocusしたい要素のFocusableプロパティは設定しなくてよい。 private void FocusItem(IInputElement item) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate() { Keyboard.F…

C# MD5を計算させる

C#

private string CalculateMD5(string str) { using (var md5 = MD5.Create()) { var bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(str)); return BitConverter.ToString(bytes).ToLower().Replace("-", ""); } }

C# 簡単に簡易的なランダム文字列を生成する

C#

最大32文字の0〜9, a〜fの文字でランダム文字列が作れる // 10文字の乱数 string random = Guid.NewGuid().ToString("N").Substring(0, 10); // 出力: eb29ab2d92 // 12文字の乱数 string random = Guid.NewGuid().ToString("N").Substring(0, 12); // 出力:…

C# IL boolの戻り値を反転させる。

パターン1 bool hoge() { return gege(); } // ↓こうしたい bool hoge() { return !gege(); } bool gege { // return false // または // return true; } ldc.i4.0 ceq を追加する call gege() stloc.0 ... ret ↓ call gege() ldc.i4.0 ceq stloc.0 .. ret …

アラド戦記 自動 ログインツール

C#

DFO用として作ったものを日本のアラド戦記にも対応させました。 Chrome用のプラグインも以前作成しましたが今回紹介するツールの方が高速です。■ダウンロード https://github.com/kagasu/ARAD-Auto-Launcher/releases/■ソースコード https://github.com/kaga…

DFOをプレイする

C#

https://www.youtube.com/watch?v=njTdDibWIf4アラド戦記の海外版です。 現在はまだOBTのようです。Dungeon Fighter Online | NEOPLE http://www.dfoneople.com/しかし会員登録、ランチャーでのログインの際は、 proxyやVPNを通す必要があります。 (ゲーム…

SoundCloudでlikeしたものを全部ダウンロードする

C#

kagasu/SoundCloudLikeDownloader https://github.com/kagasu/SoundCloudLikeDownloaderDownload https://github.com/kagasu/SoundCloudLikeDownloader/releases

WPF ListViewのタイトルを左に寄せる

これを加えるだけ <ListView.Resources> <Style TargetType="{x:Type GridViewColumnHeader}"> <Setter Property="HorizontalContentAlignment" Value="Left" /> </Style> </ListView.Resources> 加えるとこんな感じになる <ListView HorizontalAlignment="Left" Height="113" Margin="10,162,0,0" VerticalAlignment="Top" Width="226"> </listview>

C# WebBrowserのcookieを消す(削除する)

C#

方法1 webBrowser1.Document.ExecCommand("ClearAuthenticationCache", false, null); http://stackoverflow.com/questions/21265674/delete-cookies-in-webbrowser-without-restart※2017/09/20追記 Windows 10 Professional 64bit 1703 .NET Framework 4.6.…