• 웹서버 한글파일 다운로드 안될때 리눅스 파일 인코딩 방법

    웹서버 한글파일 다운로드 안될때 리눅스 파일 인코딩 방법

    웹서버 운영하다보면 한글파일을 다운받아야하는경우가 있습니다.

    그런데 한글을 인식못하여서 다운로드가 안될때 파일명을 인코딩하여 다운받는 방법이 있습니다.

    한글 유형이 EUC-KR, CP949 등 많습니다.

    우선 범용적으로 접속할수있도록 해야하니 최종 인코딩은 UTF-8로 지정해야합니다.

    yum install convmv.noarch
    convmv -f cp949 -t utf8 -r --notest ../app/

     

    euckr -> utf8

    cp949 -> utf8

     

    이렇게 한글로 된 파일이름을 변환해주면 외부에서 접근이 가능해집니다.

    폴더를 전체를 걸어도 되며 원하는 방식대로 할수 있어 좋더군요

    이제 한글파일도 다운로드가 가능해졌습니다.

    덕분에 자동화프로그램의 자동업데이트 기능을 한글파일 그대로 다운받아서 할 수 있게되었네요.

     convmv noarch 1.15-2.el7 base 31 k

    이제 한글로 된 파일도 서버 인코딩 바꾸지 않고 쉽게 바꾸실수있습니다.

     

     

    convmv 1.15 - converts filenames from one encoding to another
    Copyright (C) 2003-2011 Bjoern JACKE <bjoern@j3e.de>
    
    This program comes with ABSOLUTELY NO WARRANTY; it may be copied or modified
    under the terms of the GNU General Public License version 2 or 3 as published
    by the Free Software Foundation.
    
    USAGE: convmv [options] FILE(S)
    -f enc encoding *from* which should be converted
    -t enc encoding *to* which should be converted
    -r recursively go through directories
    -i interactive mode (ask for each action)
    --nfc target files will be normalization form C for UTF-8 (Linux etc.)
    --nfd target files will be normalization form D for UTF-8 (OS X etc.)
    --qfrom be quiet about the "from" of a rename (if it screws up your terminal e.g.)
    --qto be quiet about the "to" of a rename (if it screws up your terminal e.g.)
    --exec c execute command instead of rename (use #1 and #2 and see man page)
    --list list all available encodings
    --lowmem keep memory footprint low (see man page)
    --nosmart ignore if files already seem to be UTF-8 and convert if posible
    --notest actually do rename the files
    --replace will replace files if they are equal
    --unescape convert%20ugly%20escape%20sequences
    --upper turn to upper case
    --lower turn to lower case
    --parsable write a parsable todo list (see man page)
    --help print this help

     

     

  • c# LiteDB nuget install package method

    c# LiteDB nuget install package method

    C:\Users\ation\Downloads>nuget install litedb -o "C:\Users\ation\Documents\Visual Studio 2013\Projects\_DLL"
    Feeds used:
    https://www.nuget.org/api/v2/
    
    Installing package 'litedb' to 'C:\Users\ation\Documents\Visual Studio 2013\Projects\_DLL'.
    CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='litedb'&semVerLevel=2.0.0
    
    
    Attempting to gather dependency information for package 'litedb.5.0.2' with respect to project 'C:\Users\ation\Documents\Visual Studio 2013\Projects\_DLL', targeting 'Any,Version=v0.0'
    Gathering dependency information took 26.94 ms
    Attempting to resolve dependencies for package 'litedb.5.0.2' with DependencyBehavior 'Lowest'
    Resolving dependency information took 0 ms
    Resolving actions to install package 'litedb.5.0.2'
    Resolved actions to install package 'litedb.5.0.2'
    Retrieving package 'LiteDB 5.0.2' from 'nuget.org'.
    Adding package 'LiteDB.5.0.2' to folder 'C:\Users\ation\Documents\Visual Studio 2013\Projects\_DLL'
    Added package 'LiteDB.5.0.2' to folder 'C:\Users\ation\Documents\Visual Studio 2013\Projects\_DLL'
    Successfully installed 'LiteDB 5.0.2' to C:\Users\ation\Documents\Visual Studio 2013\Projects\_DLL
    Executing nuget actions took 125.12 ms

    c# nuget Lite DB install

  • [Solved] c# datagridview cell click immediately change method

    [Solved] c# datagridview cell click immediately change method

    private void dataGridView_smsList_전체체크버튼()
    {
        bool 한개라도체크된부분확인 = false;
        for (int i = 0; i < dataGridView_smsList.Rows.Count; i++)
        {
            if (Convert.ToBoolean(dataGridView_smsList.Rows[i].Cells[SMS_LIST_COLUMN_CHECKBOX].Value))
            {
                한개라도체크된부분확인 = true;
            }
        }
    
        if (한개라도체크된부분확인)
        {
            한개라도체크된부분확인 = false;
        }
        else
        {
            한개라도체크된부분확인 = true;
    
        }
    
        for (int i = 0; i < dataGridView_smsList.Rows.Count; i++)
        {
            dataGridView_smsList.Rows[i].Cells[SMS_LIST_COLUMN_CHECKBOX].Value = 한개라도체크된부분확인;
        }
    
        dateGridView_Update();
    }
    private void dataGridView_smsList_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
    
        if (e.RowIndex == -1)
        {
            if (e.ColumnIndex == SMS_LIST_COLUMN_CHECKBOX)
            {
                dataGridView_smsList_전체체크버튼();
            }
        }
        else
        {
            //이부분이 없으면 개별 Cell 클릭시 반응 한템포 느려짐
            dataGridView_smsList.CommitEdit(DataGridViewDataErrorContexts.Commit);
    
        }
    }
    
         
    private void dataGridView_smsList_CellValueChanged(object sender, DataGridViewCellEventArgs e)
    {
        dateGridView_Update();
    }
    
    private void dateGridView_Update()
    {
    
        dataGridView_smsList.Invoke(
        new Action(
            delegate()
            {
                button_전체선택.Focus();
                dataGridView_smsList.Focus();
    
                int smsListCount = 0;
    
                for (int i = 0; i < dataGridView_smsList.Rows.Count; i++)
                {
                    if (Convert.ToBoolean(dataGridView_smsList.Rows[i].Cells[SMS_LIST_COLUMN_CHECKBOX].Value))
                    {
                        smsListCount++;
                    }
                }
    
                label_smsList_count.Text = string.Format("문자발송 LIST [ 선택: {0} / 전체: {1} ]", smsListCount, dataGridView_smsList.Rows.Count);
            }
            ));
    
    }

    solved

  • c# Form 스타일 None 에서 폼 늘리기

    c# Form 스타일 None 에서 폼 늘리기

    c# Form 스타일 None 일때에도 폼을 늘릴수 있습니다.

     

            private const int
             HTLEFT = 10,
             HTRIGHT = 11,
             HTTOP = 12,
             HTTOPLEFT = 13,
             HTTOPRIGHT = 14,
             HTBOTTOM = 15,
             HTBOTTOMLEFT = 16,
             HTBOTTOMRIGHT = 17;
    
            const int _ = 10; // you can rename this variable if you like
    
            Rectangle Top { get { return new Rectangle(0, 0, this.ClientSize.Width, _); } }
            Rectangle Left { get { return new Rectangle(0, 0, _, this.ClientSize.Height); } }
            Rectangle Bottom { get { return new Rectangle(0, this.ClientSize.Height - _, this.ClientSize.Width, _); } }
            Rectangle Right { get { return new Rectangle(this.ClientSize.Width - _, 0, _, this.ClientSize.Height); } }
    
            Rectangle TopLeft { get { return new Rectangle(0, 0, _, _); } }
            Rectangle TopRight { get { return new Rectangle(this.ClientSize.Width - _, 0, _, _); } }
            Rectangle BottomLeft { get { return new Rectangle(0, this.ClientSize.Height - _, _, _); } }
            Rectangle BottomRight { get { return new Rectangle(this.ClientSize.Width - _, this.ClientSize.Height - _, _, _); } }
    
    
            protected override void WndProc(ref Message message)
            {
                base.WndProc(ref message);
    
                if (message.Msg == 0x84) // WM_NCHITTEST
                {
                    var cursor = this.PointToClient(Cursor.Position);
    
                    if (TopLeft.Contains(cursor)) message.Result = (IntPtr)HTTOPLEFT;
                    else if (TopRight.Contains(cursor)) message.Result = (IntPtr)HTTOPRIGHT;
                    else if (BottomLeft.Contains(cursor)) message.Result = (IntPtr)HTBOTTOMLEFT;
                    else if (BottomRight.Contains(cursor)) message.Result = (IntPtr)HTBOTTOMRIGHT;
    
                    else if (Top.Contains(cursor)) message.Result = (IntPtr)HTTOP;
                    else if (Left.Contains(cursor)) message.Result = (IntPtr)HTLEFT;
                    else if (Right.Contains(cursor)) message.Result = (IntPtr)HTRIGHT;
                    else if (Bottom.Contains(cursor)) message.Result = (IntPtr)HTBOTTOM;
                }
            }

     

    운영하는 c# 소스코드에 그대로 복사해서 넣기만 하면 자동으로 처리됩니다.

    저는 위의 코드보다 아래코드가 바로 되어서 아래 코드를 이용하고 있습니다.

    this.FormBorderStyle, DoubleBuffered, SetStyle 부분은 삭제를 하더라도 잘 돌아가더군요.

     

    참조: https://stackoverflow.com/questions/2575216/how-to-move-and-resize-a-form-without-a-border

  • C# 스크린샷 캡쳐할때 사용함수

    C# 스크린샷 캡쳐할때 사용함수

    출처: http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=18&MAEULNO=8&no=2010&page=2

     

     

    [[DllImport(“gdi32.dll”)]
    static extern bool BitBlt(IntPtr hdcDest, int xDest, int yDest, int
    wDest, int hDest, IntPtr hdcSource, int xSrc, int ySrc, CopyPixelOperation rop);
    [DllImport(“user32.dll”)]
    static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDc);
    [DllImport(“gdi32.dll”)]
    static extern IntPtr DeleteDC(IntPtr hDc);
    [DllImport(“gdi32.dll”)]
    static extern IntPtr DeleteObject(IntPtr hDc);
    [DllImport(“gdi32.dll”)]
    static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight);
    [DllImport(“gdi32.dll”)]
    static extern IntPtr CreateCompatibleDC(IntPtr hdc);
    [DllImport(“gdi32.dll”)]
    static extern IntPtr SelectObject(IntPtr hdc, IntPtr bmp);
    [DllImport(“user32.dll”)]
    public static extern IntPtr GetDC(IntPtr ptr);
    private Bitmap CaptureScreen(int x, int y, int 넓이, int 높이)
    {
    IntPtr hDC = GetDC(IntPtr.Zero);
    IntPtr hMemDC = CreateCompatibleDC(hDC);
    IntPtr hBitmap = CreateCompatibleBitmap(hDC, 넓이, 높이);
    IntPtr hOld = (IntPtr)SelectObject(hMemDC, hBitmap);
    BitBlt(hMemDC, -x, -y, 넓이+x, 높이+y, hDC, 0, 0, CopyPixelOperation.SourceCopy | CopyPixelOperation.CaptureBlt);
    SelectObject(hMemDC, hOld);
    DeleteDC(hMemDC);
    ReleaseDC(IntPtr.Zero, hDC);
    Bitmap memoryImage = System.Drawing.Image.FromHbitmap(hBitmap);
    DeleteObject(hBitmap);
    return memoryImage;
    }
  • Standard Clipboard  Formats

    Standard Clipboard Formats

    Standard Clipboard Formats

    Shell clipboard Formats

    Drag & Drop Related Formats

    OLE Formats

     

    Common Text Formats

    Common Image Formats

     

    참조: https://www.codeproject.com/Reference/1091137/Windows-Clipboard-Formats

    [원문]

    Introduction

    This reference gives you an overview of standard and common clipboard formats with links to the data structures.

    Definitions

    The following type definitions are used in the below tables:

    ANSI text
    Null terminated ANSI or multi byte string.
    Unicode text
    Null terminated Unicode (UTF-16LE) string.
    ANSI / Unicode text list
    List of null terminated strings followed by a NULL character (double NULL terminated).
    ASCII / ANSI text
    ASCII 7-bit text by definition but ANSI 8-bit text may be supported.
    DWORD (BOOL)
    DWORD value representing a boolean value (true if not zero).

    Links indicate the destination in brackets. For MSDN links in the tables the indication is omitted.

    Standard Clipboard Formats

    The Standard Clipboard Formats [MSDN] use numeric IDs defined in WinUser.h. All non-standard formats must be registered using a unique format name.

    Format Identifier Data Type Description
    CF_TEXT (1) ANSI text Text.
    CF_BITMAP (2) HBITMAP Handle to a bitmap (GDI object).
    CF_METAFILEPICT (3) METAFILEPICT Windows-Format Metafiles picture.
    CF_SYLK (4) ANSI text Microsoft Symbolic Link [Wikipedia].
    CF_DIF (5) ASCII text Software Arts Data Interchange Format [Wikipedia].
    CF_TIFF (6) TIFF [Wikipedia] TIFF image.
    CF_OEMTEXT (7) 8-Bit DOS text Text.
    CF_DIB (8) BITMAPINFO Structure followed by bitmap bits.
    CF_PALETTE (9) HPALETTE Handle to a color palette (GDI object).
    CF_PENDATA (10) Windows 3.1 pen extension data.
    CF_RIFF (11) RIFF Resource Interchange File Format (RIFF) audio.
    CF_WAVE (12) WAVE WAVE audio.
    CF_UNICODETEXT (13) Unicode text Text.
    CF_ENHMETAFILE (14) HENHMETAFILE Enhanced-Format Metafiles handle.
    CF_HDROP (15) DROPFILES List of file names.
    CF_LOCALE (16) DWORD (LCID) LCID for CF_TEXT to CF_UNICODE conversion.
    CF_DIBV5 (17) BITMAPV5HEADER Structure followed by bitmap bits
    CF_DSPTEXT (0x0081) ANSI text Text.
    CF_DSPBITMAP (0x0082) HBITMAP Handle to a bitmap (GDI object)
    CF_DSPMETAFILEPICT (0x0083) METAFILEPICT Windows-Format Metafiles picture.
    CF_DSPENHMETAFILE (0x008E) HENHMETAFILE Enhanced-Format Metafiles handle.

    Shell Clipboard Formats

    The Shell Clipboard Formats [MSDN] are used to transfer shell objects via clipboard and Drag & Drop. For most of them there is a definition for the format name in the header file shlobj.h:

    Definition Format Name
    CFSTR_SHELLIDLIST Shell IDList Array
    CFSTR_SHELLIDLISTOFFSET Shell Object Offsets
    CFSTR_NETRESOURCES Net Resource
    CFSTR_FILEDESCRIPTORA FileGroupDescriptor
    CFSTR_FILEDESCRIPTORW FileGroupDescriptorW
    CFSTR_FILECONTENTS FileContents
    CFSTR_FILENAMEA FileName
    CFSTR_FILENAMEW FileNameW
    CFSTR_PRINTERGROUP PrinterFriendlyName
    CFSTR_FILENAMEMAPA FileNameMap
    CFSTR_FILENAMEMAPW FileNameMapW
    CFSTR_SHELLURL UniformResourceLocator
    CFSTR_INETURLA UniformResourceLocator
    CFSTR_INETURLW UniformResourceLocatorW
    CFSTR_PREFERREDDROPEFFECT Preferred DropEffect
    CFSTR_PERFORMEDDROPEFFECT Performed DropEffect
    CFSTR_PASTESUCCEEDED Paste Succeeded
    CFSTR_INDRAGLOOP InShellDragLoop
    CFSTR_DRAGCONTEXT DragContext
    CFSTR_MOUNTEDVOLUME MountedVolume
    CFSTR_PERSISTEDDATAOBJECT PersistedDataObject
    CFSTR_TARGETCLSID TargetCLSID
    CFSTR_LOGICALPERFORMEDDROPEFFECT Logical Performed DropEffect
    CFSTR_AUTOPLAY_SHELLIDLISTS Autoplay Enumerated IDList Array
    CFSTR_UNTRUSTEDDRAGDROP UntrustedDragDrop
    CFSTR_FILE_ATTRIBUTES_ARRAY File Attributes Array
    CFSTR_INVOKECOMMAND_DROPPARAM InvokeCommand DropParam
    CFSTR_SHELLDROPHANDLER DropHandlerCLSID
    CFSTR_DROPDESCRIPTION DropDescription

     

    Format Name Data Type Description
    AsyncFlag DWORD (BOOL) Perform insert/paste operation in the background. Used by Explorer to avoid blocking the current instance.
    FileContents Binary File content.
    FileGroupDescriptor FILEGROUPDESCRIPTOR Array of FILEDESCRIPTORs.
    FileGroupDescriptorW FILEGROUPDESCRIPTOR Array of FILEDESCRIPTORs.
    FileName ANSI text Single file name in short (8.3) format.
    FileNameW Unicode text Single file name.
    FileNameMap ANSI text list List of file names when renaming.
    FileNameMapW Unicode text list List of file names when renaming.
    MountedVolume Unicode text Path for mounted volume.
    Shell IDList Array CIDA Array of PIDL (pointer to ITEMIDLIST) offsets.
    Autoplay Enumerated IDList Array CIDA Array of PIDL (pointer to ITEMIDLIST) offsets.
    Shell Object Offsets POINT[] Array of points.
    File Attributes Array FILE_ATTRIBUTES_ARRAY Array of file attributes.
    Net Resource NRESARRAY Array of NETRESOURCE structures.
    PrinterFriendlyName DROPFILES List of printer names.
    UniformResourceLocator ANSI text URL
    UniformResourceLocatorW Unicode text URL

    Drag & Drop Related Formats

    These formats are used with Drag & Drop. Most of them are not documented.

    Format Name Data Type Description
    ComputedImage DWORD ?
    DisableDragText DWORD (BOOL) ?
    DragContext IStream Used internally by the Windows drag/drop helpers.
    DragImageBits SHDRAGIMAGE Drag image bitmap.
    DragSourceHelperFlags DWORD Value passed to IDragSourceHelper2::SetFlags.
    DragWindow DWORD (HWND) The window handle of the drag image window.
    DropDescription DROPDESCRIPTION Aero drag cursor type and text.
    DropHandlerCLSID CLSID GUID CLSID GUID of the drop handler.
    InShellDragLoop DWORD (BOOL) Nonzero when within a drag-and-drop loop.
    InvokeCommand DropParam Unicode text ?
    IsComputingImage DWORD (BOOL) ?
    IsShowingLayered DWORD (BOOL) Nonzero when a drop target shows the drag image.
    IsShowingText DWORD (BOOL) Nonzero when a drop target requests update of Aero cursor.
    Logical Performed DropEffect DWORD (DROPEFFECT) Logically performed drop effect with optimized moves.
    Paste Succeeded DWORD (DROPEFFECT) Set by target when delete-on-paste operation succeeded.
    Performed DropEffect DWORD (DROPEFFECT) Performed drop effect set by the target.
    Preferred DropEffect DWORD (DROPEFFECT) Preferred drop effect set by source. Used also with clipboard.
    TargetCLSID CLSID GUID CLSID GUID of the drop target.
    UntrustedDragDrop DWORD URL Action Flags.
    UsingDefaultDragImage DWORD (BOOL) Nonzero when the drag image is a system default image.

    OLE Formats

    Format Name Data Type Description
    Link ANSI text list OLE 1.0 link.
    Native Binary OLE 1.0 data.
    ObjectLink ANSI text list OLE 1.0 link.
    OwnerLink ANSI text list OLE 1.0 link.
    Data Object Binary OLE 2.0 data.
    Embedded Object Binary OLE 2.0 data.
    Object Descriptor OBJECTDESCRIPTOR OLE 2.0 User interface information.
    Link Source Descriptor OBJECTDESCRIPTOR OLE 2.0 User interface information.
    Link Source IMoniker OLE 2.0. Followed by document class ID.
    Hyperlink IHlink Methods to enable a hyperlink to navigate to its target.

    Common Application Clipboard Formats

    Many applications use the file extension or the MIME type [Wikipedia] as format name and pass data using the corresponding file format. The format names are case-insensitive but is is common practice to use all lower case for MIME types, all upper case for file extensions and Pascal case (upper case for first letter of each word) for descriptive names. Clipboard and drop target applications that should be able to receive such formats should register all commonly used format name variations.

    The header file UrlMon.h contains some definitions for MIME types (see URL Moniker Clipboard Formats [MSDN]).

    Common Text Formats

    Format Name Data Type Description
    text/plain ASCII / ANSI text See also CF_TEXT.
    HTML Format UTF-8 text Microsoft specific HTML clipboard format.
    text/html Text HTML [W3C] file content. The encoding is defined by BOM and HTML headers.
    HTML (Hyper Text Markup Language) Text See text/html.
    text/csv ASCII / ANSI text Comma-Separated Values (CSV) [IETF] file content.
    CSV ASCII / ANSI text See text/csv.
    text/richtext ASCII / ANSI text Word 2007: Rich Text Format (RTF) Specification, version 1.9.1 [Microsoft]
    Rich Text Format ASCII / ANSI text See above.
    Rich Text Format Without Objects ASCII / ANSI text See above.
    RichEdit Text and Objects ASCII / ANSI text See above.
    RTF As Text ASCII / ANSI text See above.
    text/uri-list ASCII text The text/uri-list Internet Media Type [IETF].

    Common Image Formats

    Format Name Data Type Description
    image/bmp BITMAPFILEHEADER File header followed by info header (see CF_DIB and CF_DIBV5) and bitmap data.
    BMP BITMAPFILEHEADER See image/bmp.
    image/gif Binary GIF [W3C] file content.
    GIF Binary See image/gif.
    image/jpeg Binary JPEG [W3C] file content.
    JPEG Binary See image/jpeg.
    JPG Binary See image/jpeg.
    image/png Binary PNG [W3C] file content.
    PNG Binary See image/png.
    image/tiff Binary TIFF [Wikipedia] file content. See also CF_TIFF.

    Points of Interest

    My article Drag & Drop Images and Drop Descriptions for MFC Applications contains a demo application that can be used to show the objects actually on the clipboard (clipboard viewer) and the drag objects when dropping on an info list.

    References

    Clipboard Formats [MSDN]
    Standard Clipboard Formats [MSDN]
    Shell Clipboard Formats [MSDN]
    Shell Data Object [MSDN]
    Handling Shell Data Transfer Scenarios [MSDN]
    HTML Clipboard Format [MSDN]
    RegisterClipboardFormat function [MSDN]
    OLE Background [MSDN]
    Clipboard API and events [W3C]

    History

    2016-04-08 Initial version.
    2016-04-14 Minor text changings, added links to GUID and URL moniker formats.
    2016-04-18 Splitted and re-arranged tables, added some OLE formats, added text/richtext, corrected enhanced meta file type.
    2016-06-21 Added formats text/uri-list, image/bmp, BMP; added link to W3C clipboard API
    2017-06-22 Added AsyncFlag format and that Preferred DropEffect also used with clipboard.
    2018-03-08 Fixed wrong FileContents description.

  • c# 남은시간계산 날짜 시각 표시 timespan class

    c# 남은시간계산 날짜 시각 표시 timespan class

    c# 언어를 이용해서 남은시간계산 할 수 있습니다.

    날짜 시각 표시 가능하며 계산해서 포맷형식으로 원하는 모양으로도 만들 수 있습니다.

    .Days / .Hours / .Minutes / .Seconds / .Milliseconds 를 통해서 정확한 수치까지 계산됩니다.

     

    DateTime 지금시각 = DateTime.Now;
    다음재부팅시각비교 = 지금시각.AddHours(9);
    
    TimeSpan 재부팅남은시각 = 다음재부팅시각비교 - 지금시각;
    
    MessageBox.Show(재부팅남은시각.TotalSeconds.ToString());

    C# TimeSpan 클래스를 이용해서 쉽게 두 시간 차이 구할 수 있습니다.

    남은날짜 남은시간 남은초 정확하게 비교할 수 있습니다.

     

    날짜비교할때 쉽게 사용해보세요

    DateTime.Now; // 현재시각

    지금시각.addHours(9); // 9시간후 시각

  • c# 마우스 전역 포인트 이동 및 클릭 (매크로 만들때 활용)

    c# 마우스 전역 포인트 이동 및 클릭 (매크로 만들때 활용)

    C# 마우스 전역 포인트 이동 할 때 사용합니다.

    [DllImport("user32.dll")]
    static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInf);
    
    private const uint MOUSEMOVE = 0x0001; // 마우스 이동
    
    private const uint LBUTTONDOWN = 0x0002; // 왼쪽 마우스 버튼 눌림
    private const uint LBUTTONUP = 0x0004; // 왼쪽 마우스 버튼 떼어짐
    
    private const uint RBUTTONDOWN = 0x0008; // 오른쪽 마우스 버튼 눌림
    private const uint RBUTTONUP = 0x00010; // 오른쪽 마우스 버튼 떼어짐
    
    private const uint ABSOLUTEMOVE = 0x8000; // 전역 위치

    우선 Win32 API 함수를 호출해야하므로 mouse_event 함수를 Dll Import 선언합니다.

     

    그리고 클릭과 이동에 대한 함수를 하나 만들어두세요

    private void MouseClick(bool isClick, Point point, uint width, uint height)
    {
    Rectangle rtScreen = Screen.PrimaryScreen.Bounds;
    
    uint nX = (uint)(65535 * (point.X + width) / rtScreen.Width);
    uint nY = (uint)(65535 * (point.Y + height)/ rtScreen.Height);
    
    if (isClick)
    {
    mouse_event(ABSOLUTEMOVE | MOUSEMOVE | LBUTTONDOWN, nX, nY, 0, 0);
    mouse_event(ABSOLUTEMOVE | MOUSEMOVE | LBUTTONUP, nX, nY, 0, 0);
    }
    else
    {
    mouse_event(ABSOLUTEMOVE | MOUSEMOVE, nX, nY, 0, 0);
    }
    
    
    }

    그리고 최종적으로 메소드가 들어갈 위치에 배치하면 됩니다.

     

    if (input.GetAttribute("id").Equals("loginId"))
    {
    
    Point 현재마우스위치 = GetRealOffset(input);
    
    input.Focus();
    
    MouseClick(true, 현재마우스위치, 0, 0);
    Thread.Sleep(100);
    KeyboardPress(VK_BACKSPACE);
    break;
    
    }

    이렇게 하면 마우스 포지션및 마우스위치 클릭이 가능해져서

    원하는 매크로를 만들 수 있습니다.

    네이버 로그인 자동만들기 완성!^^

  • string.format c# 자릿수 통화표현식 숫자표현 String 문자 숫자표시 포맷 통화표시

    string.format c# 자릿수 통화표현식 숫자표현 String 문자 숫자표시 포맷 통화표시

    //헥사코드 HEX DEBUG 10진수 -> 16진수 표현식
    String.Format("{0:X}", Convert.ToInt32("32")); -> 20
    //소수점 0.00 두번째 자리 표현식
    String.Format("{0:0.00}", 12345.67890); 		// -> 12345.68
    String.Format("{0:0.00}", 12345.6789); 		// -> 12345.68
    String.Format("{0:0.00}", 12345.6); 		// -> 12345.60
    String.Format("{0:0.00}", 12345.0); 		// -> 12345.00
    //통화단위 표현식 1,000 천단위 ,콤마 추가
    string.Format("{0:0,0}", 123456789); // -> 123,456,789
    string.Format("{0:#,0}", 123456789); // -> 123,456,789
    string.Format("{0:0,0}", 1000); // -> 1,000
    string.Format("{0:#,0}", 1000); // -> 1,000
    string.Format("{0:0,0}", 1); // -> 01
    string.Format("{0:#,0}", 1); // -> 1 숫자앞에 0을 없애기 위해서는 0이 아닌 #을 넣어야함!!

    스트링 문자열 숫자로 표현할때 포맷형식이 존재합니다.

    toString() 함수를 이용할 수도 있지만 string.Format() 함수를 이용해서 인자값과 함께 형식을 자유롭게 바꿀 수 있습니다.

     

    통화단위를 표현할때 3자리마다 ,콤마를 넣는경우가 있는데 이때에는 0,0 대신 #,0 을 넣으면 한자리 숫자가 정상적으로 나옵니다. 0,0을 이용할경우 위의 예시처럼 01 이렇게 두자리로 표현됩니다.

     

  • c# webBrowser html element real offset height value HTML 높이값

    c# webBrowser html element real offset height value HTML 높이값

    public Point GetRealOffset(HtmlElement element)
    {
    //get element pos
    Point point = new Point(element.OffsetRectangle.Left, element.OffsetRectangle.Top);
    
    //get the parents pos
    HtmlElement tempElement = element.OffsetParent;
    while (tempElement != null)
    {
    point.X += tempElement.OffsetRectangle.Left;
    point.Y += tempElement.OffsetRectangle.Top;
    tempElement = tempElement.OffsetParent;
    }
    
    return point;
    }

    c# webBrowser html element real offset height value

    in use!

    example

    if (span.GetAttribute("className").Contains("remainSMS"))
    {
    
    int remainSMS = Int32.Parse(span.InnerHtml);
    if (remainSMS > -99999 && remainSMS <= numericUpDown_남은기간.Value)
    {
    발송가능sms가없습니까 = false;
    webBrowser_관리자.Document.Window.ScrollTo(GetRealOffset(span.Parent.Parent));
    break;
    }
    }