/*time_tick - keyboard hit(Auto)*/
/*time_tick - keyboard hit(Auto)*/
/*time_tick - keyboard hit(Auto)*/

using System;
using System.IO;
using System.Timers;
using System.Threading;
using System.Runtime.InteropServices; //DLL Import

namespace ConsoleNoLogin
{
class Program
{
[DllImport("user32.dll")]
public static extern void keybd_event(byte vk, byte scan, int flags, ref int extrainfo);

static System.Timers.Timer timer1;
static System.Timers.Timer timer2;

static int index1=0;
static int index2=0;

static int ____minus=0;

const byte EscKey=27;
const int KEY_UP=0x0002;

const int REMAINED_TIME=60000;
const int SECOND_USER_DEFINE=1000;

static void Main(string[] args)
{
int toggle=0;

timer1 = new System.Timers.Timer();
timer2 = new System.Timers.Timer();

timer1.Interval = REMAINED_TIME;
timer2.Interval = SECOND_USER_DEFINE;

timer1.Elapsed += new ElapsedEventHandler(__tick_time_1);
timer2.Elapsed += new ElapsedEventHandler(__tick_time_2);

timer1.Start();
timer2.Start();

ConsoleKey key = ConsoleKey.NoName;

Logging("Start Timer");
while(true)
{
key=Console.ReadKey(true).Key;
if(key==ConsoleKey.Enter)
{
if(toggle==0)
{
timer1.Stop();
timer2.Stop();

toggle=100;

Logging("Stop Timer");
}
else
{
Logging("Start Timer");

index1=0;
index2=0;

timer1.Start();
timer2.Start();

toggle=0;
}
}
else
if(key==ConsoleKey.Spacebar)
{
timer1.Stop();
timer2.Stop();

break;
}
}

timer1.Elapsed -= __tick_time_1;
timer2.Elapsed -= __tick_time_2;
}

static void __tick_time_1(object sender, ElapsedEventArgs e)
{
int info=0;

index2=0;
index1++;

if(index1 == 100) index1=0;

Logging("MAIN(KEYBOARD HIT)");

keybd_event(EscKey,0,0,ref info);
Thread.Sleep(10);
keybd_event(EscKey,0,KEY_UP,ref info);
}

static void __tick_time_2(object sender, ElapsedEventArgs e)
{
index2++;
____minus=REMAINED_TIME/SECOND_USER_DEFINE-index2;

Logging("SUB ");
}

static void Logging(string msg)
{
DateTime now = DateTime.Now;

if(msg=="Start Timer")
{
Console.WriteLine(">>>>[Start Timer]" + "    " + now.ToString("yyyy-MM-dd hh:mm:ss"));
Console.Title = ">>>>[Start Timer]" + "    " + now.ToString("yyyy-MM-dd hh:mm:ss");
}
else if(msg=="Stop Timer")
{
Console.WriteLine(">>>>[Stop Timer]" + "    " + now.ToString("yyyy-MM-dd hh:mm:ss"));
Console.Title = ">>>>[Stop Timer]" + "    " + now.ToString("yyyy-MM-dd hh:mm:ss");
}
else
{
Console.WriteLine(msg + ">>>>" + "    " + now.ToString("yyyy-MM-dd hh:mm:ss"));
Console.Title = msg + ">>>>" + "    " + now.ToString("yyyy-MM-dd hh:mm:ss");
}
}
}//end of class
}//end of namespace








+ Recent posts