Advertisement
volond

1C

Dec 21st, 2020
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 65.52 KB | None | 0 0
  1. ;_1CV83.au3
  2. #include-once
  3. #include <Array.au3>
  4. #include <file.au3>
  5. #Include <Log.au3>
  6. ;~ #include "ExcelReadCell.au3"
  7. ;~ #include "ExcelCOM_UDF.au3"
  8. ;~ всплывающие сообщения 1с как обработать
  9. ;~ http://autoit-script.ru/index.php?topic=4926.0
  10.  
  11. ;~ #include "_ScriptingDictionary.au3"
  12. #include <Date.au3>
  13. ;~ #include <WinAPISys.au3>
  14. ;~ #include "fFind(.au3"
  15.  
  16. Func VersionEOD()
  17.     $v = " v. 1.1.0.0."
  18. return  $v
  19. EndFunc
  20.     Func Start1C($1C,$1CpathStart, $Param,$hLog)
  21. ;~      Запуск 1с с параметрами и активация окна
  22.  
  23.     If Not  WinExists($1C,"")then
  24. ;~  _Log_Report($hLog, 'Запуск 1С'  , 6)
  25.        
  26.     _LogAndPrintDebug($hLog, 'Запуск 1С-' & $1C,6 ) 
  27.                  ShellExecute ($1CpathStart, $Param)   
  28.         EndIf
  29. ;   $title  ="Помилка сценаріїв"   
  30.  
  31.  ;WinWait($title,"",60)
  32.  
  33. ;_myWindowClose($Title,"",3)
  34. ;_LogAndPrintDebug($hLog, 'Закрыть-' & $Title,6 )
  35. ;WinWait($title,"",60)
  36. ;_activatewindow($Title,"",0,1)
  37. ;_myWindowClose($Title,"",3)
  38. ;~ WinWait($1C)
  39. ;_LogAndPrintDebug($hLog, 'Закрыть-' & $Title,6 )
  40. ;~ WinActivate($1C, "")
  41. ;~ _LogAndPrintDebug($hLog, 'Закрыть-' & $Title,6 )
  42. If WinExists($1C) Then
  43.      WinActivate($1C)
  44.     _LogAndPrintDebug($hLog, 'Проверить-' & $1C,6 )
  45. EndIf
  46. WinWait($1C)
  47. _activatewindow($1C,"",0,1)
  48. _LogAndPrintDebug($hLog, 'Активировать-' & $1C,6 )
  49.     EndFunc
  50.  
  51. ;~ $WinTitleMatchMode
  52. ;~ 1 = сопоставление с началом
  53. ;~ 2 = сопоставление с произвольным фрагментом
  54. ;~ 3 = точное сопоставление
  55. ;~ 4 = пользовательский режим сопоставления
  56.  
  57. func _activatewindow($title, $text,$sleep,$WinTitleMatchMode)
  58.  _LogAndPrintDebug($hLog, 'Start _activatewindow-' & $title,6 )
  59. Opt("WinTitleMatchMode", $WinTitleMatchMode)
  60. WinWait($title,$text)
  61. _DebugPrint("WinWait" & $title)
  62. If Not WinActive($title,$text) Then WinActivate($title,$text)
  63. WinWaitActive($title,$text)
  64. Sleep($sleep)
  65.  _DebugPrint($title)
  66.  _LogAndPrintDebug($hLog, 'stop _activatewindow-' & $title,6 )
  67. EndFunc
  68.  
  69. ;~ ******************************************************************
  70. ;~ _WindowEO.....Title
  71.  
  72. ;~ $eod,$LinkName Условные постоянные
  73. ;~ $Login,$typeTitle Условные переменнные
  74. ;~ **********************************************************************
  75. Func _WindowEOFullTitle($eod,$Login,$typeTitle,$LinkName)
  76.    
  77. ;~  E0D Звенигородське ЛГ.Приймання лісопродукції (універсальний звіт) - ЛІАЦ
  78.  
  79. $FullTitle=$eod & " " & $Login & VersionEOD() & $typeTitle & " - " & $LinkName
  80.     return $FullTitle
  81. EndFunc
  82. Func _WindowEOAppTitle($eod,$Login,$LinkName)
  83. ;~  E0D Звенигородське ЛГ.ЛІАЦ
  84. ;~ E0D Звенигородське ЛГ v. 1.1.0.0.ЛІАЦ
  85. $v = VersionEOD
  86. $AppTitle=$eod & " " & $Login & VersionEOD() & $LinkName
  87.     return $AppTitle
  88. EndFunc
  89. Func _WindowEOSmallTitle($eod,$Login)
  90. ;~  E0D Звенигородське ЛГ
  91.  
  92. $SmallTitle=$eod & " " & $Login
  93.  _DebugPrint($SmallTitle )
  94.  
  95.     return $SmallTitle
  96. EndFunc
  97. Func _WindowEOTitle($typeTitle)
  98. $FullTitle=$eod & " " & $Login & VersionEOD() & $typeTitle & " - " & $LinkName
  99.     return $FullTitle
  100. EndFunc
  101.  
  102.  
  103. ;~ ******************************************************************
  104.  
  105. Func _myWindowClose($Title,$text,$WinTitleMatchMode)
  106.     _DebugPrint("Start _myWindowClose"  )
  107.     Opt("WinTitleMatchMode", $WinTitleMatchMode)
  108.     $handle = WinGetHandle($Title,$text)
  109.  
  110.     If WinExists($handle,$text) Then
  111.         WinClose($handle,$text)
  112.        
  113.     EndIf
  114. _DebugPrint("stop _myWindowClose"  )
  115. EndFunc
  116.  
  117.  
  118. Func _myWindowCloseNoApp($Title,$pattern,$WinTitleMatchMode)
  119. Opt("WinTitleMatchMode", $WinTitleMatchMode)
  120. $var = WinList()
  121. _DebugPrint("Start _myWindowCloseNoApp"  )
  122. _DebugPrint("$pattern=" & $pattern )   
  123. ;~  $handle = WinGetHandle($Title,$text)
  124.  
  125. ;~  If WinExists($handle,$text) Then
  126. ;~      WinClose($handle,$text)
  127. ;~     
  128. ;~     EndIf
  129. For $i = 1 to $var[0][0]
  130.   ; Only display visble windows that have a title
  131.   If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
  132.    
  133.  
  134.     $z=StringInStr($var[$i][0],$pattern)
  135.    
  136.     if $z then
  137.        
  138.     $q=StringCompare($var[$i][0] , $Title )
  139. ;~  _DebugPrint("Open=" & $var[$i][0] & "-" & $q & "-" & $pattern)
  140.         if not (StringCompare($var[$i][0] , $Title  )= 0) then
  141.         _DebugPrint($var[$i][0] & "-" & $z & "-" & $Title )
  142.            
  143.     WinClose($var[$i][1],$text)
  144.    
  145. endif
  146. endif
  147.  
  148.   EndIf
  149. Next
  150.  
  151.  
  152. _DebugPrint("Stop _myWindowCloseNoApp"  )
  153.  
  154. EndFunc
  155.  
  156.  
  157. Func _myWindowCloseAllModal($hLog,$ExcelFullPath,$ListObjectName,$ListColumsName)
  158. ;~  Закрывает все модальные окна по заголовкам в зависимости от языка интерфейса
  159. ;~ $ExcelFullPath-может быть как путем к книге так и ссылкой на саму книгу
  160. ;~ $ListObjectName-Имя таблицы с заголовками("modal")
  161. ;~ $ListColumsName-Имя столбца для выбора значения($mova.value)
  162. _DebugPrint("Start _myWindowCloseAllModal"  )
  163. $ListObjectClose=_ListObjectGet($hLog,$ExcelFullPath,$ListObjectName)
  164. $ListColumsClose=_ListObjectListColumn($hLog,$ListObjectClose,$ListColumsName)
  165. for $closetitle in $ListColumsClose.range.cells
  166. _myWindowClose($closetitle,$text,4)
  167. next   
  168. _DebugPrint("Start _myWindowCloseAllModal"  )
  169. EndFunc
  170. Func _myWindowCloseAllModalADO($hLog,$oConnection,$ListColumsName)
  171. ;~  Закрывает все модальные окна по заголовкам в зависимости от языка интерфейса
  172. ;~ $ExcelFullPath-может быть как путем к книге так и ссылкой на саму книгу
  173. ;~ $ListObjectName-Имя таблицы с заголовками("modal")
  174. ;~ $ListColumsName-Имя столбца для выбора значения($mova.value)
  175. _DebugPrint("Start _myWindowCloseAllModalADO"  )
  176. $sQUERYmodal="select " & $ListColumsName & " from [" & "modal" & "$]"
  177. _DebugPrint("$sQUERYmodal" & $sQUERYmodal  )
  178. $oRecordset = _ADO_Execute($oConnection, $sQUERYmodal)
  179. _DebugPrint("__ADO_Recordset_IsValid" & __ADO_Recordset_IsValid($oRecordset)  )
  180. ;~ __ADO_Recordset_IsValid($oRecordset)
  181. ;~ _ADO_Recordset_Display($oRecordset)
  182. $oRecordset.moveFirst()
  183. ;~ MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$oRecordset.moveFirst()' & @lf & @lf & 'Return:' & @lf &$oRecordset.moveFirst()) ;### Debug MSGBOX
  184. ;~  With $oRecordset
  185.         Do
  186.           $VAR=  $oRecordset.Fields($ListColumsName).value
  187. _myWindowClose($VAR,"",4)
  188. if $oRecordset.EOF <> True  then  $oRecordset.MoveNext
  189.         Until $oRecordset.EOF = True
  190.  
  191.  
  192.  
  193.  
  194.  
  195. ;~ $ListObjectClose=_ListObjectGet($hLog,$ExcelFullPath,$ListObjectName)
  196. ;~ $ListColumsClose=_ListObjectListColumn($hLog,$ListObjectClose,$ListColumsName)
  197. ;~ for $closetitle in $ListColumsClose.range.cells
  198. ;~ _myWindowClose($closetitle,$text,4)
  199. ;~ next
  200. _DebugPrint("Stop _myWindowCloseAllModalADO" )
  201. EndFunc
  202. Func _myWindowCloseAll()
  203. _LogAndPrintDebug($hLog, "Закрытие всех ненужных окон" , 6)
  204. _myWindowClose($1CErrorTitle,$text,4)
  205. ;~ _myWindowCloseAllModal($hLog,$ExcelFullPath,"modal",$mova)
  206. _LogAndPrintDebug($hLog, $mova , 6)
  207. _myWindowCloseAllModalADO($hLog,$oConnection,$mova)
  208. _myWindowCloseNoApp($AppTitle,$SmallTitle,1)   
  209. EndFunc
  210.  
  211.  
  212. ;~ Язык окон
  213. func _mova_goto_link($mova)
  214.     If $mova="EN" then $title="Go to Link"
  215. If $mova="RU" then $title="Переход по ссылке"
  216. If $mova="UA" then $title="Перехід за посиланням"
  217.  
  218.     return $title
  219.     EndFunc
  220. func _mova_period($mova)
  221.     If $mova="EN" then $title="Go to Link"
  222. If $mova="RU" then $title="Период"
  223. If $mova="UA" then $title="Період"
  224.  
  225.     return $title
  226.     EndFunc
  227. func _mova_find($mova)
  228. If $mova="EN" then $title=""
  229. If $mova="RU" then $title="Найти"
  230. If $mova="UA" then $title="Знайти"
  231.  
  232.     return $title
  233.     EndFunc
  234.    
  235.    
  236. func _mova_Get_file($mova)
  237.     If $mova="EN" then $title="Get file"
  238. If $mova="RU" then $title="Получить файл"
  239. If $mova="UA" then $title="Одержати файл"  
  240.  
  241.  
  242.     return $title
  243.     EndFunc
  244. func _mova_Get_Link($mova)
  245.     If $mova="EN" then $title=""
  246. If $mova="RU" then $title=""
  247. If $mova="UA" then $title="Одержання посилання"  
  248.  
  249.  
  250.     return $title
  251.     EndFunc    
  252.    
  253.    
  254.    
  255.    
  256. func _mova_Save_file($mova)
  257.     If $mova="EN" then $title="Save file"
  258.     If $mova="RU" then $title="Сохранить файл"
  259.     If $mova="UA" then $title="Зберегти файл"
  260.     return $title
  261.     EndFunc    
  262. func _mova_Save_Listfile($mova)
  263.     If $mova="EN" then $title="Save file"
  264.     If $mova="RU" then $title="Сохранить файл"
  265.     If $mova="UA" then $title="Збереження файлу"
  266.     return $title
  267.     EndFunc    
  268.    
  269. func _gotolink($link,$linktext,$mova, $text,$sleep,$WinTitleMatchMode)
  270. ;~ e1cib/navigationpoint/desktop
  271.  
  272.  
  273. Send("{SHIFTDOWN}{F11}{SHIFTUP}")
  274. $title= _mova_goto_link($mova)
  275. _LogAndPrintDebug($hLog, '$title-' & $title,6 )
  276. _activatewindow($title,$text,0,$WinTitleMatchMode)
  277. Send($link)
  278. $f=Chr(35)
  279. Send($f,1)
  280. Send($linktext)
  281. Send("{ENTER}")
  282. Sleep($sleep)
  283. EndFunc
  284. func _gotolinkpr($linktext,$mova, $text,$sleep,$WinTitleMatchMode)
  285. ;~ e1cib/navigationpoint/desktop
  286.  
  287.  
  288. Send("{SHIFTDOWN}{F11}{SHIFTUP}")
  289. $title= _mova_goto_link($mova)
  290. _LogAndPrintDebug($hLog, '$title-' & $title,6 )
  291. _activatewindow($title,$text,0,$WinTitleMatchMode)
  292. ;~ Send($link)
  293. ;~ $f=Chr(35)
  294. ;~ Send($f,1)
  295. Send($linktext)
  296. Send("{ENTER}")
  297. Sleep($sleep)
  298. EndFunc
  299. func _ClikComboBoxList($myDown,$myTAB,$sleep)
  300.     ; Позволяет выбрать позицию списка ComboBox
  301.     Send("{DOWN}")
  302. Send("{Home}")
  303. $D="{DOWN " & $myDown & "}"
  304. Send($D)
  305. Send("{ENTER}")
  306. Send("{TAB " & $myTAB & "}")
  307. Sleep($sleep)
  308. EndFunc
  309. func _ClikListBoxList($titlemodal,$text,$textSend,$CLASS,$INSListBox,$sleep)
  310.     ; Позволяет выбрать позицию списка ListBox
  311. _DebugPrint('Активируем окно-' & $titlemodal)
  312. _activatewindow($titlemodal, $text,100,1)
  313. _DebugPrint('Фокус в лист бокс' & $titlemodal)
  314. _ControlFocusINSTANCE($titlemodal, "",$CLASS,$INSListBox)
  315. ;~ Переходим к позиции
  316. ;~ $textSend="{END}"
  317.  
  318. _SendText($textSend,0,100)
  319. ;~ Подтверждаем выбор
  320. _SendText("{ENTER}",0,100)
  321. EndFunc
  322. func _ClikComboBoxListCustomPeriod($CustomPeriodStart,$CustomPeriodEnd,$PeriodTitle,$typeTitleZ,$myTAB,$sleep)
  323.     ; Позволяет выбрать позицию списка ComboBox для произвольного периода
  324. ;~ _ClikComboBoxListCustomPeriod($CustomPeriodStart,$CustomPeriodEnd,"Период","Зведений щоденник",$myTAB,$sleep)
  325. ;~  переход на начало списка
  326. _myWindowClose($PeriodTitle,"",1)  
  327.  
  328. Send("{DOWN}")
  329. Send("{Home}")
  330. Send("{ENTER}")
  331. Sleep($sleep)
  332. _LogAndPrintDebug($hLog, '_myWindowClose' & $PeriodTitle,6 )
  333.  
  334. ;~ $WT= _WindowEOFullTitle($eod,$Login,$typeTitleP,$LinkName)
  335. ;~ MsgBox(4096, "$typeTitleP", $WT)
  336.  
  337. _activatewindow($PeriodTitle,"",0,1)
  338. _LogAndPrintDebug($hLog, '_activatewindow($PeriodTitle,"",0,1)' & $PeriodTitle,6 )
  339. _SendDateVba($CustomPeriodStart,1,500)
  340. _SendDateVba($CustomPeriodEnd,0,500)
  341. ;~ Нажатие кнопки ОК на форме $typeTitleP
  342.  Send("{CTRLDOWN}{ENTER}{CTRLUP}")
  343. ;~ $WT=_WindowEOFullTitle($eod,$Login,$typeTitleZ,$LinkName)
  344. _activatewindow($typeTitleZ,"",0,1)
  345.  if $myTAB<>0 then Send("{TAB " & $myTAB & "}")
  346. Sleep($sleep)
  347.  
  348.  
  349. EndFunc
  350.  
  351. func _SendCTRLENTER($sleep)
  352. Send("{CTRLDOWN}{ENTER}{CTRLUP}")
  353. Sleep($sleep)
  354. EndFunc
  355.  
  356. func _SendCTRLPlus ($Plus, $sleep)
  357. Send("{CTRLDOWN}{ENTER}{CTRLUP}")
  358. Sleep($sleep)
  359. EndFunc
  360. func _SendText($myText,$myTAB,$sleep)
  361.     ; Позволяет вставить в техтовое поле значение и после этого перейти к на указаное количество таб
  362.     Send($myText)
  363. if $myTAB<>0 then Send("{TAB " & $myTAB & "}")
  364. Sleep($sleep)
  365. EndFunc
  366. func _SendTabEnter($myTAB,$sleep)
  367.     ; Позволяет вставить в техтовое поле значение и после этого перейти к на указаное количество таб
  368.  
  369. Send("{TAB " & $myTAB & "}{ENTER}")
  370. Sleep($sleep)
  371. EndFunc
  372. func _SendTab($myTAB,$sleep)
  373.     ; Позволяет вставить в техтовое поле значение и после этого перейти к на указаное количество таб
  374.  
  375. Send("{TAB " & $myTAB & "}")
  376. Sleep($sleep)
  377. EndFunc
  378. func _SendESC($sleep)
  379.     ; Позволяет вставить в техтовое поле значение и после этого перейти к на указаное количество таб
  380.  
  381. Send("{ESC}")
  382. Sleep($sleep)
  383. EndFunc
  384. Func _SendZnach($Arr,$SplitNumb,$SplitLeters = Default)
  385. If $SplitLeters = Default Then $SplitLeters = " "
  386. ;~ MsgBox(0,$aArray[$i][$iColumnsLK],"",0) 
  387. $r=StringSplit ( $Arr, $SplitLeters )
  388.    
  389.  
  390. $f=$r[$SplitNumb]
  391. return $f
  392. endfunc
  393.  
  394.  
  395. Func CreateLiasShortcut($sFilePath,$Login,$Password,$hLog)
  396.  
  397.     $Param=" /WS" & $LinkBase & ' /N"' & $Login & '" /P' & $Password
  398.  
  399.     FileCreateShortcut($1CpathStart, $sFilePath,$1Cpath,$Param,$LinkBase,$1CpathStart)
  400.      _DebugPrint('Создание ярлыка для запуска конфигурации 1С' )
  401.      _Log_Report($hLog, 'Создание ярлыка для запуска конфигурации 1С'  , 6)   
  402.  
  403.     ; Retrieve details about the shortcut.
  404.     Local $aDetails = FileGetShortcut($sFilePath)  
  405. EndFunc
  406.    
  407.    
  408.  
  409.    
  410.    
  411.     Func ReadRowsArray($PathWorkBooks,$WorkBooksTitle,$iRows,$nRows,$iColumns,$sleep)
  412.        
  413.     local $oWorkbook
  414. ;~ Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
  415. _DebugPrint("ReadRowsArray start")
  416. _DebugPrint("_InitWorkbook")
  417. $oWorkbook= _InitWorkbook($PathWorkBooks)
  418.  
  419.  
  420.  
  421. ; чтение параметра
  422. _DebugPrint("чтение параметра")
  423. Dim $aArray[$iRows + 1][$iColumns + 1]
  424. For $i = $nRows To $iRows
  425.     For $j = 1 To $iColumns
  426.         $aArray[$i-$nRows][$j] = $oWorkbook.Activesheet.Cells($i, $j).Value
  427.     Next
  428. Next
  429. _DebugPrint("ReadRowsArray close")
  430. ;~ $oWorkbook.close
  431. ;~ $oExcel.quit
  432. return $aArray
  433.     EndFunc
  434.    
  435.  
  436.    
  437.  
  438. ;Sleep(5000)
  439.  
  440. ; #FUNCTION# ====================================================================================================================
  441. ; Name ..........: _GetDateVba
  442. ; Description ...:
  443. ; Syntax ........: _GetDateVba($DATE, $Type)
  444. ; Parameters ....: $DATE                - A binary value.
  445. ;                  $Type                - A dll struct value.day: "dd" ,motht:"mm", year:"yyyy" or "yy"
  446. ; Return values .: None
  447. ; Author ........: FOREST
  448. ; Modified ......:
  449. ; Remarks .......:
  450. ; Related .......:
  451. ; Link ..........:
  452. ; Example .......: No
  453. ; ===============================================================================================================================
  454. Func _GetDateVba($DATE,$Type);a valid date format
  455. _DebugPrint("Start _GetDateVba"  )
  456.     ;If _DateIsValid($DATE) Then
  457.       $RESULT = StringRegExp($DATE,"\d\d[/.]\d\d[/.]\d\d\d\d",3)
  458.       $RESULT=StringSplit($DATE,".")
  459.         If not @error=0 Then Exit ; Проверка ошибки ОБЯЗАТЕЛЬНА.
  460. ;~        _ArrayDisplay($RESULT, "флаг=3")
  461. ;Return $RESULT
  462.  if $Type="dd" then $zn=$RESULT[1]
  463.  if $Type="mm" then $zn=$RESULT[2]
  464.  if $Type="yyyy" then $zn=$RESULT[3]
  465.  if $Type="yy" then $zn=StringTrimLeft($RESULT[3],2)
  466.     _DebugPrint("Stop _GetDateVba" & $zn )
  467.    Return $zn
  468. EndFunc
  469. ; #FUNCTION# ====================================================================================================================
  470. ; Name ..........: _SetDateAutoIt
  471. ; Description ...:
  472. ; Syntax ........: _SetDateAutoIt($DATE)
  473. ; Parameters ....: $DATE                - A binary value.
  474. ; Return values .: None
  475. ; Author ........: FOREST
  476. ; Modified ......:
  477. ; Remarks .......:
  478. ; Related .......:
  479. ; Link ..........:
  480. ; Example .......: No
  481. ; ===============================================================================================================================EndFunc
  482. Func _SetDateAutoIt($DATE)
  483. ;~  Посмотреть здесь
  484. ;~ https://stackoverflow.com/questions/15491894/regex-to-validate-date-format-dd-mm-yyyy   
  485.    
  486. ;~ VBA- dd.mm.yyyy
  487. ;~Autoit-yyyy/mm/dd
  488. $DATE=_GetDateVba($DATE,'yyyy')&"/"&_GetDateVba($DATE,'mm')&"/"&_GetDateVba($DATE,'dd')
  489. if not _DateIsValid($DATES) Then
  490.     Return 0
  491.     exit   
  492. EndIf
  493.  
  494. Return  $DATEAI
  495. EndFunc
  496. ; #FUNCTION# ====================================================================================================================
  497. ; Name ..........: _SetDateVBA
  498. ; Description ...:
  499. ; Syntax ........: _SetDateVBA($Period, $Sleep)
  500. ; Parameters ....: $Period              - A pointer value.
  501. ;                  $Sleep               - A string value.
  502. ; Return values .: None
  503. ; Author ........: FOREST
  504. ; Modified ......:
  505. ; Remarks .......:
  506. ; Related .......:
  507. ; Link ..........:
  508. ; Example .......: No
  509. ; ===============================================================================================================================
  510. func _SetDateVBA($Period,$Sleep)
  511. Send("{LEFT}")
  512.  $data=_GetDateVba($Period,"dd")
  513. _LogAndPrintDebug($hLog, "dd"  & $data , 6)
  514.  
  515. Sleep($Sleep)
  516.  _SendText($data,0,$Sleep)
  517.  
  518. $data=_GetDateVba($Period,"mm")
  519. _LogAndPrintDebug($hLog, "mm"  & $data , 6)
  520.  _SendText($data,0,$Sleep)
  521.  
  522. $data=_GetDateVba($Period,"yyyy")
  523. _LogAndPrintDebug($hLog, "yyyy"  & $data , 6)
  524.  _SendText($data,0,$Sleep)
  525.  endfun ;=>_SetDateVBA
  526. EndFunc
  527.  
  528.  
  529. func  _SendDateVba($DATE,$myTAB,$sleep)
  530.     _DebugPrint("Start _SendDateVba"  )
  531. $data=_GetDateVba($DATE,"dd") & _GetDateVba($DATE,"mm") &_GetDateVba($DATE,"yyyy")
  532. _SendText($data,$myTAB,$sleep)
  533. EndFunc
  534. ; #FUNCTION# ====================================================================================================================
  535. ; Name ..........: todayVBA
  536. ; Description ...: Возвращает сегодняшнюю дату в форме дд.мм.гггг
  537. ; Syntax ........: todayVBA()
  538. ; Parameters ....: None
  539. ; Return values .: Возвращает сегодняшнюю дату в форме дд.мм.гггг
  540. ; Author ........: FOREST
  541. ; Modified ......:
  542. ; Remarks .......:
  543. ; Related .......:
  544. ; Link ..........:
  545. ; Example .......: No
  546. ; ===============================================================================================================================endFunc
  547. Func todayVBA() ; Возвращает сегодняшнюю дату в форме дд.мм.гггг
  548.     Return (@MDAY & "." & @MON & "." & @YEAR)
  549. EndFunc
  550.  
  551. Func NOWVBA() ; Возвращает сегодняшнюю дату в форме дд.мм.гггг
  552.     Return (@MDAY & "." & @MON & "." & @YEAR )
  553. EndFunc
  554.  
  555. func FormatZvit($QFind,$title,$titleListBox,$text,$INSBooton,$INSTextBox,$INSListBox)
  556. _DebugPrint('Start FormatZvit' & $QFind )
  557. $r=0
  558.  
  559. _ClikCommandBootonInstance($title, "","V8FormElement",$INSBooton)
  560. _ClikListBoxList($titleListBox,$text,"{END}","V8Grid",$INSListBox,100)
  561. $QEND=ocClipGet($title,$text,3,"V8FormElement",$INSTextBox,100)
  562. ;~ _DebugPrint('Получено-$QEND-' & $QEND )
  563.  
  564. _DebugPrint('Получить-$QStart для-' & $INSListBox  )
  565. _ClikCommandBootonInstance($title, "","V8FormElement",$INSBooton)
  566. _ClikListBoxList($titleListBox,$text,"{Home}","V8Grid",$INSListBox,100)
  567. $QStart=ocClipGet($title,$text,3,"V8FormElement",$INSTextBox,100)
  568.  
  569. $k=0
  570. $QTek=$QStart
  571. Do
  572. $textSend="{Home}"
  573. _DebugPrint( $k )
  574.  if $k <> 0 then
  575.     $textSend="{DOWN " & $k & "}"
  576.   Else
  577.    $textSend="{Home}"
  578.  endif
  579. _ClikCommandBootonInstance($title, "","V8FormElement",$INSBooton)
  580. _ClikListBoxList($titleListBox,$text,$textSend,"V8Grid",$INSListBox,100)
  581. $QTek=ocClipGet($title,$text,3,"V8FormElement",$INSTextBox,100)
  582.  
  583. ;~ _DebugPrint(" Текущий $QTek-" & $QTek)
  584. ;_DebugPrint( $QDOWN )
  585. sleep(3000)
  586. if  $QFind=$QTek then
  587. _DebugPrint('Получено-$QTek' & $QTek )
  588.    Send("{CTRLDOWN}{ENTER}{CTRLUP}")
  589. $r=1
  590.   ExitLoop
  591.  
  592.    endif
  593. sleep(3000)
  594. $textSend="{Home}"
  595. _ClikCommandBootonInstance($title, "","V8FormElement",$INSBooton)
  596. _ClikListBoxList($titleListBox,$text,$textSend,"V8Grid",$INSListBox,100)
  597.  
  598.    $k=$k+1
  599. Until $QEND=$QTek
  600. return $r
  601.  
  602. endfunc
  603.  
  604. Func _ClikCommandBootonInstance($title, $text, $CLASS,$INSBooton)
  605.     _DebugPrint('Сформировать-' & $INSBooton )
  606. _ControlFocusINSTANCE($title, "","V8FormElement",$INSBooton)
  607. Send("{ENTER}")
  608. EndFunc
  609.  
  610.  
  611. Func ocClipGet($title,$text,$myTAB,$CLASS,$INSTextBox,$sleep)
  612.    
  613. ;~ ControlFocus($title, "", "[CLASS:V8FormElement; INSTANCE:" & $INSBooton & "]")
  614. ;~ $myTAB=3
  615.  
  616. ;~ Send("{ENTER}")
  617. ;~ sleep(1000)
  618. ;~ WinWait($titlemodal,$text)
  619. ;~ If Not WinActive($titlemodal,$text) Then WinActivate($titlemodal,$text)
  620. ;~ WinWaitActive($titlemodal,$text)
  621.  
  622. ;~ Send($textSend)
  623. ;~ Send("{ENTER}")
  624.  
  625. ;~ sleep(1000)
  626. WinWait($title,$text)
  627. If Not WinActive($title,$text) Then WinActivate($title,$text)
  628. WinWaitActive($title,$text)
  629.  
  630. ;~ Эпуляция вызова контексного меню и копировать
  631. _ControlFocusINSTANCE($title, $text, $CLASS,$INSTextBox)
  632. $pos = MouseGetPos()
  633. $var=PixelGetColor ( $pos[0] , $pos[1] )
  634. _LogAndPrintDebug($hLog, "The decmial color is" & $var,6 )
  635. ;~ MsgBox(0, $var, $pos[0] & "," & $pos[1])
  636. _ControlFocusINSTANCE($title, "", "V8Grid",2)
  637. _SendText("+{F10}",0,1000)
  638. ;~ _SendText("{RIGHT}",0,1000)
  639. ;~ ControlClick($title, "", _ClassInstance($CLASS,$INSTextBox), "right")
  640.  
  641.  
  642.  
  643. Sleep(3000)
  644. Send("{DOWN " & $myTAB & "}{ENTER}")
  645. $QClipGet=ClipGet ( )
  646. Sleep($sleep)
  647.    return $QClipGet
  648.    EndFunc
  649.  func _ControlSendINSTANCE($title, $text, $CLASS,$INS,$SendText)
  650. ControlSend($TitleFullFind, "", _ClassInstance($CLASS,$INS), $SendText)
  651. EndFunc
  652.  
  653.  
  654. func _ClassInstance($CLASS,$INS)
  655.     $ClIns="[CLASS:" & $CLASS & "; INSTANCE:" & $INS & "]"
  656.     return $ClIns
  657. EndFunc
  658.  
  659.     func _ControlFocusINSTANCE($title, $text, $CLASS,$INS)
  660.        
  661.     ControlFocus($title, $text, _ClassInstance($CLASS,$INS))
  662.     Sleep(200)
  663.     EndFunc
  664.  
  665.  
  666. Func _fileExistAndOpen($hLog,$FileFullPath,$msg=False)
  667.    local $z
  668.    
  669.     $file = FileOpen($FileFullPath, 0)
  670.  
  671. ; Check if file opened for reading OK
  672. If $file = -1 Then
  673.   if $msg then  MsgBox(0, "Ошибка", "Файл по пути " & $FileFullPath & " не найден")
  674.  
  675. _Log_Report($hLog, "Ошибка! Файл по пути " & $FileFullPath & " не найден", 6)
  676. $z=-1
  677. ;~  _Log_Close($hLog)
  678. return $z
  679.     Exit
  680. EndIf
  681. FileClose($file)
  682. _Log_Report($hLog, "Файл по пути " & $FileFullPath & " найден", 6)
  683. ConsoleWrite("Файл по пути " & $FileFullPath & " найден" & @CRLF)
  684. $z=0
  685. ;~  _Log_Close($hLog)
  686. return $z
  687.  
  688. EndFunc
  689.  
  690. Func _WorkbookCloseEndDelete($hLog,$FullPath)
  691.     _LogAndPrintDebug($hLog, "Start _WorkbookCloseEndDelete:-"  & "(" & $FullPath & ")" , 6)
  692. ;~ **************************************************
  693. ;Удалим файл звита
  694.  
  695.   If FileExists($FullPath) Then
  696. _LogAndPrintDebug($hLog, "Файл есть _WorkbookCloseEndDelete:-"  & "(" & $FullPath & ")" , 6)   
  697. ;~ _DebugPrint("FileExists($FullPath)" & $FullPath & "-" & FileExists($FullPath))
  698.  
  699.     $R=_myIsOpen($FullPath)
  700. ;~   _DebugPrint("_myIsOpen-" & $FullPath & "-" & $R)
  701.     if $R then
  702.     _LogAndPrintDebug($hLog, "Файл есть и открыт  _WorkbookCloseEndDelete:-"  & "(" & $FullPath & ")" , 6)  
  703.  
  704.     $oWorkbook=_InitWorkbook($FullPath)
  705.    
  706.     if @error then _DebugPrint("error_InitWorkbook" & @error)
  707.     _ExcelBookClose($oWorkbook)
  708.     if @error then
  709.         _DebugPrint("error_ExcelBookClose" & @error)
  710.         else
  711.     _DebugPrint('файл Закрыт')
  712.     endif
  713.     endif
  714.    
  715.    $q= FileDelete($FullPath)
  716.     if $q then 
  717.         _DebugPrint('файл удален')
  718.         return 1
  719.        
  720.         else
  721.         _DebugPrint("Невозможно удалить файл " & $q & "Возможно он открыт в другой программе")
  722.         return 0
  723.     EndIf
  724.     else
  725.     return 1   
  726. EndIf
  727. _LogAndPrintDebug($hLog, "Stop[  _WorkbookCloseEndDelete:-"  & "(" & $FullPath & ")" , 6)  
  728.  
  729. EndFunc
  730. Func _WorkbookCloseEndDelete1($FullPath)
  731.    
  732. ;~ **************************************************
  733. ;Удалим файл звита
  734.  
  735.   If FileExists($FullPath) Then
  736.    
  737.    $q= FileDelete($FullPath)
  738.  if $q=0 then
  739.     $R=_myIsOpen($FullPath)
  740.    
  741. if $R then
  742.     $oWorkbook=_ExcelAttach($FullPath)
  743.     _DebugPrint(ObjName($oWorkbook,1))
  744.     _ExcelBookClose($oWorkbook)
  745.     $q= FileDelete($FullPath)
  746.     if $q=0 then
  747.         MsgBox(4096, "Test", "Невозможно удалить файл " & $q & "Возможно он открыт в другой программе", 10)
  748.         return 0
  749.      exit
  750.         endif
  751.     else
  752.        
  753.      MsgBox(4096, "Test", "Невозможно удалить файл " & $q & "Возможно он открыт в другой программе", 10)
  754.     return 0
  755.      exit
  756.     endif
  757. EndIf
  758. EndIf
  759. return 1
  760. EndFunc
  761. ;~ Переход к первому элементу Выбор периода
  762. Func _GetNetworkConnect($hLog)
  763.     Local Const $NETWORK_ALIVE_LAN = 0x1  ;net card connection
  764.     Local Const $NETWORK_ALIVE_WAN = 0x2  ;RAS (internet) connection
  765.     Local Const $NETWORK_ALIVE_AOL = 0x4  ;AOL
  766.  
  767.     Local $aRet, $iResult
  768.  
  769.     $aRet = DllCall("sensapi.dll", "int", "IsNetworkAlive", "int*", 0)
  770.  
  771.     If BitAND($aRet[1], $NETWORK_ALIVE_LAN) Then $iResult &= "LAN connected" & @LF
  772.     If BitAND($aRet[1], $NETWORK_ALIVE_WAN) Then $iResult &= "WAN connected" & @LF
  773.     If BitAND($aRet[1], $NETWORK_ALIVE_AOL) Then $iResult &= "AOL connected" & @LF
  774. If $iResult Then
  775. ;~     MsgBox(64, "Connections", $connect)
  776. ConsoleWrite($iResult & @CRLF)
  777. _Log_Report($hLog, "Соединения с интернетом присутствует" & @CRLF , 6)
  778. Else
  779.     ConsoleWrite( "Нет соединения с интернетом" & @CRLF)
  780. _Log_Report($hLog, "Ошибка! Нет соединения с интернетом "  , 6)
  781.  Exit
  782. EndIf
  783.     Return $iResult
  784. EndFunc
  785.  
  786. Func _SaveReportAsExcel($Title,$ControlFocusINSTANCE,$myTAB,$mova,$PathWorkBooks)
  787.  _LogAndPrintDebug($hLog, "start _SaveReportAsExcel-" & $PathWorkBooks, 6)
  788. if FileExists($PathWorkBooks)=1 then
  789.     _LogAndPrintDebug($hLog, "FileDelete " & $PathWorkBooks & "Завершен" , 1)
  790.      FileDelete($PathWorkBooks)
  791. EndIf
  792.    
  793. ;~ ControlFocus($ZVShodens, "", "[CLASS:V8FormElement; INSTANCE:16]")
  794. _ControlFocusINSTANCE($Title, "","V8FormElement",$ControlFocusINSTANCE)
  795. ;*****************************************
  796.  
  797. ;переход до Сохранить в Excel
  798. ;переход до в Excel
  799. _SendTabEnter($myTAB,5000)
  800. _activatewindow(_mova_Get_file($mova),"",1000,1)
  801.  
  802. ;переход до Сохранить
  803. _SendTabEnter(3,5000)
  804.  
  805. _activatewindow(_mova_Save_file($mova),"",1000,1)
  806. ;Вводим имя файла
  807. _SendText($PathWorkBooks,0,500)
  808. ;потверждаем имя
  809. _SendTabEnter(2,2000)
  810. _SendESC(2000)
  811. ;*****************************************
  812. _DebugPrint( "Отчет сохранен" )   
  813. _LogAndPrintDebug($hLog, "stop _SaveReportAsExcel" , 6)
  814. EndFunc
  815. ;~ Func _LogAndPrintDebug($hLog,$Text,$Steep)
  816. ;~  _Log_Report($hLog, $Text, $Steep)
  817. ;~  _DebugPrint($Text)
  818. ;~  
  819. ;~ EndFunc
  820. ;~ Func IsVisible($handle)
  821. ;~   If BitAnd( WinGetState($handle), 2 ) Then
  822. ;~     Return 1
  823. ;~   Else
  824. ;~     Return 0
  825. ;~   EndIf
  826.  
  827. ;~ EndFunc
  828.  
  829. Func _WindowEOFind($hLog,$TitleFullFind,$FindString,$ColumnNameFind,$AppTitleFullString="",$FindControlCls="",$FindControlIns="")
  830. ;~                 $hLog,$TitleFullFind,$zn.value,$GrupString,$AppTitleFullString,$FindControlCls,$FindControlIns
  831.     ;~ ***********************************************
  832. ;~ Работа с формой найти
  833. _LogAndPrintDebug($hLog,"Начало работы с формой найти: Ищем-" & $FindString & " в " & $ColumnNameFind,6 )
  834. $QEND=""
  835. ClipPut("")
  836. _SendText("{CTRLDOWN}F{CTRLUP}",0,500)
  837. ;~ Где ищем
  838. _activatewindow($TitleFullFind,"",0,1)
  839. _ControlFocusINSTANCE($TitleFullFind, "","V8FormElement",15)
  840. _ControlSendINSTANCE($TitleFullFind, "","V8FormElement",15, $ColumnNameFind)
  841. sleep(500)
  842. Send("{DOWN}{ENTER}")
  843. ;~ Что ищем
  844. _ControlFocusINSTANCE($TitleFullFind, "","V8FormElement",17)
  845. sleep(500)
  846. _ControlSendINSTANCE($TitleFullFind, "","V8FormElement",17, $FindString)
  847. ;~ Подтверждаем
  848. _activatewindow($TitleFullFind,"",0,1)
  849. sleep(500)
  850. Send("{CTRLDOWN}{ENTER}{CTRLUP}")
  851. ;~ ***********************************************
  852. if $AppTitleFullString<>"" then
  853. _LogAndPrintDebug($hLog,"Проверка найденого значения-"  & $FindString ,6 )
  854. sleep(10000)
  855. _SendText("{ENTER}",0,500)
  856. ;~ $QEND=_CtrlC($hLog,3,$AppTitleFullString,$FindControlCls,$FindControlIns)
  857. $QEND=WinWait($AppTitleFullString, "", 10)
  858. _LogAndPrintDebug($hLog,"Значение  ожидания окна-" & $AppTitleFullString  & "-" & $QEND ,6 )
  859. _SendText("{ESC}",0,500)
  860.     Return $QEND
  861.     endif
  862. EndFunc
  863.  
  864. Func _CtrlC($hLog,$myTAB,$AppTitleFullString,$FindControlCls,$FindControlIns)
  865. ;~  Эмуляция Ctrl+C через клавишу контексного меню
  866. ;~  $myTAB=3
  867.  
  868. ;~ При ошибке значение @error устанавливается равным 1 (буфер пуст), 2 (буфер не содержит текст), 3 или 4 (доступ к буферу обмена отсуствует), иначе 0
  869. _LogAndPrintDebug($hLog,"Значение буфера перед"  & ClipGet () ,6 )
  870. _activatewindow($AppTitleFullString,"",0,1)
  871. _ControlFocusINSTANCE($AppTitleFullString, "",$FindControlCls,$FindControlIns)
  872. ;~ _SendText("{APPSKEY}",0,10000)  
  873. ;~ _SendText("{TAB " & $myTAB & "}",0,10000)
  874. ;~ _SendText("{ENTER}",0,10000)
  875.  
  876. _SendText("^с",0,10000)   
  877. ;~ Send("{TAB " & $myTAB & "}{ENTER}")
  878.  
  879. $QEND=ClipGet ()
  880. _LogAndPrintDebug($hLog,"Значение буфера после"  & $QEND ,6 )
  881. _LogAndPrintDebug($hLog,"Значение буфера @error"  & @error ,6 )
  882. Return $QEND
  883. EndFunc
  884.  
  885. Func _WindowEOTitleKvartalnaSetka($AppTitleIns,$find,$FindString)
  886.     Select
  887.     Case $AppTitleIns = 1
  888.     $WindowEOTitleFindString=$Find & " (" & $FindString & ")"
  889.     Case $AppTitleIns = 2
  890.     $WindowEOTitleFindString=$Find & " (" & $FindString & ")"  
  891.     Case $AppTitleIns = 3
  892.     $WindowEOTitleFindString=$Find & " (" & $FindString & ")"  
  893.     Case $AppTitleIns = 4
  894.     $WindowEOTitleFindString=$Find & " (" & $FindString & ")"  
  895.     EndSelect
  896.     return $WindowEOTitleFindString
  897. EndFunc
  898.  
  899. Func _WindowEOSaveAS($hLog,$Title,$Path,$TypeType)
  900. ;~ Эмуляция вызова меню сохранить как
  901. ;~ Сохранение по пути
  902. ;~ Выбор типа файла
  903. ;~ Send("^s")
  904. ;~ $TypeType=3 -(*.xls)
  905. ;~  $R=_WorkbookCloseEndDelete($Path)
  906. _LogAndPrintDebug($hLog,"Эмуляция вызова меню сохранить как-" & $PathList,6)
  907.  _SendText("{Alt}",0,500)
  908.  _SendText("{Down}",0,500)
  909.  _SendText("{RIGHT}",0,500)
  910.  _SendText("{Down 3}",0,500)
  911.  _SendText("{ENTER}",0,500)
  912. _activatewindow($Title,"",0,100)
  913.  
  914. _ControlFocusINSTANCE($Title, "","ComboBox",3)
  915. ControlCommand ( $Title, "",_ClassInstance("ComboBox",3), "SetCurrentSelection" , $TypeType)
  916. _ControlFocusINSTANCE($Title, "","Edit",1)
  917. ControlCommand ( $Title, "",_ClassInstance("Edit",1), "EditPaste",  $Path )
  918. sleep(500)
  919. $R=_WorkbookCloseEndDelete($Path)
  920. _LogAndPrintDebug($hLog,"_WorkbookCloseEndDelete-" & $R,6)
  921. ControlClick( $Title, "", _ClassInstance("Button",2))
  922. sleep(500)
  923.  
  924.  
  925. EndFunc
  926.  Func _CreateNewSetka($hLog,$Title,$TitleClass,$TitleIns,$TitleNew,$TitleNewClass,$TitleNewIns,$SendText,$PL="")
  927. _LogAndPrintDebug($hLog,$Title & "-" &  $SendText ,6 ) 
  928.    
  929. _ControlFocusINSTANCE($Title, "",$TitleClass,$TitleIns)
  930. _SendText("{INS}",0,500)
  931. _activatewindow($TitleNew,"",0,1)
  932.  _ControlFocusINSTANCE($TitleNew, "",$TitleNewClass,$TitleNewIns)
  933. sleep(1000)
  934. _SendText($SendText,0,500)
  935. if $PL<>"" then
  936.     sleep(1000)
  937. _ControlFocusINSTANCE($TitleNew, "",$TitleNewClass,9)
  938. _SendText($PL,0,500)   
  939.  
  940.     endif
  941.  
  942. Send("{CTRLDOWN}{ENTER}{CTRLUP}")  
  943.  
  944.    
  945. EndFunc
  946.  
  947. ;~ func _LogAndPrintDebug($hLog,$Text,$Num)
  948. ;~  _Log_Report($hLog, $Text  , $Num)
  949. ;~  _DebugPrint($Text)
  950. ;~ EndFunc
  951. Func _WindowSizeMove($hLog,$Title, $text="",$Pozish="")
  952.    
  953. ;~ Расположение и размеры
  954. ;~ ""- во весь экран(defaul)
  955. ;~ 1 нижняя левая четверть
  956. ;~ 2 нижняя половина
  957. ;~ 3 нижняя правая
  958. ;~ 4 левая половина
  959. ;~ 5
  960. ;~ 6 правая половина
  961. ;~ 7 верхняя левая четверть
  962. ;~ 8 верхняя половина
  963. ;~ 9 Верхняя правая четверть
  964. $W=WinGetPos($Title )
  965. Local  $tRECT  =  _WinAPI_GetWorkArea ()
  966. Local  $iWidth  =  DllStructGetData ( $tRECT ,  'Right' )  -  DllStructGetData ( $tRECT ,  'Left' )
  967. Local  $iHeight  =  DllStructGetData ( $tRECT ,  'Bottom' )  -  DllStructGetData ( $tRECT ,  'Top' )
  968. Local  $X  =  DllStructGetData ( $tRECT ,  'Left' )
  969. Local  $Y  =  DllStructGetData ( $tRECT ,  'Top' )
  970.  
  971.  _LogAndPrintDebug($hLog, "$iHeight-"  & $iHeight , 6) 
  972.  
  973. ;~ ConsoleWrite($aTray[3] & @LF)
  974.  
  975. Select
  976. case $Pozish=""
  977. WinMove ($Title, "", 0, 0, $iWidth, $iHeight )
  978.     _LogAndPrintDebug($hLog, "@Desktop_Window"  & $iWidth& " "& @DesktopHeight , 6)
  979. case $Pozish=1
  980. WinMove ($Title, "", 0, $iHeight/2, $iWidth/2, $iHeight/2 )
  981.     _LogAndPrintDebug($hLog, "@Desktop_Window"  & $iWidth /2 & " "& $iHeight/2 , 6)
  982.    
  983. case $Pozish=2
  984. WinMove ($Title, "", 0, $iHeight/2, $iWidth, $iHeight/2 )  
  985. case $Pozish=3
  986. WinMove ($Title, "", $iWidth/2, $iHeight/2, $iWidth/2, $iHeight/2 )
  987. case $Pozish=4
  988. WinMove ($Title, "", 0, 0, $iWidth/2, $iHeight )   
  989. case $Pozish=5
  990. case $Pozish=6
  991. WinMove ($Title, "", $iWidth/2, 0, $iWidth/2, $iHeight )   
  992. _LogAndPrintDebug($hLog, "@Desktop_Window"  & $iWidth /2 & " "& $iHeight , 6)
  993.  
  994. case $Pozish=7
  995. WinMove ($Title, "", 0, 0, $iWidth/2, $iHeight/2 ) 
  996. case $Pozish=8
  997. WinMove ($Title, "", 0, 0, $iWidth, $iHeight/2 )   
  998. case $Pozish=9                             
  999. WinMove ($Title, "", $iWidth/2, 0, $iWidth/2, $iHeight/2 ) 
  1000.    
  1001.    
  1002.    
  1003.    
  1004.    
  1005.    
  1006.    
  1007.    
  1008.    
  1009.    
  1010.        
  1011. EndSelect  
  1012.    
  1013. EndFunc
  1014.  
  1015. Func _SearchSprav1C($hLog,$WhatFind,$SearchOrder,$TitleSprav)
  1016.     _LogAndPrintDebug($hLog, "Start  _SearchSprav1C-"   , 6)
  1017. $sFind="Знайти"
  1018.  
  1019.  
  1020. ;~ Send("{CTRLDOWN}F{CTRLUP}"); -Поиск
  1021. Send("^f"); -Поиск
  1022. $TitleFind_Window=_WindowEOFullTitle($eod,$Login,$sFind,$LinkName);-"E0D Звенигородське ЛГ.Найти - ЛІАЦ"
  1023. _LogAndPrintDebug($hLog, "Поиск в " & $TitleFind_Window  , 6)
  1024. ;~ WinWait($TitleFind_Window)
  1025. _activatewindow($TitleFind_Window,"",0,1)
  1026. sleep(1000)
  1027. _ControlFocusINSTANCE($TitleFind_Window, "", "V8FormElement",15);ГдеИскать
  1028. _SendText($SearchOrder,0,1000); ГдеИскать
  1029. _LogAndPrintDebug($hLog, "ГдеИскать-"  & $SearchOrder , 6)
  1030. sleep(1000)
  1031. _ControlFocusINSTANCE($TitleFind_Window, "", "V8FormElement",17); Что искать
  1032.  
  1033. _LogAndPrintDebug($hLog, "Что искать-"  & $WhatFind , 6)
  1034. _SendText($WhatFind,0,1000); Что искать
  1035. _LogAndPrintDebug($hLog, "Что искать-"  & $WhatFind , 6)
  1036.  
  1037.  
  1038.  
  1039. ;~ _ControlFocusINSTANCE($TitleFind_Window, "", "V8CommandBar",1)
  1040.  _SendTabEnter(2,3000)
  1041.  
  1042. ;~  _SendText("{CTRLDOWN}{ENTER}{CTRLUP}",0,3000)
  1043.  
  1044. $re=WinExists( $TitleFind_Window, "" )
  1045.  
  1046. _LogAndPrintDebug($hLog, $TitleFind_Window & " -"  & $re , 6)
  1047.  
  1048. if $re=1 then
  1049. ;~  _LogAndPrintDebug($hLog, "WinKill 1С:Предприятие-"  & $r , 6)
  1050. $z=WinKill ($TitleFind_Window, "" )
  1051. endIf
  1052.  
  1053. _activatewindow($TitleSprav,"",0,1)
  1054.  
  1055. _LogAndPrintDebug($hLog, "Stop  _SearchSprav1C-"   , 6)
  1056. EndFunc
  1057. Func _OpenSprav1C($hLog,$Window_Create_Title,$TitleSprav,$CLASS,$INS)
  1058.     _LogAndPrintDebug($hLog, "Start  _OpenSprav1C-"   , 6)
  1059. _activatewindow($Window_Create_Title,"",0,1)
  1060. _ControlFocusINSTANCE($Window_Create_Title, "", $CLASS,$INS)
  1061. _SendText("{F4}",0,100);-Открыть справочник
  1062. _activatewindow($TitleSprav,"",0,1)
  1063. _LogAndPrintDebug($hLog, "Stop  _OpenSprav1C-"   , 6)
  1064.    
  1065. EndFunc
  1066.  
  1067. func _1C_Find($WhatFind,$SearchOrder,$FindYesNumber,$FindReturnNumber,$FindYesText,$bClose,$VNaydenom)
  1068. ;~ $sFind="Знайти"
  1069. $sFind=_mova_find($mova)
  1070.  
  1071.  
  1072. _ControlFocusINSTANCE($AppTitle, "","V8Grid",1)
  1073. _SendText("{RIGHT}",0,1000)
  1074. ;~ Send("{CTRLDOWN}F{CTRLUP}"); -Поиск
  1075. Send("^f"); -Поиск
  1076. $TitleFind_Window=_WindowEOFullTitle($eod,$Login,$sFind,$LinkName);-"E0D Звенигородське ЛГ.Найти - ЛІАЦ"
  1077.  _LogAndPrintDebug($hLog, "Поиск в " & $TitleFind_Window  , 6)
  1078. ;~ WinWait($TitleFind_Window)
  1079. _activatewindow($TitleFind_Window,"",0,1)
  1080. _ControlFocusINSTANCE($TitleFind_Window, "", "V8FormElement",15);ГдеИскать
  1081.  
  1082. _SendText($SearchOrder,0,100); ГдеИскать
  1083. _ControlFocusINSTANCE($TitleFind_Window, "", "V8FormElement",17); Что искать
  1084. _SendText($WhatFind,0,100); Что искать
  1085. if $VNaydenom=1 Then
  1086. ;~  _ControlFocusINSTANCE($TitleFind_Window, "", "V8FormElement",9)
  1087.     Sleep(100)
  1088.     _SendText("{TAB 2}{SPACE}",0,100)
  1089. ;~  MsgBox(4096, "Test", $WhatFind)
  1090. EndIf
  1091. ;~ _ControlFocusINSTANCE($TitleFind_Window, "", "V8CommandBar",1)
  1092.  _SendTabEnter(1,3000)
  1093. ;~ _ControlFocusINSTANCE($AppTitle, "","V8Grid",1)
  1094. _SendText("{ENTER}",0,1000)
  1095.  
  1096. ;~ _SendText("{RIGHT}",0,1000)
  1097. Sleep(5000)
  1098. $QEND=WinGetTitle("[active]")
  1099. $mNumberDogFind=StringSplit($QEND," ")
  1100. ;~  MsgBox(0, "Пример",$mNumberDogFind[$FindReturnNumber] )
  1101. if $mNumberDogFind[0]<$FindYesNumber then
  1102. ;~ MsgBox(0, "Не соответствует ",$mNumberDogFind[0])
  1103.  
  1104. $report=0  
  1105. return $report
  1106. exit Func
  1107. EndIf
  1108. ;~ MsgBox(0, "Возвращаемое значение",$mNumberDogFind[$FindYesNumber])
  1109. _LogAndPrintDebug($hLog, "Возвращаемое значение"& $mNumberDogFind[$FindYesNumber]  , 6)
  1110. _LogAndPrintDebug($hLog, "Значение для сравнения"& $FindYesText  , 6)
  1111. If $mNumberDogFind[$FindYesNumber]= $FindYesText   then
  1112. ;~  MsgBox(0, "Пример",$mNumberDogFind[$FindReturnNumber])
  1113.    
  1114.     if $bClose=1 then WinClose($QEND,"")
  1115.     $report=$QEND
  1116.     return $report
  1117.     Else
  1118. ;~  MsgBox(0, "Пример","ПЕЧАЛЬКА")   
  1119.         $report=0
  1120. ;~      exit
  1121.         endif
  1122.     return $report
  1123.    
  1124.        
  1125.     EndFunc
  1126.    
  1127.    
  1128.     ; #FUNCTION# ====================================================================================================================
  1129. ; Name ..........: _FindBoID
  1130. ; Description ...:  Вставка значения в поле из справочника с поиском по коду
  1131. ; Syntax ........: _FindBoID($TitleFind, $WhatFind, $SearchOrder)
  1132. ; Parameters ....: $TitleFind           - Заголовок Справочника поиска.
  1133. ;                  $WhatFind            - Что искать.
  1134. ;                  $SearchOrder         - Где Искать.
  1135. ; Return values .: None
  1136. ; Author ........: FOREST
  1137. ; Modified ......: 10.01.2018
  1138. ; Remarks .......:
  1139. ; Related .......:
  1140. ; Link ..........:
  1141. ; Example .......:
  1142. ;~ $TitleFind="Продукція"; Заголовок Справочника поиска
  1143. ;~ $WhatFind=$KodSortyment; Что искать
  1144. ;~ $SearchOrder="Код"; Где Искать
  1145. ; ===============================================================================================================================
  1146. Func _FindBoID($TitleFind,$WhatFind,$SearchOrder)
  1147. ;~ Вставка значения в поле из справочника с поиском по коду
  1148. Send("{F4}")
  1149. ;~ Sleep(3000)
  1150. ;~ if $TitleFind<>"" Then
  1151. ;~ $TitleFind=WinGetTitle("[active]")    
  1152.     _activatewindow($TitleFind,"",0,1)
  1153. ;~  
  1154. ;~ EndIf
  1155.  
  1156. $sFind=_mova_find($mova)
  1157.  
  1158. Send("^f"); -Поиск
  1159. $TitleFind_Window=_WindowEOFullTitle($eod,$Login,$sFind,$LinkName);-"E0D Звенигородське ЛГ.Найти - ЛІАЦ"
  1160.  _LogAndPrintDebug($hLog, "Поиск в " & $TitleFind_Window  , 6)
  1161.  
  1162. _activatewindow($TitleFind_Window,"",0,1)
  1163. _ControlFocusINSTANCE($TitleFind_Window, "", "V8FormElement",15);ГдеИскать
  1164.  
  1165. _SendText($SearchOrder,0,100); ГдеИскать
  1166. _ControlFocusINSTANCE($TitleFind_Window, "", "V8FormElement",17); Что искать
  1167. _SendText($WhatFind,0,1000); Что искать
  1168.  _SendTabEnter(3,20000)
  1169. ;~ WinWaitClose($TitleFind_Window,"",10)
  1170.  
  1171.    
  1172. _activatewindow($TitleFind,"",0,1)
  1173. Send("{ENTER}{TAB}")
  1174. EndFunc
  1175.    
  1176.     func _1CFile($bMsg)
  1177.     #region 1CFile
  1178. local $report
  1179. if @OSArch="X86" then
  1180. Global $1Cpath_install  = "C:\Program Files\1cv82\"
  1181. Else
  1182. Global $1Cpath_install  = "C:\Program Files (x86)\1cv82\"  
  1183. endif
  1184. _LogAndPrintDebug($hLog, "1C установлена в" & $1Cpath_install,6 )
  1185. Global $1Cpath_common=$1Cpath_install & "common\"
  1186. Global $1Cpath_conf=$1Cpath_install & "conf\"  
  1187. Global $1CFile_common="1cestart.exe"
  1188. Global $1CFile_conf="conf.CFG"
  1189.  
  1190.  
  1191. FileChangeDir($1Cpath_common);"C:\Program Files (x86)\1cv82"
  1192. $search = FileFindFirstFile ($1CFile_common)
  1193. If $search = -1 Then
  1194.     MsgBox(0, "Error", "Не найден файл " & $1CFile_common)
  1195. SetError(2)
  1196.     Exit
  1197. EndIf
  1198.  
  1199.  
  1200. FileChangeDir($1Cpath_conf);"C:\Program Files (x86)\1cv82"
  1201. $search = FileFindFirstFile ($1CFile_conf)
  1202. If $search = -1 Then
  1203.    if $bMsg=1 then MsgBox(0, "Error", "Не найден файл " & $1CFile_conf)
  1204.     SetError(3)
  1205.     Exit
  1206. EndIf
  1207. Global $1CpathStart=$1Cpath_common & $1CFile_common
  1208. Global $1CpathMova=$1Cpath_conf & $1CFile_conf
  1209. $file = FileOpen($1CpathMova, 0)
  1210.  
  1211. ; Check if file opened for reading OK
  1212. If $file = -1 Then
  1213.  if $bMsg=1 then   MsgBox(0, "Error", "Unable to open file.")
  1214. SetError(3)
  1215.     Exit
  1216. EndIf
  1217.  
  1218. ; Read in lines of text until the EOF is reached
  1219. While 1
  1220.     $line = FileReadLine($file)
  1221.  
  1222.     If @error = -1 Then ExitLoop
  1223. $amovaconf=StringSplit($line,"=")
  1224.    
  1225.  
  1226. Wend
  1227.  
  1228. FileClose($file)
  1229.  
  1230.  
  1231. _LogAndPrintDebug($hLog, "Мова системы-" & @OSLang,6 )
  1232.  
  1233. if $amovaconf[2]="System" then
  1234. Select
  1235.     Case @OSLang = 0419
  1236.         Global $mova="RU"
  1237.     Case @OSLang = 0422
  1238.         Global $mova="UA"
  1239.     Case @OSLang = 0409
  1240.         Global $mova="EN"
  1241. EndSelect
  1242. Else
  1243.     Global $mova=$amovaconf[2]
  1244.    
  1245.    
  1246.  
  1247.  
  1248.  
  1249. ;~ https://forum.infostart.ru/forum83/topic117328/
  1250. ;~ http://www.forum.mista.ru/topic.php?id=758347
  1251.    
  1252.    
  1253.    
  1254.    
  1255.    
  1256.    
  1257.    
  1258.    
  1259.    
  1260.    
  1261.    
  1262.     EndIf
  1263. ;~ MsgBox(0, "Язык 1С", $mova)
  1264.  
  1265. _LogAndPrintDebug($hLog, "Язык 1С-" & $mova,6 )
  1266. Global $iPID1C = "1cv8c.exe"
  1267. _LogAndPrintDebug($hLog, "Имя процесса 1С-" & $iPID1C,6 )
  1268. #endregion 
  1269.     EndFunc
  1270.    
  1271.    
  1272.     func _InitBase($Link="ЛІАЦ", $NumberLogin = "2")
  1273.     if  $Link=="ЛІАЦ" Then
  1274. Global $LinkBase="http://eod.ulk.gov.ua"   
  1275. Global $LinkName="ЛІАЦ"
  1276. Global $eod="E0D"  
  1277.    
  1278.     else
  1279. Global $LinkBase="http://ukrles.ulk.gov.ua"
  1280. Global $LinkName="УкрЛісКонсалтінг"
  1281. Global $eod=""     
  1282.     EndIf
  1283.     _LogAndPrintDebug($hLog, 'Логин -' & $Login,6 )
  1284.     if $NumberLogin <> "" Then $pref = " " & $NumberLogin
  1285.     Global $Login=$lishoz & " ЛГ" & $pref
  1286.        
  1287.     global $AppTitle=_WindowEOAppTitle($eod,$Login,$LinkName)
  1288.    
  1289.    
  1290.     EndFunc
  1291.     func _1CStart($Link="ЛІАЦ", $NumberLogin = "2")
  1292. ;~ if   $Link=="ЛІАЦ" Then
  1293. ;~ Global $LinkBase="http://eod.ulk.gov.ua"
  1294. ;~ Global $LinkName="ЛІАЦ"
  1295. ;~ Global $eod="E0D"   
  1296. ;~  
  1297. ;~  else
  1298. ;~ Global $LinkBase="http://ukrles.ulk.gov.ua" 
  1299. ;~ Global $LinkName="УкрЛісКонсалтінг"
  1300. ;~ Global $eod=""  
  1301. ;~  
  1302. ;~  EndIf
  1303.    
  1304. ;~ Global $LinkBase="http://eod.ulk.gov.ua"
  1305. ;~ Global $LinkName="ЛІАЦ"
  1306. ;~ Global $eod="E0D"
  1307.  
  1308. ;~ Global $LinkBase="http://ukrles.ulk.gov.ua"
  1309. ;~ Global $LinkName="УкрЛісКонсалтінг"
  1310. ;~ Global $eod=""
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318. ;~ Global $linkTatle=$AppTitle
  1319. _InitBase($Link)
  1320. ;~ _AssignNotIsDeclare("linkTatle",$AppTitle,2)
  1321. $pref = ""
  1322. if $NumberLogin <> "" Then $pref = " " & $NumberLogin
  1323. Global $Login=$lishoz & " ЛГ" & $pref
  1324. Global $1C=$eod & " " & $Login & "." & $LinkName
  1325. Global $Param=" /WS" & $LinkBase & ' /N"' & $Login & '" /P' & $Password
  1326.  
  1327.  
  1328.  
  1329.  
  1330.  
  1331.  
  1332.  
  1333.  
  1334. If ProcessExists("1cv8c.exe") Then
  1335. ;~     MsgBox(0, "Пример", "1cv8c.exe is running.")
  1336. _LogAndPrintDebug($hLog, '1С уже запущена  ' ,6 )
  1337. _activatewindow($AppTitle,"",0,1)
  1338. Else
  1339.     Start1C($AppTitle,$1CpathStart, $Param,$hLog)
  1340. EndIf
  1341.  
  1342. #endregion
  1343. endfunc
  1344.  
  1345.  
  1346. Func _URorFisError($edrpu)
  1347.     $var=StringLen($edrpu)
  1348.     Select
  1349.     Case $var = 8
  1350.         return "Юр особа"
  1351.     Case $var = 10
  1352.         return "Физ особа"
  1353.  
  1354.  
  1355.     Case Else
  1356.         return 0
  1357. EndSelect
  1358.  
  1359.    
  1360. EndFunc
  1361.  
  1362. Func _GetTextFromActiveWindow()
  1363.  
  1364. _LogAndPrintDebug($hLog, "_GetTextFromActiveWindow старт" ,6 )
  1365.     ;Get window title, in case we need it
  1366.     $window_title = WinGetTitle("[active]")
  1367.    
  1368.     if $window_title == "" Then
  1369. ;~         SoundPlay(@WindowsDir & "\media\Windows XP Error.wav",1)
  1370.         Exit
  1371. return 0
  1372.     EndIf
  1373.    
  1374.  
  1375.     WinActivate($window_title)
  1376.  
  1377.  
  1378.     ClipPut("") ;Clear the clipboard, so we can check for data when we write to it
  1379.     $readtext = "" ;We'll put new clipboard data in this variable
  1380.    
  1381.     For $i = 1 to 8 Step 1
  1382.        
  1383.         $rand = random (1, 4, 1)
  1384.    
  1385.         Send ("{CTRLDOWN}")
  1386.         ;Try various methods until we get text on the clipboard
  1387.         Switch $rand
  1388.             Case 1
  1389.                 Send("{INS}")
  1390.             Case 2
  1391.                 ControlSend($window_title, "", "", "{INS}")
  1392.             Case 3
  1393.                 Send("c")
  1394.             Case 4
  1395.                 ControlSend($window_title, "", "", "c^")
  1396.         EndSwitch
  1397.    
  1398.         Send ("{CTRLUP}")
  1399.         $readtext = ClipGet() ;Any text on the clipboard?
  1400.         If $readtext <> "" Then
  1401.             return $readtext
  1402.         EndIf
  1403.        
  1404.         If $i = 4 Then
  1405.             WinActivate($window_title)
  1406.             Sleep(100)
  1407.         EndIf
  1408.        
  1409.     Next
  1410.   _LogAndPrintDebug($hLog, "$readtext" & $readtext ,6 )
  1411.     return $readtext
  1412.  
  1413. EndFunc
  1414.  
  1415. Func _RefText()
  1416. Send("{CTRLDOWN}{F11}{CTRLUP}")
  1417. $title_Get_Link=_mova_Get_Link($mova)
  1418. _activatewindow(_mova_Get_Link($mova),"",0,1)
  1419. Send("{TAB}{ENTER}")
  1420. sleep(2000)
  1421. $reftext =ClipGet()
  1422. WinWaitClose($title_Get_Link, "", 5)
  1423. return $reftext
  1424. EndFunc
  1425.  Func _isRef($ReadRef, $RefMask)
  1426. ;~  MsgBox(0, "Line read _isRef:",$ReadRef)
  1427. $result = StringInStr($ReadRef, $RefMask)
  1428. ;~ MsgBox(0, "Line read _isRef:",$result)
  1429. if $result <> 0 then
  1430.     return 1
  1431.     else
  1432.         return 0   
  1433. EndIf
  1434. EndFunc
  1435.  
  1436. Func _isTextDolar($Var,$a=0)
  1437.     if $Var<>"$" then
  1438.         if $a=0 Then
  1439. _SendText($Var,1,1000)
  1440. else
  1441.     $imax=10
  1442. _SetTextFromActiveWindow($Var,$imax)
  1443. Send("{TAB}")  
  1444.         EndIf
  1445.         else
  1446. Send("{TAB}")          
  1447.     EndIf
  1448. EndFunc
  1449. func SetLinkZov($LinkBase,$URLKey,$URLref)
  1450. ;~  http://eod.ulk.gov.ua#e1cib/data/Документ.ЛесорубныйБилет?ref=821600155d0a190411e7efa9c6fc2b19  
  1451. $parm="?ref="
  1452. $link=$LinkBase & "#" & "e1cib/data/" & $URLKey & $parm & $URLref
  1453. return $link
  1454. endfunc
  1455.  
  1456. func SetLinkVnutr($URLKey,$URLref)
  1457. ;~ e1cib/data/Документ.ЛесорубныйБилет?ref=821600155d0a190411e7efa9c6fc2b19
  1458. $parm="?ref="
  1459.  $link="e1cib/data/" & $URLKey & $parm & $URLref
  1460. return $link
  1461. endfunc
  1462.  
  1463.  
  1464. Func _CreateOnePole($WhatFind,$Window_Create_Title,$SearchOrder,$TitleSprav)
  1465. ;~ ~ Создание договора
  1466.  
  1467. _SendText("{F4}",0,100)
  1468.  
  1469.  
  1470.  
  1471. #region OpenSprav1C
  1472. ;---------------------------------------------------------------------------------
  1473. ;~ _1CV83.au3
  1474. _OpenSprav1C($hLog,$Window_Create_Title,$TitleSprav,"V8FormElement",22)
  1475.  _LogAndPrintDebug($hLog, "stop region OpenSprav1C" , 6)
  1476. #endregion
  1477.  
  1478. ;~ Send("{CTRLDOWN}F{CTRLUP}"); -Поиск
  1479.  
  1480. ;------------_SearchSprav1C-------------------------------------------------------------------------------------------
  1481.  #region SearchSprav1C
  1482. ;~ _1CV83.au3
  1483. _SearchSprav1C($hLog,$WhatFind,$SearchOrder,$TitleSprav)
  1484. _LogAndPrintDebug($hLog, "stop region SearchSprav1C" & $WhatFind, 6)
  1485. #endregion
  1486.  
  1487. ;----------Кнопка назначеная по умолчанию в 1С Выбрать---------------------------------------------
  1488. Send("{CTRLDOWN}{ENTER}{CTRLUP}")
  1489. Send("{CTRLDOWN}c{CTRLUP}")
  1490. ;~ Send("{ENTER}")
  1491.  
  1492.    
  1493. EndFunc
  1494.  
  1495. ; #FUNCTION# ====================================================================================================================
  1496. ; Name ..........: GetAllWindowsControls
  1497. ; Description ...: Виводит параметры контролов окна в консоль
  1498. ; Syntax ........: GetAllWindowsControls($hCallersWindow [, $bOnlyVisible=Default [, $sStringIncludes=Default [, $sClass=Default]]])
  1499. ; Parameters ....: $hCallersWindow      - A handle value. Получаем WinGetHandle("[ACTIVE]")
  1500. ;                  $bOnlyVisible        - [optional] A boolean value. Default is Default.
  1501. ;                  $sStringIncludes     - [optional] A string value. Default is Default.
  1502. ;                  $sClass              - [optional] A string value. Default is Default.
  1503. ; Return values .: "Func=ControlCounter(INSTANCE), ControlID,Handle, ClassNN( Class&INSTANCE), XPos,YPos,Width,Height,IsVisible,Text"
  1504. ; Author ........: FOREST
  1505. ; Modified ......:
  1506. ; Remarks .......:
  1507. ; Related .......:
  1508. ; Link ..........: https://www.autoitscript.com/forum/topic/164226-get-all-windows-controls/
  1509. ; Example .......: No
  1510. ; ===============================================================================================================================
  1511. Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default)
  1512.     If Not IsHWnd($hCallersWindow) Then
  1513.         ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF)
  1514.         Return False
  1515.     EndIf
  1516.  Local $aPos = WinGetPos($hCallersWindow)
  1517.  
  1518.     ; Display the array values returned by WinGetPos.
  1519.    ConsoleWrite("$hCallersWindow: " & $hCallersWindow & @CRLF & _
  1520. "X-Pos: "  & $aPos[0] & @CRLF & _
  1521. "Y-Pos: "  & $aPos[1] & @CRLF & _    
  1522. "Width: "  & $aPos[2] & @CRLF & _
  1523. "Height: " & $aPos[3] & @CRLF)
  1524.     ; Get all list of controls
  1525.     If $bOnlyVisible = Default Then $bOnlyVisible = False
  1526.     If $sStringIncludes = Default Then $sStringIncludes = ""
  1527.     If $sClass = Default Then $sClass = ""
  1528.     $sClassList = WinGetClassList($hCallersWindow)
  1529.  
  1530.     ; Create array
  1531.     $aClassList = StringSplit($sClassList, @CRLF, 2)
  1532.  
  1533.     ; Sort array
  1534.     _ArraySort($aClassList)
  1535.     _ArrayDelete($aClassList, 0)
  1536.  
  1537.     ; Loop
  1538.     $iCurrentClass = ""
  1539.     $iCurrentCount = 1
  1540.     $iTotalCounter = 1
  1541.  
  1542.     If StringLen($sClass)>0 Then
  1543.         For $i = UBound($aClassList)-1 To 0 Step - 1
  1544.             If $aClassList[$i]<>$sClass Then
  1545.                 _ArrayDelete($aClassList,$i)
  1546.             EndIf
  1547.         Next
  1548.     EndIf
  1549.  
  1550.     For $i = 0 To UBound($aClassList) - 1
  1551.         If $aClassList[$i] = $iCurrentClass Then
  1552.             $iCurrentCount += 1
  1553.         Else
  1554.             $iCurrentClass = $aClassList[$i]
  1555.             $iCurrentCount = 1
  1556.         EndIf
  1557.  
  1558.         $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]")
  1559.         $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}")
  1560.         $aPos = ControlGetPos($hCallersWindow, "", $hControl)
  1561.         $sControlID = _WinAPI_GetDlgCtrlID($hControl)
  1562.         $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible")
  1563.         If $bOnlyVisible And Not $bIsVisible Then
  1564.             $iTotalCounter += 1
  1565.             ContinueLoop
  1566.         EndIf
  1567.  
  1568.         If StringLen($sStringIncludes) > 0 Then
  1569.             If Not StringInStr($text, $sStringIncludes) Then
  1570.                 $iTotalCounter += 1
  1571.                 ContinueLoop
  1572.             EndIf
  1573.         EndIf
  1574.  
  1575.         If IsArray($aPos) Then
  1576.             ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF)
  1577.         Else
  1578.             ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF)
  1579.         EndIf
  1580.  
  1581.         If Not WinExists($hCallersWindow) Then ExitLoop
  1582.         $iTotalCounter += 1
  1583.     Next
  1584. return $iTotalCounter
  1585. ;~  ControlSend($dialog, "", "[CLASS:V8FormElement; X:66; Y:6]", "{HOME}+{END}{DEL}^v{TAB}")
  1586. EndFunc   ;==>GetAllWindowsControls
  1587.  
  1588.  
  1589. ; #FUNCTION# ====================================================================================================================
  1590. ; Name ..........: _ClosePrNumberDoCrateNoSave
  1591. ; Description ...:
  1592. ; Syntax ........: _ClosePrNumberDoCrateNoSave($TitlePrNumberDogSmall, $Title1CMsg, $iCurrentClass1CMsg, $iCurrentCount1CMsg, $XPos, $YPos)
  1593. ; Parameters ....: $TitlePrNumberDogSmall- Заголовок окна который необходимо закрыть через ESC.
  1594. ;                  $Title1CMsg          - Заголовок окна который появляется если мы закрываем через ESC .
  1595. ;                  $iCurrentClass1CMsg  - CLASS: кнопки которую нужно выделить и нажать чтобы зак4рыть окно $Title1CMsg.
  1596. ;                  $iCurrentCount1CMsg  - INSTANCE: кнопки которую нужно выделить и нажать чтобы выполнить действие в окне $Title1CMsg.
  1597. ;                  $XPos                - Позиция X кнопки которую нужно выделить и нажать чтобы выполнить действие в окне $Title1CMsg.
  1598. ;                  $YPos                - Позиция Y кнопки которую нужно выделить и нажать чтобы выполнить действие в окне $Title1CMsg.
  1599. ; Return values .: None
  1600. ; Author ........: FOREST
  1601. ; Modified ......: Кнопка будет выделена и нажата в окне $Title1CMsg если $YPos=$aPos[1] and $XPos= $aPos[0]
  1602. ; Remarks .......:
  1603. ; Related .......:
  1604. ; Link ..........:
  1605. ; Example .......: No
  1606. ; ===============================================================================================================================
  1607. Func _ClosePrNumberDoCrateNoSave($TitlePrNumberDogSmall,$Title1CMsg,$iCurrentClass1CMsg,$iCurrentCount1CMsg,$XPos,$YPos)
  1608. $z=_1CMSGEnterBootonIns($Title1CMsg,$iCurrentClass1CMsg,$iCurrentCount1CMsg,$XPos,$YPos)
  1609. _activatewindow( $TitlePrNumberDogSmall & " (створення) - ЛІАЦ", "", 0, 1)
  1610. send("{ESC}")
  1611. ;~ 1С:Підприємство
  1612. if WinWait ($Title1CMsg, "", 5 ) then
  1613.     $z=_1CMSGEnterBootonIns($Title1CMsg,$iCurrentClass1CMsg,$iCurrentCount1CMsg,$XPos,$YPos)
  1614. EndIf
  1615. ;~  endif
  1616. _LogAndPrintDebug($hLog,"Окно" & $TitlePrNumberDogSmall & " (створення) - ЛІАЦ закрыто без сохранения"  , 6)
  1617. return  1
  1618. endfunc
  1619.  
  1620.  
  1621. ; #FUNCTION# ====================================================================================================================
  1622. ; Name ..........: _1CMSGEnterBootonIns
  1623. ; Description ...:
  1624. ; Syntax ........: _1CMSGEnterBootonIns($Title1CMsg, $iCurrentClass1CMsg, $iCurrentCount1CMsg, $XPos, $YPos)
  1625. ; Parameters ....: $Title1CMsg          - Заголовок окна который появляется если мы закрываем через ESC .
  1626. ;                  $iCurrentClass1CMsg  - CLASS: кнопки которую нужно выделить и нажать чтобы зак4рыть окно $Title1CMsg.
  1627. ;                  $iCurrentCount1CMsg  - INSTANCE: кнопки которую нужно выделить и нажать чтобы выполнить действие в окне $Title1CMsg.
  1628. ;                  $XPos                - Позиция X кнопки которую нужно выделить и нажать чтобы выполнить действие в окне $Title1CMsg.
  1629. ;                  $YPos                - Позиция Y кнопки которую нужно выделить и нажать чтобы выполнить действие в окне $Title1CMsg.
  1630. ; Return values .: 1; Успешно Выполнено
  1631. ; Author ........: FOREST
  1632. ; Modified ......:
  1633. ; Remarks .......: Кнопка будет выделена и нажата в окне $Title1CMsg если $YPos=$aPos[1] and $XPos= $aPos[0]
  1634. ; Related .......:
  1635. ; Link ..........:
  1636. ; Example .......: No
  1637. ; ===============================================================================================================================
  1638. Func _1CMSGEnterBootonIns($Title1CMsg,$iCurrentClass1CMsg,$iCurrentCount1CMsg,$XPos,$YPos)
  1639. if WinExists($Title1CMsg,"") then
  1640.    
  1641.  
  1642.  
  1643. $hCallersWindow =WinGetHandle($Title1CMsg)
  1644. $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass1CMsg & $iCurrentCount1CMsg & "]")
  1645. $aPos = ControlGetPos($hCallersWindow, "", $hControl)
  1646. GetAllWindowsControls($hCallersWindow, Default, Default, $hCallersWindow)  
  1647.  
  1648. ;~ _LogAndPrintDebug($hLog,"Контрол INS" &  $iCurrentCount1CMsg & " XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] & " (створення) - ЛІАЦ закрыто без сохранения"  , 6)
  1649. if $YPos=$aPos[1] and $XPos= $aPos[0] Then
  1650.     _activatewindow($hCallersWindow, "", 0, 1)
  1651.     _ControlFocusINSTANCE($hCallersWindow, "", "V8FormElement",$iCurrentCount1CMsg)
  1652. send("{ENTER}")
  1653. return 1; Успешно Выполнено
  1654. Else
  1655. return 0;Контрол не обнаружен
  1656. endif
  1657. else
  1658. return -1;Окно не обнаружено
  1659. endif  
  1660. endfunc
  1661. ; #FUNCTION# ====================================================================================================================
  1662. ; Name ..........: _ErrorXMLRestart1C
  1663. ; Description ...:
  1664. ; Syntax ........: _ErrorXMLRestart1C($ChatIDs, $XPos, $YPos [, $msg="Помилка разбору XML" [, $bSendCapture=1 [, $Title1CMsg="1С:Підприємство" [, $iCurrentClass1CMsg="V8FormElement" [, $iCurrentCount1CMsg=3]]]]])
  1665. ; Parameters ....: $ChatIDs             - An AutoIt controlID.
  1666. ;                  $XPos                - An unknown value.
  1667. ;                  $YPos                - An unknown value.
  1668. ;                  $msg                 - [optional] An unknown value. Default is "Помилка разбору XML".
  1669. ;                  $bSendCapture        - [optional] A boolean value. Default is 1.
  1670. ;                  $Title1CMsg          - [optional] A dll struct value. Default is "1С:Підприємство".
  1671. ;                  $iCurrentClass1CMsg  - [optional] A integer value. Default is "V8FormElement".
  1672. ;                  $iCurrentCount1CMsg  - [optional] A integer value. Default is 3.
  1673. ; Return values .: None
  1674. ; Author ........: FOREST
  1675. ; Modified ......:
  1676. ; Remarks .......:
  1677. ; Related .......:
  1678. ; Link ..........:
  1679. ; Example .......: No
  1680. ; ===============================================================================================================================EndFunc
  1681. func _ErrorXMLRestart1C($ChatIDs,$XPos,$YPos,$msg="Помилка разбору XML",$bSendCapture=1,$Title1CMsg="1С:Підприємство",$iCurrentClass1CMsg="V8FormElement",$iCurrentCount1CMsg=3)
  1682. $Title1CMsg="1С:Підприємство"
  1683. $iCurrentClass1CMsg="V8FormElement"
  1684. $iCurrentCount1CMsg=3 ;~Ні 4-Так 2-Відмінити
  1685. $XPos= 11;112;~Ні 11-Так 213-Відмінити
  1686. $YPos=79;40;~Ні  40-Так 40-Відмінити
  1687. $msg="Помилка разбору XML"
  1688. if $bSendCapture then $FileIDs=_SendCapture($Title1CMsg,$ChatIDs,$msg)
  1689. sleep(2000)
  1690. $z=_1CMSGEnterBootonIns($Title1CMsg,$iCurrentClass1CMsg,$iCurrentCount1CMsg,$XPos,$YPos)
  1691. ;~ _ArrayDisplay($FileIDs)
  1692. _1CFile(0)
  1693. _1CStart("ЛІАЦ")
  1694. return $FileIDs
  1695. endfunc
  1696. func _SaveDocument($window_title,$CLASS,$INS,$TAB,$RefMask= Default)
  1697. ;~  для того что бы сохранить документ необходимо:
  1698. ;~  его активировать по $window_title; если $window_title="" будем считать $window_title= WinGetTitle("[active]")
  1699. ;~  активировать       текстовый элемент окна $window_title c $CLASS,$INS
  1700. ;~ Для договора по реализации
  1701. ;~ $Window_Create_Title="Договори контрагентів по реалізації (створення)"
  1702. ;~ $NumDog_title=$NumberDog & " (Договори контрагентів по реалізації)"
  1703. ;~ $RefMask = "1cib/data/Справочник.ДоговорыКонтрагентов?ref"
  1704. ;~ $CLASS,$INS,$TAB
  1705. ;~ "V8FormElement",22,9
  1706. ;~ Для предмета договора по реализации
  1707. ;~ $window_title_create_predmet="E0D Звенигородське ЛГ.Предмет договору (створення) - ЛІАЦ"
  1708. ;~ $NumDogPr_title="E0D Звенигородське ЛГ.Предмет договору ЧР-165000-00359 від 16.03.2018 14:11:23 - ЛІАЦ *"
  1709. ;~ $RefMask = "e1cib/data/Документ.ПриложенияКДоговору?ref"
  1710. ;~ $CLASS,$INS,$TAB
  1711. ;~ "V8Grid",2,2
  1712. ;~  TABом активировать кнопку Сохранить    и нажать ENTER  
  1713. ;~  Получить линк на документ во внутренем формате
  1714. ;~ Проверить на соответствие маске если она задана
  1715. if $window_title="" then $window_title = WinGetTitle("[active]")
  1716. _activatewindow($window_title,"",0,1)
  1717. ;~ _ControlFocusINSTANCE($window_title, "","V8FormElement",22)
  1718. _ControlFocusINSTANCE($window_title, "",$CLASS,$INS)
  1719.  
  1720. $window_title = WinGetTitle("[active]")
  1721.  
  1722. Send("{TAB "& $TAB & "}")
  1723. Send("{ENTER}")
  1724. $savewindow_title = WinGetTitle("[active]")
  1725. ;~ Здесь должна быть проверка на то что сохранение произошло нормально
  1726. ;~ Так как 1С добавляет к заголовку окна знак "*" он не сохранен
  1727. ;~ if $window_title = $savewindow_title Then
  1728. ;~         SoundPlay(@WindowsDir & "\media\Windows XP Error.wav",1)
  1729. ;~         Exit
  1730. ;~ return 0
  1731. ;~     EndIf
  1732. _LogAndPrintDebug($hLog, "$window_title в" & $window_title,6 )
  1733. $RefText=_RefText()
  1734. If $RefMask <> Default Then
  1735. $result = _isRef($RefText, $RefMask)
  1736. Select
  1737.                             Case $result=1 
  1738. _LogAndPrintDebug($hLog, "Линк окна " & $window_title & " соответствует маске записью "  & $RefText , 6)                                  
  1739. Return $RefText
  1740. Case Else
  1741. _LogAndPrintDebug($hLog, "Линк окна " & $NumberDog & " не соответствует маске "  & $RefText , 6)   
  1742. return 0
  1743. EndSelect                                  
  1744. EndIf
  1745. EndFunc
  1746. #region Process
  1747. ; #FUNCTION# ====================================================================================================================
  1748. ; Name ..........: _ProcessGetOwner
  1749. ; Description ...:
  1750. ;~ Помогает, узнать имя пользователя, от которого запущен процесс.
  1751. ;~ Просто необходимо закрыть именно у определенного пользователя на серваке определенный процесс.
  1752. ;~ Дело в том, что одноименных процессов (запущенных программ) на серваке много.
  1753. ;~ Вот и задача - отловить PID процесса определенного пользователя.
  1754. ; Syntax ........: _ProcessGetOwner($PID [, $sComputer = "."])
  1755. ; Parameters ....: $PID                 - An AutoIt controlID.
  1756. ;                  $sComputer           - [optional] A string value. Default is ".".
  1757. ; Return values .: DESKTOP-I29LBB0\FOREST
  1758. ; Author ........: amel27
  1759. ; Modified ......:
  1760. ; Remarks .......:
  1761. ; Related .......:
  1762. ; Link ..........: http://forum.oszone.net/thread-144403.html
  1763. ; Example .......:
  1764.  
  1765. ;~ $aList = ProcessList ("SciTE.exe")
  1766. ;~ For $i=1 To $aList[0][0]
  1767. ;~     ConsoleWrite($aList[$i][1] &": "& _ProcessGetOwner($aList[$i][1]) &@CRLF)
  1768. ;~ Next
  1769.  
  1770.  
  1771.  
  1772.  
  1773. ; ===============================================================================================================================
  1774. Func _ProcessGetOwner($PID, $sComputer = ".")
  1775. ;~  смотри http://forum.oszone.net/thread-144403.html
  1776.     Local $objWMI, $colProcs, $sUserName, $sUserDomain
  1777.     $objWMI = ObjGet("winmgmts:\\" & $sComputer & "\root\cimv2")
  1778.     If IsObj($objWMI) Then
  1779.         $colProcs = $objWMI.ExecQuery("Select ProcessId From Win32_Process Where ProcessId="& $PID)
  1780.         If IsObj($colProcs) Then
  1781.             For $Proc In $colProcs
  1782.                 If $Proc.GetOwner($sUserName, $sUserDomain)=0 Then Return $sUserDomain & "\" & $sUserName
  1783.             Next
  1784.         EndIf
  1785.     EndIf
  1786. EndFunc
  1787.  
  1788.  
  1789. ;~ https://www.autoitscript.com/forum/topic/102785-gethwnd-from-process/
  1790. Func _GetHwnd($id,$txt="")   ;Retrieve Hwnd of process(Получить Hwnd процесса)
  1791.     $proc = 0
  1792.     If _IsPIDOrProc($id) Then
  1793.         $proc = _PIDOrProcToHwnd($id)
  1794.     ElseIf _IsWinTitle($id,$txt) Then
  1795.         $proc = _WinTitleToHwnd($id,$txt)
  1796.     EndIf
  1797.     Return $proc
  1798. EndFunc
  1799.  
  1800. Func _IsPIDOrProc(ByRef $id)  ;Is running PID or Processname(работает под управлением PID или ProcessName )
  1801.     If Not ProcessExists($id) Then
  1802.         Return 0
  1803.     Else
  1804.         Return $id
  1805.     EndIf
  1806. EndFunc
  1807.  
  1808. Func _IsWinTitle(ByRef $id,$txt="")  ;Is running Window Title()
  1809.     $win = WinGetTitle($id,$txt)
  1810.     If Not $win Then Return 0
  1811.     $id = $win
  1812.     Return 1
  1813. EndFunc
  1814.  
  1815. Func _IsWinVisible($handle)   ;Is Window Visible
  1816.     If BitAnd( WinGetState($handle), 2 ) Then
  1817.         Return 1
  1818.     Else
  1819.         Return 0
  1820.     EndIf
  1821. EndFunc
  1822.  
  1823. Func _PIDOrProcToHwnd($proc)   ;Convert PID or process to Hwnd(Преобразование PID или процесс в Hwnd )
  1824.     If ProcessExists($proc) <> $proc Then
  1825.         $proclist = ProcessList($proc)
  1826.         $proc = $proclist[1][1]
  1827.     EndIf
  1828.     $var = WinList()
  1829.     For $i = 1 to $var[0][0]   ;Pair PID/Process with Window Title
  1830.         If $var[$i][0] <> "" AND _IsWinVisible($var[$i][1]) Then
  1831.             If WinGetProcess($var[$i][0]) = $proc Then $proc = WinGetHandle($var[$i][0])
  1832.         EndIf
  1833.     Next
  1834.     Return $proc
  1835. EndFunc
  1836.  
  1837. Func _WinTitleToHwnd($proc,$txt="")   ;Convert Window title to Hwnd
  1838.     $winlist = WinList($proc,$txt)
  1839.     If Not $winlist[0][0] Then Return -1
  1840.     Return $winlist[1][1]
  1841. EndFunc
  1842. #endregion Process
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement