• Support
  • Articles
  • Resources
  • Products

Autoit toolbar for Tera Term

Moderator: boris

4 postsPage 1 of 1

necod
Newbie

Posts:
7
Joined: Wed Apr 15, 2009 11:08 am
by necod » Wed May 06, 2009 6:22 am
I have modified the toolbar code from this page
http://www.autoitscript.com/forum/index ... opic=41099

I'm not a windows programmer, but it works.

This script capture NUMLOCK key and keep active numeric keypad when Tera Term window is active.

Code: Select all

  1. #########################################
  2.  
  3. #include <GUIConstantsEX.au3>
  4. #include <windowsconstants.au3>
  5. #include <buttonconstants.au3>
  6. #include <StaticConstants.au3>
  7. #include <Array.au3>
  8. #Include <Misc.au3>
  9.  
  10. Opt("WinTitleMatchMode", 2)     ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
  11. ;Opt("MustDeclareVars", 1)
  12. Opt("TrayIconHide", 1)
  13.  
  14. ; $h_ToolBar = XSkinToolBarCreate($Xh_Gui, $tool_left, $tool_top, $tool_width, $tool_bkcolor = "")
  15. ; XSkinToolBarButton($iNumber, $iDLL = "shell32.dll")
  16. ; XSkinToolBarSeparator()
  17.  
  18. ; #1 - Using Icons from a dll ( shell32.dll is default)
  19. ; XSkinToolBarButton(155)  
  20. ; #2 - Using Icons from an exe file
  21. ; XSkinToolBarButton(22)
  22. ; XSkinToolBarButton("", @ProgramFilesDir & "\Internet Explorer\iexplore.exe")
  23. ; XSkinToolBarButton( "", @WindowsDir & "\explorer.exe")
  24. ; XSkinToolBarButton( "", @SystemDir & "\calc.exe")
  25. ; #3 - Using Icons from an ico file
  26. ;XSkinToolBarButton("", @ScriptDir & "\Skins\Default-ToolBar\Admin Tools.ico")
  27. ;XSkinToolBarButton("", @ScriptDir & "\Skins\Default-ToolBar\Control Panel.ico")
  28. ;XSkinToolBarButton("", @ScriptDir & "\Skins\Default-ToolBar\E-Mail.ico")
  29.  
  30. Global Const $VK_NUMLOCK = 0x90
  31. Global $TBcnt = -1
  32.  
  33. ; Main
  34.  
  35. ; HotKeySet("{ESC}", "_Quit")   ; para pruebas salir con ESC
  36. $vDLL = DllOpen('user32.dll')
  37.  
  38. $h_ToolBar = XSkinToolBarCreate("TeraTerm-ToolBar", 200, 200, 305)
  39.  
  40. $TButton1 = XSkinToolBarButton("", @ProgramFilesDir & "\Sigca2\Pcsigca.exe")
  41. GUICtrlSetTip( -1, "Busca en SIGCA2 la referencia catastral marcada con el ratón (Cltr+F1)")
  42. $TButton2 = XSkinToolBarButton("", @ProgramFilesDir & "\Sauce\Sauce.exe")
  43. GUICtrlSetTip( -1, "Busca en SAUCE la referencia catastral o expediente marcado con el ratón (Cltr+F2)")
  44. $TButton3 = XSkinToolBarButton("", @ProgramFilesDir & "\teraterm\ttermpro.exe")
  45. GUICtrlSetTip( -1, "Busca en SIGECA la referencia catastral contenida en el portapapeles (Cltr+F3)")
  46. XSkinToolBarSeparator()
  47. $TButton5 = XSkinToolBarButton(155)     ; macro cambio tamaño
  48. GUICtrlSetTip( -1, "Cambia tamaño de letra (Cltr+F5)")
  49. $TButton6 = XSkinToolBarButton(270)     ; macro cambio color
  50. GUICtrlSetTip( -1, "Cambia combinación de colores (Cltr+F6)")
  51. $TButton7 = XSkinToolBarButton(269)     ; macro cambio perfil teclado
  52. GUICtrlSetTip( -1, "Cambia perfil de teclado (Cltr+F7)")
  53. $TButton8 = XSkinToolBarButton(243)     ; pegar
  54. GUICtrlSetTip( -1, "Pega contenido del portapapeles (Cltr+F8)")
  55. XSkinToolBarSeparator()
  56. $TButton9 = XSkinToolBarButton(512)     ; explorer
  57. GUICtrlSetTip( -1, "Internet Explorer")
  58. $TButton10 = XSkinToolBarButton("", @ProgramFilesDir & "\Microsoft Office\OFFICE11\winword.exe")
  59. GUICtrlSetTip( -1, "Microsoft Word")
  60. $TButton11 = XSkinToolBarButton("", @ProgramFilesDir & "\Microsoft Office\OFFICE11\excel.exe")
  61. GUICtrlSetTip( -1, "Microsoft Excel")
  62. XSkinToolBarSeparator()
  63. $TButton12 = XSkinToolBarButton(25)     ; winscp
  64. GUICtrlSetTip( -1, "Abre herramienta de transferencia de ficheros")
  65. ;$TButtonLast = XSkinToolBarButton(27) ; exit
  66.  
  67. ; Creamos objeto barra de herramientas y la ocultamos
  68. GUISetState(@SW_HIDE, $h_ToolBar)
  69. WinSetOnTop($h_ToolBar, "", 1)
  70. $hide = 1
  71.  
  72. While 1
  73.  
  74.     ; obtenemos posisicion de la ventana de Tera Term y posicionamos barra de herramientas
  75.     $active = 0
  76.     $wlist = WinList('[CLASS:VTWin32]')
  77.     For $i = 1 To $wlist[0][0]
  78.         $hwin = $wlist[$i][1]
  79.         If IsActive ($hwin) Then
  80.             $ttwin=$hwin
  81.             $pos = WinGetPos($hwin)
  82.             XSkinToolBarMove($h_ToolBar, $pos[0] + 400, $pos[1]+3)
  83.             $active = 1
  84.         EndIf
  85.     Next
  86.    
  87.     ; mostramos barra sólo cuando esté activa la ventana de Tera Term
  88.     If $active == 1 Then
  89.         If $hide == 1 Then
  90.             GUISetState(@SW_SHOW, $h_ToolBar)
  91.             $hide = 0
  92.         EndIf
  93.         WinActivate($ttwin)
  94.     Else
  95.         If $hide == 0 Then
  96.             If not WinActive("TeraTerm-ToolBar") Then
  97.                 GUISetState(@SW_HIDE, $h_ToolBar)
  98.                 $hide = 1
  99.             EndIf
  100.         EndIf
  101.     EndIf
  102.    
  103.     ; capturamos botón pulsado y ejecutamos la macro o programa correspondiente
  104.     $msg = GUIGetMsg()
  105.     Switch $msg
  106.     case $TButton1
  107.         WinActivate($ttwin)
  108.         Send("^{F1}")
  109.     case $TButton2
  110.         WinActivate($ttwin)
  111.         Send("^{F2}")
  112.     case $TButton3
  113.         WinActivate($ttwin)
  114.         Send("^{F3}")
  115.     case $TButton5
  116.         WinActivate($ttwin)
  117.         Send("^{F5}")
  118.     case $TButton6
  119.         WinActivate($ttwin)
  120.         Send("^{F6}")
  121.     case $TButton7
  122.         WinActivate($ttwin)
  123.         Send("^{F7}")
  124.     case $TButton8
  125.         WinActivate($ttwin)
  126.         Send("^{F8}")
  127.     case $TButton9
  128.         Run('C:\Archivos de Programa\Internet Explorer\iexplore.exe')
  129.     case $TButton10
  130.         Run('C:\Archivos de Programa\Microsoft Office\OFFICE11\winword.exe')
  131.     case $TButton11
  132.         Run('C:\Archivos de Programa\Microsoft Office\OFFICE11\excel.exe')     
  133.     case $TButton12
  134.         Run('C:\Archivos de Programa\teraterm\winscp.exe ftp://serv_unix') 
  135.     ;case $TButtonLast
  136.     ;   Exit
  137.     EndSwitch
  138.  
  139.     ; capturamos pulsación de tecla <BLOQ NUM>, y volvemos a activar el teclado numérico
  140.     If _IsPressed("90", $vDLL) Then
  141.         ;ConsoleWrite("Debug: VirtualKey NUMLOCK pressed" & @LF)
  142.         $state = WinGetState($ttwin, "")
  143.         ; Comprobar si TeraTerm está activo
  144.         If BitAnd($state, 8) Then
  145.             ;sleep(1)
  146.             WinActivate("TeraTerm-ToolBar")
  147.             Send("{NumLock on}") ;
  148.             ;sleep(1)
  149.             WinActivate($ttwin)
  150.         EndIf
  151.     EndIf
  152.        
  153.     Sleep(50)
  154.    
  155. WEnd
  156.  
  157.  
  158.  
  159.  
  160. ; ************************ FUNCIONES *****************************
  161.  
  162. Func XSkinToolBarCreate($XTitle, $tool_left, $tool_top, $tool_width, $tool_bkcolor = "")
  163.     Local $Xh_ToolBar
  164.  $Xh_ToolBar = GUICreate($XTitle, $tool_width, 24, $tool_left, $tool_top, $WS_POPUP, $WS_CLIPCHILDREN);-1, $WS_EX_STATICEDGE);, $Xh_Gui)
  165.     If $tool_bkcolor <> "" Then GUISetBkColor($tool_bkcolor, $Xh_ToolBar)
  166.     Return $Xh_ToolBar
  167. EndFunc   ;==>XSkinToolBarCreate
  168.  
  169. Func XSkinToolBarMove($Xh_ToolBar, $tool_left, $tool_top)
  170.   WinMove($Xh_ToolBar, '', $tool_left, $tool_top)
  171. EndFunc   ;==>XSkinToolBarMove
  172.  
  173. Func XSkinToolBarButton($iNumber, $iDLL = "shell32.dll")
  174.     Local $Xhadd, $TBBleft
  175.     $TBcnt = $TBcnt + 1
  176.     $TBBleft = $TBcnt * 24
  177.     $Xhadd = GUICtrlCreateButton("", $TBBleft, 1, 24, 24, $BS_ICON)
  178.     GUICtrlSetImage($Xhadd, $iDLL, $iNumber, 0)
  179.     Return $Xhadd
  180. EndFunc   ;==>XSkinToolBarButton
  181.  
  182. Func XSkinToolBarSeparator()
  183.     Local $TBBleft
  184.     $TBcnt = $TBcnt + .5
  185.     $TBBleft = $TBcnt * 24
  186.     GUICtrlCreateLabel("", $TBBleft + 17, 2, 2, 22, $SS_ETCHEDVERT, $GUI_WS_EX_PARENTDRAG)
  187. EndFunc   ;==>XSkinToolBarSeparator#cs
  188.  
  189. Func IsActive($handle)
  190.   If BitAnd( WinGetState($handle), 8 ) Then
  191.     Return 1
  192.   Else
  193.     Return 0
  194.   EndIf
  195. EndFunc
  196.  
  197. Func _Quit()
  198.     Exit
  199. EndFunc
  200.  
  201. Func _GetNumLock()
  202.     Local $ret
  203.     $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_NUMLOCK)
  204.     Return $ret[0]
  205. EndFunc
IshmaelCallMe
Guru

Posts:
670
Joined: Thu Jan 26, 2006 2:28 am
by IshmaelCallMe » Wed May 06, 2009 4:32 pm
Highly neat.

I took the liberty of translating to English, but the quality of translation may be shaky.

Code: Select all

  1.  
  2. #########################################
  3. #include <GUIConstantsEX.au3>
  4. #include <windowsconstants.au3>
  5. #include <buttonconstants.au3>
  6. #include <StaticConstants.au3>
  7. #include <Array.au3>
  8. #include <Misc.au3>
  9. Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
  10. ;Opt("MustDeclareVars", 1)
  11. ;Opt("TrayIconHide", 1)
  12.  
  13. ; $h_ToolBar = XSkinToolBarCreate($Xh_Gui, $tool_left, $tool_top, $tool_width, $tool_bkcolor = "")
  14. ; XSkinToolBarButton($iNumber, $iDLL = "shell32.dll")
  15. ; XSkinToolBarSeparator()
  16.  
  17. ; #1 - Using Icons from a dll ( shell32.dll is default)
  18. ; XSkinToolBarButton(155)
  19. ; #2 - Using Icons from an exe file
  20. ; XSkinToolBarButton(22)
  21. ; XSkinToolBarButton("", @ProgramFilesDir & "\Internet Explorer\iexplore.exe")
  22. ; XSkinToolBarButton( "", @WindowsDir & "\explorer.exe")
  23. ; XSkinToolBarButton( "", @SystemDir & "\calc.exe")
  24. ; #3 - Using Icons from an ico file
  25. ;XSkinToolBarButton("", @ScriptDir & "\Skins\Default-ToolBar\Admin Tools.ico")
  26. ;XSkinToolBarButton("", @ScriptDir & "\Skins\Default-ToolBar\Control Panel.ico")
  27. ;XSkinToolBarButton("", @ScriptDir & "\Skins\Default-ToolBar\E-Mail.ico")
  28.  
  29. Global Const $VK_NUMLOCK = 0x90
  30. Global $TBcnt = -1
  31. ; Main
  32. ; HotKeySet("{ESC}", "_Quit")   ; exit with ESC test
  33. $vDLL = DllOpen('user32.dll')
  34.  
  35. $h_ToolBar = XSkinToolBarCreate("TeraTerm-ToolBar", 200, 200, 305)
  36.  
  37. $TButton1 = XSkinToolBarButton("", @ProgramFilesDir & "\Sigca2\Pcsigca.exe")
  38. GUICtrlSetTip(-1, "Search SIGCA2 the cadastral reference mark with the mouse (Cltr + F1)")
  39. $TButton2 = XSkinToolBarButton("", @ProgramFilesDir & "\Sauce\Sauce.exe")
  40. GUICtrlSetTip(-1, "Browse SAUCE cadastral reference or file marked with the mouse (Cltr + F2)")
  41. $TButton3 = XSkinToolBarButton("", @ProgramFilesDir & "\teraterm\ttermpro.exe")
  42. GUICtrlSetTip(-1, "Search SIGECA the cadastral reference contained in the clipboard (Cltr + F3)")
  43. XSkinToolBarSeparator()
  44. $TButton5 = XSkinToolBarButton(155) ; macro change size
  45. GUICtrlSetTip(-1, "Change font size (Cltr + F5)")
  46. $TButton6 = XSkinToolBarButton(270) ; macro change color
  47. GUICtrlSetTip(-1, "Change colors (Cltr + F6)")
  48. $TButton7 = XSkinToolBarButton(269) ; macro change keyboard profile
  49. GUICtrlSetTip(-1, "Change profile keyboard (Cltr + F7)")
  50. $TButton8 = XSkinToolBarButton(243) ; paste
  51. GUICtrlSetTip(-1, "Paste the clipboard contents (Cltr + F8)")
  52. XSkinToolBarSeparator()
  53. $TButton9 = XSkinToolBarButton(512) ; explorer
  54. GUICtrlSetTip(-1, "Internet Explorer")
  55. $TButton10 = XSkinToolBarButton("", @ProgramFilesDir & "\Microsoft Office\OFFICE11\winword.exe")
  56. GUICtrlSetTip(-1, "Microsoft Word")
  57. $TButton11 = XSkinToolBarButton("", @ProgramFilesDir & "\Microsoft Office\OFFICE11\excel.exe")
  58. GUICtrlSetTip(-1, "Microsoft Excel")
  59. XSkinToolBarSeparator()
  60. $TButton12 = XSkinToolBarButton(25) ; winscp
  61. GUICtrlSetTip(-1, "Open file transfer tool")
  62. ;$TButtonLast = XSkinToolBarButton(27) ; exit
  63. ; Create object toolbar and hide
  64. GUISetState(@SW_HIDE, $h_ToolBar)
  65. WinSetOnTop($h_ToolBar, "", 1)
  66. $hide = 1
  67.  
  68. While 1
  69.     ;   Find the Tera Term window and position toolbar
  70.     $active = 0
  71.     $wlist = WinList('[CLASS:VTWin32]')
  72.     For $i = 1 To $wlist[0][0]
  73.         $hwin = $wlist[$i][1]
  74.         If IsActive($hwin) Then
  75.             $ttwin = $hwin
  76.             $pos = WinGetPos($hwin)
  77.             XSkinToolBarMove($h_ToolBar, $pos[0] + 400, $pos[1] + 3)
  78.             $active = 1
  79.         EndIf
  80.     Next
  81.     ; Bar will show only when Tera Term is the active window
  82.     If $active == 1 Then
  83.         If $hide == 1 Then
  84.             GUISetState(@SW_SHOW, $h_ToolBar)
  85.             $hide = 0
  86.         EndIf
  87.         WinActivate($ttwin)
  88.     Else
  89.         If $hide == 0 Then
  90.             If Not WinActive("TeraTerm-ToolBar") Then
  91.                 GUISetState(@SW_HIDE, $h_ToolBar)
  92.                 $hide = 1
  93.             EndIf
  94.         EndIf
  95.     EndIf
  96.     ; Capture button down and run the macro or program
  97.     $msg = GUIGetMsg()
  98.     Switch $msg
  99.         Case $TButton1
  100.             WinActivate($ttwin)
  101.             Send("^{F1}")
  102.         Case $TButton2
  103.             WinActivate($ttwin)
  104.             Send("^{F2}")
  105.         Case $TButton3
  106.             WinActivate($ttwin)
  107.             Send("^{F3}")
  108.         Case $TButton5
  109.             WinActivate($ttwin)
  110.             Send("^{F5}")
  111.         Case $TButton6
  112.             WinActivate($ttwin)
  113.             Send("^{F6}")
  114.         Case $TButton7
  115.             WinActivate($ttwin)
  116.             Send("^{F7}")
  117.         Case $TButton8
  118.             WinActivate($ttwin)
  119.             Send("^{F8}")
  120.         Case $TButton9
  121.             Run('C:\Program Files\Internet Explorer\iexplore.exe')
  122.         Case $TButton10
  123.             Run('C:\Program Files\Microsoft Office\OFFICE11\winword.exe')
  124.         Case $TButton11
  125.             Run('C:\Program Files\Microsoft Office\OFFICE11\excel.exe')
  126.         Case $TButton12
  127.             Run('C:\Program Files\Teraterm\winscp.exe ftp://serv_unix')
  128.             ;case $TButtonLast
  129.             ;   Exit
  130.     EndSwitch
  131.     ; Capture keypress <BLOQ NUM>, and re-activate the keypad
  132.     If _IsPressed("90", $vDLL) Then
  133.         ;ConsoleWrite("Debug: VirtualKey NUMLOCK pressed" & @LF)
  134.         $state = WinGetState($ttwin, "")
  135.         ; Check if Teraterm active
  136.         If BitAND($state, 8) Then
  137.             ;sleep(1)
  138.             WinActivate("TeraTerm-ToolBar")
  139.             Send("{NumLock on}") ;
  140.             ;sleep(1)
  141.             WinActivate($ttwin)
  142.         EndIf
  143.     EndIf
  144.     Sleep(50)
  145. WEnd
  146.  
  147. ; ************************ FUNCTIONS *****************************
  148. Func XSkinToolBarCreate($XTitle, $tool_left, $tool_top, $tool_width, $tool_bkcolor = "")
  149.     Local $Xh_ToolBar
  150.     $Xh_ToolBar = GUICreate($XTitle, $tool_width, 24, $tool_left, $tool_top, $WS_POPUP, $WS_CLIPCHILDREN);-1, $WS_EX_STATICEDGE);, $Xh_Gui)
  151.     If $tool_bkcolor <> "" Then GUISetBkColor($tool_bkcolor, $Xh_ToolBar)
  152.     Return $Xh_ToolBar
  153. EndFunc   ;==>XSkinToolBarCreate
  154.  
  155. Func XSkinToolBarMove($Xh_ToolBar, $tool_left, $tool_top)
  156.     WinMove($Xh_ToolBar, '', $tool_left, $tool_top)
  157. EndFunc   ;==>XSkinToolBarMove
  158.  
  159. Func XSkinToolBarButton($iNumber, $iDLL = "shell32.dll")
  160.     Local $Xhadd, $TBBleft
  161.     $TBcnt = $TBcnt + 1
  162.     $TBBleft = $TBcnt * 24
  163.     $Xhadd = GUICtrlCreateButton("", $TBBleft, 1, 24, 24, $BS_ICON)
  164.     GUICtrlSetImage($Xhadd, $iDLL, $iNumber, 0)
  165.     Return $Xhadd
  166. EndFunc   ;==>XSkinToolBarButton
  167.  
  168. Func XSkinToolBarSeparator()
  169.     Local $TBBleft
  170.     $TBcnt = $TBcnt + .5
  171.     $TBBleft = $TBcnt * 24
  172.     GUICtrlCreateLabel("", $TBBleft + 17, 2, 2, 22, $SS_ETCHEDVERT, $GUI_WS_EX_PARENTDRAG)
  173. EndFunc   ;==>XSkinToolBarSeparator
  174.  
  175. Func IsActive($handle)
  176.     If BitAND(WinGetState($handle), 8) Then
  177.         Return 1
  178.     Else
  179.         Return 0
  180.     EndIf
  181. EndFunc   ;==>IsActive
  182.  
  183. Func _Quit()
  184.     Exit
  185. EndFunc   ;==>_Quit
  186.  
  187. Func _GetNumLock()
  188.     Local $ret
  189.     $ret = DllCall("user32.dll", "long", "GetKeyState", "long", $VK_NUMLOCK)
  190.     Return $ret[0]
  191. EndFunc   ;==>_GetNumLock
  192.  
necod
Newbie

Posts:
7
Joined: Wed Apr 15, 2009 11:08 am
by necod » Fri May 08, 2009 6:46 am
Thanks IshmaelCallMe.


I think this version works better.



Code: Select all

  1. #include <GUIConstantsEX.au3>
  2. #include <windowsconstants.au3>
  3. #include <buttonconstants.au3>
  4. #include <StaticConstants.au3>
  5. #include <Array.au3>
  6. #Include <Misc.au3>
  7.  
  8. Opt("WinTitleMatchMode", 2)     ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
  9. Opt("TrayIconHide", 1)
  10. ;Opt("MustDeclareVars", 1)
  11.  
  12. Global Const $VK_NUMLOCK = 0x90
  13. Global $TBcnt = -1
  14.  
  15. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  16. ; toolbar buttons sample
  17. ; $h_ToolBar = XSkinToolBarCreate($Xh_Gui, $tool_left, $tool_top, $tool_width, $tool_bkcolor = "")
  18. ; XSkinToolBarButton($iNumber, $iDLL = "shell32.dll")
  19. ; XSkinToolBarSeparator()
  20.  
  21. ; #1 - Using Icons from a dll ( shell32.dll is default)
  22. ; XSkinToolBarButton(155)  
  23. ; #2 - Using Icons from an exe file
  24. ; XSkinToolBarButton(22)
  25. ; XSkinToolBarButton("", @ProgramFilesDir & "\Internet Explorer\iexplore.exe")
  26. ; XSkinToolBarButton( "", @WindowsDir & "\explorer.exe")
  27. ; XSkinToolBarButton( "", @SystemDir & "\calc.exe")
  28. ; #3 - Using Icons from an ico file
  29. ;XSkinToolBarButton("", @ScriptDir & "\Skins\Default-ToolBar\Admin Tools.ico")
  30. ;XSkinToolBarButton("", @ScriptDir & "\Skins\Default-ToolBar\Control Panel.ico")
  31. ;XSkinToolBarButton("", @ScriptDir & "\Skins\Default-ToolBar\E-Mail.ico")
  32. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  33.  
  34.  
  35. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  36. ; Main
  37. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  38.  
  39. ; It creates toolbar object
  40. ; Creamos objeto barra de herramientas
  41. $vDLL = DllOpen('user32.dll')
  42. $h_ToolBar = XSkinToolBarCreate("TeraTerm-ToolBar", 200, 200, 325)
  43.  
  44. ; Add toolbar buttons
  45. ; Añadimos botones de la barra
  46. $TButton1 = XSkinToolBarButton("", @ProgramFilesDir & "\Sigca2\Pcsigca.exe")
  47. GUICtrlSetTip( -1, "Busca en SIGCA2 la referencia catastral marcada con el ratón (Cltr+F1)")
  48. $TButton2 = XSkinToolBarButton("", @ProgramFilesDir & "\Sauce\Sauce.exe")
  49. GUICtrlSetTip( -1, "Busca en SAUCE la referencia catastral o expediente marcado con el ratón (Cltr+F2)")
  50. $TButton3 = XSkinToolBarButton("", @ProgramFilesDir & "\teraterm\ttermpro.exe")
  51. GUICtrlSetTip( -1, "Busca en SIGECA la referencia catastral contenida en el portapapeles (Cltr+F3)")
  52. XSkinToolBarSeparator()
  53. $TButton5 = XSkinToolBarButton(155)     ; macro cambio tamaño
  54. GUICtrlSetTip( -1, "Cambia tamaño de letra (Cltr+F5)")
  55. $TButton6 = XSkinToolBarButton(270)     ; macro cambio color
  56. GUICtrlSetTip( -1, "Cambia combinación de colores (Cltr+F6)")
  57. $TButton7 = XSkinToolBarButton(269)     ; macro cambio perfil teclado
  58. GUICtrlSetTip( -1, "Cambia perfil de teclado (Cltr+F7)")
  59. $TButton8 = XSkinToolBarButton(243)     ; pegar
  60. GUICtrlSetTip( -1, "Pega contenido del portapapeles (Cltr+F8)")
  61. XSkinToolBarSeparator()
  62. $TButton9 = XSkinToolBarButton(512)     ; explorer
  63. GUICtrlSetTip( -1, "Internet Explorer")
  64. $TButton10 = XSkinToolBarButton("", @ProgramFilesDir & "\Microsoft Office\OFFICE11\winword.exe")
  65. GUICtrlSetTip( -1, "Microsoft Word")
  66. $TButton11 = XSkinToolBarButton("", @ProgramFilesDir & "\Microsoft Office\OFFICE11\excel.exe")
  67. GUICtrlSetTip( -1, "Microsoft Excel")
  68. XSkinToolBarSeparator()
  69. $TButton12 = XSkinToolBarButton(25)     ; winscp
  70. GUICtrlSetTip( -1, "Abre herramienta de transferencia de ficheros")
  71. $TButton13 = XSkinToolBarButton(324)    ; ayuda
  72. GUICtrlSetTip( -1, "Resolución de Dudas y Problemas")
  73.  
  74. ; HotKeySet("{ESC}", "_Quit")   ; para pruebas salir con ESC
  75. ; $TButtonLast = XSkinToolBarButton(27) ; exit
  76.  
  77.  
  78. ; By default, bar will hide
  79. ; Por defecto, la barra está oculta
  80. GUISetState(@SW_HIDE, $h_ToolBar)
  81. $hide = 1
  82. WinSetOnTop($h_ToolBar, "", 1)
  83.  
  84.  
  85. While 1
  86.  
  87.     ; Find the Tera Term window and position toolbar
  88.     ; Obtenemos posisicion de la ventana de Tera Term y posicionamos barra de herramientas
  89.     $active = 0
  90.     $wlist = WinList('[CLASS:VTWin32]')
  91.     For $i = 1 To $wlist[0][0]
  92.         $hwin = $wlist[$i][1]
  93.         If IsActive ($hwin) Then
  94.             $ttwin=$hwin
  95.             $pos = WinGetPos($hwin)
  96.             XSkinToolBarMove($h_ToolBar, $pos[0] + 400, $pos[1]+3)
  97.             $active = 1
  98.         EndIf
  99.     Next
  100.  
  101.     ; Check Tera Term has no windows open
  102.     ; comprobamos si tera term está cerrado
  103.     If $wlist[0][0] == 0 Then
  104.         $closed = 1
  105.     Else
  106.         $closed = 0
  107.     EndIf
  108.    
  109.     ; Bar will show only when Tera Term is the active window
  110.     ; Mostramos barra sólo cuando esté activa la ventana de Tera Term
  111.     If $active == 1 Then
  112.         If $hide == 1 Then
  113.             If not IsMinimized ($ttwin) Then
  114.                 GUISetState(@SW_SHOW, $h_ToolBar)
  115.                 $hide = 0
  116.                 WinActivate($ttwin)
  117.             EndIf
  118.         EndIf
  119.        
  120.     Else
  121.         ; Bar will hide when Tera Term is minimized
  122.         ; ocultamos la barra de herramientas cuando está minimizado el Tera Term
  123.         If $hide == 0 Then
  124.             If not IsActive("TeraTerm-ToolBar") or IsMinimized ($ttwin) Then
  125.                 GUISetState(@SW_HIDE, $h_ToolBar)
  126.                 $hide = 1
  127.             EndIf
  128.         EndIf
  129.        
  130.         ; Bar will hide when Tera Term is closed
  131.         ; ocultamos la barra de herramientas si se cierra el Tera Term
  132.         If $closed == 1  Then
  133.             GUISetState(@SW_HIDE, $h_ToolBar)
  134.             $hide = 1
  135.         EndIf
  136.     EndIf
  137.    
  138.     ; Capture button down and run the macro or program
  139.     ; Capturamos botón pulsado y ejecutamos la macro o programa correspondiente
  140.     $msg = GUIGetMsg()
  141.     Switch $msg
  142.     case $TButton1
  143.         WinActivate($ttwin)
  144.         Send("^{F1}")
  145.     case $TButton2
  146.         WinActivate($ttwin)
  147.         Send("^{F2}")
  148.     case $TButton3
  149.         WinActivate($ttwin)
  150.         Send("^{F3}")
  151.     case $TButton5
  152.         WinActivate($ttwin)
  153.         Send("^{F5}")
  154.     case $TButton6
  155.         WinActivate($ttwin)
  156.         Send("^{F6}")
  157.     case $TButton7
  158.         WinActivate($ttwin)
  159.         Send("^{F7}")
  160.     case $TButton8
  161.         WinActivate($ttwin)
  162.         Send("^{F8}")
  163.     case $TButton9
  164.         Run('C:\Archivos de Programa\Internet Explorer\iexplore.exe')
  165.     case $TButton10
  166.         Run('C:\Archivos de Programa\Microsoft Office\OFFICE11\winword.exe')
  167.     case $TButton11
  168.         Run('C:\Archivos de Programa\Microsoft Office\OFFICE11\excel.exe')     
  169.     case $TButton12
  170.         Run('C:\Archivos de Programa\teraterm\winscp.exe ftp://serv_unix') 
  171.     case $TButton13
  172.         Run('C:\Archivos de Programa\Internet Explorer\iexplore.exe file://10.57.224.75/emulacion/Dudas_Problemas.mht')
  173.     ; case $TButtonLast
  174.     ;   Exit
  175.     EndSwitch
  176.  
  177.     ; Capture keypress <BLOQ NUM>, and re-activate the keypad
  178.     ; Capturamos pulsación de tecla <BLOQ NUM>, y volvemos a activar el teclado numérico
  179.     If _IsPressed("90", $vDLL) Then
  180.         ;ConsoleWrite("Debug: VirtualKey NUMLOCK pressed" & @LF)
  181.         ; Comprobar si TeraTerm está activo
  182.         If IsActive($ttwin) Then
  183.             WinActivate("TeraTerm-ToolBar")
  184.             Send("{NumLock on}") ;
  185.             WinActivate($ttwin)
  186.         EndIf
  187.     EndIf
  188.        
  189.     Sleep(50)
  190.    
  191. WEnd
  192.  
  193.  
  194.  
  195. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  196. ; Functions
  197. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  198.  
  199.  
  200. Func XSkinToolBarCreate($XTitle, $tool_left, $tool_top, $tool_width, $tool_bkcolor = "")
  201.     Local $Xh_ToolBar
  202.  $Xh_ToolBar = GUICreate($XTitle, $tool_width, 24, $tool_left, $tool_top, $WS_POPUP, $WS_CLIPCHILDREN);-1, $WS_EX_STATICEDGE);, $Xh_Gui)
  203.     If $tool_bkcolor <> "" Then GUISetBkColor($tool_bkcolor, $Xh_ToolBar)
  204.     Return $Xh_ToolBar
  205. EndFunc   ;==>XSkinToolBarCreate
  206.  
  207. Func XSkinToolBarMove($Xh_ToolBar, $tool_left, $tool_top)
  208.   WinMove($Xh_ToolBar, '', $tool_left, $tool_top)
  209. EndFunc   ;==>XSkinToolBarMove
  210.  
  211. Func XSkinToolBarButton($iNumber, $iDLL = "shell32.dll")
  212.     Local $Xhadd, $TBBleft
  213.     $TBcnt = $TBcnt + 1
  214.     $TBBleft = $TBcnt * 24
  215.     $Xhadd = GUICtrlCreateButton("", $TBBleft, 1, 24, 24, $BS_ICON)
  216.     GUICtrlSetImage($Xhadd, $iDLL, $iNumber, 0)
  217.     Return $Xhadd
  218. EndFunc   ;==>XSkinToolBarButton
  219.  
  220. Func XSkinToolBarSeparator()
  221.     Local $TBBleft
  222.     $TBcnt = $TBcnt + .5
  223.     $TBBleft = $TBcnt * 24
  224.     GUICtrlCreateLabel("", $TBBleft + 17, 2, 2, 22, $SS_ETCHEDVERT, $GUI_WS_EX_PARENTDRAG)
  225. EndFunc   ;==>XSkinToolBarSeparator#cs ----------------------------------------------------------------------------
  226.  
  227. Func _Quit()
  228.     Exit
  229. EndFunc   ;==> _Quit
  230.  
  231. Func _GetNumLock()
  232.     Local $ret
  233.     $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_NUMLOCK)
  234.     Return $ret[0]
  235. EndFunc   ;==> _GetNumLock
  236.  
  237. Func IsActive($handle)
  238.   If BitAnd( WinGetState($handle), 8 ) Then
  239.     Return 1
  240.   Else
  241.     Return 0
  242.   EndIf
  243. EndFunc   ;==> IsActive
  244.  
  245. Func IsMinimized($handle)
  246.   If BitAnd( WinGetState($handle), 16 ) Then
  247.     Return 1
  248.   Else
  249.     Return 0
  250.   EndIf
  251. EndFunc   ;==> IsMinimized
Zecken
Newbie

Posts:
2
Joined: Mon May 02, 2011 8:28 am
by Zecken » Mon May 02, 2011 8:34 am
Hello,

can you write a tutorial. I don´t know how to implement this script.

Thanks
Display posts from previous:
Sort by:

4 postsPage 1 of 1

Users browsing this forum: No registered users