{"id":141,"date":"2010-01-31T14:24:20","date_gmt":"2010-01-31T13:24:20","guid":{"rendered":"http:\/\/blog.rabihtawil.com\/?p=141"},"modified":"2010-01-31T14:24:20","modified_gmt":"2010-01-31T13:24:20","slug":"getasynckeystate-api-definition","status":"publish","type":"post","link":"http:\/\/www.raytawil.com\/?p=141","title":{"rendered":"GetAsyncKeyState API Definition"},"content":{"rendered":"<p>I was wondering about a way to get the keyboard strokes &amp; read them. This windows api can be used from all sorts of keylogger hacking tricks to useful shortcut keys in an OS that you would like to define. here is a small code snippet with explanation:<\/p>\n<p>This snippet shows the user how to get the key pressed. That is if the user presses control key that key is identified. Using this we can develop applications with greater flexibility. For example we can make an application to close if a key is pressed and so on.<\/p>\n<p>This code is basically a smaller one with greater potential. It just contains three lines of code.<\/p>\n<div id=\"wpshdo_1\" class=\"wp-synhighlighter-outer\"><div id=\"wpshdt_1\" class=\"wp-synhighlighter-expanded\"><table border=\"0\" width=\"100%\"><tr><td align=\"left\" width=\"80%\"><a name=\"#codesyntax_1\"><\/a><a id=\"wpshat_1\" class=\"wp-synhighlighter-title\" href=\"#codesyntax_1\"  onClick=\"javascript:wpsh_toggleBlock(1)\" title=\"Click to show\/hide code block\">Source code<\/a><\/td><td align=\"right\"><a href=\"#codesyntax_1\" onClick=\"javascript:wpsh_code(1)\" title=\"Show code only\"><img border=\"0\" style=\"border: 0 none\" src=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/code.png\" \/><\/a>&nbsp;<a href=\"#codesyntax_1\" onClick=\"javascript:wpsh_print(1)\" title=\"Print code\"><img border=\"0\" style=\"border: 0 none\" src=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/printer.png\" \/><\/a>&nbsp;<a href=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/About.html\" target=\"_blank\" title=\"Show plugin information\"><img border=\"0\" style=\"border: 0 none\" src=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/info.gif\" \/><\/a>&nbsp;<\/td><\/tr><\/table><\/div><div id=\"wpshdi_1\" class=\"wp-synhighlighter-inner\" style=\"display: block;\"><pre class=\"vbnet\" style=\"font-family:monospace;\"><span class=\"kw2\">Public<\/span> <span class=\"kw6\">Declare<\/span> <span class=\"kw6\">Function<\/span> GetAsyncKeyState Lib <span class=\"st0\">&quot;user32&quot;<\/span> <span class=\"br0\">&#40;<\/span><span class=\"kw2\">ByVal<\/span> vKey <span class=\"kw2\">As<\/span> <span class=\"kw4\">Long<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw2\">As<\/span> <span class=\"kw4\">Integer<\/span><\/pre><\/div><\/div>\n<div id=\"wpshdo_2\" class=\"wp-synhighlighter-outer\"><div id=\"wpshdt_2\" class=\"wp-synhighlighter-expanded\"><table border=\"0\" width=\"100%\"><tr><td align=\"left\" width=\"80%\"><a name=\"#codesyntax_2\"><\/a><a id=\"wpshat_2\" class=\"wp-synhighlighter-title\" href=\"#codesyntax_2\"  onClick=\"javascript:wpsh_toggleBlock(2)\" title=\"Click to show\/hide code block\">Source code<\/a><\/td><td align=\"right\"><a href=\"#codesyntax_2\" onClick=\"javascript:wpsh_code(2)\" title=\"Show code only\"><img border=\"0\" style=\"border: 0 none\" src=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/code.png\" \/><\/a>&nbsp;<a href=\"#codesyntax_2\" onClick=\"javascript:wpsh_print(2)\" title=\"Print code\"><img border=\"0\" style=\"border: 0 none\" src=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/printer.png\" \/><\/a>&nbsp;<a href=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/About.html\" target=\"_blank\" title=\"Show plugin information\"><img border=\"0\" style=\"border: 0 none\" src=\"http:\/\/www.raytawil.com\/wp-content\/plugins\/wp-synhighlight\/themes\/default\/images\/info.gif\" \/><\/a>&nbsp;<\/td><\/tr><\/table><\/div><div id=\"wpshdi_2\" class=\"wp-synhighlighter-inner\" style=\"display: block;\"><pre class=\"vbnet\" style=\"font-family:monospace;\"><span class=\"kw2\">On<\/span> <span class=\"kw2\">Error<\/span> <span class=\"kw2\">Resume<\/span> <span class=\"kw2\">Next<\/span>\n <span class=\"co1\">'To check wheteher Control key is pressed<\/span>\n <span class=\"kw6\">If<\/span> GetAsyncKeyState<span class=\"br0\">&#40;<\/span>17<span class=\"br0\">&#41;<\/span> <span class=\"kw2\">Then<\/span>\n <span class=\"kw7\">msgbox<\/span> <span class=\"st0\">&quot;Control key pressed&quot;<\/span>\n <span class=\"kw6\">End<\/span> <span class=\"kw6\">If<\/span><\/pre><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>I was wondering about a way to get the keyboard strokes &amp; read them. This windows api can be used from all sorts of keylogger hacking tricks to useful shortcut keys in an OS that you would like to define. here is a small code snippet with explanation: This snippet shows the user how to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[110],"tags":[],"_links":{"self":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/141"}],"collection":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=141"}],"version-history":[{"count":0,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/141\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}