码迷,mamicode.com
首页 > 其他好文 > 详细

AutoIt Putty Commander

时间:2016-07-18 02:52:15      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:

#include "GUIConstants.au3"
#include <WindowsConstants.au3>
#include <GuiListBox.au3>

;~ Global Const $WM_COMMAND = 0x0111
;~ Global Const $LBN_SELCHANGE = 1
;~ Global Const $LBN_DBLCLK = 2
$CONFIG_FILE = @ScriptDir & "\Putty Commander.cfg"

GUICreate("Putty Commander", 300, 500, -1, -1, 0x00040000)
$cmdList = GUICtrlCreateList("" , 10, 10, 280, 440, BitOR($WS_BORDER, $WS_VSCROLL, $GUI_FOCUS))
GUICtrlSetTip($cmdList, "Double click command to send to Putty" & @CRLF & "Double click the bottom info to edit command list")
If FileExists($CONFIG_FILE) Then
   $cmdFile = FileRead($CONFIG_FILE)
   $cmdArray = StringSplit($cmdFile, @CRLF, 1)
   For $i = 1 To UBound($cmdArray) - 1
	  _GUICtrlListBox_AddString($cmdList, $cmdArray[$i])
   Next
EndIf
$info = GUICtrlCreateLabel("* Copyright (C) SEG, 2016", 10, 450, 280, -1)
$cmdEdit = GUICtrlCreateEdit("", 10, 10, 280, 440)
GUICtrlSetState($cmdEdit, $GUI_HIDE)

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GuiSetState()
While 1
   $msg = GUIGetMsg()
   Select
	  Case $msg = $GUI_EVENT_CLOSE
		 ExitLoop 

	  Case $msg = $cmdList
		 $Selected = GUICtrlRead($cmdList)
		 GUICtrlSetData($info, "* Double click me to edit commands")
   EndSelect
Wend

Exit

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
   $nNotifyCode = BitShift($wParam, 16)
   $nID = BitAnd($wParam, 0x0000FFFF)
   $hCtrl = $lParam

   If $nID = $cmdList And ($nNotifyCode = $LBN_DBLCLK  Or $nNotifyCode = 0x00) Then
	  $Selected = GUICtrlRead($cmdList)
	  ConsoleWrite($Selected)
	  ControlSend("[CLASS:PuTTY]", "", "", $Selected & "{ENTER}")
	  Return 0
   EndIf
   
   If $nID = $info And $nNotifyCode = 0x01 Then
	  If GUICtrlRead($info) = "* Double click me to save" Then
		 ; save to config file
		 $cmdNew = GUICtrlRead($cmdEdit)
		 FileDelete($CONFIG_FILE)
		 FileWrite($CONFIG_FILE, $cmdNew)
		 ; update list box
		 GUICtrlSetData($cmdList, "")
		 $cmdArray = StringSplit($cmdNew, @CRLF, 1)
		 For $i = 1 To UBound($cmdArray) - 1
			_GUICtrlListBox_AddString($cmdList, $cmdArray[$i])
		 Next
		 ; update states of all controls
		 GUICtrlSetState($cmdEdit, $GUI_HIDE)
		 GUICtrlSetState($cmdList, $GUI_SHOW)
		 GUICtrlSetData($info, "* Double click me to edit commands")
	  Else
		 $cmdFile = FileRead($CONFIG_FILE)
		 GuiCtrlSetData($cmdEdit, $cmdFile)
		 GUICtrlSetState($cmdList, $GUI_HIDE)
		 GUICtrlSetState($cmdEdit, $GUI_SHOW)
		 GUICtrlSetData($info, "* Double click me to save")
	  EndIf
		 
	  Return 0
   EndIf
EndFunc

 

AutoIt Putty Commander

标签:

原文地址:http://www.cnblogs.com/cursorkey/p/5679846.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!