Skip to content
AutoHotKey
2011.02.11 23:24

Com_invoke to login

조회 수 10712 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄


Com_invoke to login


AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
AuthorMessage
bacon117



Joined: 26 May 2010
Posts: 18

PostPosted: Thu Jun 03, 2010 8:54 pm    Post subject: Com_invoke to loginReply with quote

Hello erbody. 

Hopefully someone can help me with this. By studying tanks awesome com tutorial (http://www.autohotkey.com/forum/topic34972.html) I have learned a few things. 

I have figured out how to push the username and pw into the website, and I can click buttons on other websites, but I cannot figure out how to click the "Log in" button on my particular site. I can make it work with Focus-> {enter}, but I would like to leave the page hidden until it is logged in. Here is the DOM of http://www.covisint.com/web/guest/login-manufacturing : 
Code (Expand):
<LINK rel="stylesheet" type="text/css" href="/www-main-theme/css/portal_login.css" />
<SCRIPT type="text/javascript"> 
/*<![CDATA[*/jQuery(function(){var a="p_p_id_56_INSTANCE_q44R_";tmpFm=jQuery("form[name="+a+"tmpLogin]"),loginFm=jQuery("form[name="+a+"login]"),tmpUser=jQuery("input[name=user]",tmpFm),tmpPw=jQuery("input[name=password]",tmpFm),user=jQuery("input[name=user]",loginFm),pw=jQuery("input[name=password]",loginFm),time=jQuery("input[name=submitTime]",loginFm);tmpUser.focus();tmpFm.submit(function(c){if(tmpUser.val().length==0){alert("Please enter a User Name");tmpUser.focus()}else{if(tmpPw.val().length==0){alert("Please enter Password");tmpPw.focus()}else{user.val(tmpUser.val().toUpperCase());pw.val(tmpPw.val());time.val((new Date).getTime());var b=new Cookie("defaultLogin");b.industry="manufacturing";b.store(90,"/");loginFm.submit()}}return false})});/*]]>*/
</SCRIPT>
</P>
<FORM method="post" name="p_p_id_56_INSTANCE_q44R_login" action="https://us.sso.covisint.com/sso?cmd=LOGIN">
<INPUT type="hidden" name="auth_mode" value="basic" /><INPUT type="hidden" name="user" value="" /><INPUT type="hidden" name="password" value="" /><INPUT type="hidden" name="submitTime" value="" /> 
</FORM>
<DIV class="portalLogin">
<H2>
Secure Login
</H2>
<DIV class="portalLoginPanel">
<DIV class="portalLoginPanelContent">
<FORM name="p_p_id_56_INSTANCE_q44R_tmpLogin" jQuery1275595950703="9">
<FIELDSET>
<LEGEND>Manufacturing <SPAN>Login</SPAN></LEGEND>
<OL>
<LI>
<LABEL for="p_p_id_56_INSTANCE_q44R_user">User Name</LABEL> <INPUT id="p_p_id_56_INSTANCE_q44R_user" class="field" name="user" jQuery1275595950703="8" index="1" value="" />
</LI>
<LI>
<LABEL for="p_p_id_56_INSTANCE_q44R_password">Password</LABEL> <INPUT id="p_p_id_56_INSTANCE_q44R_password" class="field" type="password" name="password" index="2" value="" />
</LI>
<LI>
<LABEL>&nbsp;</LABEL> <INPUT class="loginButton" type="submit" index="3" value=" " />
</LI>
</OL>
</FIELDSET>
 
</FORM>
<!-- Manufacturing -->

Using this information, I have come up with these two entries to push the user name and PW to this site (both work): 
Code:
   COM_Invoke(itemq:=COM_Invoke(all1:=COM_Invoke(document:=COM_Invoke(pwb,"document"),"All"),"item","p_p_id_56_INSTANCE_q44R_user"),"value",covuser) 
   
   COM_Invoke(item62:=COM_Invoke(all2:=COM_Invoke(document:=COM_Invoke(pwb,"Document"),"All"),"item","p_p_id_56_INSTANCE_q44R_password"),"value",covpw) 
   

But now, how do I click the link. This seems to be the code for the button: 
<LABEL>&nbsp;</LABEL> <INPUT class="loginButton" type="submit" index="3" value=" " /> 
but there is no name or id for me to select and then "click". 

I have tried these with no luck: 


Code:
;1.)
COM_Invoke(itemsubmit:=COM_Invoke(all3:=COM_Invoke(document:=COM_Invoke(pwb,"Document"),"All"),"item","submit"),"submit") 

   
;2.)   ;COM_Invoke(document, "p_p_id_56_INSTANCE_q44R_tmpLogin", "click")



;3.)
;   pbuttons := COM_Invoke(document, "getElementsByTagName", "submit") 
;   ; use loop to find the right button ->pbutton 
;     COM_Invoke(pbutton, "click")
;   
;4.)
;   COM_Invoke(itemsubmit:=COM_Invoke(all3:=COM_Invoke(document:=COM_Invoke(pwb,"Document"),"All"),"getElementsbytagname","submit"),"click") 


Any ides or other clarification?
Back to top
View user's profile Send private message 
bacon117



Joined: 26 May 2010
Posts: 18

PostPosted: Thu Jun 03, 2010 9:20 pm    Post subject:Reply with quote

I have had some moderate sucess using the name of the input form. But when I run the script, it submits nothing to the website, and I get "invalid user name or password": 

Code:
COM_Invoke(itemsubmit:=COM_Invoke(all3:=COM_Invoke(document:=COM_Invoke(pwb,"Document"),"All"),"item","p_p_id_56_INSTANCE_q44R_Login"),"submit")


Again, here is the code of the form: 

Code (Expand):
link href="/www-main-theme/css/portal_login.css" type="text/css" rel="stylesheet" /><script type="text/javascript">/*<![CDATA[*/jQuery(function(){var a="p_p_id_56_INSTANCE_q44R_";tmpFm=jQuery("form[name="+a+"tmpLogin]"),loginFm=jQuery("form[name="+a+"login]"),tmpUser=jQuery("input[name=user]",tmpFm),tmpPw=jQuery("input[name=password]",tmpFm),user=jQuery("input[name=user]",loginFm),pw=jQuery("input[name=password]",loginFm),time=jQuery("input[name=submitTime]",loginFm);tmpUser.focus();tmpFm.submit(function(c){if(tmpUser.val().length==0){alert("Please enter a User Name");tmpUser.focus()}else{if(tmpPw.val().length==0){alert("Please enter Password");tmpPw.focus()}else{user.val(tmpUser.val().toUpperCase());pw.val(tmpPw.val());time.val((new Date).getTime());var b=new Cookie("defaultLogin");b.industry="manufacturing";b.store(90,"/");loginFm.submit()}}return false})});/*]]>*/</script></p>
<form method="POST" action="https://us.sso.covisint.com/sso?cmd=LOGIN" name="p_p_id_56_INSTANCE_q44R_login">
    <input type="hidden" value="basic" name="auth_mode" /><input type="hidden" name="user" /><input type="hidden" name="password" /><input type="hidden" value="" name="submitTime" />
</form><div class="portalLogin">
<h2>Secure Login</h2>
<div class="portalLoginPanel">
<div class="portalLoginPanelContent">
<form name="p_p_id_56_INSTANCE_q44R_tmpLogin">
    <fieldset>                     <legend>Manufacturing <span>Login</span></legend>
    <ol>
        <li><label for="p_p_id_56_INSTANCE_q44R_user">User Name</label>                             <input type="text" index="1" name="user" id="p_p_id_56_INSTANCE_q44R_user" class="field" /></li><li><label for="p_p_id_56_INSTANCE_q44R_password">Password</label>                             <input type="password" index="2" name="password" id="p_p_id_56_INSTANCE_q44R_password" class="field" /></li><li><label> </label>                             <input type="submit" index="3" value=" " class="loginButton" /></li></ol>
    </fieldset>
</form><!-- Manufacturing -->
Back to top
View user's profile Send private message 
sinkfaze



Joined: 18 Mar 2008
Posts: 3612
Location: the tunnel(?=light)

PostPosted: Thu Jun 03, 2010 10:30 pm    Post subject:Reply with quote

tank's tutorials are a little dated, as the syntax for using COM has been greatly simplified by using the "dotted path": 

Code:
COM_Invoke(itemq:=COM_Invoke(all1:=COM_Invoke(document:=COM_Invoke(pwb,"document"),"All"),"item","p_p_id_56_INSTANCE_q44R_user"),"value",covuser) ; <~ old method

COM_Invoke(pwb,"document.all.item[p_p_id_56_INSTANCE_q44R_user].value",covuser) ; <~ new method
    
COM_Invoke(item62:=COM_Invoke(all2:=COM_Invoke(document:=COM_Invoke(pwb,"Document"),"All"),"item","p_p_id_56_INSTANCE_q44R_password"),"value",covpw) ; <~ old method

COM_Invoke(pwb,"document.all.item[
p_p_id_56_INSTANCE_q44R_password].value",covpw) ; <~ new method


Using that will cut down on a great deal of confusion for you and for others trying to assist you. But alas, I digress... 

You could of course submit the form directly, but the key to making the button work is to find out information about your button: 

Code:
<input type="submit" index="3" value=" " class="loginButton" />


You'll notice that the button doesn't have anything readily identifiable for it like a name or id, which will allow us the easiest access to it. The next easiest thing to do will be to determine how many buttons are on the page. We can't immediately distinguish buttons but we can distinguish how many page elements with its root HTML tag 'input' exist by using the length collection: 

Code:
COM_Invoke(pwb,"document.all.tags[input].length")


Saving the result of that function call to a variable will tell you how many elements with the input tag are on the page: 

Code:
p := COM_Invoke(pwb,"document.all.tags[input].length")
MsgBox, %p% input elements.


This is valuable information because we can now create a loop that will only run for as many input elements as there are on the page. But what do we look for? We know this particular input element's type is submit: 

Code:
<input type="submit" index="3" value=" " class="loginButton" />


So that's how we'll look for it, look at only input elements whose type is submit: 

Code:
p := COM_Invoke(pwb,"document.all.tags[input].length")
Loop %p%
{
  t := COM_Invoke(pwb,"document.all.tags[input].item[" A_Index-1 "].type") ; item collections are zero-based indices (first item is item 0, second is 1, etc.)
. . .


The problem is that there may be multiple input items of type 'submit', so what else can uniquely match our button? The next likely suspect is the class: 

Code:
<input type="submit" index="3" value=" " class="loginButton" />


Now the class is kind of tricky because there is no class property of an item per se, but a className property: 

Code:
p := COM_Invoke(pwb,"document.all.tags[input].length")
Loop %p%
{
  c := COM_Invoke(pwb,"document.all.tags[input].item[" A_Index-1 "].className")
. . .


So now we have two items which should reasonably identify our button, so we just have to use the loop to search for them! 

Code:
p := COM_Invoke(pwb,"document.all.tags[input].length")
Loop %p%
{
  t := COM_Invoke(pwb,"document.all.tags[input].item[" A_Index-1 "].type") 
  c := COM_Invoke(pwb,"document.all.tags[input].item[" A_Index-1 "].className")
  if (t="submit") AND (c="loginButton") { ; if both things about the input element match
    COM_Invoke(pwb,"document.all.tags[input].item[" A_Index-1 "].click") ; click on the element
    break ; and break the loop
  }
}


Having worked with COM in this way for a while I write it slightly differently: 

Code:
Loop %   COM_Invoke(pwb,"document.all.tags[input].length") {
   if   (COM_Invoke(pwb,"document.all.tags[input].item[" A_Index-1 "].type")="submit")
    &&   (COM_Invoke(pwb,"document.all.tags[input].item[" A_Index-1 "].className")="loginButton") {
      COM_Invoke(pwb,"document.all.tags[input].item[" A_Index-1 "].click")
      break
   }
}


HTH
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message 
bacon117



Joined: 26 May 2010
Posts: 18

PostPosted: Fri Jun 04, 2010 11:59 pm    Post subject:Reply with quote

Thank you very much, your post is very easy for me to understand, but more importantly, it works. Smile 

sinkfaze wrote:
You could of course submit the form directly,


How do I submit the form directly? The website runs a Java code locally that sanitizes the inputs (makes sure the fields are not blank), capitalizes the username, and then also submits a "SubmitTime" with the current date and time to the server. It may do other things that I don't understand. This code is the reason I wanted to click the button in the first place 

How do I submit the form directly and bypass this code? 

BTW, here is the code I refer to, I suspect it has something to do with the *loginFm.submit()* at the bottom, but i'm not sure how to use it: 

Code:
<SCRIPT type="text/javascript"> 
/*<![CDATA[*/jQuery(function(){var a="p_p_id_56_INSTANCE_q44R_";tmpFm=jQuery("form[name="+a+"tmpLogin]"),loginFm=jQuery("form[name="+a+"login]"),tmpUser=jQuery("input[name=user]",tmpFm),tmpPw=jQuery("input[name=password]",tmpFm),user=jQuery("input[name=user]",loginFm),pw=jQuery("input[name=password]",loginFm),time=jQuery("input[name=submitTime]",loginFm);tmpUser.focus();tmpFm.submit(function(c){if(tmpUser.val().length==0){alert("Please enter a User Name");tmpUser.focus()}else{if(tmpPw.val().length==0){alert("Please enter Password");tmpPw.focus()}else{user.val(tmpUser.val().toUpperCase());pw.val(tmpPw.val());time.val((new Date).getTime());var b=new Cookie("defaultLogin");b.industry="manufacturing";b.store(90,"/");loginFm.submit()}}return false})});/*]]>*/
</SCRIPT>
Back to top
View user's profile Send private message 


















로그인 후 댓글쓰기가 가능합니다.

?

List of Articles
번호 분류 제목 날짜 조회 수
537 컴퓨터잡담 HTML 엔티티(Entities) 2010.02.05 11190
536 컴퓨터잡담 Windows와 DOS 명령 프롬프트 환경 변수 리스트 1 4 2010.06.18 11187
535 Server TIME_WAIT를 남기지 않는 세션종료 (Graceful Shutdown) 3 2013.03.02 11173
534 컴퓨터잡담 Autohotkey 파일 저장시 한글 깨짐 현상 2010.10.11 11172
533 Server make ping with PHP(핑테스트) 11 2013.04.01 11144
532 WindowsTip 랜카드 전원관리 기능 해제로 인터넷 끊킴 해결방법 1 file 2013.02.13 11111
531 컴퓨터잡담 MouseOver - Background color, 마우스오버시 백그라운드 컬러 지정 7 2010.07.10 11035
530 컴퓨터잡담 삼성, 프로그래머들에게 스마트폰 콘텐츠 개발하고 싶게 만들어라. 2 2010.04.09 10989
529 컴퓨터잡담 로그인 아이디 쿠키로 기억하기 2010.04.05 10966
528 컴퓨터잡담 [엑셀] 와일드카드 문자의 변환처리 방법 1 2 2010.10.04 10960
527 AutoHotKey autohotkey) WinSpector spy를 이용한 post,sendmessage Control ID 추출하기 3 file 2012.02.22 10901
526 컴퓨터잡담 파이썬 JSON으로 받아온 데이터의 Key 값 가져오기 2021.08.27 10858
525 컴퓨터잡담 HTML 엔티티(Entities) 2010.02.05 10844
524 AutoHotKey Autohotkey) EditPlus에 구문 색깔 입히기 3 file 2012.08.23 10811
523 HTMLPHPMSQL 자주 쓰이는 정규식(Regular Expression) 2018.01.23 10807
522 [Docs]스프레드시트 구글 스프레드시트를 이용한 지메일 예약발송 방법 file 2017.04.30 10790
521 컴퓨터잡담 차단된 사이트 프록시서버로 우회하는 방법 3 2012.10.24 10766
520 WindowsTip 무선공유기 잦은 끊킴시 해결방법 file 2013.03.15 10751
» AutoHotKey Com_invoke to login 2011.02.11 10712
518 WindowsTip Fasoo DRM 삭제하기(fph) file 2015.04.13 10678
Board Pagination Prev 1 ... 18 19 20 21 22 ... 46 Next
/ 46

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소