{"id":1438,"date":"2016-01-09T16:58:56","date_gmt":"2016-01-09T15:58:56","guid":{"rendered":"http:\/\/netrix.org.pl\/?p=1438"},"modified":"2016-01-09T16:58:56","modified_gmt":"2016-01-09T15:58:56","slug":"nassist","status":"publish","type":"post","link":"https:\/\/netrix.org.pl\/index.php\/2016\/01\/09\/nassist\/","title":{"rendered":"NAssist"},"content":{"rendered":"<style>\nimg.post-image{\n   margin: 5px;\n   padding: 10px;\n}\np.wp-caption-text{\n  text-align: center;\n  font-size: x-small;\n}\na.post-link{\n  text-decoration: underline;\n}\na.post-link:hover{\n  text-decoration: underline;\n  font-weight: bold;\n}\n<\/style>\n<p>This time I would like to publish my application that I wrote some time ago and I&#8217;ve been actively using. I call it <strong>NAssist<\/strong>. Purpose of this application is to provide an on demand window (accessed with global keyboard shortcut) that allows to enter some commands whose effects would be displayed inside it.<div id=\"attachment_1442\" style=\"width: 212px\" class=\"wp-caption alignright\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1442\" src=\"http:\/\/netrix.org.pl\/wp-content\/2016\/01\/nassist_basic.png\" alt=\"Basic application window\" width=\"202\" height=\"74\" class=\"size-full wp-image-1442 post-image\" \/><p id=\"caption-attachment-1442\" class=\"wp-caption-text\">Basic application window<\/p><\/div><\/p>\n<p>Application is written in Python 3 with PyQt5 and PyWin (for Windows) or python-xlib (for Linux). PyQt is used as an application framework while PyWin or python-xlib are needed for handling global hotkeys.<\/p>\n<h4>Usage<\/h4>\n<p>Global hotkeys are used to call application which is normally hidden in the background with icon in Notification Area or Tray (both on Windows and Linux). Application window can be called with predefined global hotkeys &#8211; <em>CTRL + SHIFT + SPACE<\/em>. On the other hand the window can be hidden with <em>ESCAPE<\/em> hotkey while focused.<\/p>\n<p>Application in default mode appears only with one Command field which should be already focused by previously pressing mentioned hotkey combination (<em>CTRL + SHIFT + SPACE<\/em>). If it&#8217;s not, it can be made so by pressing them again. In this state application is ready to accept commands which are defined in <em>__init__<\/em> function in <em>mainwindow.py<\/em> file. Those commands come from <em>modules<\/em> package.<div id=\"attachment_1453\" style=\"width: 310px\" class=\"wp-caption alignright\"><a href=\"http:\/\/netrix.org.pl\/wp-content\/2016\/01\/ap_example.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1453\" src=\"http:\/\/netrix.org.pl\/wp-content\/2016\/01\/ap_example-300x248.png\" alt=\"Example of translation from English to Polish\" width=\"300\" height=\"248\" class=\"size-medium wp-image-1453 post-image\" srcset=\"https:\/\/netrix.org.pl\/wp-content\/2016\/01\/ap_example-300x248.png 300w, https:\/\/netrix.org.pl\/wp-content\/2016\/01\/ap_example-768x634.png 768w, https:\/\/netrix.org.pl\/wp-content\/2016\/01\/ap_example.png 824w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1453\" class=\"wp-caption-text\">Example of translation from English to Polish<\/p><\/div><\/p>\n<p>Basic commands that come with the application are:<\/p>\n<ul>\n<li><em>ap {text}<\/em> &#8211; English -> Polish translator (google translate),<\/li>\n<li><em>pa {text}<\/em> &#8211; Polish -> English translator (google translate),<\/li>\n<li><em>np {text}<\/em> &#8211; German -> Polish translator (google translate),<\/li>\n<li><em>pn {text}<\/em> &#8211; Polish -> German translator (google translate),<\/li>\n<li><em>sjp {word}<\/em> &#8211; Polish language dictionary (sjp.pl).<\/li>\n<\/ul>\n<p>To use one of those commands simply write them in Command field with arguments after space. The result of <em>&#8220;ap I translate to Polish&#8221;<\/em> is presented in the image on the right. As shown, the result appears right below the Command field, also the window is enlarged to make the result visible.<\/p>\n<p>To quickly delete everything from Command field there is an additional hotkey &#8211; <em>SHIFT + DELETE<\/em>.<\/p>\n<h4>Writing own modules<\/h4>\n<p>Writing own modules is pretty straightforward. It requires a module to handle following events which are defined in <em>BaseModule.py<\/em> file:<\/p>\n<ul>\n<li><em>onKeyPress(event)<\/em> &#8211; key has been pressed inside application window, event represents PyQt event,<\/li>\n<li><em>onTextUpdate(text)<\/em> &#8211; argument text has been updated for given module (from command &#8220;ap text&#8221; only &#8220;text&#8221; will be passed,<\/li>\n<li><em>onActivate()<\/em> &#8211; current module has been activated,<\/li>\n<li><em>onDeactivate()<\/em> &#8211; current module has been deactivated (new module will be activated if command was changed, not removed),<\/li>\n<li><em>onClose()<\/em> &#8211; application is closing. <\/li>\n<\/ul>\n<p>The basic commands are implemented using some more specialized base classes that are available for extension:<\/p>\n<ul>\n<li><em>TranslatorModule<\/em> &#8211; uses google translator to provide web page with results via <em>&#8220;https:\/\/translate.google.com\/#{}\/{}\/{}&#8221;<\/em> pattern,<\/li>\n<li><em>WebModule<\/em> &#8211; is used to implement above module, can be used to add other webpages as commands.<\/li>\n<\/ul>\n<h4>Download and requirements<\/h4>\n<p>Application is already public on <a href=\"https:\/\/github.com\/Netrix\/nassist\" target=\"_blank\" class=\"post-link\">GitHub<\/a> with GPL2 license. <\/p>\n<p>Requirements for Windows:<\/p>\n<ul>\n<li>Python 3.4 (<a href=\"https:\/\/www.python.org\/ftp\/python\/3.4.4\/python-3.4.4.msi\" target=\"_blank\" class=\"post-link\">x86<\/a>, <a href=\"https:\/\/www.python.org\/ftp\/python\/3.4.4\/python-3.4.4.amd64.msi\" target=\"_blank\" class=\"post-link\">x64<\/a>)<\/li>\n<li>PyQt5 for Python 3.4 (<a href=\"http:\/\/sourceforge.net\/projects\/pyqt\/files\/PyQt5\/PyQt-5.5.1\/PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x32.exe\" target=\"_blank\" class=\"post-link\">x86<\/a>, <a href=\"http:\/\/sourceforge.net\/projects\/pyqt\/files\/PyQt5\/PyQt-5.5.1\/PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x64.exe\" target=\"_blank\" class=\"post-link\">x64<\/a>)<\/li>\n<li>PyWin32 for Python 3.4 (<a href=\"http:\/\/sourceforge.net\/projects\/pywin32\/files\/pywin32\/Build%20219\/pywin32-219.win32-py3.4.exe\/download\" target=\"_blank\" class=\"post-link\">x86<\/a>, <a href=\"http:\/\/sourceforge.net\/projects\/pywin32\/files\/pywin32\/Build%20219\/pywin32-219.win-amd64-py3.4.exe\/download\" target=\"_blank\" class=\"post-link\">x64<\/a>)<\/li>\n<\/ul>\n<p>Requirements for Linux:<\/p>\n<ul>\n<li>Python 3<\/li>\n<li>PyQt5 matching Python version<\/li>\n<li>python3-xlib (pip install python3-xlib)<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This time I would like to publish my application that I wrote some time ago and I&#8217;ve been actively using. I call it NAssist. Purpose of this application is to provide an on demand window (accessed with global keyboard shortcut) that allows to enter some commands whose effects would be displayed inside it. Application is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[200,204,181,199,202,201,203,11,116],"_links":{"self":[{"href":"https:\/\/netrix.org.pl\/index.php\/wp-json\/wp\/v2\/posts\/1438"}],"collection":[{"href":"https:\/\/netrix.org.pl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netrix.org.pl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netrix.org.pl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/netrix.org.pl\/index.php\/wp-json\/wp\/v2\/comments?post=1438"}],"version-history":[{"count":60,"href":"https:\/\/netrix.org.pl\/index.php\/wp-json\/wp\/v2\/posts\/1438\/revisions"}],"predecessor-version":[{"id":1500,"href":"https:\/\/netrix.org.pl\/index.php\/wp-json\/wp\/v2\/posts\/1438\/revisions\/1500"}],"wp:attachment":[{"href":"https:\/\/netrix.org.pl\/index.php\/wp-json\/wp\/v2\/media?parent=1438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netrix.org.pl\/index.php\/wp-json\/wp\/v2\/categories?post=1438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netrix.org.pl\/index.php\/wp-json\/wp\/v2\/tags?post=1438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}