Beispiel #1
0
        static void Main()
        {
            // http://techracho.bpsinc.jp/baba/2009_02_10/164
            // エラーハンドラを登録
            // 例外をキャッチしたらerror.txtに吐いて終了する
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Thread.GetDomain().UnhandledException += new UnhandledExceptionEventHandler(Program_UnhandledException);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new MainForm());

            // 二重起動をチェックする
            if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
            {
                // 同じプロセス名で他にプロセスが起動してたら、終了
                MessageBox.Show("他にTweetKeyPressが起動しているため、終了します。。。");
                return;
            }

            // アプリケーションの設定を読み込む
            Settings.LoadFromXmlFile();

            // Twitterの認証を行う
            if (Settings.FileExists)
            {
                tokens = Tokens.Create(
                    Settings.Instance.ConsumerKey,
                    Settings.Instance.ConsumerSecret,
                    Settings.Instance.AccessToken,
                    Settings.Instance.AccessTokenSecret);
            }
            else
            {
                Auth();
                MessageBox.Show(
                    "認証が完了しました。" + Environment.NewLine +
                    "タスクトレイに常駐開始します。" + Environment.NewLine +
                    "0時になると一番押されたキーやマウスのボタンを回数と共にツイートします。" + Environment.NewLine +
                    "(既定ではプログラムの終了時にもツイートします)");
            }

            // ログファイルの読み込み
            myDataTable = new MyDataTable();

            // メインフォームのインスタンスを生成
            MainForm mainForm = new MainForm();

            // 1秒ごとに呼び出されるタイマー
            timer1.Tick += new EventHandler(MyClock1);
            timer1.Interval = 1000;  // 1秒ごとに呼び出す
            timer1.Enabled = true;   // タイマー開始

            // 自動バックアップ処理
            timer2.Tick += new EventHandler(MyClock2);
            timer2.Interval = 600000;  // 10分ごとに呼び出す
            timer2.Enabled = true;   // タイマー開始

            // フックの開始
            Hook();

            // フォームを非表示のままメッセージループを開始する
            Application.Run();
        }
Beispiel #2
0
        static void Main()
        {
            // http://techracho.bpsinc.jp/baba/2009_02_10/164
            // エラーハンドラを登録
            // 例外をキャッチしたらerror.txtに吐いて終了する
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Thread.GetDomain().UnhandledException += new UnhandledExceptionEventHandler(Program_UnhandledException);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new MainForm());

            // 二重起動をチェックする
            if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
            {
                // 同じプロセス名で他にプロセスが起動してたら、終了
                MessageBox.Show("他にTweetKeyPressが起動しているため、終了します。。。");
                return;
            }

            // アプリケーションの設定を読み込む
            Settings.LoadFromXmlFile();

            // Twitterの認証を行う
            if (Settings.FileExists)
            {
                tokens = Tokens.Create(
                    Settings.Instance.ConsumerKey,
                    Settings.Instance.ConsumerSecret,
                    Settings.Instance.AccessToken,
                    Settings.Instance.AccessTokenSecret);
            }
            else
            {
                Auth();
                MessageBox.Show(
                    "認証が完了しました。" + Environment.NewLine +
                    "タスクトレイに常駐開始します。" + Environment.NewLine +
                    "0時になると一番押されたキーやマウスのボタンを回数と共にツイートします。" + Environment.NewLine +
                    "(既定ではプログラムの終了時にもツイートします)");
            }

            // ログファイルの読み込み
            myDataTable = new MyDataTable();

            // メインフォームのインスタンスを生成
            MainForm mainForm = new MainForm();

            // 1秒ごとに呼び出されるタイマー
            timer1.Tick    += new EventHandler(MyClock1);
            timer1.Interval = 1000;  // 1秒ごとに呼び出す
            timer1.Enabled  = true;  // タイマー開始

            // 自動バックアップ処理
            timer2.Tick    += new EventHandler(MyClock2);
            timer2.Interval = 600000; // 10分ごとに呼び出す
            timer2.Enabled  = true;   // タイマー開始

            // フックの開始
            Hook();

            // フォームを非表示のままメッセージループを開始する
            Application.Run();
        }