Tuesday, July 28, 2009

Key blogger

1. http://www.codeproject.com/KB/DLL/Keyboardhook
2. http://www.codeguru.com/code/legacy/system/KBHookDemo.zip
(source: http://www.codeguru.com/code/legacy/system/KBHookSrc.zip)

Saturday, July 25, 2009

Disable Additional plugins are required in Firefox

Disabling popups from plugins should be enough to also get rid of the dialog. Enter about:config in the location bar, add (right-click and select New) the Integer setting privacy.popups.disable_from_plugins, then set the value to 2. Possible values for this setting are:
privacy.popups.disable_from_plugins
0 Allow popups from plugins
1 Limit popups to dom.popup_maximum
2 Block popups from plugins
3 Block popups from all plugins (even on whitelisted sites)

Tuesday, July 21, 2009

Serialize object to a string instead of stream


StringBuilder sb = new StringBuilder();
XmlSerializer s = new XmlSerializer(typeof(TradeInfoArray));
StringWriter stringWriter = new StringWriter();
s.Serialize(stringWriter, arrTrade);
result = stringWriter.ToString();

log on locally permission

You can configure this security setting by opening the appropriate policy and expanding the console tree as such: Computer Configuration\Windows Settings\Security Settings\Local Policies\User Rights Assignment\

Log on as a service account

  1. Click Start, point to Run, type mmc, and then click OK.

  2. On the File menu, click Add/Remove Snap-in.

  3. In Add/Remove Snap-in, click Add, and then, in Add Standalone Snap-in, double-click Group Policy Object Editor.

  4. In Select Group Policy Object, click Browse, browse to the Group Policy object (GPO) that you want to modify, click OK, and then click Finish.

  5. Click Close, and then click OK.

  6. In the console tree, click User Rights Assignment.

    Where?

    • GroupPolicyObject [ComputerName] Policy
    • Computer Configuration
    • Windows Settings
    • Security Settings
    • Local Policies
    • User Rights Assignment
  7. In the details pane, double-click Log on as a service.

  8. If the security setting has not yet been defined, select the Define these policy settings check box.

  9. Click Add User or Group, and then add the appropriate account to the list of accounts that possess the Log on as a service right.

Mail server on windows server 2008

1. Tool name: ArGoSoft Mail Server
2 Config
Firstly, stop all services using port 25 and 110
a. DNS (detect)
b. domain (add)
c. Port (change two default ports)

Option in Expresso



Sunday, July 19, 2009

Create a new thread


Thread trd;
private void btnRun_Click(object sender, EventArgs e)
{
trd = new Thread(new ThreadStart(this.ThreadTask));
trd.IsBackground = true;
trd.Start();
}

[STAThread]
private void ThreadTask()
{
//Do something here
}

private void btnStop_Click(object sender, EventArgs e)
{
if (trd != null)
{
trd.Abort();
trd = null;
}
}
private void btmExit_Click(object sender, EventArgs e)
{
Application.Exit();
}

copy and paste data to and from Clipboard

Push: System.Windows.Forms.Clipboard.SetDataObject("hello", true);
Get: System.Windows.Forms.Clipboard.GetText();

Wednesday, July 15, 2009

Mouse class


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace FFSAutoTrade
{
class Mouse
{
#region System constants
const uint MOUSEEVENTF_MOVE = 0x0001; /* mouse move */
const uint MOUSEEVENTF_LEFTDOWN = 0x0002; /* left button down */
const uint MOUSEEVENTF_LEFTUP = 0x0004; /* left button up */
const uint MOUSEEVENTF_RIGHTDOWN = 0x0008; /* right button down */
const uint MOUSEEVENTF_RIGHTUP = 0x0010; /* right button up */
const uint MOUSEEVENTF_MIDDLEDOWN = 0x0020; /* middle button down */
const uint MOUSEEVENTF_MIDDLEUP = 0x0040; /* middle button up */
const uint MOUSEEVENTF_XDOWN = 0x0080; /* x button down */
const uint MOUSEEVENTF_XUP = 0x0100; /* x button down */
const uint MOUSEEVENTF_WHEEL = 0x0800; /* wheel button rolled */
const uint MOUSEEVENTF_ABSOLUTE = 0x8000; /* absolute move */
const int SM_CXSCREEN = 0;
const int SM_CYSCREEN = 1;
#endregion
#region Base routines
[DllImport("user32.dll", EntryPoint = "mouse_event")]
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, uint dwExtraInfo);
[DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]
static extern int GetSystemMetrics(int index);
private static void DoEvent(uint eventType, int globalX, int globalY)
{
globalX = globalX > 0 ? globalX : 0;
globalY = globalY > 0 ? globalY : 0;
uint x = Convert.ToUInt32((float)globalX * 65536 / GetSystemMetrics(SM_CXSCREEN));
uint y = Convert.ToUInt32((float)globalY * 65536 / GetSystemMetrics(SM_CYSCREEN));
mouse_event(MOUSEEVENTF_ABSOLUTE | eventType, x, y, 0, 0);
Thread.Sleep(Delay);
Application.DoEvents();
}
#endregion
public static int Delay = 0;
/// <summary>
/// Press down left mouse button
/// </summary>
/// <param name="globalX">Global X coordinate</param>
/// <param name="globalY">Global Y coordinate</param>
public static void LeftDown(int globalX, int globalY)
{
DoEvent(MOUSEEVENTF_MOVE, globalX, globalY);
DoEvent(MOUSEEVENTF_LEFTDOWN, globalX, globalY);
}
/// <summary>
/// Release left mouse button
/// </summary>
/// <param name="globalX">Global X coordinate</param>
/// <param name="globalY">Global Y coordinate</param>
public static void LeftUp(int globalX, int globalY)
{
DoEvent(MOUSEEVENTF_MOVE, globalX, globalY);
DoEvent(MOUSEEVENTF_LEFTUP, globalX, globalY);
}
/// <summary>
/// Press down right mouse button
/// </summary>
/// <param name="globalX">Global X coordinate</param>
/// <param name="globalY">Global Y coordinate</param>
public static void RightDown(int globalX, int globalY)
{
DoEvent(MOUSEEVENTF_MOVE, globalX, globalY);
DoEvent(MOUSEEVENTF_RIGHTDOWN, globalX, globalY);
}
/// <summary>
/// Release right mouse button
/// </summary>
/// <param name="globalX">Global X coordinate</param>
/// <param name="globalY">Global Y coordinate</param>
public static void RightUp(int globalX, int globalY)
{
DoEvent(MOUSEEVENTF_MOVE, globalX, globalY);
DoEvent(MOUSEEVENTF_RIGHTUP, globalX, globalY);
}
/// <summary>
/// Move Mouse with emulated speed
/// </summary>
/// <param name="globalX">Global X coordinate</param>
/// <param name="globalY">Global Y coordinate</param>
/// <param name="speed">Speed in pixels per move</param>
public static void MoveTo(int globalX, int globalY, int speed)
{
int temp = Delay;
Delay = 50;
if (speed != 0)
{
int cursorX = Cursor.Position.X;
int cursorY = Cursor.Position.Y;
int dX = globalX - cursorX;
int dY = globalY - cursorY;
int steps = Math.Max(Math.Abs(dX / speed), Math.Abs(dY / speed));
if (steps != 0)
{
int stepX = dX / steps;
int stepY = dY / steps;
for (int i = 0; i < steps; i++)
{
cursorX += stepX;
cursorY += stepY;
DoEvent(MOUSEEVENTF_MOVE, cursorX, cursorY);
}
}
}
DoEvent(MOUSEEVENTF_MOVE, globalX, globalY);
Delay = temp;
}
/// <summary>
/// Move mouse
/// </summary>
/// <param name="globalX">Global X coordinate</param>
/// <param name="globalY">Global Y coordinate</param>
public static void MoveTo(int globalX, int globalY)
{
MoveTo(globalX, globalY, 0);
}
public static void DragAndDrop(int startX, int startY, int finishX, int finishY)
{
LeftDown(startX, startY);
MoveTo(finishX, finishY, 10);
LeftUp(finishX, finishY);
}
public static void MoveToAndClick(int globalX, int globalY, int delay)
{
Delay = delay;
MoveTo(globalX, globalY, 10);
Mouse.LeftDown(globalX, globalY);
Mouse.LeftUp(globalX, globalY);
}
public static void ClickAround(int x, int y, int delx, int dely, int step, int DelayTime)
{
int newx, newy;
for (int i = 0; i < delx; i++)
for (int j = 0; j < dely; j++)
{
newx = x + delx * i;
newy = y + dely * j;
Mouse.MoveTo(newx, newy, 10);
if (i + j == 0)
Mouse.Delay = DelayTime;
Mouse.LeftDown(newx, newy);
Mouse.LeftUp(newx, newy);
}
}
}
}

View mouse position on screen

1. Tool: Visual Studio, Spy++
2. Menu --> Messages --> Logging Option:
3. Windows: All Windows In System
4. Messages: WM_NCHITTEST
5. Output: 100 line
Start

Sharepoint Receive Port

Tuesday, July 14, 2009

Open infopath by browser in Sharepoint


  1. Open Sharepoint Administration

  2. Open http:///_admin/ManageFormsServiceProxy.aspx

  3. Check both checkboxes

  4. Try to public again.

Monday, July 13, 2009

Modidify the condition for how the workflow be started

1. Open the *.??proj.user file
2. Modify value of following elements:
<ManualStart>true</ManualStart>
<StartOnCreate>false</StartOnCreate>
<StartOnChange>false</StartOnChange>

Sunday, July 12, 2009

Get field name from schemas

1. Remove unnessesary lines
Find: ^(~(name\=)~(\).)+\n
Rep:
2 Remove unnessessary words
Find: ^(~(name).)+name\=\"{[^"]+}\".+\n.+documentation\>{[^<]+}\<.+
Rep: \1#\2
3. Manually check and clean-up

Thursday, July 9, 2009

Want to insert html code into blogger

1. Go here: http://www.reconn.us/component/option,com_wrapper/Itemid,62/
2. Uncheck 2 check-boxes and paste your html code in
3. Copy result and paste into blogger windows (tab Edit Html).
4. Click review to see the result.

Can't open .svc file

1. Open: C:\Windows\System32\inetsrv\config\applicationHost.config
2. Find "location path" which appropriate path value and insert below handlers section as below


<location path="Default Web Site/PersonnelBiz">
<system.webServer>
<handlers accessPolicy="Execute, Script">
<add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode" />
<add name="svc-ISAPI-2.0" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
</handlers>