Advertisement
AZJIO

HELP_AutoIt3.au3

Dec 10th, 2011
1,205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 7.49 KB | None | 0 0
  1. ;  @AZJIO
  2. ; Скрипт для вызова справки из Notepad++ выделенного слова. Скрипт передаёт в ком строку слово и число 1-3, всоответствии с этим открывается соответствующая справка с поиском слова. Если справка открыта, то она не открывается повторно, а активизируется необходимое окно. Предыдущая версия перезапускала справку, с неудобством закрытия дерева содержания.
  3. ;"C:\Program Files\AutoIt3\AutoIt3.exe" "C:\Program Files\AutoIt3\\HELP_AutoIt3.au3 $(CURRENT_WORD) 1
  4.  
  5.  
  6. ; En
  7. ; $LngMs1='Error'
  8. ; $LngMs2='Select the text you want to send to the help file'
  9. ; $LngMs3='Word in the UDF, but the directory (Include) is not found'
  10. ; $LngMs4='Not found'
  11.  
  12. ; Ru
  13. $LngMs1='Ошибка'
  14. $LngMs2='Выделите текст, который требуется отправить в справку'
  15. $LngMs3='Слово в списке UDF, но каталог Include не найден'
  16. $LngMs4='Не найден'
  17.  
  18. ; $LngTitle1='AutoIt Help' ; En
  19. $LngTitle1='Справка AutoIt' ; Ru
  20. $sFile1='AutoIt.chm'
  21.  
  22. $LngTitle2='AutoIt'
  23. $sFile2='AutoIt3_2_5_4_ru.chm'
  24.  
  25. $LngTitle3='Справка AutoIt по UDF'
  26. $sFile3='UDFs3_google.chm'
  27.  
  28. ; Выбираем редактор в котором открывать UDF
  29. $sPath_Edit = 'Notepad++\notepad++.exe'
  30. ; $sPath_Edit = 'SciTE\SciTE.exe'
  31.  
  32. ; Global $Title_File[3][2] = [ _
  33. ; ['Справка AutoIt', 'AutoIt.chm'], _
  34. ; ['AutoIt', 'AutoIt3_2_5_4_ru.chm'], _
  35. ; ['Справка AutoIt по UDF', 'UDFs3_google.chm']]
  36.  
  37. ;#include <Array.au3>
  38. Opt("WinTitleMatchMode", 3) ; выставляем точное соответствие, чтобы точно определить окно
  39.  
  40. If $CmdLine[0] > 1 Then
  41.     ; Opt("WinTextMatchMode", 3) ; точный поиск окна
  42.     Opt("WinTextMatchMode", 2) ; быстрый режим
  43.     $sAutoIt_Path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir")
  44.     ; в ком-строке параметром 1-3 вызываем соответствующую справку
  45.     Switch $CmdLine[2]
  46.         Case 1
  47.             ; _call('AutoIt UDFs Help', 'UDFs3.chm')
  48.             ; _call('AutoIt Help', 'AutoIt.chm') ; команда объединяет AutoIt3 (новая русская) и UDFs3 справку
  49.             _call($LngTitle1, $sFile1) ; команда объединяет AutoIt3 (новая русская) и UDFs3 справку
  50.         Case 2
  51.             _call($LngTitle2, $sFile2) ; старая русская от Иванова.
  52.         Case 3
  53.             _call($LngTitle3, $sFile3) ; справка с переводом в google
  54.     EndSwitch
  55. Else
  56.     MsgBox(0, $LngMs1, $LngMs2)
  57. EndIf
  58.  
  59. Func _call($sWinTitle, $sName_File_CHM)
  60.     ; Участок кода открывает UDF в редакторе
  61.     $SearchText = 'SQLite.dll,GDIP,WinAPIEx,WinAPI,GuiListView,GuiRichEdit,GuiTreeView,StructureConstants,IE,GDIPlus,GuiToolbar,AutoItObject,Services,Date,GuiMenu,GuiReBar,GuiComboBoxEx,GuiEdit,Word,ModernMenuRaw,GuiListBox,GuiToolTip,GuiComboBox,GDIPConstants,GuiMonthCal,GuiHeader,WinNet,NetShare,_XMLDomWrapper,FTPEx,GuiTab,Array,Excel,SQLite,Visa,Table,GuiSlider,GuiScrollBars,GuiButton,SoundGetSetQuery,GuiStatusBar,GuiImageList,ID3,Midiudf - для v3.3.0.0,Clipboard,Icons,EventLog,Misc,Midiudf,File,audio,LocalAccount,ColorPicker,GDIpProgress,GuiDateTimePicker,NamedPipes,Security,GraphGDIPlus,Crypt,Sound,Memory,ExpListView,Debug,SysTray_UDF,HotKey_17b,BigNum,HotKey,GUICtrlOnHover,WindowsConstants,HKCUReg,Constants,Resources,Encoding,GuiIPAddress,ListViewConstants,AutoItObject.dll,GUICtrlSetOnHover_UDF,HotKeyInput,GuiAVI,String,GUICtrlSetOnHover,Inet,hash,ScreenCapture,Timers,IsPressed_UDF,Reg,ToolTip_UDF,ToolbarConstants,RichEditConstants,HotKeySelect,GDIPlusConstants,Registry_UDFs,Color,TIG,WMMedia,ComboConstants,ListView_Progress,TreeViewConstants,UDFGlobalID,Math,GUIScroll,HeaderConstants,DateTimeConstants,RebarConstants,TabConstants,ToolTipConstants,ListBoxConstants,vkConstants,Process,MenuConstants,EditConstants,SendMessage,vkArray,SliderConstants,SecurityConstants,ButtonConstants,Privilege,FileConstants,StatusBarConstants,GUIConstantsEx,FontConstants,WinAPIError,ColorConstants,Описание Include.txt,ProgressConstants,BorderConstants,MemoryConstants,FrameConstants,ScrollBarConstants,ImageListConstants,StaticConstants,IPAddressConstants,ProcessConstants,UpDownConstants,DirConstants,AVIConstants,GUIConstants'
  62.     $CmdLine_1 = $CmdLine[1]
  63.     If StringRight($CmdLine_1, 4) = '.au3' Then $CmdLine_1 = StringTrimRight($CmdLine_1, 4)
  64.     If StringInStr($SearchText, ',' & $CmdLine_1 & ',') Then
  65.  
  66.         $sInclude_Path = RegRead("HKLM\SOFTWARE\AutoIt v3\AutoIt", "InstallDir")
  67.         If @error Or Not FileExists($sInclude_Path) Then
  68.             $sInclude_Path = RegRead('HKCU\Software\AutoIt v3\Autoit', 'Include')
  69.             If @error Or Not FileExists($sInclude_Path) Then
  70.                 MsgBox(0, $LngMs1, $LngMs3)
  71.             EndIf
  72.         Else
  73.             $sInclude_Path &= "\Include"
  74.         EndIf
  75.         If FileExists($sInclude_Path & '\' & $CmdLine_1 & '.au3') Then
  76.             Run('"' & $sAutoIt_Path & '\' & $sPath_Edit & '" "' & $sInclude_Path & '\' & $CmdLine_1 & '.au3"')
  77.         Else
  78.             MsgBox(0, $LngMs1, $LngMs4 & ' ' & $CmdLine_1 & '.au3')
  79.         EndIf
  80.         Exit
  81.     EndIf
  82.    
  83.     ; Если слово не UDF-файл, то открываем его как функцию в справке
  84.     $WinR = '[TITLE:' & $sWinTitle & ';CLASS:HH Parent]'
  85.  
  86.     If WinExists($WinR) Then
  87.         $hWnd = WinActivate($WinR)
  88.         If Not $hWnd Then Exit
  89.     Else
  90.         If $CmdLine[2]=1 And FileExists($sAutoIt_Path & '\AutoIt3Help.exe') Then ; если основная справка и существует exe, то
  91.             Run($sAutoIt_Path & '\AutoIt3Help.exe ' & $CmdLine_1) ; запускаем основную
  92.             Exit
  93.         Else
  94.             ShellExecute($sAutoIt_Path & '\' & $sName_File_CHM, "", $sAutoIt_Path) ; запускаем указанный файл
  95.             $hWnd = WinWaitActive($WinR, '', 3)
  96.             If Not $hWnd Then Exit
  97.         EndIf
  98.     EndIf
  99.     ; $hWnd получен
  100.     $hControl = ControlGetHandle($hWnd, "", '[CLASS:SysTabControl32;INSTANCE:1]') ; Получаем дескриптор вкладки
  101.     If Not $hControl Then Exit
  102.     $Tab = ControlCommand($hWnd, "", $hControl, "CurrentTab") ; Получаем номер вкладки
  103.  
  104.     If ControlGetFocus($hWnd)='Internet Explorer_Server1' Then ; Если активна правая часть окна, то
  105.         ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server;INSTANCE:1]", '{F6}')
  106.         Sleep(50)
  107.     EndIf
  108.  
  109.     Switch $Tab ; Взависимости от текущего номера вкладки переключаем на нужную вкладку
  110.         Case 1
  111.             ControlCommand($hWnd, "", $hControl, "TabRight")
  112.         Case 2
  113.             Sleep(10)
  114.         Case 3
  115.             ControlCommand($hWnd, "", $hControl, "TabLeft")
  116.         Case 4
  117.             ControlCommand($hWnd, "", $hControl, "TabLeft")
  118.             ControlCommand($hWnd, "", $hControl, "TabLeft")
  119.         Case Else ; если что то иное, значит это неправильно и выход
  120.             Exit
  121.     EndSwitch
  122.     $hControlEdit = ControlGetHandle($hWnd, "", '[CLASS:Edit;INSTANCE:3]') ; Получаем дескриптор поля ввода
  123.     ControlSetText($hWnd, '', $hControlEdit, $CmdLine_1) ; Вставляем текст в поле ввода
  124.     ControlFocus($hWnd, '', $hControlEdit) ; Фокусируем поле ввода
  125.     Sleep(50)
  126.     Send("{ENTER}") ; Эмулируем Enter в поле ввода, для перехода к функции
  127. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement