<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>i__h4x programming?</title>
	<atom:link href="http://ih4x.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ih4x.wordpress.com</link>
	<description></description>
	<pubDate>Wed, 21 May 2008 17:25:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
	<language>en</language>
			<item>
		<title>Vb Net Function - GetWindowPos</title>
		<link>http://ih4x.wordpress.com/2008/05/21/vb-net-function-getwindowpos/</link>
		<comments>http://ih4x.wordpress.com/2008/05/21/vb-net-function-getwindowpos/#comments</comments>
		<pubDate>Wed, 21 May 2008 17:24:04 +0000</pubDate>
		<dc:creator>ih4x</dc:creator>
		
		<category><![CDATA[VB.net]]></category>

		<category><![CDATA[.net]]></category>

		<category><![CDATA[API]]></category>

		<category><![CDATA[window function]]></category>

		<guid isPermaLink="false">http://ih4x.wordpress.com/2008/05/21/vb-net-function-getwindowpos/</guid>
		<description><![CDATA[GetWindowPos - The equivalent of SetWindowPos API
Right, well for anyone that has used the SetWindowPos API, you will realise that there is no single way to get the equivalent values returned to you.
As I&#8217;m lazy, I like to be able to do things easily in one nice neat function, without having to call things here [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNoSpacing"><strong><span>GetWindowPos</span></strong><span> - <em>The equivalent of SetWindowPos API</em></span></p>
<p class="MsoNoSpacing"><span>Right, well for anyone that has used the SetWindowPos API, you will realise that there is no single way to get the equivalent values returned to you.</span></p>
<p class="MsoNoSpacing"><span>As I&#8217;m lazy, I like to be able to do things easily in one nice neat function, without having to call things here and there to achieve my target.</span></p>
<p class="MsoNoSpacing"><span>If you use the function on a control, it will return the handles for the buttons next in the forms Z order.</span></p>
<p class="MsoNoSpacing"><span>If the handle passed for hwnd is invalid, the function will return 0 for all values.</span></p>
<p class="MsoNoSpacing"><span> </span></p>
<p class="MsoNoSpacing"><span><span> </span>hwnd - <em>In</em> - The handle of the window you wish to get the information from</span></p>
<p class="MsoNoSpacing"><span><span> </span>ptrPhwnd - <em>Out</em> - Returns the handle of the previous window in the Z order</span></p>
<p class="MsoNoSpacing"><span><span> </span>ptrNhwnd - <em>Out</em> - Returns the handle of the next window in the Z order</span></p>
<p class="MsoNoSpacing"><span><span> </span>ptPoint - <em>Out</em> - Returns the location of the specified window on the screen</span></p>
<p class="MsoNoSpacing"><span><span> </span>szSize - <em>Out</em> - Returns the size of the specified window</span></p>
<p class="MsoNoSpacing"><span><span> </span>intShowCmd - <em>Out</em> - Returns the state of the window, returns a WNDSTATE value</span></p>
<p class="MsoNoSpacing"><span> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> <span style="color:blue;">Sub</span> GetWindowPos( _</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ByVal</span> hwnd <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, _</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ByRef</span> ptrPhwnd <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, _</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ByRef</span> ptrNhwnd <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, _</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ByRef</span> ptPoint <span style="color:blue;">As</span> Point, _</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ByRef</span> szSize <span style="color:blue;">As</span> Size, _</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ByRef</span> intShowCmd <span style="color:blue;">As</span> WNDSTATE _</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Dim</span> wInf <span style="color:blue;">As</span> WINDOWPLACEMENT</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>wInf.Length = System.Runtime.InteropServices.Marshal.SizeOf(wInf)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>GetWindowPlacement(hwnd, wInf)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>szSize = <span style="color:blue;">New</span> Size(wInf.rcNormalPosition.Right - wInf.rcNormalPosition.Left, _</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>wInf.rcNormalPosition.Bottom - wInf.rcNormalPosition.Top)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>ptPoint = <span style="color:blue;">New</span> Point(wInf.rcNormalPosition.Left, wInf.rcNormalPosition.Top)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>ptrPhwnd = GetNextWindow(hwnd, GW_HWNDPREV)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>ptrNhwnd = GetNextWindow(hwnd, GW_HWNDNEXT)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>intShowCmd = wInf.showCmd</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;"> </span></p>
<p class="MsoNoSpacing"><span>Example usage of this:</span></p>
<p class="MsoNoSpacing"><span> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:green;">&#8221;The size of the window</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">Dim</span><span style="font-size:10pt;font-family:&quot;"> wSize <span style="color:blue;">As</span> <span style="color:blue;">New</span> Size</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:green;">&#8221;The location of the window</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">Dim</span><span style="font-size:10pt;font-family:&quot;"> wLocation <span style="color:blue;">As</span> <span style="color:blue;">New</span> Point</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:green;">&#8221;The previous/next windows handles</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">Dim</span><span style="font-size:10pt;font-family:&quot;"> wPhwnd, wNhwnd <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:green;">&#8221;The window state of the window</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">Dim</span><span style="font-size:10pt;font-family:&quot;"> wShowCmd <span style="color:blue;">As</span> WNDSTATE</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:green;">&#8221;Calling the function to these variables</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;">GetWindowPos(<span style="color:blue;">Me</span>.Handle, wPhwnd, wNhwnd, wLocation, wSize, wShowCmd)</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&quot;">________________________</span></p>
<p class="MsoNoSpacing">And for the <strong>WNDSTATE</strong> Enum used in the function</p>
<p class="MsoNoSpacing">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">Public</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Enum</span> WNDSTATE</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>SW_HIDE = 0</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>SW_SHOWNORMAL = 1</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>SW_NORMAL = 1</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>SW_SHOWMINIMIZED = 2</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>SW_MAXIMIZE = 3</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>SW_SHOWNOACTIVATE = 4</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>SW_SHOW = 5</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>SW_MINIMIZE = 6</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>SW_SHOWMINNOACTIVE = 7</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>SW_SHOWNA = 8</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>SW_RESTORE = 9</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>SW_SHOWDEFAULT = 10</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>SW_MAX = 10</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;">End</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Enum</span></span></p>
<p class="MsoNoSpacing"><span> </span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&quot;">________________________</span></p>
<p class="MsoNoSpacing"><span>And the APIs used in the Function</span></p>
<p class="MsoNoSpacing"><span> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">Private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Declare</span> <span style="color:blue;">Function</span> GetNextWindow <span style="color:blue;">Lib</span> <span style="color:#a31515;">&#8220;user32&#8243;</span> <span style="color:blue;">Alias</span> <span style="color:#a31515;">&#8220;GetWindow&#8221;</span> (<span style="color:blue;">ByVal</span> hwnd <span style="color:blue;">As</span> IntPtr, <span style="color:blue;">ByVal</span> wFlag <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>) <span style="color:blue;">As</span> IntPtr</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">Private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Declare</span> <span style="color:blue;">Function</span> GetWindowPlacement <span style="color:blue;">Lib</span> <span style="color:#a31515;">&#8220;user32&#8243;</span> (<span style="color:blue;">ByVal</span> hwnd <span style="color:blue;">As</span> IntPtr, <span style="color:blue;">ByRef</span> lpwndpl <span style="color:blue;">As</span> WINDOWPLACEMENT) <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;"> </span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&quot;">________________________</span></p>
<p class="MsoNoSpacing"><span>And the rest</span></p>
<p class="MsoNoSpacing"><span> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">Private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Const</span> GW_HWNDNEXT = 2</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;">Private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Const</span> GW_HWNDPREV = 3</span></p>
<p class="MsoNoSpacing"><span> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">Private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Structure</span> POINTAPI</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> x <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> y <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">End</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Structure</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">Private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Structure</span> RECT</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> Left <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> Top <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> Right <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> Bottom <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">End</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Structure</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">Private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Structure</span> WINDOWPLACEMENT</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> Length <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> flags <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> showCmd <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">Public</span> ptMinPosition <span style="color:blue;">As</span> POINTAPI</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> ptMaxPosition <span style="color:blue;">As</span> POINTAPI</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> rcNormalPosition <span style="color:blue;">As</span> RECT</span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&quot;color:blue;">End</span><span style="font-size:10pt;line-height:115%;font-family:&quot;"> <span style="color:blue;">Structure</span></span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ih4x.wordpress.com/44/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ih4x.wordpress.com/44/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ih4x.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ih4x.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ih4x.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ih4x.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ih4x.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ih4x.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ih4x.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ih4x.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ih4x.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ih4x.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ih4x.wordpress.com&blog=3140361&post=44&subd=ih4x&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ih4x.wordpress.com/2008/05/21/vb-net-function-getwindowpos/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/ih4x-128.jpg" medium="image">
			<media:title type="html">ih4x</media:title>
		</media:content>
	</item>
		<item>
		<title>Vb Net - Change MSN Name</title>
		<link>http://ih4x.wordpress.com/2008/05/18/vb-net-change-msn-name/</link>
		<comments>http://ih4x.wordpress.com/2008/05/18/vb-net-change-msn-name/#comments</comments>
		<pubDate>Sun, 18 May 2008 17:18:51 +0000</pubDate>
		<dc:creator>ih4x</dc:creator>
		
		<category><![CDATA[VB.net]]></category>

		<category><![CDATA[.net]]></category>

		<category><![CDATA[API]]></category>

		<category><![CDATA[MSN]]></category>

		<category><![CDATA[Name changer]]></category>

		<category><![CDATA[SendMessage]]></category>

		<category><![CDATA[spammer]]></category>

		<guid isPermaLink="false">http://ih4x.wordpress.com/?p=43</guid>
		<description><![CDATA[This is just a slightly more efficient way to change your MSN name than using SendKeys.
It uses the SendMessage API in order to set the text, rather than SendKeys.

The code is pretty fully commented, and so there is nothing much to explain…
Below is the full source file:

Imports System.Runtime.InteropServices
Public Class Form1
 
 &#8221;API
 &#60;DllImport(&#8220;User32.dll&#8221;)&#62; Private Shared [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNoSpacing">This is just a slightly more efficient way to change your MSN name than using SendKeys.</p>
<p class="MsoNoSpacing">It uses the SendMessage API in order to set the text, rather than SendKeys.</p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing">The code is pretty fully commented, and so there is nothing much to explain…</p>
<p class="MsoNoSpacing">Below is the full source file:</p>
<p class="MsoNoSpacing">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;">Imports</span><span style="font-size:10pt;"> System.Runtime.InteropServices</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;">Public</span><span style="font-size:10pt;"> <span style="color:blue;">Class</span> Form1</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;API</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>&lt;DllImport(<span style="color:#a31515;">&#8220;User32.dll&#8221;</span>)&gt; <span style="color:blue;">Private</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Function</span> EnumChildWindows(<span style="color:blue;">ByVal</span> WindowHandle <span style="color:blue;">As</span> IntPtr, <span style="color:blue;">ByVal</span> Callback <span style="color:blue;">As</span> EnumWindowProcess, <span style="color:blue;">ByVal</span> lParam <span style="color:blue;">As</span> IntPtr) <span style="color:blue;">As</span> <span style="color:blue;">Boolean</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Function</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>&lt;DllImport(<span style="color:#a31515;">&#8220;user32.dll&#8221;</span>, CharSet:=CharSet.Auto)&gt; <span style="color:blue;">Private</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Sub</span> GetClassName(<span style="color:blue;">ByVal</span> hWnd <span style="color:blue;">As</span> System.IntPtr, <span style="color:blue;">ByVal</span> lpClassName <span style="color:blue;">As</span> System.Text.StringBuilder, <span style="color:blue;">ByVal</span> nMaxCount <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>&lt;DllImport(<span style="color:#a31515;">&#8220;user32.dll&#8221;</span>, SetLastError:=<span style="color:blue;">True</span>, CharSet:=CharSet.Auto)&gt; <span style="color:blue;">Private</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Function</span> GetWindowText(<span style="color:blue;">ByVal</span> hwnd <span style="color:blue;">As</span> IntPtr, <span style="color:blue;">ByVal</span> lpString <span style="color:blue;">As</span> System.Text.StringBuilder, <span style="color:blue;">ByVal</span> cch <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>) <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Function</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>&lt;DllImport(<span style="color:#a31515;">&#8220;user32.dll&#8221;</span>, SetLastError:=<span style="color:blue;">True</span>, CharSet:=CharSet.Auto)&gt; <span style="color:blue;">Private</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Function</span> GetWindowTextLength(<span style="color:blue;">ByVal</span> hwnd <span style="color:blue;">As</span> IntPtr) <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Function</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Declare</span> <span style="color:blue;">Auto</span> <span style="color:blue;">Function</span> SendMessage <span style="color:blue;">Lib</span> <span style="color:#a31515;">&#8220;user32&#8243;</span> (<span style="color:blue;">ByVal</span> hwnd <span style="color:blue;">As</span> IntPtr, <span style="color:blue;">ByVal</span> wMsg <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> wparam <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> lparam <span style="color:blue;">As</span> System.Text.StringBuilder) <span style="color:blue;">As</span> IntPtr</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Declare</span> <span style="color:blue;">Auto</span> <span style="color:blue;">Function</span> SendMessage <span style="color:blue;">Lib</span> <span style="color:#a31515;">&#8220;user32&#8243;</span> (<span style="color:blue;">ByVal</span> hWnd <span style="color:blue;">As</span> IntPtr, <span style="color:blue;">ByVal</span> msg <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> wParam <span style="color:blue;">As</span> IntPtr, <span style="color:blue;">ByVal</span> lParam <span style="color:blue;">As</span> <span style="color:blue;">String</span>) <span style="color:blue;">As</span> IntPtr</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Declare</span> <span style="color:blue;">Auto</span> <span style="color:blue;">Function</span> FindWindow <span style="color:blue;">Lib</span> <span style="color:#a31515;">&#8220;user32&#8243;</span> (<span style="color:blue;">ByVal</span> lpClassName <span style="color:blue;">As</span> <span style="color:blue;">String</span>, <span style="color:blue;">ByVal</span> lpWindowName <span style="color:blue;">As</span> <span style="color:blue;">String</span>) <span style="color:blue;">As</span> IntPtr</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;API Functions</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Function</span> GetChildWindows(<span style="color:blue;">ByVal</span> ParentHandle <span style="color:blue;">As</span> IntPtr) <span style="color:blue;">As</span> IntPtr()</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> ChildrenList <span style="color:blue;">As</span> <span style="color:blue;">New</span> List(<span style="color:blue;">Of</span> IntPtr)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> ListHandle <span style="color:blue;">As</span> GCHandle = GCHandle.Alloc(ChildrenList)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Try</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>EnumChildWindows(ParentHandle, <span style="color:blue;">AddressOf</span> EnumWindow, GCHandle.ToIntPtr(ListHandle))</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Finally</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">If</span> ListHandle.IsAllocated <span style="color:blue;">Then</span> ListHandle.Free()</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Try</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Return</span> ChildrenList.ToArray</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Function</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Function</span> EnumWindow(<span style="color:blue;">ByVal</span> Handle <span style="color:blue;">As</span> IntPtr, <span style="color:blue;">ByVal</span> Parameter <span style="color:blue;">As</span> IntPtr) <span style="color:blue;">As</span> <span style="color:blue;">Boolean</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> ChildrenList <span style="color:blue;">As</span> List(<span style="color:blue;">Of</span> IntPtr) = GCHandle.FromIntPtr(Parameter).Target</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">If</span> ChildrenList <span style="color:blue;">Is</span> <span style="color:blue;">Nothing</span> <span style="color:blue;">Then</span> <span style="color:blue;">Throw</span> <span style="color:blue;">New</span> Exception(<span style="color:#a31515;">&#8220;GCHandle Target could not be cast as List(Of IntPtr)&#8221;</span>)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>ChildrenList.Add(Handle)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Return</span> <span style="color:blue;">True</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Function</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Public</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Function</span> GetText(<span style="color:blue;">ByVal</span> hWnd <span style="color:blue;">As</span> IntPtr) <span style="color:blue;">As</span> <span style="color:blue;">String</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> length <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">If</span> hWnd.ToInt32 &lt;= 0 <span style="color:blue;">Then</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Return</span> <span style="color:blue;">Nothing</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>length = GetWindowTextLength(hWnd)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">If</span> length = 0 <span style="color:blue;">Then</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Return</span> <span style="color:blue;">Nothing</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> sb <span style="color:blue;">As</span> <span style="color:blue;">New</span> System.Text.StringBuilder(<span style="color:#a31515;">&#8220;&#8221;</span>, length + 1)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span> </span>GetWindowText(hWnd, sb, sb.Capacity)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Return</span> sb.ToString()</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Function</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Constants</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_SETTEXT = &amp;HC</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_CHAR = &amp;H102</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_KEYDOWN = &amp;H100</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_KEYUP = &amp;H101</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_SETFOCUS = &amp;H7</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Window Enum Delegate</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Delegate</span> <span style="color:blue;">Function</span> EnumWindowProcess(<span style="color:blue;">ByVal</span> Handle <span style="color:blue;">As</span> IntPtr, <span style="color:blue;">ByVal</span> Parameter <span style="color:blue;">As</span> IntPtr) <span style="color:blue;">As</span> <span style="color:blue;">Boolean</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;This function finds the Handle for the MSN Options window</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Function</span> FindMSN() <span style="color:blue;">As</span> IntPtr</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>FindMSN = FindWindow(vbNullString, <span style="color:#a31515;">&#8220;Options&#8221;</span>)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Function</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;This function Sends the text to the Options window</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Public</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Function</span> SendText(<span style="color:blue;">Optional</span> <span style="color:blue;">ByVal</span> Display_Text <span style="color:blue;">As</span> <span style="color:blue;">String</span> = <span style="color:#a31515;">&#8220;&#8221;</span>, <span style="color:blue;">Optional</span> <span style="color:blue;">ByVal</span> Personal_Text <span style="color:blue;">As</span> <span style="color:blue;">String</span> = <span style="color:#a31515;">&#8220;&#8221;</span>) <span style="color:blue;">As</span> <span style="color:blue;">Boolean</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Create the Messenger API</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> iMessenger <span style="color:blue;">As</span> MessengerAPI.Messenger</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>iMessenger = <span style="color:blue;">New</span> MessengerAPI.Messenger</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Show the options window</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>iMessenger.OptionsPages(0, MessengerAPI.MOPTIONPAGE.MOPT_GENERAL_PAGE)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Get the options windows handle</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> handle <span style="color:blue;">As</span> IntPtr = FindMSN()</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;This will keep looping until the window is found</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Do</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>handle = FindMSN()</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Loop</span> <span style="color:blue;">Until</span> handle &lt;&gt; 0</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Sleeps the thread while the options window loads</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>System.Threading.Thread.Sleep(60)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;i is our counter for which control we are on</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> i <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = 0</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Loop through each of the child windows</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">For</span> <span style="color:blue;">Each</span> child <span style="color:blue;">As</span> IntPtr <span style="color:blue;">In</span> GetChildWindows(handle)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Gets the class name of the child</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> sClassName <span style="color:blue;">As</span> <span style="color:blue;">New</span> System.Text.StringBuilder(<span style="color:#a31515;">&#8220;&#8221;</span>, 256)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Call</span> GetClassName(child, sClassName, 256)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Converts it to a readable string</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> x <span style="color:blue;">As</span> <span style="color:blue;">String</span> = sClassName.ToString</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;If its a textbox</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">If</span> x = <span style="color:#a31515;">&#8220;RichEdit20W&#8221;</span> <span style="color:blue;">Then</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>i += 1</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;If we are on the first control, the display name box</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">If</span> i = 1 <span style="color:blue;">Then</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;If display text is being changed</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">If</span> Display_Text &lt;&gt; <span style="color:#a31515;">&#8220;&#8221;</span> <span style="color:blue;">Then</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Send the display text to the textbox</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> sb <span style="color:blue;">As</span> <span style="color:blue;">New</span> System.Text.StringBuilder(Display_Text)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>SendMessage(child, WM_SETTEXT, 0, sb)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>SendMessage(child, WM_CHAR, 13, 1)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;If we are on the second control, the personal message box</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">ElseIf</span> i = 2 <span style="color:blue;">Then</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;If we are changing the personal text</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">If</span> Personal_Text &lt;&gt; <span style="color:#a31515;">&#8220;&#8221;</span> <span style="color:blue;">Then</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Send the personal message text to the textbox</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> sb <span style="color:blue;">As</span> <span style="color:blue;">New</span> System.Text.StringBuilder(Personal_Text)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span> </span>SendMessage(child, WM_SETTEXT, 0, sb)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>SendMessage(child, WM_CHAR, 13, 1)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;If the child control is the &#8220;OK&#8221; button</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">ElseIf</span> GetText(child) = <span style="color:#a31515;">&#8220;OK&#8221;</span> <span style="color:blue;">Then</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Focus the button</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>SendMessage(child, WM_SETFOCUS, 0, 0)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Press the Space button, to save changes</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>SendMessage(child, WM_KEYDOWN, &amp;H20, 390001)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>SendMessage(child, WM_CHAR, &amp;H63, 11101)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>SendMessage(child, WM_KEYUP, &amp;H20, 390001)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Next</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Function</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Sub</span> Form1_Load(<span style="color:blue;">ByVal</span> sender <span style="color:blue;">As</span> System.Object, <span style="color:blue;">ByVal</span> e <span style="color:blue;">As</span> System.EventArgs) <span style="color:blue;">Handles</span> <span style="color:blue;">MyBase</span>.Load</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Create the Messenger API</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> oMessenger <span style="color:blue;">As</span> MessengerAPI.Messenger</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>oMessenger = <span style="color:blue;">New</span> MessengerAPI.Messenger</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Set the status to offline</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_INVISIBLE</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Change name</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>SendText(<span style="color:#a31515;">&#8220;Mine&#8221;</span>)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Sleep the thread</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>System.Threading.Thread.Sleep(700)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Set status to online</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_ONLINE</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Repeat</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_INVISIBLE</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>SendText(<span style="color:#a31515;">&#8220;beats&#8221;</span>)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>System.Threading.Thread.Sleep(700)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_ONLINE</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_INVISIBLE</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>SendText(<span style="color:#a31515;">&#8220;yours&#8221;</span>)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>System.Threading.Thread.Sleep(700)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_ONLINE</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_INVISIBLE</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>SendText(<span style="color:#a31515;">&#8220;cyb3r&#8221;</span>)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>System.Threading.Thread.Sleep(700)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_ONLINE</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_INVISIBLE</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>SendText(<span style="color:#a31515;">&#8220;d3m0n&#8221;</span>)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>System.Threading.Thread.Sleep(700)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span> </span>oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_ONLINE</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;">End</span><span style="font-size:10pt;"> <span style="color:blue;">Class</span></span></p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing">You might want to make a function that automates the repeating</p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing">
<p>Imports System.Runtime.InteropServices<br />
Public Class Form1</p>
<p>&#8221;API<br />
&lt;DllImport(&#8221;User32.dll&#8221;)&gt; Private Shared Function EnumChildWindows(ByVal WindowHandle As IntPtr, ByVal Callback As EnumWindowProcess, ByVal lParam As IntPtr) As Boolean<br />
End Function<br />
&lt;DllImport(&#8221;user32.dll&#8221;, CharSet:=CharSet.Auto)&gt; Private Shared Sub GetClassName(ByVal hWnd As System.IntPtr, ByVal lpClassName As System.Text.StringBuilder, ByVal nMaxCount As Integer)<br />
End Sub<br />
&lt;DllImport(&#8221;user32.dll&#8221;, SetLastError:=True, CharSet:=CharSet.Auto)&gt; Private Shared Function GetWindowText(ByVal hwnd As IntPtr, ByVal lpString As System.Text.StringBuilder, ByVal cch As Integer) As Integer<br />
End Function<br />
&lt;DllImport(&#8221;user32.dll&#8221;, SetLastError:=True, CharSet:=CharSet.Auto)&gt; Private Shared Function GetWindowTextLength(ByVal hwnd As IntPtr) As Integer<br />
End Function</p>
<p>Private Declare Auto Function SendMessage Lib &#8220;user32&#8243; (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wparam As Integer, ByVal lparam As System.Text.StringBuilder) As IntPtr<br />
Private Declare Auto Function SendMessage Lib &#8220;user32&#8243; (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As String) As IntPtr<br />
Private Declare Auto Function FindWindow Lib &#8220;user32&#8243; (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr</p>
<p>&#8221;API Functions<br />
Private Shared Function GetChildWindows(ByVal ParentHandle As IntPtr) As IntPtr()<br />
Dim ChildrenList As New List(Of IntPtr)<br />
Dim ListHandle As GCHandle = GCHandle.Alloc(ChildrenList)<br />
Try<br />
EnumChildWindows(ParentHandle, AddressOf EnumWindow, GCHandle.ToIntPtr(ListHandle))<br />
Finally<br />
If ListHandle.IsAllocated Then ListHandle.Free()<br />
End Try<br />
Return ChildrenList.ToArray<br />
End Function<br />
Private Shared Function EnumWindow(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean<br />
Dim ChildrenList As List(Of IntPtr) = GCHandle.FromIntPtr(Parameter).Target<br />
If ChildrenList Is Nothing Then Throw New Exception(&#8221;GCHandle Target could not be cast as List(Of IntPtr)&#8221;)<br />
ChildrenList.Add(Handle)<br />
Return True<br />
End Function<br />
Public Shared Function GetText(ByVal hWnd As IntPtr) As String<br />
Dim length As Integer<br />
If hWnd.ToInt32 &lt;= 0 Then<br />
Return Nothing<br />
End If<br />
length = GetWindowTextLength(hWnd)<br />
If length = 0 Then<br />
Return Nothing<br />
End If<br />
Dim sb As New System.Text.StringBuilder(&#8221;", length + 1)<br />
GetWindowText(hWnd, sb, sb.Capacity)<br />
Return sb.ToString()<br />
End Function</p>
<p>&#8221;Constants<br />
Private Const WM_SETTEXT = &amp;HC<br />
Private Const WM_CHAR = &amp;H102<br />
Private Const WM_KEYDOWN = &amp;H100<br />
Private Const WM_KEYUP = &amp;H101<br />
Private Const WM_SETFOCUS = &amp;H7</p>
<p>&#8221;Window Enum Delegate<br />
Private Delegate Function EnumWindowProcess(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean</p>
<p>&#8221;This function finds the Handle for the MSN Options window<br />
Private Shared Function FindMSN() As IntPtr<br />
FindMSN = FindWindow(vbNullString, &#8220;Options&#8221;)<br />
End Function</p>
<p>&#8221;This function Sends the text to the Options window<br />
Public Shared Function SendText(Optional ByVal Display_Text As String = &#8220;&#8221;, Optional ByVal Personal_Text As String = &#8220;&#8221;) As Boolean<br />
&#8221;Create the Messenger API<br />
Dim iMessenger As MessengerAPI.Messenger<br />
iMessenger = New MessengerAPI.Messenger<br />
&#8221;Show the options window<br />
iMessenger.OptionsPages(0, MessengerAPI.MOPTIONPAGE.MOPT_GENERAL_PAGE)<br />
&#8221;Get the options windows handle<br />
Dim handle As IntPtr = FindMSN()<br />
&#8221;This will keep looping until the window is found<br />
Do<br />
handle = FindMSN()<br />
Loop Until handle &lt;&gt; 0<br />
&#8221;Sleeps the thread while the options window loads<br />
System.Threading.Thread.Sleep(60)<br />
&#8221;i is our counter for which control we are on<br />
Dim i As Integer = 0<br />
&#8221;Loop through each of the child windows<br />
For Each child As IntPtr In GetChildWindows(handle)<br />
&#8221;Gets the class name of the child<br />
Dim sClassName As New System.Text.StringBuilder(&#8221;", 256)<br />
Call GetClassName(child, sClassName, 256)<br />
&#8221;Converts it to a readable string<br />
Dim x As String = sClassName.ToString<br />
&#8221;If its a textbox<br />
If x = &#8220;RichEdit20W&#8221; Then<br />
i += 1<br />
&#8221;If we are on the first control, the display name box<br />
If i = 1 Then<br />
&#8221;If display text is being changed<br />
If Display_Text &lt;&gt; &#8220;&#8221; Then<br />
&#8221;Send the display text to the textbox<br />
Dim sb As New System.Text.StringBuilder(Display_Text)<br />
SendMessage(child, WM_SETTEXT, 0, sb)<br />
SendMessage(child, WM_CHAR, 13, 1)<br />
End If<br />
&#8221;If we are on the second control, the personal message box<br />
ElseIf i = 2 Then<br />
&#8221;If we are changing the personal text<br />
If Personal_Text &lt;&gt; &#8220;&#8221; Then<br />
&#8221;Send the personal message text to the textbox<br />
Dim sb As New System.Text.StringBuilder(Personal_Text)<br />
SendMessage(child, WM_SETTEXT, 0, sb)<br />
SendMessage(child, WM_CHAR, 13, 1)<br />
End If<br />
End If<br />
&#8221;If the child control is the &#8220;OK&#8221; button<br />
ElseIf GetText(child) = &#8220;OK&#8221; Then<br />
&#8221;Focus the button<br />
SendMessage(child, WM_SETFOCUS, 0, 0)<br />
&#8221;Press the Space button, to save changes<br />
SendMessage(child, WM_KEYDOWN, &amp;H20, 390001)<br />
SendMessage(child, WM_CHAR, &amp;H63, 11101)<br />
SendMessage(child, WM_KEYUP, &amp;H20, 390001)<br />
End If<br />
Next<br />
End Function</p>
<p>Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
&#8221;Create the Messenger API<br />
Dim oMessenger As MessengerAPI.Messenger<br />
oMessenger = New MessengerAPI.Messenger<br />
&#8221;Set the status to offline<br />
oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_INVISIBLE<br />
&#8221;Change name<br />
SendText(&#8221;Mine&#8221;)<br />
&#8221;Sleep the thread<br />
System.Threading.Thread.Sleep(700)<br />
&#8221;Set status to online<br />
oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_ONLINE</p>
<p>&#8221;Repeat<br />
oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_INVISIBLE<br />
SendText(&#8221;beats&#8221;)<br />
System.Threading.Thread.Sleep(700)<br />
oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_ONLINE<br />
oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_INVISIBLE<br />
SendText(&#8221;yours&#8221;)<br />
System.Threading.Thread.Sleep(700)<br />
oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_ONLINE<br />
oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_INVISIBLE<br />
SendText(&#8221;cyb3r&#8221;)<br />
System.Threading.Thread.Sleep(700)<br />
oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_ONLINE<br />
oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_INVISIBLE<br />
SendText(&#8221;d3m0n&#8221;)<br />
System.Threading.Thread.Sleep(700)<br />
oMessenger.MyStatus = MessengerAPI.MISTATUS.MISTATUS_ONLINE<br />
End Sub<br />
End Class</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ih4x.wordpress.com/43/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ih4x.wordpress.com/43/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ih4x.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ih4x.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ih4x.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ih4x.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ih4x.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ih4x.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ih4x.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ih4x.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ih4x.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ih4x.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ih4x.wordpress.com&blog=3140361&post=43&subd=ih4x&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ih4x.wordpress.com/2008/05/18/vb-net-change-msn-name/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/ih4x-128.jpg" medium="image">
			<media:title type="html">ih4x</media:title>
		</media:content>
	</item>
		<item>
		<title>Vb Net - Adding extensions to explorers context menu</title>
		<link>http://ih4x.wordpress.com/2008/05/11/vb-net-adding-extensions-to-explorers-context-menu/</link>
		<comments>http://ih4x.wordpress.com/2008/05/11/vb-net-adding-extensions-to-explorers-context-menu/#comments</comments>
		<pubDate>Sun, 11 May 2008 12:43:55 +0000</pubDate>
		<dc:creator>ih4x</dc:creator>
		
		<category><![CDATA[VB.net]]></category>

		<category><![CDATA[.net]]></category>

		<category><![CDATA[customise]]></category>

		<category><![CDATA[explorer]]></category>

		<category><![CDATA[Registry]]></category>

		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://ih4x.wordpress.com/2008/05/11/vb-net-adding-extensions-to-explorers-context-menu/</guid>
		<description><![CDATA[Adding extensions to explorers context menu

This program will add a menu to a specific files explorer context menu.
I’ve never seen a good piece of source code to do this with, so here is a nice basic example which can be modified to do what you wish:

 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNoSpacing">Adding extensions to explorers context menu</p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing">This program will add a menu to a specific files explorer context menu.</p>
<p class="MsoNoSpacing">I’ve never seen a good piece of source code to do this with, so here is a nice basic example which can be modified to do what you wish:</p>
<p class="MsoNoSpacing">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Sub</span> Form1_Load(<span style="color:blue;">ByVal</span> sender <span style="color:blue;">As</span> System.Object, <span style="color:blue;">ByVal</span> e <span style="color:blue;">As</span> System.EventArgs) <span style="color:blue;">Handles</span> <span style="color:blue;">MyBase</span>.Load</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> RegKey <span style="color:blue;">As</span> <span style="color:blue;">String</span> = <span style="color:maroon;">&#8220;ShockwaveFlash.ShockwaveFlash\shell\Open With AE H-Studio\command&#8221;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Try</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">If</span> Registry.ClassesRoot.OpenSubKey(RegKey).GetValue(<span style="color:maroon;">&#8220;&#8221;</span>) = <span style="color:maroon;">&#8220;&#8221;</span> <span style="color:blue;">Then</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;If the key exists but is blank, creates the subkey</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>Registry.ClassesRoot.CreateSubKey(RegKey).SetValue(<span style="color:maroon;">&#8220;&#8221;</span>, (ControlChars.Quote &amp; Application.ExecutablePath &amp; ControlChars.Quote &amp; <span style="color:maroon;">&#8221; %1&#8243;</span>))</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>MessageBox.Show(<span style="color:maroon;">&#8220;Explorer Context Entry Added for .swf Files&#8221;</span>, <span style="color:maroon;">&#8220;Registry entry added:&#8221;</span>, MessageBoxButtons.OK, MessageBoxIcon.Asterisk)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Exit</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>Application.Exit()</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Catch</span> ex <span style="color:blue;">As</span> Exception</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;If the key does not exist at all, OpenSubKey will error (No object refrence) and this will create the key</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>Registry.ClassesRoot.CreateSubKey(RegKey).SetValue(<span style="color:maroon;">&#8220;&#8221;</span>, (ControlChars.Quote &amp; Application.ExecutablePath &amp; ControlChars.Quote &amp; <span style="color:maroon;">&#8221; %1&#8243;</span>))</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>MessageBox.Show(<span style="color:maroon;">&#8220;Explorer Context Entry Added for .swf Files&#8221;</span>, <span style="color:maroon;">&#8220;Registry entry added:&#8221;</span>, MessageBoxButtons.OK, MessageBoxIcon.Asterisk)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Exit</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>Application.Exit()</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Try</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNoSpacing"><span>Then, you have to add in the actual code that checks which file is being selected:</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">If</span> Command() = <span style="color:maroon;">&#8220;&#8221;</span> <span style="color:blue;">Then</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;If there is no command parameters, exit program</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>Application.Exit()</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Exit</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;This gets the fileinfo for the selected file, and calls the LoadSWF Function</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Dim</span> _file <span style="color:blue;">As</span> <span style="color:blue;">New</span> FileInfo(Interaction.Command)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>LoadSWF(_file.FullName)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>Application.Exit()</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNoSpacing"><span>That can be placed in the Form Load even too, and it calls the sub LoadSWF (the selected file)</span></p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing"><span> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:blue;">Public</span> <span style="color:blue;">Sub</span> LoadSWF(<span style="color:blue;">ByVal</span> _path <span style="color:blue;">As</span> <span style="color:blue;">String</span>)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;This is where you would add in your code to handle the file loading.</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span><span style="color:green;">&#8221;Currently it just creates a message box with the files name</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"><span> </span>MessageBox.Show(<span style="color:maroon;">&#8220;Loaded File: &#8220;</span> &amp; _path, <span style="color:maroon;">&#8220;Success:&#8221;</span>, MessageBoxButtons.OK, MessageBoxIcon.Asterisk)</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNoSpacing">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;"> </span></p>
<p class="MsoNoSpacing"><span>As you can see, its not that hard, and the code would be very easy to modify.</span></p>
<p class="MsoNoSpacing"><span>For example, to add a shell extension for a .exe file change RegKey to:</span></p>
<p class="MsoNoSpacing">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;">Dim</span><span style="font-size:10pt;"> RegKey <span style="color:blue;">As</span> <span style="color:blue;">String</span> = <span style="color:maroon;">&#8220;exefile\shell\Open With Program Name\command&#8221;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;">
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ih4x.wordpress.com/42/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ih4x.wordpress.com/42/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ih4x.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ih4x.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ih4x.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ih4x.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ih4x.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ih4x.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ih4x.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ih4x.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ih4x.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ih4x.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ih4x.wordpress.com&blog=3140361&post=42&subd=ih4x&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ih4x.wordpress.com/2008/05/11/vb-net-adding-extensions-to-explorers-context-menu/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/ih4x-128.jpg" medium="image">
			<media:title type="html">ih4x</media:title>
		</media:content>
	</item>
		<item>
		<title>Vb Net - Low Level Mouse Hook (Global)</title>
		<link>http://ih4x.wordpress.com/2008/05/05/vb-net-low-level-mouse-hook-global/</link>
		<comments>http://ih4x.wordpress.com/2008/05/05/vb-net-low-level-mouse-hook-global/#comments</comments>
		<pubDate>Mon, 05 May 2008 19:07:29 +0000</pubDate>
		<dc:creator>ih4x</dc:creator>
		
		<category><![CDATA[VB.net]]></category>

		<category><![CDATA[.net]]></category>

		<category><![CDATA[API]]></category>

		<category><![CDATA[global]]></category>

		<category><![CDATA[Hook]]></category>

		<category><![CDATA[low level]]></category>

		<category><![CDATA[Mouse]]></category>

		<guid isPermaLink="false">http://ih4x.wordpress.com/2008/05/05/vb-net-low-level-mouse-hook-global/</guid>
		<description><![CDATA[Installing a Low Level Mouse Hook

MouseHookYeah!

This hook is basically the same as the Keyboard hook, just, with a mouse and a few extra things…
Below is the basic class that you need:

Private Class MouseHook
 &#8221;Constants
 Private Const HC_ACTION As Integer = 0
 Private Const WH_MOUSE_LL As Integer = 14
 Private Const WM_MOUSEMOVE As Integer = &#38;H200
 [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNoSpacing">Installing a Low Level Mouse Hook</p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing">MouseHookYeah!</p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing">This hook is basically the same as the Keyboard hook, just, with a mouse and a few extra things…</p>
<p class="MsoNoSpacing">Below is the basic class that you need:</p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;">Private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Class</span> MouseHook</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;Constants</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> HC_ACTION <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = 0</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WH_MOUSE_LL <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = 14</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_MOUSEMOVE <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = &amp;H200</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_LBUTTONDOWN <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = &amp;H201</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_LBUTTONUP <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = &amp;H202</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_LBUTTONDBLCLK <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = &amp;H203</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_RBUTTONDOWN <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = &amp;H204</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_RBUTTONUP <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = &amp;H205</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_RBUTTONDBLCLK <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = &amp;H206</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_MBUTTONDOWN <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = &amp;H207</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_MBUTTONUP <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = &amp;H208</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_MBUTTONDBLCLK <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = &amp;H209</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_MOUSEWHEEL <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = &amp;H20A</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;Mouse Structures</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> <span style="color:blue;">Structure</span> POINT</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> x <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> y <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Structure</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Structure</span> MSLLHOOKSTRUCT</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> pt <span style="color:blue;">As</span> POINT</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> mouseData <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> flags <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> time <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> dwExtraInfo <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Structure</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;API Functions</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Declare</span> <span style="color:blue;">Function</span> SetWindowsHookEx <span style="color:blue;">Lib</span> <span style="color:maroon;">&#8220;user32&#8243;</span> <span style="color:blue;">Alias</span> <span style="color:maroon;">&#8220;SetWindowsHookExA&#8221;</span> (<span style="color:blue;">ByVal</span> idHook <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> lpfn <span style="color:blue;">As</span> MouseProcDelegate, <span style="color:blue;">ByVal</span> hmod <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> dwThreadId <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>) <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Declare</span> <span style="color:blue;">Function</span> CallNextHookEx <span style="color:blue;">Lib</span> <span style="color:maroon;">&#8220;user32&#8243;</span> (<span style="color:blue;">ByVal</span> hHook <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> nCode <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> wParam <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> lParam <span style="color:blue;">As</span> MSLLHOOKSTRUCT) <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Declare</span> <span style="color:blue;">Function</span> UnhookWindowsHookEx <span style="color:blue;">Lib</span> <span style="color:maroon;">&#8220;user32&#8243;</span> (<span style="color:blue;">ByVal</span> hHook <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>) <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;Our Mouse Delegate</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Delegate</span> <span style="color:blue;">Function</span> MouseProcDelegate(<span style="color:blue;">ByVal</span> nCode <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> wParam <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByRef</span> lParam <span style="color:blue;">As</span> MSLLHOOKSTRUCT) <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;The Mouse events</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Event</span> MouseMove()</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Event</span> MouseEvent(<span style="color:blue;">ByVal</span> mEvent <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>)</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;The identifyer for our MouseHook</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Shared</span> MouseHook <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;MouseHookDelegate</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Shared</span> MouseHookDelegate <span style="color:blue;">As</span> MouseProcDelegate</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> <span style="color:blue;">Sub</span> <span style="color:blue;">New</span>()</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;Installs a Low Level Mouse Hook</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>MouseHookDelegate = <span style="color:blue;">New</span> MouseProcDelegate(<span style="color:blue;">AddressOf</span> MouseProc)</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>MouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseHookDelegate, Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0)).ToInt32, 0)</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;"> </span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Function</span> MouseProc(<span style="color:blue;">ByVal</span> nCode <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> wParam <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByRef</span> lParam <span style="color:blue;">As</span> MSLLHOOKSTRUCT) <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;If it is a Mouse event</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">If</span> (nCode = HC_ACTION) <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">If</span> wParam = WM_MOUSEMOVE <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;If it is the mouse moving</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">RaiseEvent</span> MouseMove()</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ElseIf</span> wParam = WM_LBUTTONDOWN <span style="color:blue;">Or</span> wParam = WM_LBUTTONUP <span style="color:blue;">Or</span> wParam = WM_LBUTTONDBLCLK <span style="color:blue;">Or</span> wParam = WM_RBUTTONDOWN <span style="color:blue;">Or</span> wParam = WM_RBUTTONUP <span style="color:blue;">Or</span> wParam = WM_RBUTTONDBLCLK <span style="color:blue;">Or</span> wParam = WM_MBUTTONDOWN <span style="color:blue;">Or</span> wParam = WM_MBUTTONUP <span style="color:blue;">Or</span> wParam = WM_MBUTTONDBLCLK <span style="color:blue;">Or</span> wParam = WM_MOUSEWHEEL <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;If it is a different mouse event</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">RaiseEvent</span> MouseEvent(wParam)</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;Next</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Return</span> CallNextHookEx(MouseHook, nCode, wParam, lParam)</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Function</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;"> </span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Protected</span> <span style="color:blue;">Overrides</span> <span style="color:blue;">Sub</span> Finalize()</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;On close it UnHooks the Hook</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>UnhookWindowsHookEx(MouseHook)</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">MyBase</span>.Finalize()</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;"> </span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Class</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;"> </span></p>
<p class="MsoNoSpacing">The important part this time is in the <span style="font-size:10pt;font-family:&quot;">MouseProc</span> function</p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;">If</span><span style="font-size:10pt;font-family:&quot;"> (nCode = HC_ACTION) <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">If</span> wParam = WM_MOUSEMOVE <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;If it is the mouse moving</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">RaiseEvent</span> MouseMove()</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ElseIf</span> wParam = WM_LBUTTONDOWN <span style="color:blue;">Or</span> wParam = WM_LBUTTONUP <span style="color:blue;">Or</span> wParam = WM_LBUTTONDBLCLK <span style="color:blue;">Or</span> wParam = WM_RBUTTONDOWN <span style="color:blue;">Or</span> wParam = WM_RBUTTONUP <span style="color:blue;">Or</span> wParam = WM_RBUTTONDBLCLK <span style="color:blue;">Or</span> wParam = WM_MBUTTONDOWN <span style="color:blue;">Or</span> wParam = WM_MBUTTONUP <span style="color:blue;">Or</span> wParam = WM_MBUTTONDBLCLK <span style="color:blue;">Or</span> wParam = WM_MOUSEWHEEL <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;If it is a different mouse event</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">RaiseEvent</span> MouseEvent(wParam)</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing">This raises one of the two events: <span style="font-size:10pt;font-family:&quot;">MouseMove </span>or<span style="font-size:10pt;font-family:&quot;"> MouseEvent</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;">Private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Shadows</span> <span style="color:blue;">Sub</span> MouseMove() <span style="color:blue;">Handles</span> MHook.MouseMove</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;This keeps the form on top, and sets it so that it moves with the cursor</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Me</span>.BringToFront()</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Me</span>.Location = <span style="color:blue;">New</span> Point(Windows.Forms.Cursor.Position.X - (<span style="color:blue;">Me</span>.Width / 2), Windows.Forms.Cursor.Position.Y - (<span style="color:blue;">Me</span>.Height / 2))</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;"> </span></p>
<p class="MsoNoSpacing">That’s just a basic sub that moves the form’s centre to the location of the mouse cursor, whenever the mouse is moved it follows it around.</p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;">Private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Sub</span> MouseEvent(<span style="color:blue;">ByVal</span> mEvent <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>) <span style="color:blue;">Handles</span> MHook.MouseEvent</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;Saves a basic log of the mouse events</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Dim</span> x <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = Windows.Forms.Cursor.Position.X</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Dim</span> y <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = Windows.Forms.Cursor.Position.Y</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">If</span> mEvent = 513 <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>Log &amp;= Now &amp; <span style="color:maroon;">&#8221; - Left Down - (&#8221;</span> &amp; x &amp; <span style="color:maroon;">&#8220;, &#8220;</span> &amp; y &amp; <span style="color:maroon;">&#8220;)&#8221;</span> &amp; vbNewLine</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ElseIf</span> mEvent = 514 <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>Log &amp;= Now &amp; <span style="color:maroon;">&#8221; - Left Up - (&#8221;</span> &amp; x &amp; <span style="color:maroon;">&#8220;, &#8220;</span> &amp; y &amp; <span style="color:maroon;">&#8220;)&#8221;</span> &amp; vbNewLine</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ElseIf</span> mEvent = &amp;H203 <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>Log &amp;= Now &amp; <span style="color:maroon;">&#8221; - Left Double Click - (&#8221;</span> &amp; x &amp; <span style="color:maroon;">&#8220;, &#8220;</span> &amp; y &amp; <span style="color:maroon;">&#8220;)&#8221;</span> &amp; vbNewLine</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ElseIf</span> mEvent = &amp;H204 <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>Log &amp;= Now &amp; <span style="color:maroon;">&#8221; - Right Down - (&#8221;</span> &amp; x &amp; <span style="color:maroon;">&#8220;, &#8220;</span> &amp; y &amp; <span style="color:maroon;">&#8220;)&#8221;</span> &amp; vbNewLine</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ElseIf</span> mEvent = &amp;H205 <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>Log &amp;= Now &amp; <span style="color:maroon;">&#8221; - Right Up - (&#8221;</span> &amp; x &amp; <span style="color:maroon;">&#8220;, &#8220;</span> &amp; y &amp; <span style="color:maroon;">&#8220;)&#8221;</span> &amp; vbNewLine</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ElseIf</span> mEvent = &amp;H206 <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>Log &amp;= Now &amp; <span style="color:maroon;">&#8221; - Right Double Click - (&#8221;</span> &amp; x &amp; <span style="color:maroon;">&#8220;, &#8220;</span> &amp; y &amp; <span style="color:maroon;">&#8220;)&#8221;</span> &amp; vbNewLine</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ElseIf</span> mEvent = &amp;H207 <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>Log &amp;= Now &amp; <span style="color:maroon;">&#8221; - Middle Down - (&#8221;</span> &amp; x &amp; <span style="color:maroon;">&#8220;, &#8220;</span> &amp; y &amp; <span style="color:maroon;">&#8220;)&#8221;</span> &amp; vbNewLine</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ElseIf</span> mEvent = &amp;H208 <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>Log &amp;= Now &amp; <span style="color:maroon;">&#8221; - Middle Up - (&#8221;</span> &amp; x &amp; <span style="color:maroon;">&#8220;, &#8220;</span> &amp; y &amp; <span style="color:maroon;">&#8220;)&#8221;</span> &amp; vbNewLine</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ElseIf</span> mEvent = &amp;H209 <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>Log &amp;= Now &amp; <span style="color:maroon;">&#8221; - Middle Double Click - (&#8221;</span> &amp; x &amp; <span style="color:maroon;">&#8220;, &#8220;</span> &amp; y &amp; <span style="color:maroon;">&#8220;)&#8221;</span> &amp; vbNewLine</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ElseIf</span> mEvent = &amp;H20A <span style="color:blue;">Then</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>Log &amp;= Now &amp; <span style="color:maroon;">&#8221; - Mouse Scroll - (&#8221;</span> &amp; x &amp; <span style="color:maroon;">&#8220;, &#8220;</span> &amp; y &amp; <span style="color:maroon;">&#8220;)&#8221;</span> &amp; vbNewLine</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;Displays the log</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>MsgBox(Log)</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">If</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;"> </span></p>
<p class="MsoNoSpacing">That has a little more to it, it determines what the event was, then saves a log accordingly.</p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing">Now, in order to make this function, just add the MouseHook class, and the two subs to your form along with this:</p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;">Private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">WithEvents</span> MHook <span style="color:blue;">As</span> MouseHook</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Dim</span> Log <span style="color:blue;">As</span> <span style="color:blue;">String</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;"> </span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Sub</span> Form1_Load(<span style="color:blue;">ByVal</span> sender <span style="color:blue;">As</span> System.Object, <span style="color:blue;">ByVal</span> e <span style="color:blue;">As</span> System.EventArgs) <span style="color:blue;">Handles</span> <span style="color:blue;">MyBase</span>.Load</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;Hooks The Mouse</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span>MHook = <span style="color:blue;">New</span> MouseHook</span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNoSpacing"><span style="font-size:10pt;font-family:&quot;color:blue;"> </span></p>
<p class="MsoNoSpacing">Which makes the whole thing work <span style="font-family:Wingdings;"><span>J</span></span></p>
<p class="MsoNoSpacing">Oh, and just for the record, either run this program OUTSIDE the IDE or:</p>
<p class="MsoNoSpacing">In solution explorer, click on My Project</p>
<p class="MsoNoSpacing">Go to Debug</p>
<p class="MsoNoSpacing">Uncheck ‘Enable the Visual Studio hosting process’</p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing">Same goes with the keyboard hook.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ih4x.wordpress.com/41/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ih4x.wordpress.com/41/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ih4x.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ih4x.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ih4x.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ih4x.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ih4x.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ih4x.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ih4x.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ih4x.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ih4x.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ih4x.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ih4x.wordpress.com&blog=3140361&post=41&subd=ih4x&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ih4x.wordpress.com/2008/05/05/vb-net-low-level-mouse-hook-global/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/ih4x-128.jpg" medium="image">
			<media:title type="html">ih4x</media:title>
		</media:content>
	</item>
		<item>
		<title>Vb Net - Low Level Keyboard Hook (Global)</title>
		<link>http://ih4x.wordpress.com/2008/05/05/vb-net-low-level-keyboard-hook-global/</link>
		<comments>http://ih4x.wordpress.com/2008/05/05/vb-net-low-level-keyboard-hook-global/#comments</comments>
		<pubDate>Mon, 05 May 2008 15:52:18 +0000</pubDate>
		<dc:creator>ih4x</dc:creator>
		
		<category><![CDATA[VB.net]]></category>

		<category><![CDATA[.net]]></category>

		<category><![CDATA[API]]></category>

		<category><![CDATA[global]]></category>

		<category><![CDATA[Hook]]></category>

		<category><![CDATA[keyboard]]></category>

		<category><![CDATA[low level]]></category>

		<guid isPermaLink="false">http://ih4x.wordpress.com/2008/05/05/vb-net-low-level-keyboard-hook-global/</guid>
		<description><![CDATA[Installing a Low Level Keyboard Hook

KeyBoardHookYeah!

Below is the basic class you need in order to Hook the Keyboard:

Private Class KeyboardHook
 &#8221;Constants
 Private Const HC_ACTION As Integer = 0
 Private Const WH_KEYBOARD_LL As Integer = 13
 Private Const WM_KEYDOWN = &#38;H100
 Private Const WM_KEYUP = &#38;H101
 Private Const WM_SYSKEYDOWN = &#38;H104
 Private Const WM_SYSKEYUP = &#38;H105
 [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p class="MsoNoSpacing">Installing a Low Level Keyboard Hook</p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing">KeyBoardHookYeah!</p>
<p class="MsoNoSpacing">
<p class="MsoNoSpacing">Below is the basic class you need in order to Hook the Keyboard:</p>
<p class="MsoNoSpacing">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;">Private</span><span style="font-size:10pt;font-family:&quot;"> <span style="color:blue;">Class</span> KeyboardHook</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;Constants</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> HC_ACTION <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = 0</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WH_KEYBOARD_LL <span style="color:blue;">As</span> <span style="color:blue;">Integer</span> = 13</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_KEYDOWN = &amp;H100</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_KEYUP = &amp;H101</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_SYSKEYDOWN = &amp;H104</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Const</span> WM_SYSKEYUP = &amp;H105</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;Keypress Structure</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> <span style="color:blue;">Structure</span> KBDLLHOOKSTRUCT</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> vkCode <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> scancode <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">Public</span> flags <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> time <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> dwExtraInfo <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Structure</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;API Functions</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Declare</span> <span style="color:blue;">Function</span> SetWindowsHookEx <span style="color:blue;">Lib</span> <span style="color:maroon;">&#8220;user32&#8243;</span> <span style="color:blue;">Alias</span> <span style="color:maroon;">&#8220;SetWindowsHookExA&#8221;</span> (<span style="color:blue;">ByVal</span> idHook <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> lpfn <span style="color:blue;">As</span> KeyboardProcDelegate, <span style="color:blue;">ByVal</span> hmod <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> dwThreadId <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>) <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Declare</span> <span style="color:blue;">Function</span> CallNextHookEx <span style="color:blue;">Lib</span> <span style="color:maroon;">&#8220;user32&#8243;</span> (<span style="color:blue;">ByVal</span> hHook <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> nCode <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> wParam <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> lParam <span style="color:blue;">As</span> KBDLLHOOKSTRUCT) <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Declare</span> <span style="color:blue;">Function</span> UnhookWindowsHookEx <span style="color:blue;">Lib</span> <span style="color:maroon;">&#8220;user32&#8243;</span> (<span style="color:blue;">ByVal</span> hHook <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>) <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;Our Keyboard Delegate</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Delegate</span> <span style="color:blue;">Function</span> KeyboardProcDelegate(<span style="color:blue;">ByVal</span> nCode <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> wParam <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByRef</span> lParam <span style="color:blue;">As</span> KBDLLHOOKSTRUCT) <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;The KeyPress event</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Event</span> KeyDown(<span style="color:blue;">ByVal</span> vkCode <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Event</span> KeyUp(<span style="color:blue;">ByVal</span> vkCode <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;The identifyer for our KeyHook</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Shared</span> KeyHook <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;KeyHookDelegate</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Shared</span> KeyHookDelegate <span style="color:blue;">As</span> KeyboardProcDelegate</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Public</span> <span style="color:blue;">Sub</span> <span style="color:blue;">New</span>()</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;Installs a Low Level Keyboard Hook</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>KeyHookDelegate = <span style="color:blue;">New</span> KeyboardProcDelegate(<span style="color:blue;">AddressOf</span> KeyboardProc)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>KeyHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyHookDelegate, Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0)).ToInt32, 0)</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">End</span> <span style="color:blue;">Sub</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;color:blue;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Private</span> <span style="color:blue;">Shared</span> <span style="color:blue;">Function</span> KeyboardProc(<span style="color:blue;">ByVal</span> nCode <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByVal</span> wParam <span style="color:blue;">As</span> <span style="color:blue;">Integer</span>, <span style="color:blue;">ByRef</span> lParam <span style="color:blue;">As</span> KBDLLHOOKSTRUCT) <span style="color:blue;">As</span> <span style="color:blue;">Integer</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;If it is a keypress</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">If</span> (nCode = HC_ACTION) <span style="color:blue;">Then</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Select</span> <span style="color:blue;">Case</span> wParam</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;If it is a Keydown Evend</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">Case</span> WM_KEYDOWN, WM_SYSKEYDOWN</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">&#8221;Activates the KeyDown event in Form 1</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">RaiseEvent</span> KeyDown(lParam.vkC