﻿
{"id":6069,"date":"2017-04-20T22:24:12","date_gmt":"2017-04-20T22:24:12","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=6069"},"modified":"2017-06-24T17:04:46","modified_gmt":"2017-06-24T17:04:46","slug":"c-win32-api-araciligiyla-mouse-olaylari-yaratmak","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/c-win32-api-araciligiyla-mouse-olaylari-yaratmak\/","title":{"rendered":"C# &#8211; Win32 API Arac\u0131l\u0131\u011f\u0131yla Mouse Olaylar\u0131 Yaratmak"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p>\u00d6nceki yaz\u0131lar\u0131mdan <a href=\"http:\/\/www.gencayyildiz.com\/blog\/c-ile-mousea-hukmedelim\/\" target=\"_blank\" rel=\"noopener noreferrer\">C# \u0130le Mouse\u2019a H\u00fckmedelim<\/a> ba\u015fl\u0131kl\u0131 yaz\u0131mda Win32 API kullanarak mouse&#8217;a programatik m\u00fcdahale ederek hareket ettirmeyi incelemi\u015ftik. \u015eimdi ise tekrardan Win32 API arac\u0131l\u0131\u011f\u0131yla programatik olarak mouse&#8217;a olaylar yaratt\u0131raca\u011f\u0131z. Tabi bu i\u015flemi yaparken yukar\u0131da verdi\u011fim adreste yapt\u0131\u011f\u0131m\u0131z gibi animasyon e\u015fli\u011finde icra etmeye \u00e7al\u0131\u015faca\u011f\u0131z.<\/p>\n<p>\u00d6ncelikle sizleri mouse eventlar\u0131 yarataca\u011f\u0131m\u0131z s\u0131n\u0131f\u0131m\u0131zla ta\u015f\u0131nt\u0131ray\u0131m.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    class MouseEventWin32\r\n    {\r\n        &#x5B;DllImport(&quot;user32.dll&quot;)]\r\n        static extern bool SetCursorPos(int x, int y);\r\n\r\n        &#x5B;DllImport(&quot;user32.dll&quot;)]\r\n        public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);\r\n\r\n        public const int MOUSEEVENTF_LEFTDOWN = 0x02;\r\n        public const int MOUSEEVENTF_LEFTUP = 0x04;\r\n        public const int MOUSEEVENTF_RIGHTDOWN = 0x08;\r\n        public const int MOUSEEVENTF_RIGHTUP = 0x10;\r\n    }\r\n<\/pre>\n<p>Yukar\u0131daki g\u00f6rd\u00fc\u011f\u00fcn\u00fcz \u00fczere &#8220;mouse_event&#8221; isimli extern fonksiyon arac\u0131l\u0131\u011f\u0131yla faremize olay yaratt\u0131rabilece\u011fiz. Bunun d\u0131\u015f\u0131nda &#8220;SetCursorPos&#8221; extern fonksiyonu \u00e7ok yabanc\u0131 olmad\u0131\u011f\u0131m\u0131z, bir \u00f6nceki makalede de kulland\u0131\u011f\u0131m\u0131z farenin programatik lokasyonunu ayarlayan bir fonksiyondur. Di\u011fer sabit de\u011fi\u015fkenlerimiz ise mouse tu\u015flar\u0131n\u0131n binary kar\u015f\u0131l\u0131klar\u0131n\u0131 tutmaktad\u0131rlar.<\/p>\n<p>Fareye programatik olay tan\u0131mlayabilmek i\u00e7in yukar\u0131daki s\u0131n\u0131f i\u00e7erisine a\u015fa\u011f\u0131daki gibi metotlar tan\u0131mlamam\u0131z ihtiyac\u0131m\u0131za d\u00f6n\u00fck olacakt\u0131r.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        public static void SolMouseClick(int xpos, int ypos)\r\n        {\r\n            SetCursorPos(xpos, ypos);\r\n            \/\/Sol T\u0131klad\u0131\r\n            mouse_event(MOUSEEVENTF_LEFTDOWN, xpos, ypos, 0, 0);\r\n            \/\/Sol B\u0131rakt\u0131\r\n            mouse_event(MOUSEEVENTF_LEFTUP, xpos, ypos, 0, 0);\r\n        }\r\n        public static void SolMouseBasiliClick(int xpos, int ypos)\r\n        {\r\n            SetCursorPos(xpos, ypos);\r\n            \/\/Sol T\u0131klad\u0131\r\n            mouse_event(MOUSEEVENTF_LEFTDOWN, xpos, ypos, 0, 0);\r\n        }\r\n        public static void SagMouseClick(int xpos, int ypos)\r\n        {\r\n            SetCursorPos(xpos, ypos);\r\n            \/\/Sa\u011f T\u0131klad\u0131\r\n            mouse_event(MOUSEEVENTF_RIGHTDOWN, xpos, ypos, 0, 0);\r\n            \/\/Sa\u011f B\u0131rakt\u0131\r\n            mouse_event(MOUSEEVENTF_RIGHTUP, xpos, ypos, 0, 0);\r\n        }\r\n        public static void SagMouseBasiliClick(int xpos, int ypos)\r\n        {\r\n            SetCursorPos(xpos, ypos);\r\n            \/\/Sa\u011f T\u0131klad\u0131\r\n            mouse_event(MOUSEEVENTF_RIGHTDOWN, xpos, ypos, 0, 0);\r\n        }\r\n<\/pre>\n<p>Bu metotlar\u0131 a\u015fa\u011f\u0131daki gibi kullan\u0131rsak programatik olarak gayemizi ger\u00e7ekle\u015ftirmi\u015f olaca\u011f\u0131z.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            MouseEventWin32.SolMouseClick(500, 300);\r\n            Thread.Sleep(1500);\r\n            MouseEventWin32.SagMouseBasiliClick(500, 700);\r\n            Thread.Sleep(1500);\r\n            MouseEventWin32.SolMouseBasiliClick(500, 200);\r\n            Thread.Sleep(1500);\r\n            MouseEventWin32.SagMouseClick(550, 250);\r\n<\/pre>\n<p>Tabi benim as\u0131l amac\u0131m olaylar\u0131 animasyonlu bir \u015fekilde yaratabilmek. Haliyle bunun \u00fczerine bir \u00e7al\u0131\u015fma ger\u00e7ekle\u015ftirmi\u015f bulunmaktay\u0131m. Yapm\u0131\u015f oldu\u011fum \u00e7al\u0131\u015fman\u0131n nitelik ve \u00f6zelliklerini h\u0131zl\u0131 bir \u015fekilde incelemek i\u00e7in g\u00f6rsel olarak a\u015fa\u011f\u0131daki videodan seyredebilirsin.<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/Y8zm7cr3xqc\" width=\"400\" height=\"250\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>Tabi teknik olarak incelemek i\u00e7inde projenin kaynak kodlar\u0131na a\u015fa\u011f\u0131dan eri\u015febilirsiniz.<br \/>\n<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/04\/C-Win32-API-Mouse-Events.rar\" target=\"_blank\" rel=\"noopener noreferrer\">C# Win32 API Mouse Events Projesini indirmek i\u00e7in buraya t\u0131klay\u0131n\u0131z.<\/a><\/p>\n<p>Sonraki yaz\u0131lar\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar&#8230;<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Merhaba, \u00d6nceki yaz\u0131lar\u0131mdan C# \u0130le Mouse\u2019a H\u00fckmedelim ba\u015fl\u0131kl\u0131 yaz\u0131mda Win32 API kullanarak mouse&#8217;a programatik m\u00fcdahale ederek hareket ettirmeyi incelemi\u015ftik. \u015eimdi ise tekrardan Win32 API arac\u0131l\u0131\u011f\u0131yla programatik olarak mouse&#8217;a olaylar yaratt\u0131raca\u011f\u0131z. Tabi bu i\u015flemi yaparken&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":3223,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,1856],"tags":[1721,1741,1690,1742],"class_list":["post-6069","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-sharp-c","category-win32","tag-c-win32-api","tag-c-win32-api-mouse","tag-win32-api","tag-win32-api-mouse-events"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/6069","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=6069"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/6069\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/3223"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=6069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=6069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=6069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}