|
|
@@ -0,0 +1,50 @@
|
|
|
+
|
|
|
+
|
|
|
+$ErrorActionPreference = 'Stop'
|
|
|
+
|
|
|
+Add-Type -A System.Windows.Forms
|
|
|
+Add-Type –memberDefinition '[DllImport("user32.dll")]public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);' -name W32 -namespace MyTools –passThru
|
|
|
+[MyTools.W32]::ShowWindow((Get-Process –id $pid).MainWindowHandle, 0)
|
|
|
+
|
|
|
+$global:form = New-Object System.Windows.Forms.Form -Property @{
|
|
|
+ Name = "form"
|
|
|
+ Text = "form"
|
|
|
+ Width = 1
|
|
|
+ Height = 1
|
|
|
+ Visible = $false
|
|
|
+ ShowInTaskbar = $false
|
|
|
+ WindowState= 'Minimized'
|
|
|
+}
|
|
|
+$global:shell = New-Object -Com "Wscript.Shell"
|
|
|
+$global:timer = New-Object System.Windows.Forms.Timer -Property @{Interval = 6000}
|
|
|
+$global:timer.add_tick({
|
|
|
+ # action starts here
|
|
|
+ $global:shell.SendKeys("WOLOLOT")
|
|
|
+ $global:nicon.ShowBalloonTip(1000,'MyAction',"My action fired",'Info')
|
|
|
+})
|
|
|
+
|
|
|
+$global:cmenu = New-Object System.Windows.Forms.ContextMenuStrip
|
|
|
+$global:cmenu.Items.Add('Pause',$null,{
|
|
|
+ if ($this.Text -eq "Pause"){
|
|
|
+ $global:timer.Stop()
|
|
|
+ $this.Text = "Start"
|
|
|
+ }else{
|
|
|
+ $global:timer.Start()
|
|
|
+ $this.Text = "Pause"
|
|
|
+ }
|
|
|
+}) | out-null
|
|
|
+
|
|
|
+$global:cmenu.Items.Add('Exit',$null,{
|
|
|
+ $global:timer.Stop()
|
|
|
+ $global:timer.Dispose()
|
|
|
+ $global:nicon.Dispose()
|
|
|
+ $global:form.Close()
|
|
|
+}) | out-null
|
|
|
+
|
|
|
+$global:nicon = New-Object System.Windows.Forms.NotifyIcon -Property @{
|
|
|
+ Icon = [System.Drawing.Icon]::ExtractAssociatedIcon((Join-Path $env:windir "System32\SystemSettingsBroker.exe"))
|
|
|
+ Visible = $true
|
|
|
+ ContextMenuStrip = $global:cmenu
|
|
|
+}
|
|
|
+$global:timer.Start()
|
|
|
+$global:form.ShowDialog() | out-null
|