Archive for August, 2008

h1

CopyPaste+

August 31, 2008

I have always been bitten with the limitation of the windows clipboard. I have a bad habit (completely my fault as a user) to copy (usually important) things into my clipboard and then close down the screen with the intention to paste the clipboard contents into another application which is usually a browser, word, notepad or maybe even excel. Sometimes tho, I get distracted before I paste in the content and accidently press control c again over some other content, thereby losing what was in my clipboard.. Arghh! Normally, I would have to relaunch the application and fetch the original contents of what I wanted copied into my clipboard. Well this week end I finally got around to creating CopyPaste+ which is pronounced CopyPastePlus, sort of like C#. Yes, so I’m not the most creative guy around, but hey – I don’t care! Anyway, here is what I would LIKE my application to look like:

CopyPaste+

CopyPaste+

This is just a quick mock-up that I made… Okay maybe not me but, my so much more creative friend William did.

And here is what the app currently looks like:

puke

puke

Okay, so it looks like puke… BUT, I promise, it’s super useful!

Download the application here

Note: Requires .net framework 3.5 to run which can be found here

How to Use

The application monitors the windows clipboard and adds it to a list of 5 clipboard contents (The default is 5 but this is configurable). At this point you may want to retrieve clipboard content #3 so you would press control + shift + v instead of the normal control v to paste. This activates the applications sexy UI which appears in front of you, fixed and glued to the centre of the screen. From here, you should click on the box you would like to paste. Once clicking on the rectangle, the application hides itself and has overwritten your current clipboard with the selected item. You then simply paste in (tip: control v ;p) your content into whatever application you want. Simply repeat this step to retrieve any clipboard content you would like.

Configuring Number of Clipboard Content Items:

To increase or decrease the number of items you would like to have, all you need to do is have this config file sitting side by side to the exe and change the “NumberOfBoxes” value from 5 to whatever you like

Future Releases

  • Configurable number of Items will be done via User Interfaces options
  • UI will look like Williams
  • Selecting Icon in task bar will activate the UI
  • Will be able to handle content other than just text i.e. images, files etc.

License Agreement

On Request, I will supply the source code to anyone that wants it for non commercial use, for free.

Contact me here to request the source code.

Advertisements
h1

Using T-SQL and the Registry to Retrieve a List of Countries

August 20, 2008

I was catching up on some blog reading tonight when I saw this post. For retrieval purposes, I have made a copy of the post and will keep it for when in use. Thanks Omar!

Using T-SQL and the Registry to Retrieve a List of Countries

So every time I create a SQL script to populate a countries table I end up losing it. So here is proc I decided to keep forever on my blog that retrieves the list of countries from the registry of the machine it’s sitting on. Remember to run it under elevated permissions.

1:
PRINT
‘Building dbo.ListCountryFromRegistry’

2:
IF
EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N‘dbo.ListCountryFromRegistry’) AND OBJECTPROPERTY(id, N‘IsProcedure’) = 1)

3:
BEGIN

4:
DROP
PROC dbo.ListCountryFromRegistry

5:
END

6:
GO

7:
CREATE
PROC dbo.ListCountryFromRegistry

8:
AS

9: –Root Key

10:
DECLARE @RootKey nvarchar(255)

11:
SET @RootKey = ‘HKEY_LOCAL_MACHINE’

12: 

13: –Registry Key
for country list

14:
DECLARE @CountryListKey nvarchar(255)

15:
SET @CountryListKey = ‘SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\Country List\’

16: 

17:Table
to store registry extracts

18:
CREATE
TABLE #RegistryOutput ( countryKey int)

19: 

20:Table
to store registry outputs with rownumbers.

21:
CREATE
TABLE #NumberedRegistryOutput ( rowNumber int, countryKey int)

22: 

23:Get the the list of country nodes under the cuntry list tree

24: INSERT INTO #RegistryOutput EXEC master..xp_regenumkeys @RootKey, @CountryListKey

25: 

26:Add RowNumbers to
use
as indexers later

27: INSERT INTO #NumberedRegistryOutput ( rowNumber, countryKey )

28: (SELECT ROW_NUMBER() OVER(ORDER
BY countryKey), countryKey

29:
FROM #RegistryOutput)

30: 

31: –Grab a counter to
use
in looping through country nodes

32:
DECLARE @Counter int;

33:
SET @Counter = (SELECT
MAX(rowNumber) FROM #NumberedRegistryOutput);

34: 

35:Current
index
to be used to
iterate the countr nodes.

36:
DECLARE @CurrentCountryKey int;

37: 

38:Current Country Registry Key

39:
DECLARE @CountryRegistryKey nvarchar(150)

40: 

41: –Country name returned form registry and
to be added to
output

42:
DECLARE @CountryName nvarchar(255)

43: 

44:Output
table
with Country Names

45:
Create
table #CountryNames ( CountryName nvarchar(255))

46: 

47: –Loop through country nodes

48:
WHILE (@Counter > 0)

49:
BEGIN

50:
SET @Counter = @Counter – 1

51:
SET @CurrentCountryKey = (SELECT countryKey FROM #NumberedRegistryOutput WHERE rowNumber = @Counter)

52:
SET @CountryRegistryKey = @CountryListKey + RTRIM(LTRIM(CAST( @CurrentCountryKey as nvarchar(20))))

53: 

54:
EXEC master..xp_regread

55: @RootKey,

56: @CountryRegistryKey,

57:
‘Name’,

58: @CountryName OUTPUT

59: 

60: Insert #CountryNames VALUES (@CountryName)

61:
END

62: 

63:Output

64:
Select * from #CountryNames ORDER
BY CountryName

65: 

66: –Cleanup

67:
drop
table #RegistryOutput

68:
drop
table #NumberedRegistryOutput

69:
drop
table #CountryNames

70: 

71:
GO