1 (изменено: inseption86, 2021-04-01 22:06:05)

Тема: AHK: IE_COM_выбор из списка

Добрый вечер, подскажите как можно сделать выбор из списка? В окне хрома и IE в консоли ошибок не возникает, но и ничего не меняется.


url := "https://ise.mos.ru"

; результат получаю
 MsgBox % ie.document.querySelector("select[Name=""p_t05""]").value "_" ie.document.querySelector("select[Name=""p_t05""]").selectedIndex
 
; не работает
ie.document.getElementById("P681_TYPE").Focus()
ie.document.getElementById("P681_TYPE").value := 31 ; "31"
..
ie.document.getElementById("P681_TYPE").value := 31 ; "31"
....
ie.document.getElementById("P681_TYPE").selectedIndex := "2" ; 2
..
ie.document.getElementById("P681_TYPE").selectedIndex := "2" ; 2
ie.document.getElementById("P681_TYPE").onchange()
....
ie.document.querySelector("select[Name=""p_t05""]").selectedIndex := 4
ie.document.querySelector("select[Name=""p_t05""]").value := 32
..........
ie.document.querySelector("select[Name='p_t05']").value := 32
Event := ie.document.createEvent("Event")
Event.initEvent("select", False, False)
ie.document.querySelector("select[Name='p_t05']").dispatchEvent(Event)
.......
MouseDownEvent := IE.document.createEvent("MouseEvent")
MouseDownEvent.initMouseEvent("mousedown",true,false, _, _, _, _, _, _, _, _, _, _, _, _)

MouseUpEvent := IE.document.createEvent("MouseEvent")
MouseUpEvent.initMouseEvent("mouseup",true,false, _, _, _, _, _, _, _, _, _, _, _, _)

ie.document.querySelector("select[Name=""p_t05""]").dispatchEvent(MouseDownEvent)
ie.document.querySelector("select[Name=""p_t05""]").dispatchEvent(MouseUpEvent)



apex.da.initDaEventList = function(){
apex.da.gEventList = [
{"triggeringElement":"P681_QUATER","triggeringElementType":"ITEM","bindType":"bind","bindEventType":"change",actionList:[{"eventResult":true,"executeOnPageInit":false,"stopExecutionOnError":true,javascriptFunction:apex.da.submitPage,"attribute02":"Y","action":"NATIVE_SUBMIT_PAGE"}]},
{"triggeringElement":"P681_YEAR","triggeringElementType":"ITEM","bindType":"bind","bindEventType":"change",actionList:[{"eventResult":true,"executeOnPageInit":false,"stopExecutionOnError":true,javascriptFunction:apex.da.submitPage,"attribute02":"Y","action":"NATIVE_SUBMIT_PAGE"}]},
{"triggeringElement":"document","triggeringElementType":"DOM_OBJECT","bindType":"bind","bindEventType":"ready",actionList:[{"eventResult":true,"executeOnPageInit":false,"stopExecutionOnError":true,javascriptFunction:function (){ var _name;

if ($v('P681_TYPE') == '1') _name = 'ЭЭ'
else if ($v('P681_TYPE') == '2') _name = 'ТЭ'
else if ($v('P681_TYPE') == '31') _name = 'ХВС'
else if ($v('P681_TYPE') == '32') _name = 'ГВС'
else if ($v('P681_TYPE') == '4') _name = 'Газ'


var _name;
if ($v('P632_TYPE') == '1') _name = 'ЭЭ'
else if ($v('P632_TYPE') == '2') _name = 'ТЭ'
else if ($v('P632_TYPE') == '31') _name = 'ХВС'
else if ($v('P632_TYPE') == '32') _name = 'ГВС'
else if ($v('P632_TYPE') == '4') _name = 'Газ'

$('.apexir_WORKSHEET_DATA tbody tr').first().before('<tr id="irColGrpRow1"><th colspan="4"></th><th colspan="23">' + _name)

},"action":"NATIVE_JAVASCRIPT_CODE"}]},
{"triggeringElementType":"BUTTON","triggeringButtonId":"B1703318217089378584","bindType":"live","bindEventType":"click",actionList:[{"eventResult":true,"executeOnPageInit":false,"stopExecutionOnError":true,javascriptFunction:function (){ if ($v('apexir_SEARCH'))
  gReport.search('SEARCH');},"action":"NATIVE_JAVASCRIPT_CODE"},{"eventResult":true,"executeOnPageInit":false,"stopExecutionOnError":true,javascriptFunction:apex.da.executePlSqlCode,"ajaxIdentifier":"57FE04DF9A18FBC16000B821B81A245348A287FE4F51B2A984FD6AFE57CF0D93","attribute01":"P681_DEPARTMENT_TYPE,P681_FILTER_BLD_TYPE,P681_FILTER_RENT","attribute04":"N","action":"NATIVE_EXECUTE_PLSQL_CODE"},{"eventResult":true,"executeOnPageInit":false,"stopExecutionOnError":true,javascriptFunction:apex.da.submitPage,"attribute02":"Y","action":"NATIVE_SUBMIT_PAGE"}]},
{"triggeringElementType":"BUTTON","triggeringButtonId":"B1703318401312378586","bindType":"live","bindEventType":"click",actionList:[{"eventResult":true,"executeOnPageInit":false,"stopExecutionOnError":true,javascriptFunction:apex.da.executePlSqlCode,"ajaxIdentifier":"5097AF6DA49B5BCF56D28E3C92BE055FA62AF4F2F2CF3863DACDE24605744F9F","attribute01":"P681_DATE_FROM,P681_DATE_TILL,P681_DEPARTMENT_TYPE,P681_FILTER_BLD_TYPE,P681_FILTER_RENT","attribute04":"N","action":"NATIVE_EXECUTE_PLSQL_CODE"},{"eventResult":true,"executeOnPageInit":false,"stopExecutionOnError":true,javascriptFunction:apex.da.submitPage,"attribute02":"Y","action":"NATIVE_SUBMIT_PAGE"}]},
{"triggeringElementType":"REGION","triggeringRegionId":"R1703319202272378594","triggeringButtonId":"B1703318401312378586","bindType":"bind","bindEventType":"change",actionList:[{"eventResult":true,"executeOnPageInit":false,"stopExecutionOnError":true,javascriptFunction:function (){ var _name;

if ($v('P681_TYPE') == '1') _name = 'ЭЭ'
else if ($v('P681_TYPE') == '2') _name = 'ТЭ'
else if ($v('P681_TYPE') == '31') _name = 'ХВС'
else if ($v('P681_TYPE') == '32') _name = 'ГВС'
else if ($v('P681_TYPE') == '4') _name = 'Газ'
Post's attachments

2021-04-01_205528.png
2021-04-01_205528.png 12.61 kb, 2 downloads since 2021-04-01 

You don't have the permssions to download the attachments of this post.

2

Re: AHK: IE_COM_выбор из списка

Чтобы что-то сказать нужен сам сайт и ваш текущий код работы с ним.

3

Re: AHK: IE_COM_выбор из списка

Malcev


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance force   ; игнор уже запущенного скрипта, переоткрытие

URL := "https://ise.mos.ru/euchet/f?p=185:70:754429688007501"

login := 
pass := 

ComObjError(false)
HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1")
HTTP.Open("GET", URL)
HTTP.Send()
if (HTTP.ResponseText = "")
{
   MsgBox, 262208, , Сайт ИСЭ не доступен!!!
   ExitApp
}
ComObjError(true)


ie := ComObjCreate("InternetExplorer.Application")
ie.Visible := true 
ie.Navigate(URL)
while ie.readystate <> 4
	continue
sleep 500
	
	
ie.document.querySelector("Input[Name=""p_t01""]").value := login
ie.document.querySelector("Input[Name=""p_t02""]").value := pass
ie.document.querySelector("button[Id=""P101_LOGIN""]").click()


while ie.document.getElementsByClassName("metrouicss baron").length = 0
{
	sleep 300
    continue
}
   
Array1 := ["li", "li", "td", "li"]
Array2 := ["nav nav-tabs clearfix", "nav nav-pills clearfix", "borderless-region", "apexir_ACTIONSMENU" ]
Array3 := ["Отчетность", "Приборы учета по строениям", "тип ресурса", "Выгрузить"]

ArrayCount := 0
for k, v in Array3
{
   ComObjError(false)
   HTMLAnchorElements := ie.document.getElementsByClassName(array2[k])[0].getElementsByTagName(array1[k])
   ComObjError(true)
   
   if (ArrayCount = 0) or if (ArrayCount = 1) 
	{
		loop % HTMLAnchorElements.length 
		{
			if (HTMLAnchorElements[A_index - 1].getElementsByTagName("a")[0].innerText = v)
               HTMLAnchorElements[A_index - 1].getElementsByTagName("a")[0].click()
        }
	}
	
   if (ArrayCount = 2) 
    {
		loop % HTMLAnchorElements.length 
		{	
			if InStr(HTMLAnchorElements[A_index - 1].innerText, v)
			{
			     MsgBox % HTMLAnchorElements[A_index - 1].innerText
                 MsgBox % ie.document.querySelector("select[Name='p_t05']").value "_" ie.document.querySelector("select[Name='p_t05']").selectedIndex

                  ie.document.querySelector("select[Name='p_t05']").value := 32
                  Event := ie.document.createEvent("Event")
                  Event.initEvent("select", False, False)
                  ie.document.querySelector("select[Name='p_t05']").dispatchEvent(Event)   
             }
		}  
	}
	
	if (ArrayCount = 3) 
    {
		
		HTMLAnchorElements := ie.document.getElementById(array2[k]).getElementsByTagName(array1[k])
		 loop % HTMLAnchorElements.length 
		{	
			if (HTMLAnchorElements[A_index - 1].innerText = v)
			{
	           MsgBox % HTMLAnchorElements[A_index - 1].innerText
			   HTMLAnchorElements[A_index - 1].click()
		     }
		 }
	 }
	 
 
	while ie.document.readyState = "loading"
   {
	  sleep 200
      continue
   }
   
  ArrayCount += 1
}



4

Re: AHK: IE_COM_выбор из списка

Нужен логин и пароль.

5

Re: AHK: IE_COM_выбор из списка

Да и зачем мучиться через IE, если есть апи.
https://apidata.mos.ru/

6

Re: AHK: IE_COM_выбор из списка

Malcev

С Api хотел разобраться позже, пока тёмный лес, хотел сделать временное решение через IE. Логин и пароль это проблемно, вижу, что там и получить его  нельзя