{"id":7675,"date":"2023-04-14T11:04:11","date_gmt":"2023-04-14T10:04:11","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=7675"},"modified":"2023-05-12T10:00:21","modified_gmt":"2023-05-12T09:00:21","slug":"simulate-barcode","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/simulate-barcode\/","title":{"rendered":"Simulate barcode"},"content":{"rendered":"\n<p><a href=\"https:\/\/github.com\/mroach\/barcode-simulator\">https:\/\/github.com\/mroach\/barcode-simulator<\/a><\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"csharp\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">using System;\nusing System.ComponentModel;\nusing System.Diagnostics;\nusing System.Linq;\nusing System.Threading;\nusing System.Windows.Forms;\n\n\/\/ System.Windows.Forms.SendKeys\n\n\/\/ do the delayed key sending in a separate thread so we don't hang the window\nThreadStart starter = () => StartSending(s, 10, endKey);\nvar t = new Thread(starter) { Name = \"Sending keys \" + s };\nt.Start();\n\n\nprivate static void StartSending(string text, int delay, Keys endKey = Keys.None)\n{\n\tforeach (var s in text.Select(character => character.ToString()))\n\t{\n\t\tDebug.WriteLine(\"{0} Sending text '{1}'\", DateTime.Now.ToString(\"HH:mm:ss.fff\"), s);\n\t\tSendKeys.SendWait(s);\n\t\tSendKeys.Flush();\n\t\tThread.Sleep(delay);\n\t}\n\n\t\/\/ if configured, send an 'end' key to signal that we're at the end of the barcode\n\tif (endKey != Keys.None)\n\t\tSendKeys.SendWait(\"{\" + Enum.GetName(typeof (Keys), endKey) + \"}\");\n\n\t\/\/ beep!\n\tSystem.Media.SystemSounds.Beep.Play();\n}<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/github.com\/mroach\/barcode-simulator<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7675","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7675","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=7675"}],"version-history":[{"count":2,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7675\/revisions"}],"predecessor-version":[{"id":7677,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7675\/revisions\/7677"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=7675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=7675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=7675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}