This repository has been archived by the owner on Jun 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
601 lines (535 loc) · 23.2 KB
/
Form1.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows;
namespace IOU_Helper
{
public partial class Form1 : Form
{
// import the necessary API function so .NET can
// marshall parameters appropriately
[DllImport("user32.dll")]
static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
// constants for the mouse_input() API function
private const int MOUSEEVENTF_MOVE = 0x0001;
private const int MOUSEEVENTF_LEFTDOWN = 0x0002;
private const int MOUSEEVENTF_LEFTUP = 0x0004;
private const int MOUSEEVENTF_RIGHTDOWN = 0x0008;
private const int MOUSEEVENTF_RIGHTUP = 0x0010;
private const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;
private const int MOUSEEVENTF_MIDDLEUP = 0x0040;
private const int MOUSEEVENTF_ABSOLUTE = 0x8000;
private int count = 0;
public Form1()
{
InitializeComponent();
}
//Global Variables
string kongUsername;
string kongID;
string kongToken;
/// <summary>
/// Load the Account Details from a CSV File
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
{
const string FILTER = "CSV Files|*.csv|TXT FILES|*.txt|All Files|*.*";
string[] lineRead = null;
string lineReadFull = "";
AutoSave.Filter = FILTER;
if (AutoSave.ShowDialog() == DialogResult.OK)
{
try
{
StreamReader reader = File.OpenText(AutoSave.FileName);
while (!reader.EndOfStream)
{
lineReadFull = reader.ReadLine();
lineRead = lineReadFull.Split(',');
if (lineReadFull == "<!DOCTYPE html PUBLIC")
{
}
else
{
try
{
//Set the textboxes equal to data
if (lineRead[0] != null)
{
kongUsername = lineRead[0];
textBoxKongUser.Text = lineRead[0];
}
if (lineRead[1] != null)
{
kongID = lineRead[1];
textBoxKongID.Text = lineRead[1];
}
if (lineRead[2] != null)
{
kongToken = lineRead[2];
textBoxKongToken.Text = lineRead[2];
}
if (tabPage1.Text == "Client")
{
this.Size = new Size(736, 538);
//Set the IOU Client to its approiate sizing
tabControl.Width = 746;
tabControl.Height = 580;
this.Size = new Size(756, 600);
//this.Size = new Size(1052, 768);
oldIOUclient.Height = 550;
oldIOUclient.Width = 736;
//Get the black cut off
oldIOUclient.Location = new Point(0, 0);
updateClient(oldIOUclient);
}
else
{
string title = "TabPage " + (tabControl.TabCount + 1).ToString();
TabPage myTabPage = new TabPage(title);
tabControl.TabPages.Add(myTabPage);
myTabPage.Text = kongUsername;
tabControl.SelectedTab = myTabPage;
WebBrowser IOUclient2 = new WebBrowser();
myTabPage.Controls.Add(IOUclient2);
IOUclient2.Height = 550;
IOUclient2.Width = 736;
//Update the client
updateClient(IOUclient2);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
reader.Close();
}
catch (FileNotFoundException ex)
{
MessageBox.Show(ex.Message);
}
}
}
/// <summary>
/// Run the IOU Client
/// </summary>
public void updateClient(WebBrowser client)
{
//Change the Form Title
if (kongUsername != "")
{
tabControl.SelectedTab.Text = kongUsername;
}
else
{
tabControl.SelectedTab.Text = textBoxKongUser.Text;
}
//Take out all other form elements
IOUtitle.Visible = false;
groupBoxAccount.Visible = false;
buttonStartClient.Visible = false;
client.Visible = true;
//System.Uri uri = new System.Uri("http://chat.kongregate.com/gamez/0022/7576/live/iou.swf?kongregate_username=" + kongUsername + "&kongregate_user_id=" + kongID + "&kongregate_game_auth_token=" + kongToken + "&kongregate_api_path=http%3A%2F%2Fchat.kongregate.com%2Fflash%2FAPI_AS3_20fff5ba92ad2028adf76a275de69d65.swf");
System.Uri uri = new System.Uri("http://chat.kongregate.com/gamez/0022/7576/live/iou.swf?kongregate_username=" + kongUsername + "&kongregate_user_id=" + kongID + "&kongregate_game_auth_token=" + kongToken + "&kongregate_api_path=http%3A%2F%2Fchat.kongregate.com%2Fflash%2FAPI_AS3_20fff5ba92ad2028adf76a275de69d65.swf");
//Before pet ^^^^^^^^^^
System.Windows.Forms.Clipboard.SetText("http://chat.kongregate.com/gamez/0022/7576/live/iou.swf?kongregate_username=" + textBoxKongUser.Text + "&kongregate_user_id=" + textBoxKongID.Text + "&kongregate_game_auth_token=" + textBoxKongToken.Text + "&kongregate_api_path=http%3A%2F%2Fchat.kongregate.com%2Fflash%2FAPI_AS3_20fff5ba92ad2028adf76a275de69d65.swf");
//System.Uri official = new System.Uri("http://chat.kongregate.com/gamez/0022/7576/live/iou.swf?kongregate_username=<YOUR_USERNAME>&kongregate_user_id=<YOUR_KONG_ID>&kongregate_game_auth_token=<YOUR_AUTH_TOKEN>&kongregate_api_path=http%3A%2F%2Fchat.kongregate.com%2Fflash%2FAPI_AS3_3b998fc2df3d80d02b78142e0fd8ad7e.swf");
//System.Uri uri = new System.Uri("http://chat.kongregate.com/gamez/0022/7576/live/iou.swf?kongregate_username=" + textBoxKongUser.Text + "&kongregate_user_id=" + textBoxKongID.Text + "&kongregate_game_auth_token=" + textBoxKongToken.Text + "&kongregate_api_path=http%3A%2F%2Fchat.kongregate.com%2Fflash%2FAPI_AS3_3b998fc2df3d80d02b78142e0fd8ad7e.swf");
//System.Uri uri = new System.Uri("https://www.google.co.nz/?gws_rd=cr,ssl&ei=3uZGV4rKFMKq0ASUiL3oCw");
client.Url = uri;
}
/// <summary>
/// Save the current account details to the Auto Save file
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
saveDetails();
}
/// <summary>
/// Saves the details into the AutoSave CSV
/// </summary>
public void saveDetails() {
try
{
StreamWriter writer = File.CreateText(Application.StartupPath + @"\AutoSave.CSV");
writer.WriteLine(textBoxKongUser.Text + "," + textBoxKongID.Text + "," + textBoxKongToken.Text);
writer.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
/// <summary>
/// Save a new CSV including the current Account Details
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
const string FILTER = "CSV Files|*.csv|All Files|*.*";
saveFileDialog1.Filter = FILTER;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
StreamWriter writer = File.CreateText(saveFileDialog1.FileName);
writer.WriteLine(textBoxKongUser.Text + "," + textBoxKongID.Text + "," + textBoxKongToken.Text);
writer.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
/// <summary>
/// Run the IOU Client
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonStartClient_Click(object sender, EventArgs e)
{
//MessageBox.Show(label1.Location.ToString());
if (textBoxKongUser.Text != "" && textBoxKongID.Text != "" && textBoxKongToken.Text != "")
{
//Set the IOU Client to its approiate sizing
tabControl.Width = 746;
tabControl.Height = 580;
this.Size = new Size(756, 600);
//this.Size = new Size(1052, 768);
oldIOUclient.Height = 550;
oldIOUclient.Width = 736;
//Get the black cut off
oldIOUclient.Location = new Point(0, 0);
updateClient(oldIOUclient);
saveDetails();
}
else
{
MessageBox.Show("Please fill out the textboxes provided.");
}
}
/// <summary>
/// Close the client
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
/// <summary>
/// On Form Load, check if AutoSave has data, if so run client
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_Load(object sender, EventArgs e)
{
//Form Settings
this.FormBorderStyle = FormBorderStyle.FixedSingle;
string[] lineRead = null;
string lineReadFull = "";
try
{
StreamReader reader = File.OpenText(Application.StartupPath + @"\AutoSave.CSV");
while (!reader.EndOfStream)
{
lineReadFull = reader.ReadLine();
lineRead = lineReadFull.Split(',');
try
{
if (lineRead[0] != null)
{
kongUsername = lineRead[0];
textBoxKongUser.Text = lineRead[0];
}
if (lineRead[1] != null)
{
kongID = lineRead[1];
textBoxKongID.Text = lineRead[1];
}
if (lineRead[2] != null)
{
kongToken = lineRead[2];
textBoxKongToken.Text = lineRead[2];
//Set the IOU Client to its approiate sizing
tabControl.Width = 746;
tabControl.Height = 580;
this.Size = new Size(756, 600);
//this.Size = new Size(1052, 768);
oldIOUclient.Height = 550;
oldIOUclient.Width = 736;
//Get the black cut off
oldIOUclient.Location = new Point(0, 0);
updateClient(oldIOUclient);
}
else
{
break;
}
}
catch (Exception ex)
{
//MessageBox.Show(ex.ToString());
}
}
reader.Close();
}
catch (FileNotFoundException ex)
{
//MessageBox.Show(ex.Message);
}
}
/// <summary>
/// Links to different URL's
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void iOUHelperToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("http://www.iouhelper.com/");
}
private void iOUChatToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("https://discordapp.com/channels/146007387466235905/146007387466235905");
}
private void iOUForumToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("https://iourpg.com/forum/");
}
private void iOUWikiToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("http://iourpg.wikia.com/wiki/Idle_Online_Universe_Wiki");
}
private void startAutoClickerToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("hi");
}
private void refreshToolStripMenuItem_Click(object sender, EventArgs e)
{
updateClient(oldIOUclient);
}
private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
{
Settings settingsForm = new Settings(this);
settingsForm.Show();
}
private void refreshToolStripMenuItem1_Click(object sender, EventArgs e)
{
updateClient(oldIOUclient);
}
/// <summary>
/// Start AutoClicker
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void startAutoClickerToolStripMenuItem1_Click(object sender, EventArgs e)
{
if (startAutoClickerToolStripMenuItem1.Text == "Start AutoClicker") {
autoClickTimer.Enabled = true;
startAutoClickerToolStripMenuItem1.Text = "Stop AutoClicker";
}
else if (startAutoClickerToolStripMenuItem1.Text == "Stop AutoClicker")
{
autoClickTimer.Enabled = false;
startAutoClickerToolStripMenuItem1.Text = "Start AutoClicker";
}
}
public void enableTimer(int milSeconds, bool isEnabled)
{
try
{
refreshTimer.Interval = milSeconds;
refreshTimer.Enabled = isEnabled;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void refreshTimer_Tick(object sender, EventArgs e)
{
updateClient(oldIOUclient);
}
/// <summary>
/// simulates a click-and-release action of the left mouse
/// button at its current position
/// </summary>
public static void LeftClick()
{
mouse_event(MOUSEEVENTF_LEFTDOWN, Control.MousePosition.X, Control.MousePosition.Y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, Control.MousePosition.X, Control.MousePosition.Y, 0, 0);
}
private void autoClickTimer_Tick(object sender, EventArgs e)
{
LeftClick();
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if ((keyData == Keys.F1) && (autoClickTimer.Enabled == false))
{
autoClickTimer.Enabled = true;
startAutoClickerToolStripMenuItem1.Text = "Stop AutoClicker";
return true;
}
else if ((keyData == Keys.F3) && (autoClickTimer.Enabled == true))
{
autoClickTimer.Enabled = false;
startAutoClickerToolStripMenuItem1.Text = "Start AutoClicker";
return true;
}
else if (keyData == Keys.F5)
{
updateClient(oldIOUclient);
return true;
}
else if (keyData == Keys.F6)
{
if (tabControl.TabCount == 1)
{
DialogResult result = MessageBox.Show("Are you sure you want to close your only active tab?", "Close tab",
MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
this.Close();
}
}
else
{
tabControl.TabPages.Remove(tabControl.SelectedTab);
}
}
// Call the base class
return base.ProcessCmdKey(ref msg, keyData);
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
oldIOUclient.Visible = false;
this.Size = new Size(490, 392);
groupBoxAccount.Visible = true;
buttonStartClient.Visible = true;
IOUtitle.Visible = true;
this.Text = "IOU Client v1.0";
}
public void autoClicker(int milSeconds)
{
try
{
autoClickTimer.Interval = milSeconds;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void newTabToolStripMenuItem_Click(object sender, EventArgs e)
{
//Tab
string title = "TabPage " + (tabControl.TabCount + 1).ToString();
TabPage myTabPage = new TabPage(title);
tabControl.TabPages.Add(myTabPage);
myTabPage.Text = "Client";
tabControl.SelectedTab = myTabPage;
myTabPage.BackColor = System.Drawing.ColorTranslator.FromHtml("#222222");
int c = tabControl.TabCount;
//Label
Label label = new Label();
label.Location = new System.Drawing.Point(144, 17);
label.Parent = myTabPage;
label.Name = "IOUtitle" + c.ToString();
label.Text = "IOU Helper";
label.ForeColor = System.Drawing.ColorTranslator.FromHtml("#B92E2E");
label.Size = new System.Drawing.Size(209, 44);
label.Font = new Font("Microsoft Sans Serif", 28);
myTabPage.Controls.Add(label);
//GroupBox
GroupBox groupBox = new GroupBox();
groupBox.Location = new System.Drawing.Point(66, 76);
groupBox.Parent = myTabPage;
groupBox.Name = "groupBoxAccount" + c.ToString();
groupBox.Text = "Account Details";
groupBox.ForeColor = System.Drawing.ColorTranslator.FromHtml("#B4B4B4");
groupBox.Size = new System.Drawing.Size(341, 137);
myTabPage.Controls.Add(groupBox);
Label label1 = new Label();
label1.Location = new System.Drawing.Point(12, 36);
label1.Parent = myTabPage;
label1.Name = "label1" + c.ToString();
label1.Text = "Kongregate Username : ";
label1.ForeColor = System.Drawing.ColorTranslator.FromHtml("#B4B4B4");
label1.Size = new System.Drawing.Size(122, 13);
label1.Font = new Font("Microsoft Sans Serif", 8);
groupBox.Controls.Add(label1);
Label label2 = new Label();
label2.Location = new System.Drawing.Point(12, 63);
label2.Parent = myTabPage;
label2.Name = "label2" + c.ToString();
label2.Text = "Kongregate ID : ";
label2.ForeColor = System.Drawing.ColorTranslator.FromHtml("#B4B4B4");
label2.Size = new System.Drawing.Size(85, 13);
label2.Font = new Font("Microsoft Sans Serif", 8);
groupBox.Controls.Add(label2);
Label label3 = new Label();
label3.Location = new System.Drawing.Point(12, 90);
label3.Parent = myTabPage;
label3.Name = "label3" + c.ToString();
label3.Text = "Kongregate Token : ";
label3.ForeColor = System.Drawing.ColorTranslator.FromHtml("#B4B4B4");
label3.Size = new System.Drawing.Size(102, 13);
label3.Font = new Font("Microsoft Sans Serif", 8);
groupBox.Controls.Add(label3);
TextBox textBox1 = new TextBox();
textBox1.Location = new System.Drawing.Point(12, 90);
textBox1.Parent = myTabPage;
textBox1.Name = "label3" + c.ToString();
label3.ForeColor = System.Drawing.ColorTranslator.FromHtml("#B4B4B4");
textBox1.BackColor = System.Drawing.ColorTranslator.FromHtml("#B4B4B4");
textBox1.Size = new System.Drawing.Size(102, 13);
textBox1.Font = new Font("Microsoft Sans Serif", 8);
groupBox.Controls.Add(textBox1);
//Button
Button button = new Button();
button.Location = new System.Drawing.Point(151, 245);
button.Parent = myTabPage;
button.Name = "buttonStartClient" + c.ToString();
button.Text = "Start Client";
button.BackColor = System.Drawing.ColorTranslator.FromHtml("#161616");
button.ForeColor = System.Drawing.ColorTranslator.FromHtml("#B4B4B4");
button.Size = new System.Drawing.Size(186, 60);
button.Font = new Font("Microsoft Sans Serif", 10);
myTabPage.Controls.Add(button);
}
private void closeTabToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tabControl.TabCount == 1)
{
DialogResult result = MessageBox.Show("Are you sure you want to close your only active tab?", "Close tab",
MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
this.Close();
}
}
else
{
tabControl.TabPages.Remove(tabControl.SelectedTab);
}
}
}
}