Sign in to follow this  
Followers 0
Siemien

Search in HTML

6 posts in this topic

Hi ,i'd like to do script who can search 1 word in html and when AutoIT cant find it ,my script will do func()

i wrote :

<---- This part is working ---->
Func loguj()
$oIE = _IECreate ("www.battleknight.pl");

$oUser = _IEGetObjByName ($oIE, "user_name")
$oPass = _IEGetObjByName ($oIE, "user_password")
$oServer = _IEGetObjByName ($oIE, "Server")
$oSubmit = _IEGetObjByName ($oIE, "Submit")

_IEFormElementOptionselect($oServer,GUICtrlRead($server))
_IEFormElementSetValue ($oUser,GUICtrlRead($log))
_IEFormElementSetValue ($oPass, GUICtrlRead($haslo))


_IEAction ($oSubmit, "click")
_IELoadWait($oIE)


sprlogowanie()

EndFunc
<---- This part is working ---->
<--- But it isnt working ---->
Func sprlogowanie()
$zalogowany =   _IEBodyReadHTML("art/switch_7.gif")
If($zalogowany <> "art/switch_7.gif") Then
loguj()
EndIf
EndFunc

<--- But it isnt working ---->

How i can do it?:/

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Func sprlogowanie()

$zalogowany = _IEBodyReadHTML("art/switch_7.gif")

If($zalogowany <> "art/switch_7.gif") Then

loguj()

EndIf

EndFunc

First off $oIE should be declared as a global variable. Then try this

;
Func sprlogowanie()
$zalogowany =   _IEBodyReadHTML($oIE)
If NOT StringInStr($zalogowany, "art/switch_7.gif") Then
[indent]loguj()[/indent]
EndIf
EndFunc
;

EDIT: If for some reason you can't declare $oIE globaly then this should also work

Func loguj()
$oIE = _IECreate ("www.battleknight.pl");

$oUser = _IEGetObjByName ($oIE, "user_name")
$oPass = _IEGetObjByName ($oIE, "user_password")
$oServer = _IEGetObjByName ($oIE, "Server")
$oSubmit = _IEGetObjByName ($oIE, "Submit")

_IEFormElementOptionselect($oServer,GUICtrlRead($server))
_IEFormElementSetValue ($oUser,GUICtrlRead($log))
_IEFormElementSetValue ($oPass, GUICtrlRead($haslo))


_IEAction ($oSubmit, "click")
_IELoadWait($oIE)


sprlogowanie($oIE)

EndFunc

Func sprlogowanie($obj)
$zalogowany =   _IEBodyReadHTML($obj)
If NOT StringInStr($zalogowany, "art/switch_7.gif") Then
   loguj()
EndIf
EndFunc
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Cheers! It works but i have 1 question more:

How can i write to $oIE2 current website addres or window name?

Share this post


Link to post
Share on other sites

Cheers! It works but i have 1 question more:

How can i write to $oIE2 current website addres or window name?

What is $oIE2??? I don't see that in your code anyplace. And just where are you planning on writing this?

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

When i using:

Func loguj()
Global $oIE = _IECreate ("www.battleknight.pl");

$oUser = _IEGetObjByName ($oIE, "user_name")
$oPass = _IEGetObjByName ($oIE, "user_password")
$oServer = _IEGetObjByName ($oIE, "Server")
$oSubmit = _IEGetObjByName ($oIE, "Submit")

_IEFormElementOptionselect($oServer,GUICtrlRead($server))
_IEFormElementSetValue ($oUser,GUICtrlRead($log))
_IEFormElementSetValue ($oPass, GUICtrlRead($haslo))


_IEAction ($oSubmit, "click")
_IELoadWait($oIE)

WinWaitActive ("BattleKnight - Windows Internet Explorer")
Sleep (5000)

sprlogowanie()

EndFunc
    
Func sprlogowanie()
$zalogowany =   _IEBodyReadHTML($oIE)
If NOT StringInStr($zalogowany, "art/switch_7.gif") Then
loguj()
EndIf
EndFunc

my boot always does new Weendow

i want do about :

Func loguj()
Global $oIE = _IECreate ("www.battleknight.pl");

$oUser = _IEGetObjByName ($oIE, "user_name")
$oPass = _IEGetObjByName ($oIE, "user_password")
$oServer = _IEGetObjByName ($oIE, "Server")
$oSubmit = _IEGetObjByName ($oIE, "Submit")

_IEFormElementOptionselect($oServer,GUICtrlRead($server))
_IEFormElementSetValue ($oUser,GUICtrlRead($log))
_IEFormElementSetValue ($oPass, GUICtrlRead($haslo))


_IEAction ($oSubmit, "click")
_IELoadWait($oIE)

WinWaitActive ("BattleKnight - Windows Internet Explorer")
Sleep (5000)

sprlogowanie()

EndFunc
func loguj2()
Global $oIE2 =[b] "Curent Website Addres or Window Name"[/b]

$oUser = _IEGetObjByName ($oIE, "user_name")
$oPass = _IEGetObjByName ($oIE, "user_password")
$oServer = _IEGetObjByName ($oIE, "Server")
$oSubmit = _IEGetObjByName ($oIE, "Submit")

_IEFormElementOptionselect($oServer,GUICtrlRead($server))
_IEFormElementSetValue ($oUser,GUICtrlRead($log))
_IEFormElementSetValue ($oPass, GUICtrlRead($haslo))


_IEAction ($oSubmit, "click")
_IELoadWait($oIE)

WinWaitActive ("BattleKnight - Windows Internet Explorer")
Sleep (5000)



EndFunc
    
Func sprlogowanie()
$zalogowany =   _IEBodyReadHTML($oIE)
If NOT StringInStr($zalogowany, "art/switch_7.gif") Then
loguj2()
EndIf
EndFunc

And it will do still all in the same window

Share this post


Link to post
Share on other sites

It's creating a new window because you have $oIE declared inside your first function. Just move the

Global $oIE = _IECreate ("www.battleknight.pl");
to someplace before the function. Since you are calling loguj2() when the string is not found then you are telling it to create another instance of the object ($oIE) which points to the same page.

Example of better placement

#include<ie.au3>
Global $oIE = _IECreate ("www.battleknight.pl");
more code here (possibly)
Func loguj()
$oUser = _IEGetObjByName ($oIE, "user_name")
$oPass = _IEGetObjByName ($oIE, "user_password")
$oServer = _IEGetObjByName ($oIE, "Server")
$oSubmit = _IEGetObjByName ($oIE, "Submit")

_IEFormElementOptionselect($oServer,GUICtrlRead($server))
_IEFormElementSetValue ($oUser,GUICtrlRead($log))
_IEFormElementSetValue ($oPass, GUICtrlRead($haslo))


_IEAction ($oSubmit, "click")
_IELoadWait($oIE)

WinWaitActive ("BattleKnight - Windows Internet Explorer")
Sleep (5000)

sprlogowanie()

EndFunc
#cs;; You shouldn't need this one
func loguj2()
$oUser = _IEGetObjByName ($oIE, "user_name")
$oPass = _IEGetObjByName ($oIE, "user_password")
$oServer = _IEGetObjByName ($oIE, "Server")
$oSubmit = _IEGetObjByName ($oIE, "Submit")

_IEFormElementOptionselect($oServer,GUICtrlRead($server))
_IEFormElementSetValue ($oUser,GUICtrlRead($log))
_IEFormElementSetValue ($oPass, GUICtrlRead($haslo))


_IEAction ($oSubmit, "click")
_IELoadWait($oIE)

WinWaitActive ("BattleKnight - Windows Internet Explorer")
Sleep (5000)



EndFunc
#ce
Func sprlogowanie()
$zalogowany =   _IEBodyReadHTML($oIE)
If NOT StringInStr($zalogowany, "art/switch_7.gif") Then
loguj2()
EndIf
EndFunc

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0