{"id":2294,"date":"2010-10-25T01:43:33","date_gmt":"2010-10-25T07:43:33","guid":{"rendered":"http:\/\/gregsowell.com\/?p=2294"},"modified":"2010-10-23T07:07:40","modified_gmt":"2010-10-23T13:07:40","slug":"launch-menu-for-the-dude","status":"publish","type":"post","link":"https:\/\/gregsowell.com\/?p=2294","title":{"rendered":"Launch Menu For The Dude"},"content":{"rendered":"<p>As a consultant I use the dude a lot.  I connect to a myriad of dude servers on a regular basis, which can be somewhat cumbersome.  Why is this cumbersome&#8230;because you don&#8217;t have the ability to save multiple sets of connection information in the dude.  Sooooo, I wrote a little menu system so you can enter as many dude systems as you want, each with their own sets of credentials and IP information.  All you have to do is choose the server from the list you want to connect to and click launch \ud83d\ude42<\/p>\n<p>Binary is here: <div class=\"wp-block-button\">\n<a  data-e-Disable-Page-Transition=\"true\" class=\"dlm-download-link dlm-download-default wp-block-button__link wp-element-button\" title=\"\" href=\"https:\/\/gregsowell.com?download=5701&amp;tmstv=1784644507\" rel=\"nofollow\" id=\"download-link-5701\" data-redirect=\"false\" >\n\tDude-Menu\t(1945 downloads\t)\n<\/a>\n<\/div>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"\/images\/dude-menu.PNG\" title=\"dude-menu\" class=\"alignnone\" width=\"331\" height=\"473\" \/><\/p>\n<p>Here&#8217;s the code for all of my basement dwelling friends:<\/p>\n<pre class=\"gs-code\"><code class=\"language-plaintext\">#include &lt;Array.au3&gt;\r\n#include &lt;file.au3&gt;\r\n\r\n;check for config file&#039;s existance\r\nif not FileExists(@ScriptDir &amp; &quot;\\config.txt&quot;) then\r\n\t;file isn&#039;t here, generate it\r\n\t$fConfig = FileOpen(@ScriptDir &amp; &quot;\\config.txt&quot;, 1)\r\n\r\n\t; Check if file opened for writing OK\r\n\tIf $fConfig = -1 Then\r\n\t\tMsgBox(0, &quot;Error&quot;, &quot;Unable to open file.&quot;)\r\n\t\tExit\r\n\tEndIf\r\n\r\n\tFileWriteLine($fConfig, &quot;C:\\Program Files\\Dude\\dude.exe&quot; &amp; @CRLF)\r\n\tFileWriteLine($fConfig, &quot;delete me,username,password,Secure,1.1.1.1,2211&quot;)\r\n\r\n\tFileClose($fConfig)\r\nEndIf\r\n\r\nDim $aConfig\r\nIf Not _FileReadToArray(@ScriptDir &amp; &quot;\\config.txt&quot;,$aConfig) Then\r\n   MsgBox(4096,&quot;Error&quot;, &quot; Error reading log to Array     error:&quot; &amp; @error)\r\n   Exit\r\nEndIf\r\n\r\n\r\n;#############################\r\n\r\n#include &lt;ButtonConstants.au3&gt;\r\n#include &lt;ComboConstants.au3&gt;\r\n#include &lt;EditConstants.au3&gt;\r\n#include &lt;GUIConstantsEx.au3&gt;\r\n#include &lt;GUIListBox.au3&gt;\r\n#include &lt;StaticConstants.au3&gt;\r\n#include &lt;WindowsConstants.au3&gt;\r\n#Region ### START Koda GUI section ### Form=C:\\Documents and Settings\\greg\\Desktop\\autoit\\dude menu\\dudemenu.kxf\r\n$Form1_1 = GUICreate(&quot;Dude Menu - GregSowell.com MikrotikUniversity.com&quot;, 325, 448, 192, 114)\r\n$InDesc = GUICtrlCreateInput(&quot;&quot;, 72, 232, 225, 21)\r\n$InUser = GUICtrlCreateInput(&quot;&quot;, 72, 277, 225, 21)\r\n$InPassword = GUICtrlCreateInput(&quot;&quot;, 72, 301, 225, 21)\r\n$Combo1 = GUICtrlCreateCombo(&quot;Secure&quot;, 72, 328, 225, 25)\r\nGUICtrlSetData(-1, &quot;Remote&quot;)\r\n$InIP = GUICtrlCreateInput(&quot;&quot;, 72, 358, 225, 21)\r\n$InPort = GUICtrlCreateInput(&quot;&quot;, 72, 389, 225, 21)\r\n$List1 = GUICtrlCreateList(&quot;&quot;, 16, 8, 289, 201)\r\n$Label1 = GUICtrlCreateLabel(&quot;Description&quot;, 8, 232, 57, 17)\r\n$Label2 = GUICtrlCreateLabel(&quot;Username&quot;, 8, 271, 52, 17)\r\n$Label3 = GUICtrlCreateLabel(&quot;Password&quot;, 8, 298, 50, 17)\r\n$Label4 = GUICtrlCreateLabel(&quot;Type&quot;, 8, 327, 28, 17)\r\n$Label5 = GUICtrlCreateLabel(&quot;IP Address&quot;, 8, 359, 55, 17)\r\n$Label6 = GUICtrlCreateLabel(&quot;Port&quot;, 8, 388, 23, 17)\r\n$BtnLaunch = GUICtrlCreateButton(&quot;Launch&quot;, 48, 416, 65, 25, $WS_GROUP)\r\n$BtnAdd = GUICtrlCreateButton(&quot;Add\/Edit&quot;, 130, 416, 65, 25, $WS_GROUP)\r\n$BtnDelete = GUICtrlCreateButton(&quot;Delete&quot;, 211, 416, 65, 25, $WS_GROUP)\r\nGUISetState(@SW_SHOW)\r\n#EndRegion ### END Koda GUI section ###\r\n\r\n;fill in the listbox\r\n_LoadConfig()\r\n$ListLocation = 1\r\n\r\nWhile 1\r\n\t$nMsg = GUIGetMsg()\r\n\tSwitch $nMsg\r\n\tCase $GUI_EVENT_CLOSE\r\n\t\tExit\r\n\r\n\tcase $GUI_EVENT_PRIMARYUP\r\n\t\t;mouse was pressed, lets check to see if they choose a new item in list\r\n\t\t;check which list item is highlighted\r\n\t\t$tempList = GUICtrlRead($List1)\r\n\t\t;see if this is new item chosen or just a click somewhere on the prog\r\n\t\tif $tempList &lt;&gt; $ListLocation and $tempList &lt;&gt; &quot;&quot; Then\r\n\t\t\t;change, update everything\r\n\t\t\t;set list location to the temp value\r\n\t\t\t$ListLocation = $tempList\r\n\t\t\t;set all our gui values\r\n\r\n\t\t\tGUICtrlSetData($InDesc,stringleft($ListLocation,StringInStr($ListLocation,&quot;,&quot;) - 1))\r\n\t\t\tGUICtrlSetData($InUser, StringMid($ListLocation, StringInStr($ListLocation,&quot;,&quot;) + 1, StringInStr($ListLocation,&quot;,&quot;, 0, 2) - StringInStr($ListLocation,&quot;,&quot;) - 1))\r\n\t\t\tGUICtrlSetData($InPassword, StringMid($ListLocation, StringInStr($ListLocation,&quot;,&quot;, 0, 2) + 1, StringInStr($ListLocation,&quot;,&quot;, 0, 3) - StringInStr($ListLocation,&quot;,&quot;, 0, 2) - 1))\r\n\t\t\tGUICtrlSetData($Combo1, StringMid($ListLocation, StringInStr($ListLocation,&quot;,&quot;, 0, 3) + 1, StringInStr($ListLocation,&quot;,&quot;, 0, 4) - StringInStr($ListLocation,&quot;,&quot;, 0, 3) - 1))\r\n\t\t\tGUICtrlSetData($InIP, StringMid($ListLocation, StringInStr($ListLocation,&quot;,&quot;, 0, 4) + 1, StringInStr($ListLocation,&quot;,&quot;, 0, 5) - StringInStr($ListLocation,&quot;,&quot;, 0, 4) - 1))\r\n\t\t\tGUICtrlSetData($InPort, StringMid($ListLocation, StringInStr($ListLocation,&quot;,&quot;, 0, 5) + 1))\r\n\t\tEndIf\r\n\r\n\t\tCase $BtnAdd\r\n\t\t\t;update existing or commit the new one\r\n\t\t\t\t;lets rock it\r\n\t\t\t\t$new = 1\r\n\t\t\t\t;where in the loop are we\r\n\t\t\t\t$updateNum = 0\r\n\t\t\t\t;check to see if it exists\r\n\t\t\t\tfor $y = 2 to $aConfig[0]\r\n\t\t\t\t\t;check if the IP exists\r\n\t\t\t\t\tif StringInStr($aConfig[$y], GUICtrlRead($InIP)) &gt; 0 Then\r\n\t\t\t\t\t\t;we have a match\r\n\t\t\t\t\t\t$new = 0\r\n\t\t\t\t\t\t$updateNum = $y\r\n\t\t\t\t\tEndIf\r\n\t\t\t\tNext\r\n\t\t\t\t;ready to rock, save it\r\n\t\t\t\tif $new = 1 Then\r\n\t\t\t\t\t;new one\r\n\t\t\t\t\t;add to end of the array\r\n\t\t\t\t\t_ArrayAdd($aConfig, GUICtrlRead($InDesc) &amp; &quot;,&quot; &amp; GUICtrlRead($InUser) &amp; &quot;,&quot; &amp; GUICtrlRead($InPassword) &amp; &quot;,&quot; &amp; GUICtrlRead($Combo1) &amp; &quot;,&quot; &amp; GUICtrlRead($InIP) &amp; &quot;,&quot; &amp; GUICtrlRead($InPort))\r\n\t\t\t\t\t;sort our array\r\n\t\t\t\t\t_ArraySort($aConfig,0,2)\r\n\t\t\t\t\t;write the file\r\n\t\t\t\t\t_FileWriteFromArray(@ScriptDir &amp; &quot;\\config.txt&quot;,$aConfig,1)\r\n\t\t\t\t\t;run plink to accept cert\r\n\t\t\t\t\t;Run(@ComSpec &amp; &quot; \/c &quot; &amp; FileGetShortName(@ScriptDir) &amp; &#039;\\plink.exe -ssh &#039; &amp; GUICtrlRead($IPAddress1))\r\n\t\t\t\t\t;load the list again\r\n\t\t\t\t\t_LoadConfig()\r\n\t\t\t\tElse\r\n\t\t\t\t\t;update\r\n\t\t\t\t\t;set existing value\r\n\t\t\t\t\t$aConfig[$updateNum] = GUICtrlRead($InDesc) &amp; &quot;,&quot; &amp; GUICtrlRead($InUser) &amp; &quot;,&quot; &amp; GUICtrlRead($InPassword) &amp; &quot;,&quot; &amp; GUICtrlRead($Combo1) &amp; &quot;,&quot; &amp; GUICtrlRead($InIP) &amp; &quot;,&quot; &amp; GUICtrlRead($InPort)\r\n\t\t\t\t\t;sort array\r\n\t\t\t\t\t_ArraySort($aConfig,0,2)\r\n\t\t\t\t\t;write the array to file\r\n\t\t\t\t\t_FileWriteFromArray(@ScriptDir &amp; &quot;\\config.txt&quot;,$aConfig,1)\r\n\t\t\t\t\t;reload list\r\n\t\t\t\t\t_LoadConfig()\r\n\t\t\t\tEndIf\r\n\r\n\t\tCase $BtnDelete\r\n\t\t\t;delete an existing entry\r\n\t\t\t$sure = MsgBox(4, &quot;Delete Record?&quot;, &quot;Are you sure you want to delete &quot; &amp; GUICtrlRead($InDesc) &amp; &quot;?&quot;)\r\n\t\t\tif $sure == 6 Then\r\n\t\t\t\t;delete it\r\n\t\t\t\t$updateNum = 0\r\n\t\t\t\t;find the array #\r\n\t\t\t\tfor $y = 1 to $aConfig[0]\r\n\t\t\t\t\t;check if the IP exists\r\n\t\t\t\t\tif StringInStr($aConfig[$y], GUICtrlRead($InIP)) &gt; 0 Then\r\n\t\t\t\t\t\t;we have a match\r\n\t\t\t\t\t\t$updateNum = $y\r\n\t\t\t\t\tEndIf\r\n\t\t\t\tNext\r\n\t\t\t\t;delete the entry\r\n\t\t\t\t_ArrayDelete($aConfig,$updateNum)\r\n\t\t\t\t;write it to file\r\n\t\t\t\t_FileWriteFromArray(@ScriptDir &amp; &quot;\\config.txt&quot;,$aConfig,1)\r\n\t\t\t\t;reload list\r\n\t\t\t\t_LoadConfig()\r\n\t\t\tEndIf\r\n\r\n\t\tCase $BtnLaunch\r\n\t\t\t;launch it\r\n\t\t\trun($aConfig[1])\r\n\t\t\t;wait for the dude to start\r\n\t\t\t$pie = 1\r\n\t\t\t;loop while waiting for dude to start\r\n\t\t\twhile 1 == $pie\r\n\t\t\t\tIf ProcessExists(&quot;dude.exe&quot;) Then\r\n\t\t\t\t\t$pie = 2\r\n\t\t\t\tEndIf\r\n\t\t\t\tsleep(1000)\r\n\t\t\tWEnd\r\n\t\t\t;activate the connect screen\r\n\t\t\t$pie = 1\r\n\t\t\t;loop while waiting for dude to start\r\n\t\t\twhile 1 == $pie\r\n\t\t\t\tWinActivate(&quot;Connect&quot;)\r\n\t\t\t\tif winactive(&quot;Connect&quot;) Then\r\n\t\t\t\t\t$pie = 2\r\n\t\t\t\tEndIf\r\n\t\t\t\tsleep(200)\r\n\t\t\tWEnd\r\n\t\t\t;fill in the blanks and hit enter\r\n\t\t\tSend(&quot;{TAB}&quot;)\r\n\t\t\tSleep(200)\r\n\t\t\tSend(&quot;{TAB}&quot;)\r\n\t\t\tSleep(200)\r\n\t\t\tif guictrlread($Combo1) == &quot;Secure&quot; Then\r\n\t\t\t\tSend(&quot;s&quot;)\r\n\t\t\tElse\r\n\t\t\t\tSend(&quot;r&quot;)\r\n\t\t\tEndIf\r\n\t\t\tSleep(200)\r\n\t\t\tSend(&quot;{TAB}&quot;)\r\n\t\t\tSleep(200)\r\n\t\t\tSend(guictrlread($InUser))\r\n\t\t\tSleep(200)\r\n\t\t\tSend(&quot;{TAB}&quot;)\r\n\t\t\tSleep(200)\r\n\t\t\tSend(guictrlread($InPassword))\r\n\t\t\tSleep(200)\r\n\t\t\tSend(&quot;{TAB}&quot;)\r\n\t\t\tSleep(200)\r\n\t\t\tSend(&quot;{TAB}&quot;)\r\n\t\t\tSleep(200)\r\n\t\t\tSend(&quot;{TAB}&quot;)\r\n\t\t\tSleep(200)\r\n\t\t\tSend(guictrlread($InIP))\r\n\t\t\tSleep(200)\r\n\t\t\tSend(&quot;{TAB}&quot;)\r\n\t\t\tSleep(200)\r\n\t\t\tSend(guictrlread($InPort))\r\n\t\t\tSleep(200)\r\n\t\t\tSend(&quot;{TAB}&quot;)\r\n\t\t\tSleep(200)\r\n\t\t\tSend(&quot;{ENTER}&quot;)\r\n\t\t\t;Exit\r\n\t\t\tGUISetState(@SW_MINIMIZE)\r\n\r\nEndSwitch\r\nWEnd\r\n\r\nFunc _LoadConfig()\r\n\r\ngUICtrlSetData($List1, &quot;&quot;)\r\n\r\nDim $aConfig\r\nIf Not _FileReadToArray(@ScriptDir &amp; &quot;\\config.txt&quot;,$aConfig) Then\r\n   MsgBox(4096,&quot;Error&quot;, &quot; Error reading log to Array     error:&quot; &amp; @error)\r\n   Exit\r\nEndIf\r\n\r\nFor $x = 2 to $aConfig[0]\r\n    guictrlsetdata($List1,$aConfig[$x])\r\nNext\r\n\r\nEndFunc<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>As a consultant I use the dude a lot. I connect to a myriad of dude servers on a regular basis, which can be\u2026<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37,6,7,35],"tags":[],"class_list":["post-2294","post","type-post","status-publish","format-standard","hentry","category-autoit","category-dude","category-mikrotik","category-programmingscripting","category-script"],"_links":{"self":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/2294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2294"}],"version-history":[{"count":4,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/2294\/revisions"}],"predecessor-version":[{"id":2299,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/2294\/revisions\/2299"}],"wp:attachment":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}