forked from tianruoyouxin/tianruoocr_last
-
Notifications
You must be signed in to change notification settings - Fork 410
/
AliTable.cs
141 lines (129 loc) · 3.9 KB
/
AliTable.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using TrOCR.Helper;
namespace TrOCR
{
public partial class AliTable : Form
{
public AliTable()
{
string fileName = Path.GetFileName(Application.ExecutablePath);
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
if (registryKey != null)
{
registryKey.SetValue(fileName, 11001, RegistryValueKind.DWord);
registryKey.SetValue(fileName, 11001, RegistryValueKind.DWord);
}
registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
if (registryKey != null)
{
registryKey.SetValue(fileName, 11001, RegistryValueKind.DWord);
registryKey.SetValue(fileName, 11001, RegistryValueKind.DWord);
}
InitializeComponent();
}
[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool InternetGetCookieEx(string pchURL, string pchCookieName, StringBuilder pchCookieData, ref int pcchCookieData, int dwFlags, object lpReserved);
private string GetCookieString(string url)
{
int num = 256;
StringBuilder stringBuilder = new StringBuilder(num);
if (!InternetGetCookieEx(url, null, stringBuilder, ref num, 8192, null))
{
if (num < 0)
{
return null;
}
stringBuilder = new StringBuilder(num);
if (!InternetGetCookieEx(url, null, stringBuilder, ref num, 8192, null))
{
return null;
}
}
return stringBuilder.ToString();
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
try
{
count++;
textBox1.Text = GetCookieString(e.Url.ToString());
webBrowser1.Document.Window.ScrollTo(10000, 145);
webBrowser1.Document.Body.SetAttribute("scroll", "no");
webBrowser1.Document.GetElementById("guid-762944").OuterHtml = "";
if (count <= 10)
{
timer1.Interval = 500;
timer1.Start();
}
}
catch
{
}
}
private void Form2_Load(object sender, EventArgs e)
{
webBrowser1.Url = new Uri("https://data.aliyun.com/ai/ocr-other#/ocr-other");
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text.Contains("login_aliyunid=\""))
{
webBrowser1.Url = new Uri("https://data.aliyun.com/ai/ocr-other#/ocr-other");
IniHelper.SetValue("特殊", "ali_cookie", textBox1.Text);
Hide();
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
try
{
cclick();
}
catch
{
}
if (count >= 2)
{
count = 0;
Show();
}
timer1.Stop();
}
}
// (get) Token: 0x0600030A RID: 778 RVA: 0x00003043 File Offset: 0x00001243
// (set) Token: 0x0600030B RID: 779 RVA: 0x00003007 File Offset: 0x00001207
public string getcookie
{
get
{
return textBox1.Text;
}
set
{
webBrowser1.Url = new Uri("https://data.aliyun.com/ai/ocr-other#/ocr-other");
}
}
public void cclick()
{
try
{
if (IniHelper.GetValue("特殊", "ali_account").Trim() != "" && IniHelper.GetValue("特殊", "ali_password").Trim() != "")
{
// WebBrowserHelper.GetDocumentFromWindow(webBrowser1.Document.Window.Frames["alibaba-login-box"].DomWindow as IHTMLWindow2).getElementById("fm-login-id").setAttribute("value", IniHelper.GetValue("特殊", "ali_account"), 1);
// WebBrowserHelper.GetDocumentFromWindow(webBrowser1.Document.Window.Frames["alibaba-login-box"].DomWindow as IHTMLWindow2).getElementById("fm-login-password").setAttribute("value", IniHelper.GetValue("特殊", "ali_password"), 1);
}
}
catch
{
}
}
private int count;
}
}