Что нового

[Автоматизация] Заполнение поля в IE из блокнота

Fanatmb

Новичок
Сообщения
50
Репутация
0
Добрый день!

Помогите пожалуйста. Я новичок в этом деле. Надо решить такую задачу.

Версия AutoIt: 3.3.10.1

Описание:

Есть открытая страница "http://192.168.1.12/default/en_US/tools.html?type=sms&line=3".
Далее надо вырезать из блокнота 1-ю строку (12 символов), удалить оставшийся пустой разделитель, что бы вторая строка стала первой.

далее в поле <input type="text" name="telnum" class="edit" style="width:200"> вставить номер

в поле <textarea name="smscontent" class="edit" rows="6" style="width:200"></textarea> внести определенный текст (один и тот же)

Нажать кнопку Send (submit). После чего в переадресованном окне http://192.168.1.12/default/en_US/sms_info.html дождаться надписи "Line 3 Return: Send successful!" и вернуться в начало скрипта кнопкой "back".

Я делал похожее через "нажатия клавиш", но понимаю, что это не надежно.

Пробовал сам, но в начале с проверкой сразу в тупике.

Попробую сам начать. Тут же буду редактировать, что получается.
Примечания:
Код:
#include <IE.au3>

Global $oIE
WinActivate("GoIP4 - Internet Explorer","")


$oForm = _IEFormGetCollection ($oIE)

$oTelnum = _IEFormElementGetObjByName ($oForm, "telnum")
$oSmscontent = _IEFormElementGetObjByName ($oForm, "smscontent")

_IEFormElementSetValue ($oTelnum, "123456789123")
_IEFormElementSetValue ($oSmscontent, "Текст сообщения")

_IELoadWait ($oIE)
_IEFormSubmit ($oForm)


Код:
<form action="sms_info.html" method="post" onSubmit="return send_sms(this);">
	<div>
	<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr>
		<td colspan="3" class="title2" height="25">Send SMS</td>
	</tr>

	<tr>
		<td colspan="3" class="text">
		<input type=radio name="line" value="1" onclick="toggle2('sms_send_tab', 8, 0)" checked>Line 1 
		
                <input type=radio name="line" value="2" onclick="toggle2('sms_send_tab', 8, 1)">Line 2 
                
		
                <input type=radio name="line" value="3" onclick="toggle2('sms_send_tab', 8, 2)">Line 3 
                
		
                <input type=radio name="line" value="4" onclick="toggle2('sms_send_tab', 8, 3)">Line 4 
                
		
		
		
		
                <input type=radio name="line" value="9" onclick="toggle2('sms_send_tab', 9, 8)">All Lines 
		</td>
	</tr>
	</table>
	</div>
	<!-- -->
	<div id="sms_send_tab_0_div" class="visable">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 1 GSM Status:</td>
				<td width="160" class="text">LOGIN</td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 1 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>
	<div id="sms_send_tab_1_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 2 GSM Status:</td>
				<td width="160" class="text">LOGIN</td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 2 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

	<div id="sms_send_tab_2_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 3 GSM Status:</td>
				<td width="160" class="text">LOGIN</td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 3 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

	<div id="sms_send_tab_3_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 4 GSM Status:</td>
				<td width="160" class="text">LOGIN</td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 4 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

	<div id="sms_send_tab_4_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 5 GSM Status:</td>
				<td width="160" class="text"></td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 5 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

	<div id="sms_send_tab_5_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 6 GSM Status:</td>
				<td width="160" class="text"></td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 6 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

	<div id="sms_send_tab_6_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 7 GSM Status:</td>
				<td width="160" class="text"></td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 7 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

	<div id="sms_send_tab_7_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 8 GSM Status:</td>
				<td width="160" class="text"></td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 8 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

<input type="hIdden" name="smskey" value="52fd0e7c">
<input type="hIdden" name="action" value="SMS">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr>
		<td class="title1" width="120" align="right" height="30">Phone Number:</td>
		<td align="center" width="300"><input type="text" name="telnum" class="edit" style="width:200"></td>
		<td></td>
	</tr>
	<tr>
		<td class="title1" align="right" height="30">SMS Content:</td>
		<td align="center" width="300"><textarea name="smscontent" class="edit" rows="6" style="width:200"></textarea></td>
		<td><input type="submit" name="send" class="button" value="Send"></td>
	</tr>
</table>
</form>
 
Автор
F

Fanatmb

Новичок
Сообщения
50
Репутация
0
Я так понял, что не в том разделе опубликовался. Можно меня переместить в стол заказов? А то проблема есть, вдруг она там быстрее решиться.

Я уже сам понял, что код мой работать не будет, но как заставить заполнять нужные поля въехать сам не могу.
Заранее спасибо.
 

Garrett

Модератор
Локальный модератор
Сообщения
3,999
Репутация
967
Fanatmb [?]
Далее надо вырезать из блокнота 1-ю строку (12 символов), удалить оставшийся пустой разделитель, что бы вторая строка стала первой.
Дайте пример содержимого в блокноте.
 
Автор
F

Fanatmb

Новичок
Сообщения
50
Репутация
0
Примерно так
80291234567
80291234567
80291234567
80291234567
80291234567

а текст повторяется.
 

Garrett

Модератор
Локальный модератор
Сообщения
3,999
Репутация
967
Fanatmb [?]
Далее надо вырезать из блокнота 1-ю строку (12 символов), удалить оставшийся пустой разделитель, что бы вторая строка стала первой.

[?]
1. Строка имеет 11 символов.
2. Что это за "оставшийся пустой разделитель"?
3. Для чего это нужно "что бы вторая строка стала первой"?
 
Автор
F

Fanatmb

Новичок
Сообщения
50
Репутация
0
Garrett [?]
1. Строка имеет 11 символов.
Виноват. Ошибся.

Garrett [?]
2. Что это за "оставшийся пустой разделитель"?
я это делал путем выделения символов, и после вырезания оставался "пробел", после которого строка поднималась вверх.


3. Для чего это нужно "что бы вторая строка стала первой"?

Для того, что бы скрипт отрабатывал нужный список из файла с номерами и после его окончания, либо обнаружения определенного номера останавливал свою работу. А что бы случайных повторений не было, все отправленные номера должны удаляться из этого списка.
 

Garrett

Модератор
Локальный модератор
Сообщения
3,999
Репутация
967
Fanatmb
Выложите полный html код tools.html и sms_info.html
 
Автор
F

Fanatmb

Новичок
Сообщения
50
Репутация
0
Код:
<html>

<head>
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>GoIP4</title>

<link rel="stylesheet" type="text/css" href="/style/default.css?0">
<style type="text/css">
.visible{
display:block;
}
</style>
<script lang="javascript" src="/script/dynamic.js"></script>
<script lang="javascript">
if (document.getElementById){

	document.write('<style type="text/css">\n');
	document.write('.invisible{display:none;}\n');
	document.write('</style>\n');
}
</script>
</head>

<body>
<table id="mainframe" height="100%" cellSpacing="0" cellPadding="0" width="768" border="0">
	<tr>
		<td width="314" class="banner" height="124">
			<img height="134" src="/images/title.jpg" width="312" border="0">
		</td>
		<td class="banner" height="124" valign="bottom" width="454">
			<table cellSpacing="0" cellPadding="0" width="100%" height="100%"border="0">
				<tr>
					<td height="24" width="324">
					</td>
					<td width="65">
						<a href="../zh_CN/status.html"><image height="20" width="60" border="0" src="/images/chs.gif"></a>
					</td>
				</tr>
				<tr>
					<td colspan="3" height="100" valign="bottom">
					
						<span class="subtitle">GoIP4</span>
					
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td colSpan="2">
			<table height="100%" cellSpacing="0" cellPadding="0" width="100%" bgColor="#ffffff" border="0">
				<tr>
					<td vAlign="top" width="196" class="sidebar">
<script lang="javascript">
function confirm_reset()
{
	return window.confirm("Are you sure to reset to factory default?");
}
function confirm_reboot()
{
	return window.confirm("Are you sure to reboot the device?");
}
</script>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
	<tr>
		<td colspan="2" align="left" height="15"></td>
	</tr>
	<tr>
		<td width="20"></td>
		<td align="left" height="40">
			<a href="status.html"><div class="title5">Status</div></a></td>
	</tr>
	<tr>
		<td width="20"></td>
		<td align="left" height="40"><a href="config.html"><div class="title5">Configurations</div></a></td>
	</tr>
	<tr>
		<td width="20"></td>
		<td height="40"><div class="title4">Tools</div></td>
	</tr>
	<tr>
		<td width="20"></td>
		<td align="right" valign="top">
			<table border="0" width="82%" cellspacing="0" cellpadding="0">
				<tr>
					<td height="30"><a href="tools.html?type=upgrade"><div class="title3" id="upgrade">Online Upgrade</div></a></td>
				</tr>
				<tr>
					<td height="30"><a href="tools.html?type=password"><div class="title3" id="password">Change Password</div></a></td>
				</tr>
				<tr>
					<td height="30"><a href="tools.html?type=ussd"><div class="title3" id="ussd">Send USSD</div></a></td>
				</tr>
				<tr>
					<td height="30"><a href="tools.html?type=sms"><div class="title3" id="sms">Send SMS</div></a></td>
				</tr>
				<tr>
					<td height="30"><a href="tools.html?type=sms_inbox"><div class="title3" id="sms_inbox">SMS In Box</div></a></td>
				</tr>
				<tr>
					<td height="30"><a href="tools.html?type=channel"><div class="title3" id="channel">GSM Channel Control</div></a></td>
				</tr>

				<tr>
					<td height="30"><a href="tools.html?type=config"><div class="title3" id="config">Backup/Restore</div></a></td>
				</tr>

				<tr>
					<td height="10"></td>
				</tr>
				
				<tr>
					<form action="reset_config.html" method="post" onsubmit="return confirm_reset()">
						<td height="30"><div class="title3"><input type="submit" value="Reset Config" class="savebutton"></div></td>
					</form>
				</tr>
				
				<tr>
					<form action="reboot.html" method="post" onsubmit="return confirm_reboot()">
						<td height="30"><div class="title3"><input type="submit" value="Reboot" class="savebutton"></div></td>
					</form>
				</tr>
			</table>
		</td>
	</tr>
</table>
<script lang="javascript">
	
		document.getElementById('sms').className="title4";
	
</script>

					</td>
					<td width="828" vAlign="top" class="content">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td>
			
			
			
			
			
			<div id="tools_page_3_div" style="padding:5px">
<script lang="javascript" src="/script/ajaxroutine.js"></script>

<script lang="javascript">

function myescape(sStr){
		sStr=sStr.replace(/\n|\r/g," ");
}

function send_sms(frm){
	var poststr;

	if((frm["line"][0].checked && "LOGIN" == "LOGIN") || 
	   (frm["line"][1].checked && "LOGIN" == "LOGIN") || 
	   (frm["line"][2].checked && "LOGIN" == "LOGIN") || 
	   (frm["line"][3].checked && "LOGIN" == "LOGIN")
	
	
	
	
        
           || frm["line"][4].checked
        
	){
	}
	else {
		window.alert("GSM LINE LOGOUT!");
		return false
	}
	if(frm["telnum"].value == ""){
		window.alert("phone number should not be empty!");
		return false
	}
        if(frm["smscontent"].value == ""){
                window.alert("content should not be empty!");
                return false
        }
	frm["smscontent"].value = frm["smscontent"].value.replace(/[\r\n]/g," ");
	return true
}

</script>
<div>
<form action="sms_info.html" method="post" onSubmit="return send_sms(this);">
	<div>
	<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr>
		<td colspan="3" class="title2" height="25">Send SMS</td>
	</tr>

	<tr>
		<td colspan="3" class="text">
		<input type=radio name="line" value="1" onclick="toggle2('sms_send_tab', 8, 0)" checked>Line 1 
		
                <input type=radio name="line" value="2" onclick="toggle2('sms_send_tab', 8, 1)">Line 2 
                
		
                <input type=radio name="line" value="3" onclick="toggle2('sms_send_tab', 8, 2)">Line 3 
                
		
                <input type=radio name="line" value="4" onclick="toggle2('sms_send_tab', 8, 3)">Line 4 
                
		
		
		
		
                <input type=radio name="line" value="9" onclick="toggle2('sms_send_tab', 9, 8)">All Lines 
		</td>
	</tr>
	</table>
	</div>
	<!-- -->
	<div id="sms_send_tab_0_div" class="visable">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 1 GSM Status:</td>
				<td width="160" class="text">LOGIN</td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 1 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>
	<div id="sms_send_tab_1_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 2 GSM Status:</td>
				<td width="160" class="text">LOGIN</td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 2 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

	<div id="sms_send_tab_2_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 3 GSM Status:</td>
				<td width="160" class="text">LOGIN</td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 3 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

	<div id="sms_send_tab_3_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 4 GSM Status:</td>
				<td width="160" class="text">LOGIN</td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 4 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

	<div id="sms_send_tab_4_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 5 GSM Status:</td>
				<td width="160" class="text"></td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 5 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

	<div id="sms_send_tab_5_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 6 GSM Status:</td>
				<td width="160" class="text"></td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 6 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

	<div id="sms_send_tab_6_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 7 GSM Status:</td>
				<td width="160" class="text"></td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 7 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

	<div id="sms_send_tab_7_div" class="invisible">
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 8 GSM Status:</td>
				<td width="160" class="text"></td>
			</tr>
			<tr>
				<td width="120" height="25" class="title1" align="right">Line 8 GSM Number:</td>
				<td width="160" class="text"></td>
			</tr>
		
		</table>
	</div>

<input type="hIdden" name="smskey" value="52ffdc1c">
<input type="hIdden" name="action" value="SMS">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr>
		<td class="title1" width="120" align="right" height="30">Phone Number:</td>
		<td align="center" width="300"><input type="text" name="telnum" class="edit" style="width:200"></td>
		<td></td>
	</tr>
	<tr>
		<td class="title1" align="right" height="30">SMS Content:</td>
		<td align="center" width="300"><textarea name="smscontent" class="edit" rows="6" style="width:200"></textarea></td>
		<td><input type="submit" name="send" class="button" value="Send"></td>
	</tr>
</table>
</form>


</div>
<script lang="javascript">
var line_obj = document.getElementsByName("line"); 
line_obj[3-1].checked=true;
toggle2('sms_send_tab', 9, 3-1);
</script>
			</div>
			
			
			

		</td>
	</tr>
</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

</body>

</html>

Код:
<html>

<head>
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>GoIP4</title>

<link rel="stylesheet" type="text/css" href="/style/default.css?0">
<style type="text/css">
.visible{
display:block;
}
</style>
<script lang="javascript" src="/script/dynamic.js"></script>
<script lang="javascript">
if (document.getElementById){

	document.write('<style type="text/css">\n');
	document.write('.invisible{display:none;}\n');
	document.write('</style>\n');
}
</script>
</head>

<body>
<table id="mainframe" height="100%" cellSpacing="0" cellPadding="0" width="768" border="0">
	<tr>
		<td width="314" class="banner" height="124">
			<img height="134" src="/images/title.jpg" width="312" border="0">
		</td>
		<td class="banner" height="124" valign="bottom" width="454">
			<table cellSpacing="0" cellPadding="0" width="100%" height="100%"border="0">
				<tr>
					<td height="24" width="324">
					</td>
					<td width="65">
						<a href="../zh_CN/status.html"><image height="20" width="60" border="0" src="/images/chs.gif"></a>
					</td>
				</tr>
				<tr>
					<td colspan="3" height="100" valign="bottom">
					
						<span class="subtitle">GoIP4</span>
					
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td colSpan="2">
			<table height="100%" cellSpacing="0" cellPadding="0" width="100%" bgColor="#ffffff" border="0">
				<tr>
					<td vAlign="top" width="196" class="sidebar">

					</td>
					<td width="828" vAlign="top" class="content">
<script lang="javascript" src="/script/ajaxroutine.js"></script>
<script lang="javascript" src="/script/progress_bar.js"></script>
<script lang="javascript">

function getElementText(elem)
{
	if(elem.childNodes.length > 0){
		if(elem.childNodes.length > 1){
			return elem.childNodes[1].nodeValue
		}
		else {
			return elem.firstChild.nodeValue
		}
	}
	return ""
}

function sms_return(msg, i, ok_flag)
{
	stageobj=document.getElementById("send"+i);
	if(stageobj){
		if(!ok_flag) stageobj.innerHTML = " Line "+i+" Send Error: "+msg;
		else stageobj.innerHTML = " Line "+i+" Return: "+msg;
	}
}

var trycount = 0
var sms_key="52ffdc1c"

function processGetPost(){
        var myajax=ajaxpack.ajaxobj,line_min,line_max,i;
        if(3==9){
                line_min=1;
                line_max=4;
        }
        else {
                line_min=3;
                line_max=3;
        }
	if (myajax.readyState == 4){ //if request of file completed
		if (myajax.status==200){ 
			var errors,error,stagetags,stage,keys,key;

			for(i=line_min;i<=line_max;i++){
				errors=myajax.responseXML.getElementsByTagName("error"+i);
				if(errors.length){
					error = getElementText(errors[0])
				}
				stagetags=myajax.responseXML.getElementsByTagName("status"+i);
				if(stagetags.length){
					stage = getElementText(stagetags[0])
				}
				keys=myajax.responseXML.getElementsByTagName("smskey"+i);
				if(keys.length){
					key = getElementText(keys[0])
				}
				if(sms_key != key){
					sms_return("ERROR! LINE BUSY!", i);
				}
				else if(error != ""){
					sms_return(error, i);
				}
				else if(stage == "DONE"){
					sms_return("Send successful!", i, 1);
				}
			}
		}
		trycount++;
		for(i=line_min;i<=line_max;i++){
			var stageobj=document.getElementById("send"+i);
			if(stageobj && stageobj.innerText == "Line "+i+" Sending...") {
				if(trycount > 10) sms_return("Can not get response from line", i);
				else break;
			}
		}
		if(i<=line_max) setTimeout('getSmsInfo()', 3000);
	}
}

function getSmsInfo()
{
	ajaxpack.postAjaxRequest("send_sms_status.xml", "line=3", processGetPost, "text/xml")
}
setTimeout('getSmsInfo()', 3000);

	</script>
	<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr>
                <td colspan="2" class="title2" height="25">Send SMS</td>
        </tr>
	<tr>
		<td width="120" height="25" class="title1" align="right">Line</td>
		<td width="180" class="text">3</td>
	</tr>
	<tr>
		<td width="120" height="25" class="title1" align="right">Send Number</td>
		<td width="180" class="text">80295803108</td>
	</tr>
	<tr>
		<td width="120" height="25" class="title1" align="right">Send Content</td>
		<td width="180" class="text" style="word-break : break-all; ">1</td>
	</tr>

</table>

	<table cellSpacing="0" cellPadding="0" width="100%" border="0">








        <tr>
        <td width="120" height="30" class="title1" id="send3"><img src="/images/progress.gif" border="0">Line 3 Sending...</td>
        </tr>









		<tr>
			<td height="30">
				<input type="button" value="Back" class="button" onclick=javascript:window.location='tools.html?type=sms&line=3'>
			</td>
		</tr>
	</table>

					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

</body>

</html>

Код:
<html>

<head>
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>GoIP4</title>

<link rel="stylesheet" type="text/css" href="/style/default.css?0">
<style type="text/css">
.visible{
display:block;
}
</style>
<script lang="javascript" src="/script/dynamic.js"></script>
<script lang="javascript">
if (document.getElementById){

	document.write('<style type="text/css">\n');
	document.write('.invisible{display:none;}\n');
	document.write('</style>\n');
}
</script>
</head>

<body>
<table id="mainframe" height="100%" cellSpacing="0" cellPadding="0" width="768" border="0">
	<tr>
		<td width="314" class="banner" height="124">
			<img height="134" src="/images/title.jpg" width="312" border="0">
		</td>
		<td class="banner" height="124" valign="bottom" width="454">
			<table cellSpacing="0" cellPadding="0" width="100%" height="100%"border="0">
				<tr>
					<td height="24" width="324">
					</td>
					<td width="65">
						<a href="../zh_CN/status.html"><image height="20" width="60" border="0" src="/images/chs.gif"></a>
					</td>
				</tr>
				<tr>
					<td colspan="3" height="100" valign="bottom">
					
						<span class="subtitle">GoIP4</span>
					
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td colSpan="2">
			<table height="100%" cellSpacing="0" cellPadding="0" width="100%" bgColor="#ffffff" border="0">
				<tr>
					<td vAlign="top" width="196" class="sidebar">

					</td>
					<td width="828" vAlign="top" class="content">
<script lang="javascript" src="/script/ajaxroutine.js"></script>
<script lang="javascript" src="/script/progress_bar.js"></script>
<script lang="javascript">

function getElementText(elem)
{
	if(elem.childNodes.length > 0){
		if(elem.childNodes.length > 1){
			return elem.childNodes[1].nodeValue
		}
		else {
			return elem.firstChild.nodeValue
		}
	}
	return ""
}

function sms_return(msg, i, ok_flag)
{
	stageobj=document.getElementById("send"+i);
	if(stageobj){
		if(!ok_flag) stageobj.innerHTML = " Line "+i+" Send Error: "+msg;
		else stageobj.innerHTML = " Line "+i+" Return: "+msg;
	}
}

var trycount = 0
var sms_key="52ffdc1c"

function processGetPost(){
        var myajax=ajaxpack.ajaxobj,line_min,line_max,i;
        if(3==9){
                line_min=1;
                line_max=4;
        }
        else {
                line_min=3;
                line_max=3;
        }
	if (myajax.readyState == 4){ //if request of file completed
		if (myajax.status==200){ 
			var errors,error,stagetags,stage,keys,key;

			for(i=line_min;i<=line_max;i++){
				errors=myajax.responseXML.getElementsByTagName("error"+i);
				if(errors.length){
					error = getElementText(errors[0])
				}
				stagetags=myajax.responseXML.getElementsByTagName("status"+i);
				if(stagetags.length){
					stage = getElementText(stagetags[0])
				}
				keys=myajax.responseXML.getElementsByTagName("smskey"+i);
				if(keys.length){
					key = getElementText(keys[0])
				}
				if(sms_key != key){
					sms_return("ERROR! LINE BUSY!", i);
				}
				else if(error != ""){
					sms_return(error, i);
				}
				else if(stage == "DONE"){
					sms_return("Send successful!", i, 1);
				}
			}
		}
		trycount++;
		for(i=line_min;i<=line_max;i++){
			var stageobj=document.getElementById("send"+i);
			if(stageobj && stageobj.innerText == "Line "+i+" Sending...") {
				if(trycount > 10) sms_return("Can not get response from line", i);
				else break;
			}
		}
		if(i<=line_max) setTimeout('getSmsInfo()', 3000);
	}
}

function getSmsInfo()
{
	ajaxpack.postAjaxRequest("send_sms_status.xml", "line=3", processGetPost, "text/xml")
}
setTimeout('getSmsInfo()', 3000);

	</script>
	<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr>
                <td colspan="2" class="title2" height="25">Send SMS</td>
        </tr>
	<tr>
		<td width="120" height="25" class="title1" align="right">Line</td>
		<td width="180" class="text">3</td>
	</tr>
	<tr>
		<td width="120" height="25" class="title1" align="right">Send Number</td>
		<td width="180" class="text">80295803108</td>
	</tr>
	<tr>
		<td width="120" height="25" class="title1" align="right">Send Content</td>
		<td width="180" class="text" style="word-break : break-all; ">1</td>
	</tr>

</table>

	<table cellSpacing="0" cellPadding="0" width="100%" border="0">








        <tr>
        <td width="120" height="30" class="title1" id="send3"><img src="/images/progress.gif" border="0">Line 3 Sending...</td>
        </tr>









		<tr>
			<td height="30">
				<input type="button" value="Back" class="button" onclick=javascript:window.location='tools.html?type=sms&line=3'>
			</td>
		</tr>
	</table>

					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

</body>

</html>

хотя там Javascript ... Думаю два последних одинаковы.
 

Garrett

Модератор
Локальный модератор
Сообщения
3,999
Репутация
967
Тестируйте:
Код:
#include<IE.au3>
; *****************************************************
;	IE должен быть открыт на странице tools.html
; *****************************************************
$sSmscontent = "Текст сообщения"

$hFile = FileOpen('list_tel.txt', 0)
$oIE = _IEAttach('GoIP4')

While 1
    $sTelnum = FileReadLine($hFile)
    If @error = -1 Then ExitLoop
	$oForm = _IEFormGetCollection ($oIE, 2)
	$oTelnum = _IEFormElementGetObjByName ($oForm, "telnum")
	$oSmscontent = _IEFormElementGetObjByName ($oForm, "smscontent")
	$oSend = _IEFormElementGetObjByName ($oForm, "send")
	_IEFormElementSetValue ($oTelnum, $sTelnum)
	_IEFormElementSetValue ($oSmscontent, $sSmscontent)
	_IEAction($oSend, 'click')
	_IELoadWait($oIE)
	$oBack = _IETagNameGetCollection($oIE, 'input', 0)
	While Sleep(250)
		$oEl = _IEGetObjById($oIE, 'send3')
		If Not @error And StringRegExp(_IEPropertyGet($oEl, 'innerText'), 'Send successful', 0) Then
			_IEAction($oBack, 'click')
			_IELoadWait($oIE)
			ConsoleWrite(StringFormat("! Send successful! %s\n", $sTelnum))
			ExitLoop
		ElseIf Not @error And StringRegExp(_IEPropertyGet($oEl, 'innerText'), 'Can not get response from line', 0) Then
			_IEAction($oBack, 'click')
			_IELoadWait($oIE)
			ConsoleWrite(StringFormat("> Can not get response from line%s\n", '...'))
			ExitLoop
		EndIf
		ConsoleWrite(StringFormat("> Sending%s\n", '...'))
	WEnd
Wend

FileClose($hFile)
 
Автор
F

Fanatmb

Новичок
Сообщения
50
Репутация
0
Вот что выдает

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\Automatic\goip4-sms-robot.au3"
--> IE.au3 T3.0-1 Warning from function _IEFormElementGetObjByName, $_IEStatus_NoMatch
--> IE.au3 T3.0-1 Warning from function _IEFormElementGetObjByName, $_IEStatus_NoMatch
--> IE.au3 T3.0-1 Warning from function _IEFormElementGetObjByName, $_IEStatus_NoMatch
--> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
--> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
--> IE.au3 T3.0-1 Error from function _IEAction(click), $_IEStatus_InvalidDataType
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch (send3)
> Sending...

А ссылка там так выглядит

http : //192.168.1.12/default/en_US/tools.html?type=sms

а после первой отправки

http : //192.168.1.12/default/en_US/tools.html?type=sms&line=3

И наверное самое важно, отправка происходит по третьей линии.
 

Garrett

Модератор
Локальный модератор
Сообщения
3,999
Репутация
967
Fanatmb [?]
А ссылка там так выглядит
Это не важно, важно то, что у вас находится на этой странице между
Код:
<title>...</title>
Текст вам нужно поместить сюда
Код:
$oIE = _IEAttach('...title text...')

Далее запустите IE, откройте страницу tools.html и потом запустите скрипт.
Результат напишите.
 
Автор
F

Fanatmb

Новичок
Сообщения
50
Репутация
0
Ну да. Именно так вы первоначально и предложили.

Скрипт запускаю в SciTE. Ничего не происходит. Логи следующие

"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\Automatic\goip4-sms-robot.au3"
--> IE.au3 T3.0-1 Warning from function _IEFormGetCollection, $_IEStatus_NoMatch
--> IE.au3 T3.0-1 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType
--> IE.au3 T3.0-1 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType
--> IE.au3 T3.0-1 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType
--> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
--> IE.au3 T3.0-1 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
--> IE.au3 T3.0-1 Error from function _IEAction(click), $_IEStatus_InvalidDataType
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...
> Sending...

>Process failed to respond; forcing abrupt termination...
>Exit code: 1 Time: 19.701


Только что попробовал запустить через контекстное меню мыши. Один раз выполнило и все.
 

Garrett

Модератор
Локальный модератор
Сообщения
3,999
Репутация
967
Fanatmb
Зайдите сюда и выложите здесь отчёт о своей tools.html
 
Автор
F

Fanatmb

Новичок
Сообщения
50
Репутация
0
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
; Отчёт по сайту http://192.168.1.12/default/en_US/tools.html?type=sms
;
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

; Всего найдено форм: 3

; Форма: #1

FORM [index -> 0]

; Элементов в форме: 1

( INPUT )
[index -> 0]
[type -> submit]
[value -> Reset Config]

; Форма: #2

FORM [index -> 1]

; Элементов в форме: 1

( INPUT )
[index -> 0]
[type -> submit]
[value -> Reboot]

; Форма: #3

FORM [index -> 2]

; Элементов в форме: 10

( INPUT )
[index -> 0]
[type -> radio]
[name -> line]
[value -> 1]

( INPUT )
[index -> 1]
[type -> radio]
[name -> line]
[value -> 2]

( INPUT )
[index -> 2]
[type -> radio]
[name -> line]
[value -> 3]

( INPUT )
[index -> 3]
[type -> radio]
[name -> line]
[value -> 4]

( INPUT )
[index -> 4]
[type -> radio]
[name -> line]
[value -> 9]

( INPUT )
[index -> 5]
; Элемент скрыт

( INPUT )
[index -> 6]
; Элемент скрыт

( INPUT )
[index -> 7]
[type -> text]
[name -> telnum]

( TEXTAREA )
[index -> 8]
[type -> textarea]
[name -> smscontent]

( INPUT )
[index -> 9]
[type -> submit]
[name -> send]
[value -> Send]
 

Garrett

Модератор
Локальный модератор
Сообщения
3,999
Репутация
967
Всё верно. Должно работать.
Если у вас IE8 или выше, попробуйте включить режим совместимости.
 
Автор
F

Fanatmb

Новичок
Сообщения
50
Репутация
0
Garrett [?]
Всё верно. Должно работать.Если у вас IE8 или выше, попробуйте включить режим совместимости.

Ваш скрипт должен повторяться циклично или нет?
 

Garrett

Модератор
Локальный модератор
Сообщения
3,999
Репутация
967
Fanatmb [?]
Ваш скрипт должен повторяться циклично
Да, до тех пор пока в list_tel.txt не закончатся номера.
Давайте так, скрипт ниже отправляет сообщение?
Код:
#include<IE.au3>
$sSmscontent = "Текст сообщения"

#include<IE.au3>
$sSmscontent = "Текст сообщения"

$hFile = FileOpen('list_tel.txt', 0)
$sTelnum = FileReadLine($hFile)
FileClose($hFile)

$oIE = _IEAttach('GoIP4')
$oForm = _IEFormGetCollection ($oIE, 2)
$oTelnum = _IEFormElementGetObjByName ($oForm, "telnum")
$oSmscontent = _IEFormElementGetObjByName ($oForm, "smscontent")
$oSend = _IEFormElementGetObjByName ($oForm, "send")
_IEFormElementSetValue ($oTelnum, $sTelnum)
_IEFormElementSetValue ($oSmscontent, $sSmscontent)
_IEAction($oSend, 'click')
_IELoadWait($oIE)
 
Автор
F

Fanatmb

Новичок
Сообщения
50
Репутация
0
Garrett [?]
Давайте так, скрипт ниже отправляет сообщение?
Да - 1 раз

Текстовый файл должен быть открыт?

Разобрался. не надо... 1-й Скрипт считывает только первую строку, на этом и останавливается
 

Garrett

Модератор
Локальный модератор
Сообщения
3,999
Репутация
967
Fanatmb [?]
Текстовый файл должен быть открыт?
Нет, его скрипт сам откроет.
[box title=формат файла - list_tel.txt]25427233083
23861247763
88184772387
92436795912
19368417391
10697516246
36567338226
97141916948
33028368172
07314747705[/box]

Это хорошо.
Теперь так:
Код:
#include<IE.au3>
$sSmscontent = "Текст сообщения"

$hFile = FileOpen('list_tel.txt', 0)
$oIE = _IEAttach('GoIP4')


$sTelnum = FileReadLine($hFile)
$oForm = _IEFormGetCollection ($oIE, 2)
$oTelnum = _IEFormElementGetObjByName ($oForm, "telnum")
$oSmscontent = _IEFormElementGetObjByName ($oForm, "smscontent")
$oSend = _IEFormElementGetObjByName ($oForm, "send")
_IEFormElementSetValue ($oTelnum, $sTelnum)
_IEFormElementSetValue ($oSmscontent, $sSmscontent)
_IEAction($oSend, 'click')
_IELoadWait($oIE)

$oBack = _IETagNameGetCollection($oIE, 'input', 0)
While Sleep(250)
	$oEl = _IEGetObjById($oIE, 'send3')
	If Not @error And StringRegExp(_IEPropertyGet($oEl, 'innerText'), 'Send successful', 0) Then
		_IEAction($oBack, 'click')
		_IELoadWait($oIE)
		ConsoleWrite(StringFormat("! Send successful! %s\n", $sTelnum))
		ExitLoop
	ElseIf Not @error And StringRegExp(_IEPropertyGet($oEl, 'innerText'), 'Can not get response from line', 0) Then
		_IEAction($oBack, 'click')
		_IELoadWait($oIE)
		ConsoleWrite(StringFormat("> Can not get response from line%s\n", '...'))
		ExitLoop
	EndIf
	ConsoleWrite(StringFormat("> Sending%s\n", '...'))
WEnd

FileClose($hFile)


Скрипт должен отправить одно сообщение, проверить статус "Send successful" и потом вернуться назад.
 
Верх