-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path1006.html
More file actions
218 lines (183 loc) · 8 KB
/
1006.html
File metadata and controls
218 lines (183 loc) · 8 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="PoshCode - Community resources for PowerShell coders">
<meta name="author" content="cz9qvh">
<title>Out-Balloon.ps1 - PoshCode</title>
<link rel="stylesheet" href="/css/superhero.min.css">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="/css/highlight/arta.css">
<style>
body {
padding-top: 50px;
padding-bottom: 20px;
}
</style>
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm fixed-top navbar-dark bg-dark">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="https://PoshCode.org/">PoshCode</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<div id="navbarResponsive" class="collapse navbar-collapse navbar-responsive-collapse navbar-right">
<ul class="nav navbar-nav nav-tabs ml-auto" id="tabs">
<li class="nav-item"><a class="nav-link" href="/">Join Us!</a></li>
<li class="nav-item"><a class="nav-link active show" href="/scripts" data-toggle="tab">Scripts</a></li>
<li class="nav-item"><a class="nav-link" href="/video">Videos</a></li>
</ul>
</div><!--/.navbar-collapse -->
</div>
</nav>
</header>
<div class="container">
<div class="blog-header">
<h1 class="blog-title">PoshCode</h1>
<p class="lead blog-description">Community resources for PowerShell coders</p>
</div>
<div class="row">
<div class="blog-post">
<h2 class="blog-post-title">Out-Balloon.ps1</h2>
<p class="blog-post-meta">
<span class="blog-post-time">2009-04-08</span> by <a class="blog-post-author">cz9qvh</a>
</p>
<h3>Download <a href="/scripts/1006.ps1">Out-Balloon.ps1.ps1</a> - <a href="/scripts/1005.html">parent</a></h3>
<pre><code> With just a few arguments, it is easy to make some text appear in a little balloon.
You can specify an icon file (*.ico) with the -icon argument, if you don't then
the first icon of the host is used.
out-balloon accepts pipeline input, strings only please.
It blocks for the duration of the balloon display, 3 seconds by default. Simple
fixes for this are welcome.
timeout should be an integer value.
INSTALLATION:
um, save this text in a file named out-balloon.ps1 in your path
</code></pre>
<pre><code class="language-powershell"><#
.Synopsis
Makes a baloon tip in the notification area
.Description
With just a few arguments, it is easy to make some text appear in a little balloon.
You can specify an icon file (*.ico) with the -icon argument, if you don't then
the first icon of the host is used.
out-balloon accepts pipeline input, strings only please.
It blocks for the duration of the balloon display, 3 seconds by default. Simple
fixes for this are welcome.
timeout should be an integer value.
INSTALLATION:
um, save this text in a file named out-balloon.ps1 in your path
.Example
out-balloon "hey, your job is done." -icon "C:\Program Files\Microsoft Office\Office12\MYSL.ICO"
"job done." | out-balloon
#>
param(
[Parameter(ValueFromPipeline=$true,Position=0,Mandatory=$true)]
[Alias('output')]
[string]$text,
[string]$icon,
[int32]$timeout = 3
)
begin
{
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
$not = new-object System.Windows.Forms.NotifyIcon
if ($icon -eq $null)
{
if ($win32extraciconex -eq $null)
{
$script:ExtractIconEx = Add-Type –memberDefinition @"
[DllImport("Shell32", CharSet=CharSet.Auto)]
private static extern int ExtractIconEx (string lpszFile, int nIconIndex,
IntPtr[] phIconLarge,IntPtr[] phIconSmall,int nIcons);
[DllImport("user32.dll", EntryPoint="DestroyIcon", SetLastError=true)]
private static extern int DestroyIcon(IntPtr hIcon);
public static System.Drawing.Icon ExtractIconFromExe(string file, bool large)
{
int readIconCount = 0;
IntPtr[] hDummy = new IntPtr[1] {IntPtr.Zero};
IntPtr[] hIconEx = new IntPtr[1] {IntPtr.Zero};
try
{
if(large)
readIconCount = ExtractIconEx(file,0, hIconEx, hDummy, 1);
else
readIconCount = ExtractIconEx(file,0, hDummy, hIconEx, 1);
if(readIconCount > 0 && hIconEx[0] != IntPtr.Zero)
{
System.Drawing.Icon extractedIcon = (System.Drawing.Icon)System.Drawing.Icon.FromHandle(hIconEx[0]).Clone();
return extractedIcon;
}
else // NO ICONS READ
return null;
}
catch(Exception ex)
{
throw new ApplicationException("Failed extracting icon", ex);
}
finally
{
foreach(IntPtr ptr in hIconEx)
if(ptr != IntPtr.Zero)
DestroyIcon(ptr);
foreach(IntPtr ptr in hDummy)
if(ptr != IntPtr.Zero)
DestroyIcon(ptr);
}
}
"@ -name “Win32ExtractIconEx” -namespace win32api –passThru -ReferencedAssemblies "System.Drawing"
}
$not.Icon = $extractIconEx::ExtractIconFromExe((get-process -Id $pid).mainmodule.filename, $true)
}
else
{
$not.Icon = new-object System.Drawing.Icon($icon)
}
$not.visible = $true
}
process
{
$not.BalloonTipText = $text
$not.ShowBalloonTip($timeout)
sleep $timeout
}
end
{
$not.dispose()
}
</code></pre>
</div>
<!-- sidebar? -->
</div>
<hr>
<footer class="blog-footer">
<p>Generated by Joel "Jaykul" Bennett - 2018</p>
</footer>
</div> <!-- /container -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<script src="/js/main.js"></script>
<script src="/js/vendor/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-59988721-1', 'auto');
ga('send', 'pageview');
$(function () {
$('#contentTabs a:first').tab('show')
})
</script>
</body>
</html>