Kev tswj hwm ntawm "nas" yog hom tsim nyog ntawm ib lub khoos phis tawm. Yog tsis muaj nws, nws tsis yooj yim sua kom xav txog kev tswj hwm lossis kev tshawb fawb los ntawm kev siv. Tus neeg saib xyuas zoo li no cuam tshuam nrog tus neeg siv los ntawm kev qhia nws cov kev ua (txav, nyem, scrolling) ntawm qhov screen. Rau qee qhov haujlwm ua haujlwm, software nas emulation yuav tsum muaj.
Nws yog qhov tsim nyog
Microsoft Visual C ++.net kev loj hlob ib puag ncig (tsis qis dua 2003)
Cov Lus Qhia
Kauj ruam 1
Nruab Microsoft Visual C ++. Net (2003 lossis tom qab). Muaj ntau ntau cov qauv ntawm txoj kev loj hlob no - them nyiaj thiab dawb. Lawv tuaj yeem rub tawm los ntawm tus tsim tawm lub vev xaib. Tom qab kev teeb tsa, tsim txoj haujlwm tshiab thiab txuas System. Windows. Forms thiab System. Drawing raws li qhia hauv qab no: siv System. Windows. Forms; siv System. Drawing;
Kauj ruam 2
Txhawm rau txav cov nas hla lub vijtsam hauv Windows operating systems, siv cov haujlwm ua haujlwm ncaj qha rau ntawm txoj haujlwm tus chij ntawm lub vijtsam. Siv, piv txwv li cov cai hauv qab no: Cursor. Position = tshiab Point (x, y); Cov kab no yuav txav tus cursor mus rau qhov chaw tau teev tseg hauv tus tsim ntawm chav kawm Point (x, y) (qhov x thiab y yog lub saib xyuas ntawm txoj hauj lwm uas tus cursor yuav tsum tau muab tso rau) … Yog tias koj xav muab tus txheej txheem ntawm tus cursor dua, tsim ib qho piv txwv ntawm chav kawm Point thiab siv tus qauv rau kev hloov pauv kev koom tes rau nws. Qhov no yuav txuag tau qhov kev nco: Tus lej taw tes = Cov Lus Tshiab (0, 0); Cursor. Position = point. Offset (20, 100); Cursor. Position = point. Offset (40, -20); Txoj cai no tsim cov khoom ntawm chav kawm Point () nrog cov tswj 0, 0. Kab ob txoj kab txav Cov Ncauj Lus yog 20 pixels nyob rau hauv X thiab 100 pixels nyob rau hauv Y. Qhov tam sim no kev sib koom tes taw qhia mus rau los ntawm kis khoom yog 20, 100. Kab peb dua tshwm sim Offset Taw tes los ntawm cov kev cai ntawm tus pixels (40 thiab -20, feem). Txoj haujlwm tam sim no yog 60 (20 + 40) hauv X thiab 80 (100-20) hauv Y.
Kauj ruam 3
Siv Win32 SendInput () lossis mouse_event () haujlwm los yoog nas. Piv txwv li, txhawm rau programmatically sim ib txoj cai nyem, siv cov cai hauv qab no: // ntshuam mouse_event (): [DllImport ("User32.dll")] zoo li qub khoob khoob khawm nas_event (MouseFlags dwFlags, int dx, int dy, int dwData, UIntPtr dwExtraInfo); // kom yooj yim siv, tsim ib qho kev suav nrog cov xaj tseem ceeb (chij) // uas txhais cov yeeb yam nas: [Chij] enum MouseFlags {Tsiv = 0x0001, LeftDown = 0x0002, LeftUp = 0x0004, RightDown = 0x0008, RightUp = 0x0010, Kev Tsis Raug = 0x8000}; // siv - nyem rau ntawm cov haujlwm uas tau teeb tsa hauv qab no: const int x = 39000; // ua haujlwm los ntawm Xconst rau cov menyuam y = 12000; // ua haujlwm ua ke los ntawm Ymouse_event (MouseFlags. Absolute | MouseFlags. Mov, x, y, 0, UIntPtr. Zero); mouse_event (MouseFlags. Absolute | MouseFlags. RightDown, x, y, 0, UIntPtr. Zero); mouse_event (MouseFlags. Absolute | MouseFlags. RightUp, x, y, 0, UIntPtr. Zero);
Kauj ruam 4
Caws tus nas nias los ntawm xa WM_LBUTTONDOWN thiab WM_LBUTTONUP cov lus uas siv Win API SendMessage () muaj nuj nqi. Piv txwv, raws li qhia hauv qab no: tsis muaj dab tsi OnBtPerformClick (tus xa khoom, EventArgs e) {xaMessage (btDemo. Handle, Messages. WM_LBUTTONDOWN, MK_LBUTTON, IntPtr. Zero);