Skip to content

Commit

Permalink
반복 방법 변경, 메세지 알림 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
AquaRains committed Jul 23, 2019
1 parent 0e0f550 commit 679ebe6
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 50 deletions.
20 changes: 4 additions & 16 deletions KKADBlow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,10 @@
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>F5845991FAEB79230E4B4BE2E534C33FEBE09AA5</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>KKADBlow_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>




<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -98,7 +87,6 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="KKADBlow_TemporaryKey.pfx" />
<None Include="Properties\app.manifest" />
</ItemGroup>
<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해
// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
// 이러한 특성 값을 변경하세요.
[assembly: AssemblyTitle("kakaoADFinder")]
[assembly: AssemblyTitle("KKADBlow")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("kakaoADFinder")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyCompany("myhome")]
[assembly: AssemblyProduct("KKADBlow")]
[assembly: AssemblyCopyright("Copyright © suwoo 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
12 changes: 6 additions & 6 deletions Tray.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 44 additions & 24 deletions Tray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,47 @@ namespace KKADBlow
{
public partial class Tray : Form
{
private System.Timers.Timer timer;
int errorcount = 0;
static int ErrorLimit = 5;
IntPtr kakaoMainHandle;

delegate void TimerInvoker();

public Tray()
{
InitializeComponent();

Init();
}

private void Init()
{
WindowState = FormWindowState.Minimized;
ShowInTaskbar = false;
Visible = false;
notifyIcon1.Visible = true;
notifyIcon1.ContextMenuStrip = contextMenuStrip1;

ShowNotify();

}
timer = new System.Timers.Timer(10000);

private void ShowNotify()
{
if (MessageBox.Show("프로그램이 실행되었습니다. 바로 ㄱㄱ할까요?", "기능 실행", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
timer.Elapsed += (sender, e) => BeginInvoke(new TimerInvoker(doit));

광고날리기ToolStripMenuItem.PerformClick();

}
MessageBox.Show("트레이에 아이콘을 확인해주세요.", "안내", MessageBoxButtons.OK, MessageBoxIcon.Information);
notifyIcon1.Visible = true;
notifyIcon1.ContextMenuStrip = contextMenuStrip1;

notifyIcon1.ShowBalloonTip(5000, "실행 확인", "프로그램이 실행되었습니다.", ToolTipIcon.Info);

timer.Start();
}



//ini파일 읽고 쓰기 넣을 예정
//삭제 반복 주기
//hwnd용 클래스 임의로 넣기


private void 자동갱신ToolStripMenuItem_Click(object sender, EventArgs e)
{
자동갱신ToolStripMenuItem.Checked = !자동갱신ToolStripMenuItem.Checked;
}

private void 종료XToolStripMenuItem_Click(object sender, EventArgs e)
{
Expand All @@ -56,28 +61,39 @@ private void 종료XToolStripMenuItem_Click(object sender, EventArgs e)

public void doit()
{
IntPtr kakaoMainHandle = FindWindow("EVA_Window_Dblclk", "카카오톡");
if (kakaoMainHandle.Equals(IntPtr.Zero))
{
MessageBox.Show("카톡 프로그램을 찾을 수 없습니다. 작업이 취소됩니다.", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
kakaoMainHandle = FindWindow("EVA_Window_Dblclk", "카카오톡");
if (kakaoMainHandle.Equals(IntPtr.Zero))
{
notifyIcon1.ShowBalloonTip(5000, "오류", $"카톡 프로그램을 찾을 수 없습니다. {Environment.NewLine}({errorcount++}번째 시도, {ErrorLimit}회 누적시 종료됨).", ToolTipIcon.Error);

if (errorcount > ErrorLimit) this.Close();
return;
}
else
{
notifyIcon1.ShowBalloonTip(5000, "성공", "카톡 창을 찾았습니다. 작업에 들어갑니다!", ToolTipIcon.Info);
errorcount = 0;
}
}


IntPtr KakaoAD = FindWindowEx(kakaoMainHandle, IntPtr.Zero, "EVA_Window", null);

if (KakaoAD.Equals(IntPtr.Zero))
kakaoMainHandle = IntPtr.Zero;

_ = ShowWindow(KakaoAD, ShowWindowCommands.Hide);
// W32.EnableWindow(KakaoAD, true);

RECT ADrect;


_ = GetWindowRect(KakaoAD, out ADrect);
_ = EnumChildWindows(kakaoMainHandle, EnumWindowsCommand, IntPtr.Zero);


do
{
_ = GetWindowRect(KakaoAD, out ADrect);
_ = EnumChildWindows(kakaoMainHandle, EnumWindowsCommand, IntPtr.Zero);
}
while (자동갱신ToolStripMenuItem.Checked);


bool EnumWindowsCommand(IntPtr hwnd, IntPtr lParam)
Expand Down Expand Up @@ -116,5 +132,9 @@ private void Worker_DoWork(object sender, DoWorkEventArgs e)
doit();
}

private void 자동갱신ToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
{
timer.Enabled = 자동갱신ToolStripMenuItem.Checked;
}
}
}

0 comments on commit 679ebe6

Please sign in to comment.