private void FrmSetOCRKey_Load(object sender, EventArgs e)
        {
            if (local.X >= 0 && local.Y >= 0)
            {
                this.Location = local;
            }

            // 加载ApiKey文件
            DirectoryInfo dir = new DirectoryInfo(Application.StartupPath);

            FileInfo[] files = dir.GetFiles("*.txt");// 查找目录下时txt的文件
            foreach (var f in files)
            {
                if (f.ToString().ToLower() == "apikey.txt")
                {
                    apikeyPath = Path.Combine(Application.StartupPath + "\\", "apikey.txt");
                }
            }

            if (!File.Exists(apikeyPath))
            {
                return;
            }

            string ak, sk;

            OCR.ReadApiKeyFile(apikeyPath, out ak, out sk);
            textBox1_APIKey.Text    = ak;
            textBox2_SecretKey.Text = sk;
        }
Ejemplo n.º 2
0
        private void FrmSetOCRKey_Load(object sender, EventArgs e)
        {
            if (local.X >= 0 && local.Y >= 0)
            {
                this.Location = local;
            }

            // 加载mth文件(教程)
            try
            {
                if (!File.Exists(OCR_KEYMth))
                {
                    File.WriteAllBytes(OCR_KEYMth, Properties.Resources.OCR_KEY);// 将资源文件(*.mht)写入到磁盘
                    FileInfo fi = new FileInfo(OCR_KEYMth);
                    fi.Attributes = FileAttributes.Temporary | FileAttributes.Hidden;
                }
                webBrowser1.Navigate(OCR_KEYMth);                            // 用webBrowser控件加载“mth”文件
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "自动进入钉钉直播", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // 加载ApiKey文件
            DirectoryInfo dir = new DirectoryInfo(Application.StartupPath);

            FileInfo[] files = dir.GetFiles("*.txt");// 查找目录下时txt的文件
            foreach (var f in files)
            {
                if (f.ToString().ToLower() == "apikey.txt")
                {
                    apikeyPath = Path.Combine(Application.StartupPath + "\\", f.ToString());
                }
            }
            if (!File.Exists(apikeyPath))
            {
                return;
            }
            string ak, sk;

            OCR.ReadApiKeyFile(apikeyPath, out ak, out sk);
            textBox1_APIKey.Text    = ak;
            textBox2_SecretKey.Text = sk;
        }