Homemade serial Number (SN) Filling Machine

Source: Internet
Author: User
Tags sleep

A few days ago on the internet to see a software called sncopy, used to help fill in the serial number (SN). The idea is still very good. Install the software often to fill in the serial number, and many series number should be divided into sections to fill out, can not use CTRL + C and CTRL + V (copy and paste) to a one-time fix, only section of the copy and paste, very troublesome. Sncopy is here to help us solve this problem. Feel this is not very difficult to do, that is, from the Clipboard to get the entire serial number, and then decompose, and then fill in. So you do it yourself!

First, create an application snpaste based on the dialog box.

Second, write code

We use Shift+v as a shortcut to quickly fill in the entire serial number at once. A hotkey is registered first. In InitDialog (), add the following code:

if(!::RegisterHotKey(this->GetSafeHwnd(),0x3333,MOD_SHIFT,0x56))
{
 ::AfxMessageBox("热键注册失败!");
 this->CloseWindow();
}

The hotkey must be logged off before the program exits. In OnClose ():

::UnregisterHotKey(this->GetSafeHwnd(),0x3333);

Response Hotkey:

Lresult Csnpastedlg::onhotkey (WPARAM wparam,lparam LPARAM)
{if (! OpenClipboard ())
{:: AfxMessageBox ("Unable to open the Pasteboard!") ");
return-1;
}
CString str=cstring (char*):: GetClipboardData (Cf_text));
? CString oldstr=str;//Save the original string
CloseClipboard ();
Str. Trim ();
CString strtemp;
int FIND_I=STR. Find ('-');
if (FIND_I!=-1)//series number has "-" in order to divide the serial number string
{
while (Find_i!=-1)
{
Strtemp=str. Left (find_i);
Str=str. Mid (find_i+1);
Find_i=str. Find ('-');
Sleep (100);//Because the Clipboard operation is slow, must add a certain delay, otherwise the data will be wrong.
This->sendstrtoclipboard (strtemp);//Copy the decomposed bar string to the Clipboard
THIS->PERFORMCTRLV ()//imitate keyboard keystroke Ctrl + V
This->performclicktab ()//Imitate Keyboard keystroke tab
}
if (!str. IsEmpty ())
{This->sendstrtoclipboard (str);
This->performctrlv ();
This->performclicktab ();
}
}
There is no "-" in the else//serial number string, which is divided by pre-set lengths.
{
while (!str. IsEmpty ())
{
Strtemp=str. Left (This->m_spinctrl. GetPos ());
Str=str. Mid (This->m_spinctrl. GetPos ());
Sleep (100);
This->sendstrtoclipboard (strtemp);
This->performctrlv ();
This->performclicktab ();
}
}
Sleep (100);
This->sendstrtoclipboard (OLDSTR)//Restore the data on the original clipboard
return 1;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.