블로그 이미지
Every unexpected event is a path to learning for you. blueasa

카테고리

분류 전체보기 (2809)
Unity3D (865)
Programming (479)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (234)
협업 (61)
3DS Max (3)
Game (12)
Utility (140)
Etc (98)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (55)
Android (16)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday

I had a real pain recently where I wanted to control one windows app from another. I found some useful stuff on the net, but nothing that gave an end to end solution. So here’s what I came up with.

Firstly I’ll explain why this is useful. SendMessage is part of the Win32 API, and is used to send messages from one application to another. There are a set of predefined properties that the message can relate to, and these can be used to send messages to existing applications to perform all sorts of useful functions such as changing the font in notepad, or bringing a window to the fore. For more information of the wider use of the SendMessage function, have a look at:

http://www.autohotkey.com/docs/commands/PostMessage.htm

http://msdn.microsoft.com/en-us/library/ms644950(VS.85).aspx

The main use that I’m interested in is passing a specific instruction (via a string) from one app that I’ve written, to another one that I’ve written. This way I can effectively remote control one app from another (particularly useful if you want your main application to open a pop-up, and you don’t want to worry about the pop-up’s performance affecting the main application). Let’s now have a quick look at the SendMessage function:

SendMessage(int hWnd, int Msg, int wParam, int lParam)

hWnd – This is the window instance id of the application you want to send a message to. This id is retrieved using the FindWindow function

Msg – This is the type of message you want to send

wParam – Message specific data you pass in

wParam – Message specific data you pass in

Also used is the FindWindow function. This is to get the relevant window id:

FindWindow(String lpClassName, String lpWindowName)

lpClassName -The name of the class you want

lpWindowName – The name of the window that you want

To send a message that is a string, you need to use the WM_DATACOPY message property. The hard part is that you cannot just send the string as a parameter across. You need to send a pointer to the memory address of the string. If you just want to send an integer as a message you can use the WM_USER message property and send it as a value without a problem.

Below now is a brief listing of my MessageHelper.cs class, for the whole class file see:

http://craigcook.co.uk/samples/MessageHelper.cs.txt

01using System;
02using System.Collections.Generic;
03using System.Linq;
04using System.Text;
05using System.Runtime.Serialization.Formatters.Binary;
06using System.Runtime.InteropServices;
07using System.Diagnostics;
08 
09public class MessageHelper
10{
11[DllImport("User32.dll")]
12private static extern int RegisterWindowMessage(string lpString);
13 
14[DllImport("User32.dll", EntryPoint = "FindWindow")]
15public static extern Int32 FindWindow(String lpClassName, String lpWindowName);
16 
17//For use with WM_COPYDATA and COPYDATASTRUCT
18[DllImport("User32.dll", EntryPoint = "SendMessage")]
19public static extern int SendMessage(int hWnd, int Msg, int wParam, refCOPYDATASTRUCT lParam);
20 
21//For use with WM_COPYDATA and COPYDATASTRUCT
22[DllImport("User32.dll", EntryPoint = "PostMessage")]
23public static extern int PostMessage(int hWnd, int Msg, int wParam, refCOPYDATASTRUCT lParam);
24 
25[DllImport("User32.dll", EntryPoint = "SendMessage")]
26public static extern int SendMessage(int hWnd, int Msg, int wParam, intlParam);
27 
28[DllImport("User32.dll", EntryPoint = "PostMessage")]
29public static extern int PostMessage(int hWnd, int Msg, int wParam, intlParam);
30 
31[DllImport("User32.dll", EntryPoint = "SetForegroundWindow")]
32public static extern bool SetForegroundWindow(int hWnd);
33 
34public const int WM_USER = 0x400;
35public const int WM_COPYDATA = 0x4A;
36 
37//Used for WM_COPYDATA for string messages
38public struct COPYDATASTRUCT
39{
40     public IntPtr dwData;
41     public int cbData;
42     [MarshalAs(UnmanagedType.LPStr)]
43     public string lpData;
44}
45 
46public bool bringAppToFront(int hWnd)
47{
48     return SetForegroundWindow(hWnd);
49}
50 
51public int sendWindowsStringMessage(int hWnd, int wParam, string msg)
52{
53    int result = 0;
54 
55     if (hWnd != 0)
56     {
57            byte[] sarr = System.Text.Encoding.Default.GetBytes(msg);
58            int len = sarr.Length;
59            COPYDATASTRUCT cds;
60            cds.dwData = (IntPtr)100;
61            cds.lpData = msg;
62            cds.cbData = len + 1;
63            result = SendMessage(hWnd, WM_COPYDATA, wParam, ref cds);
64     }
65 
66     return result;
67}
68 
69public int sendWindowsMessage(int hWnd, int Msg, int wParam, int lParam)
70{
71     int result = 0;
72 
73     if (hWnd != 0)
74     {
75            result = SendMessage(hWnd, Msg, wParam, lParam);
76     }
77 
78     return result;
79}
80 
81public int getWindowId(string className, string windowName)
82{
83 
84     return FindWindow(className, windowName);
85 
86}
87}

So now you can call the code to send a message like so:

MessageHelper msg = new MessageHelper();
int result = 0;
//First param can be null
int hWnd = msg.getWindowId(null, “My App Name”);
result = msg.sendWindowsStringMessage(hWnd, 0, “Some_String_Message”);
//Or for an integer message
result = msg.sendWindowsMessage(hWnd, MessageHelper.WM_USER, 123, 456);

Now all you need to do on the app that you want to receive the message is override the following function in the form class (obviously you can change what the responses are, and you’ll need to create constants for the parameters):

01protected override void WndProc(ref Message m)
02{
03switch (m.Msg)
04{
05     case WM_USER:
06            MessageBox.Show("Message recieved: " + m.WParam + " - " + m.LParam);
07            break;
08     case WM_COPYDATA:
09            COPYDATASTRUCT mystr = new COPYDATASTRUCT();
10            Type mytype = mystr.GetType();
11            mystr = (COPYDATASTRUCT)m.GetLParam(mytype);
12            this.doSomethingWithMessage(mystr.lpData);
13            break;
14}
15base.WndProc(ref m);
16}


출처 : http://boycook.wordpress.com/2008/07/29/c-win32-messaging-with-sendmessage-and-wm_copydata/

반응형
Posted by blueasa
, |

Spy++의 창 핸들을 찾는 방식을 어떻게 구현하나 뒤지다가 C++ 로 코드프로젝트에 만들어져 있는걸 보고,


C# 으로 만들어진 게 없나 하고 찾아봤는데..


역시나 있다..


만쉐~ 역시 선구자들은 많아.. 잘사용해보세~ -_-;


링크 : http://devpia.co.kr/MAEUL/Contents/Detail.aspx?BoardID=50&MAEULNO=20&no=881823&ref=881821&page=1


C++ 소스 링크 : http://www.codeproject.com/Articles/1698/MS-Spy-style-Window-Finder


C# 소스 링크 : http://www.codeproject.com/Articles/34981/FindWindow

반응형
Posted by blueasa
, |

1
2
3
4
5
6
7
8
9
10
11
12
13
typedef BOOL __stdcall Callback(int a, int b);   //Hslee 콜백 등록!
Callback *_cb;   //C#의 콜백루틴 받아오는 포인터변수
 
void CallBackCall()  //콜백 루틴시키는 함수...(Callback함수와 연결됨)
{
    if(_cb != NULL)
        (_cb)(10,20);
}
 
void RegCallback(Callback *pcb)  //C#의 콜백루틴 받아와 연결하는 함수
{
    _cb = pcb;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System.Runtime.InteropServices;
 
namespace CallbackTest
{
    class Program
    {  
        [DllImport("CallbackTestDll.dll")]
        static extern void RegCallback1(Callback1 callback);
        delegate bool Callback1(int a, int b);
         
        static bool PrintWindow1(int a, int b)
        {
            Console.Write("a:"+a.ToString() + "b:" + b.ToString()+"\t");
            return true;
        }
 
        static void Main(string[] args)
        {
            Callback1 callback1 = new Callback1(PrintWindow1);
            RegCallback1(callback1);
        }
    }
}



C#의 delegate루틴을 C++에 넘겨준뒤. C++에서 콜백이 발생됬을경우 C#으로 넘기게된다.
여기서 주의할점.. C#은 콜백을 받아올때 가바지컬렉터 라는 놈이 관리를 하게된다..

Callback발생 -> 카비지컬렉터 -> C# 루틴

뭐 이런식으로 알고있다.. C#은 가비지컬렉터 수집을 자동으로 한다...
Callback이 사용자가 요청했을때만 들어온다면 상관없지만...

uRON(ETRI)의 로봇주행알고리즘 을 사용할경우 콜백이 미친듯이 들어와버리게된다..
그러면서 가비지컬렉터가 싸이면서.. 프로그램이 종료되게된다..

콜백이 미친듯이 들어오므로 가비지컬렉터수집을 사용자가 직접 해줘야 한다...

C#의 콜백 루틴 안에다가 
GC.Collect();

를 넣어주게되면 가비지컬렉터를 강제로 수집하게된다..

자세한사항은 MSDN 참고!



이방법을 구현하기위하 온갖 MSDN을 뒤지면서 나만의 방법으로 바꿔주는데 성공했다.

정말 힘들었던 작업....중 하나.. 정말 유용하게 쓰인다! 

나같은 Robot Programming을 하는 사람이라면.. 디바이스제어는 C++ 
Main Program은 Error가 적은 C#을 사용하용하는 사람들이 꽤 있을거 같다..


출처 : http://periar.tistory.com/entry/C-DLL-Callback-%EC%9D%84-C-%EB%A3%A8%ED%8B%B4%EC%9C%BC%EB%A1%9C-%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B8%B0

반응형
Posted by blueasa
, |



링크 : http://klmekleot.tistory.com/37



반응형
Posted by blueasa
, |

링크 : http://mh-nexus.de/en/hxd/


HxD is a carefully designed and fast hex editor which, additionally to raw disk editing and modifying of main memory (RAM), handles files of any size.

The easy to use interface offers features such as searching and replacing, exporting, checksums/digests, insertion of byte patterns, a file shredder, concatenation or splitting of files, statistics and much more.

Editing works like in a text editor with a focus on a simple and task-oriented operation, as such functions were streamlined to hide differences that are purely technical.
For example, drives and memory are presented similar to a file and are shown as a whole, in contrast to a sector/region-limited view that cuts off data which potentially belongs together. Drives and memory can be edited the same way as a regular file including support for undo. In addition memory-sections define a foldable region and inaccessible sections are hidden by default.

Furthermore a lot of effort was put into making operations fast and efficient, instead of forcing you to use specialized functions for technical reasons or arbitrarily limiting file sizes. This includes a responsive interface and progress indicators for lengthy operations.

 

Features

  • Available as a portable and installable edition
  • RAM-Editor
    • To edit the main memory
    • Memory sections are tagged with data-folds
  • Disk-Editor (Hard disks, floppy disks, ZIP-disks, USB flash drives, CDs, ...)
    • RAW reading and writing of disks and drives
    • for Win9x, WinNT and higher
  • Instant opening regardless of file-size
    • Up to 8EB; opening and editing is very fast
  • Liberal but safe file sharing with other programs
  • Flexible and fast searching/replacing for several data types
    • Data types: text (including Unicode), hex-values, integers and floats
    • Search direction: Forward, Backwards, All (starting from the beginning)
  • File compare (simple)
  • View data in Ansi, DOS, EBCDIC and Macintosh character sets
  • Checksum-Generator: Checksum, CRCs, Custom CRC, SHA-1, SHA-512, MD5, ...
  • Exporting of data to several formats
    • Source code (Pascal, C, Java, C#, VB.NET)
    • Formatted output (plain text, HTML, Richtext, TeX)
    • Hex files (Intel HEX, Motorola S-record)
  • Insertion of byte patterns
  • File tools
    • File shredder for safe file deletion
    • Splitting or concatenating of files
  • Basic data analysis (statistics)
    • Graphical representation of the byte/character distribution
    • Helps to identify the data type of a selection
  • Byte grouping
    • 1, 2, 4, 8 or 16 bytes packed together into one column
  • "Hex only" or "text only"-modes
  • Progress-window for lengthy operations
    • Shows the remaining time
    • Button to cancel
  • Modified data is highlighted
  • Unlimited undo
  • "Find updates..."-function
  • Easy to use and modern interface
  • Goto address
  • Printing
  • Overwrite or insert mode
  • Cut, copy, paste insert, paste write
  • Clipboard support for other hex editors
    • Visual Studio/Visual C++, WinHex, HexWorkshop, ...
  • Bookmarks
    • Ctrl+Shift+Number (0-9) sets a bookmark
    • Ctrl+Number (0-9) goes to a bookmark
  • Navigating to nibbles with Ctrl+Left or Ctrl+Right
  • Flicker free display and fast drawing

 

Version1.7.7.0 (April 3, 2009)What's new?
OSWindows 95, 98, ME, NT 4, 2000, XP, 2003, Vista, or 7
Download page

 

반응형
Posted by blueasa
, |

Python을 설치하면 기본적으로 파이썬 셸과 IDLE이 설치됩니다.
하지만 윈도우에서 텍스트 에디터 또는 이클립스 등 다른 개발환경에 익숙해져 버린 저는 조금 어색하기만 합니다.

그래서 수소문하다보니 PyScripter라는 무료 IDE(통합개발환경:Integrated development environment)이 있더군요^^ 아싸!

어떤 언어를 배우기 위해서 환경을 꾸리는 일은 너무도 당연한 일이라고 생각해서 지나칠 수 있지만
대부분의 책머리에 이런 환경을 꾸리는 방법을 설명하듯이 저도 시작합니다!!

PyScripter 설치하기!!

먼저 PyScripter를 다운 받기 위해서 http://code.google.com/p/pyscripter/ 에 접속합니다. 
구글에서 PyScripter를 검색하셔도 링크가 나옵니다.



상단 메뉴의 Downloads를 클릭하기면 PyScripter 설치 파일을 다운로드 할 수 있습니다.



압축 파일 하나와 설치 파일 두개가 보일 겁니다. 자신의 컴퓨터 환경에 맞는 버전을 다운 받으시면 됩니다.
(저는 64bit 윈도우를 사용하기 때문에 64용 설치 파일을 다운 받았습니다.)



이제 다운로드 받은 파일을 실행합니다!
인터넷 익스플로러의 SmartScreen 필터 기능을 사용하신다면 설치 파일을 실행시 경고 메시지가 뜰 수 있습니다.
이 때  [작업] 버튼을 눌러 프로그램을 강제로 실행시켜 주시면 설치가 진행됩니다.



지금부터는 너무나 쉽습니다. 곰플레이어 설치하듯이 네이트온 설치하듯이 넘어가주시면 됩니다.



우선 설치할 폴더 경로를 확인하고 다음으로 넘어갑니다.



시작 메뉴에 등록할 이름을 지정하고 다음으로 넘어갑니다.



설치할 PyScripter에 대한 정보를 확인하고 다음으로 넘어갑니다.
제가 받은 PyScripter는 최소한 Python2.4 버전 이상은 설치 돼있어야 한다고 적혀있네요.



다음 바탕화면과 빠른실행메뉴에 추가적으로 아이콘을 생성할지 선택하고,
탐색기의 context menu에 "Edit with PyScripter"라는 항목을 넣을지 선택합니다.(마우스 우클릭 시 나오는 메뉴에요.)



실제 설치가 되기전 마지막으로 선택 사항들을 확인하고 Install 버튼을 클릭!!!!



설치는 순식간에 끝납니다.(캡쳐하기조차 힘들었네요;;;)



설치가 끝나고 또 PyScripter에 대한 정보가 출력됩니다 .블라블라~~ @ㅁ@;;



설치가 끝났습니다 PyScripter를 바로 실행 하시려면 Launch PyScripter를 체크하고 Finish를 눌러줍니다.



짜잔~~ 오오 그래도 뭐가 편집기도 있고 탐색기도 있고 파이썬 인터프리터도 함께 뜨는 모양새 있는 파이썬 개발 환경이 설치 됬습니다. 이제 공부 열심히 할 일만 남았네요 에공. 화이팅!!



반응형
Posted by blueasa
, |

파이썬(Python)에 대한 몇몇 글을 쓴 적이 있는데 정작 파이썬을 설치하는 방법은 소개한 적이 없네요.
이제 막 파이썬을 시작하시는 분들을 위해서 파이썬 설치에 대해서 간략히 소개하겠습니다^^
저는 Python 3.2.2 버전으로 공부를 하고 있으므로 이 버전의 설치에 대해서 쓰도록 하겠습니다.

우선 파이썬이라는 언어는 공개되어 있고 무료입니다.
즉 필요하다면 다운받아서 사용하면 된다는 것이죠.


먼저 http://www.python.org에 접속합니다.
구글이나 네이버등 검색 사이트에서 'python' 또는 '파이썬'으로 검색하셔도 최상위에 검색 결과가 나올겁니다.



페이지 왼쪽에 몇가지 메뉴가 보입니다. 이중에 DOWNLOAD를 클릭하세요!



Download Python 페이지에서 스크롤을 조금만 내리시면 Python 3.2.2 에대한 여러가지 배포판 링크가 보입니다.
여러분의 컴퓨터 환경에 맞는 bit와 OS를 선택해서 다운 받습니다. 
저는 Windows 64bit 환경에서 사용할 것이므로 Python 3.2.2 Windows X86_64 MSI Installer를 다운 받았습니다.



다운로드가 완료되면 설치 파일을 실행 합니다.



윈도우에서의 설치는 우리가 흔히 알집이나 곰플레이어를 설치할 때처럼 편하게 진행됩니다.
먼저 윈도우 사용자 중 누가 파이썬을 사용할지에 대한 선택부터 시작됩니다. 저는 제 컴퓨터를 혼자 쓰므로 Install for all users를 선택했습니다. 혹시 여러 사용자가 같이 사용하는 컴퓨터에서 혼자 사용하시려면 Install just for me를 선택하시면 됩니다.



그 다음 Python을 설치할 폴더를 정해줍니다. Python 3.2.2의 기본 경로는 C:\Python32\로 지정되어 있군요.



마지막으로 선택사항에 대해 물어보는데요 다음으로 넘어가시면 되겠습니다. 각 항목을 선택하면 아래 상자에 항목에 대한 설명이 나옵니다. 참고하세요.



설치가 진행됩니다.
진행 중 아래와 같이 사용자 계정 컨트롤 메시지가 나온다면 반드시 '예'를 클릭 하셔서 설치가 진행되도록 해주세요. '아니오'를 클릭하시면 당연히 설치가 안됩니다.



설치가 완료되었습니다. 이제 파이썬을 사용할 수 있습니다.

 

시작 메뉴에서 Python 3.2라는 폴더가 등록 되었군요.



이대로 파이썬을 사용할 수도 있지만 좀 더 편리하고 원활한 사용을 위해서 환경 변수 Path에 Python이 설치된 경로를 추가해 줍니다.
[제어판] - [시스템 및 보안] - [시스템] 에서 왼쪽 메뉴의 [고급 시스템 설정] 을 선택합니다.



시스템 속성 창이 뜹니다. 그러면 고급 탭을 선택하고 아래의 환경 변수를 선택합니다.


환경 변수 창에서 시스템 변수 Path를 찾아서 선택한 후 편집을 클릭합니다.


변수 값에 다른 값들이 있다면 지우지 마시고 그 변수의 마지막에 ;(세미콜론)을 적으시고 그 다음에 Python의 설치된 경로명을 적어줍니다. 


이렇게 환경 변수 Path를 지정해 주시면 사용자가 어떤 위치에서 python을 실행 시키더라도 Python 설치 경로에 있는 Python.exe가 실행 됩니다. 



이렇게 파이썬을 공부하기 위한 첫번째 준비! Python 설치하기가 끝났습니다^^ 
다같이 Python 세계에 빠져 봅시다!



출처 : http://kkoseul.tistory.com/136

반응형
Posted by blueasa
, |

이 책은 파이썬이란 언어를 처음 접해보는 독자들과 프로그래밍을 한 번도 해 본적이 없는 사람들을 대상으로 한다. 프로그래밍을 할 때 사용되는 전문적인 용어들을 알기 쉽게 풀어서 쓰려고 노력하였으며, 파이썬이란 언어의 개별적인 특성만을 강조하지 않고 프로그래밍 전반에 관한 사항을 파이썬이란 언어를 통해 알 수 있도록 알기 쉽게 설명하였다.

 

파이썬에 대한 기본적인 지식을 알고 있는 사람이라도 이 책은 파이썬 프로그래밍에 대한 흥미를 가질 수 있는 좋은 안내서가 될 것이다. 이 책의 목표는 독자가 파이썬을 통해 프로그래밍에 대한 전반적인 이해를 갖게하는 것이며, 또 파이썬이라는 도구를 이용하여 원하는 프로그램을 쉽고 재미있게 만들 수 있게 하는 것이다.

 

이 문서가 마음에 드신다면 추천 한표 부탁드려요~! ^^


파이썬
python
입문서
약 1주, 6일 전에 마지막으로 수정
26
※ 이 문서에 투표 해 주세요.




출처 : http://codejob.co.kr/docs/view/2/

반응형
Posted by blueasa
, |

언리얼 볼만한 곳

Unreal / 2012. 4. 29. 03:56

링크 : http://mgun.tistory.com/category/Unreal


링크2 : http://ncanis.tistory.com/category/Unreal%20%EA%B2%8C%EC%9E%84%20%EC%97%94%EC%A7%84

반응형

'Unreal' 카테고리의 다른 글

[펌] 유니티 사용자가 본 언리얼엔진4  (0) 2018.10.31
[링크] 배울 곳..?  (0) 2018.07.31
언리얼 개발 키트, 에픽 게임스 - Epic UDK  (0) 2012.06.10
Posted by blueasa
, |

감쇠 와 감쇄

한글 / 2012. 4. 27. 14:23

감쇠의 "쇠"는 점점 약해짐 또는 점점 적어짐 의 진행의 뜻이 있습니다.
감쇄의 "쇄"는 죽었다. 없어졌다.의 "살"의 뜻이 있습니다.상황 종료의 뜻이지요!

어떤 에너지로 비유하면 감쇠는 어떤 힘에의하거나 스스로의 힘에 의해 에너지가 점점 작아진다는 뜻이지만 변이가 생겨 다시 그 힘이 켜질수도 있는 상황입니다.

감쇄는 어떤 힘에의하거나 스스로의 힘에 의해 에너지가 없어졌음을 나타낸것입니다.

그래서 일예의 내용을 올리면. 에너지가 감쇠하고 있다.(진행)
그리고 에너지가 감쇄되었다.(종료)

[출처] 감쇠 와 감쇄|작성자 진백




출처 : http://blog.naver.com/wlsqor2/40039533069

반응형

'한글' 카테고리의 다른 글

쉬운 맞춤법 공부  (0) 2012.10.23
율/률(열/렬)  (0) 2012.06.03
설레임 / 설렘  (0) 2012.06.03
이것이 우리말(TIG와 함께하는 바르고, 고운 우리말!)  (0) 2012.05.08
역할? 역활?  (0) 2012.05.08
Posted by blueasa
, |