FMS

XML search get change settings.

31 posts in this topic

#1 ·  Posted (edited)

Hello ,

I've the following problem and hope somebody can push me in the right direction or have a good example on how to do it.
The problem is :I want to search / select / change /check a XML setting in a XML file.

The example XML file is as following :

<Configuration>
  <Categories>
    <Category Name="default">
      <SubCategories>
        <SubCategory Name="defaultsettings">
          <Settings>
            <Setting Name="machinename" TypeName="System.String" Value="defaultname" />
            <Setting Name="cpuspeed" TypeName="System.String" Value="false" />
            <Setting Name="cmptemp" TypeName="System.String" Value="false" />
            <Setting Name="cmpspeed_set" TypeName="System.String" Value="" />
            <Setting Name="cmptemp_set" TypeName="System.String" Value="" />
          </Settings>
        </SubCategory>
      </SubCategories>
    </Category>
    <Category Name="settings">
      <SubCategories>
        <SubCategory Name="comp1">
          <Settings>
            <Setting Name="machinename" TypeName="System.String" Value="comp1" />
            <Setting Name="cpuspeed" TypeName="System.String" Value="true" />
            <Setting Name="cmptemp" TypeName="System.String" Value="false" />
            <Setting Name="cmpspeed_set" TypeName="System.String" Value="12" />
            <Setting Name="cmptemp_set" TypeName="System.String" Value="" />
          </Settings>
        </SubCategory>
        <SubCategory Name="comp2">
          <Settings>
            <Setting Name="machinename" TypeName="System.String" Value="comp2" />
            <Setting Name="cpuspeed" TypeName="System.String" Value="false" />
            <Setting Name="cmptemp" TypeName="System.String" Value="true" />
            <Setting Name="cmpspeed_set" TypeName="System.String" Value="" />
            <Setting Name="cmptemp_set" TypeName="System.String" Value="9" />
          </Settings>
        </SubCategory>
      </SubCategories>
    </Category>
  </Categories>
</Configuration>

In this XML file I want to :

-search if subcategory whit the name "comp3" exists
-if exist change of setting "cpuspeed" value to false
-if not exist make a new subcategory "comp3" whit the default settings from subcategory "default settings"

what i have this far is :

Func xml_test1()
   Dim $return[0]
   Local $file = @ScriptDir & "\test.xml"
   FileOpen($file, $FO_READ)
   _FileReadToArray($file,$return)
   FileClose($file)
         msg("",$return[28])
         msg("",$return[29])
EndFunc
   
func xml_test2()
   Local $file = @ScriptDir & "\test.xml"
   Local $oXML = ObjCreate("Microsoft.XMLDOM")
;~    $oXML.load("D:\___BUILDS___\___SRMT___\test.xml")
   $oXML.load($file)
   
   $oOther= $oXML.SelectSingleNode("//Configuration/Categories/Category/SubCategories/SubCategory/Settings/Setting") ; or //other
   ConsoleWrite("$oOther.text=[" & $oOther.text & "]" & @CRLF)
EndFunc

i know it is not enough what I'm trying to do but I'm realy stuk in what to do next.
I've searched in the XML.udf but could not find in the examples what to do what i want to do.
The things what i found are about <settings>false</settings> writing style of XML and not the way I've the XML.
(or I'm reading it wrong)

Is there somebody who can help me on mine way or has a good example script?

Thanks in advanced
 

Edited by FMS

as finishing touch god created the dutch

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

11 hours ago, FMS said:

-search if subcategory whit the name "comp3" exists

$oMatches = $oXML.selectNodes("SubCategory[Name='comp3']")
If $oMatches.Length>0 Then
    ;1 or more matches
Else
    ;no matches
EndIf

 

11 hours ago, FMS said:

-if exist change of setting "cpuspeed" value to false

For $i=0 To $oMatches.Length-1
    $oMatches.Item($i).selectSingleNode(".//Setting[@Name='cpuspeed']").SetAttribute("Value", "False"); Using selectSingleNode due to expectation that it only appears once withing the match?
Next

 

11 hours ago, FMS said:

-if not exist make a new subcategory "comp3" whit the default settings from subcategory "default settings"

$oMatch = $oXML.selectSingleNode("//Category[@Name='default']//SubCategory[@Name='defaultsettings']")
$oNode = $oMatch.CloneNode( True )
$oNode.SetAttribute("Name", "comp3")
$oNode.selectSingleNode(".//Setting[@Name='cpuspeed']").SetAttribute("Value", "false")
$oMatch = $oXML.selectSingleNode("//Category[@Name='settings']/SubCategories")
$oMatch.AppendChild( $oNode )

MsgBox(0, "", $oXML.xml); showing the xml after changes

 

Now I'm a bit lazy, so i did not add much error checking... but you can check up on the documentation, should you need it:

DOM Reference

XPath Syntax

IXMLDOMElement Members

 

Let me know if you need further help, or this makes no sense to you :)

Edited by genius257

Share this post


Link to post
Share on other sites

hello,
 

thanks for the example script @genius257.
I think i got it (for a bit i must say)
I fiddeled something around whit it because it was indeed something rocky code :)
(strangly i got a error whish i don't understand - "Variable used without being declared. - > For $i=0 To $oMathes.Length-1")
But this variable was made a sentence before :
 

Local $file = @ScriptDir & "test.xml"
Local $oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.load($file)
;-if exist change of setting "cpuspeed" value to false
$oMatches = $oXML.selectNodes("SubCategory[Name='comp3']")
If $oMatches.Length>0 Then
    ConsoleWrite("hit = 1 or more" & @CRLF)
Else
    ConsoleWrite("hit = 0" & @CRLF)
EndIf

;-if exist change of setting "cpuspeed" value to false

For $i=0 To $oMathes.Length-1
    $oMatches.Item($i).selectSingleNode(".//Setting[@Name='cpuspeed']").SetAttribute("Value", "False"); Using selectSingleNode due to expectation that it only appears once withing the match?
Next
ConsoleWrite("setting should be changed cpuspeed = False" & @CRLF)
;-if not exist make a new subcategory "comp3" whit the default settings from subcategory "default settings"

$oMatch = $oXML.selectSingleNode("//Category[@Name='default']//SubCategory[@Name='defaultsettings']")
$oNode = $oMatch.CloneNode( True )
$oNode.SetAttribute("Name", "comp3")
$oNode.selectSingleNode(".//Setting[@Name='cpuspeed']").SetAttribute("Value", "false")
$oMatch = $oXML.selectSingleNode("//Category[@Name='settings']/SubCategories")
$oMatch.AppendChild( $oNode )
ConsoleWrite("section comp3 should be present" & @CRLF)
MsgBox(0, "", $oXML.xml); showing the xml after changes

anyway ,
i made 2 functions for it whish i hope u can help me whit.
The first funcion is to change the variable
Here he din't find any but i know it's there, so i fiddled around whit the $LC_hits (nothing found this far:))
if it lays on this i dont know.
 

Func XML_change()
   Local $LC_XML_file = @ScriptDir & "LocalSettings_forum.xml"
   Local $LC_XML_obj = ObjCreate("Microsoft.XMLDOM")
   $LC_XML_obj.load($LC_XML_file)
;~    Local $LC_hits = $LC_XML_obj.selectNodes("//Configuration/Categories/Category/SubCategories/SubCategory[name='Initialization']")
;~    Local $LC_hits = $LC_XML_obj.selectNodes("SubCategory[name='comp1']")
   Local $LC_hits = $LC_XML_obj.selectNodes("//Configuration//Categories//Category[@name='default']//SubCategory[name='comp1']")
   If $LC_hits.length = 0 Then
      ConsoleWrite("hit = 0" & @CRLF)
   ElseIf $LC_hits.length = 1 Then
      ConsoleWrite("hit = 1 " & @CRLF)
      For $i = 0 To $LC_hits.length - 1
         $LC_hits.Item($i).SelectSingleNode(".//Setting[@name='PosId']").SetAttribute("Value","1")
      Next
      ConsoleWrite("value should be changed" & @CRLF)
   ElseIf $LC_hits.length > 1 Then
      ConsoleWrite("hit = more then 1" & @CRLF)
   EndIf
EndFunc

The second function i made is to search and make
here i get an error " The requested action with this object has failed." -> ""Local $LC_XML_node = $LC_hit.CloneNode( True )"
and possibly also that he cant find even if it exist.

Func XML_search_or_make()
   Local $LC_XML_file = @ScriptDir & "LocalSettings_forum.xml"
   Local $LC_XML_obj = ObjCreate("Microsoft.XMLDOM")
   $LC_XML_obj.load($LC_XML_file)
;~    Local $LC_hits = $LC_XML_obj.selectNodes("//Configuration/Categories/Category/SubCategories/SubCategory[name='Initialization']")
   Local $LC_hits = $LC_XML_obj.selectNodes("SubCategory[name='comp3']")
   If $LC_hits.length = 0 Then
      ConsoleWrite("hit = 0" & @CRLF)
      Local $LC_hit = $LC_XML_obj.SelectSingleNode("//Category[@name='default']//SubCategory[@name='defaultsettings']")
      Local $LC_XML_node = $LC_hit.CloneNode( True )
      $LC_XML_node.SetAttribute["Name","Comp3"]
      $LC_XML_node.selectSingleNode(".//Setting[@name='cpuspeed']".SetAttribute("Value","false")
      $LC_hit = $LC_XML_obj.selectSingleNode("//Category[@name='settings']/Subcategories")
      $LC_hit.AppendChild( $LC_XML_node )
      MsgBox(0,"",$LC_XML_obj.xml)
   ElseIf $LC_hits.length = 1 Then
      ConsoleWrite("hit = 1" & @CRLF)
   ElseIf $LC_hits.length > 1 Then
      ConsoleWrite("hit = more then 1" & @CRLF)
   EndIf
EndFunc

Could somebody help whit this?

PS. Are there any includes i need for all this?

Thanks in advanced.

 


 


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
5 minutes ago, FMS said:

(strangly i got a error whish i don't understand - "Variable used without being declared. - > For $i=0 To $oMathes.Length-1")

Sorry, that's my mistake :sweating:

I mispelled a variable in my second answer:

$oMathes

should be:

$oMatches

I will edit it in the post above right away :>

 

7 minutes ago, FMS said:

here i get an error " The requested action with this object has failed." -> ""Local $LC_XML_node = $LC_hit.CloneNode( True )"

That's what i was talking about with the error handling i did not do much of. "SelectSingleNode" will return a null object, if no match was found, whereas the selectNodes return a collection you can measure the length of. So the error is the result of you trying to call a function that does not exist in a null object.

 

11 minutes ago, FMS said:

PS. Are there any includes i need for all this?

For my examples? No.

Share this post


Link to post
Share on other sites

 lol I din't find that misspelling :S.
But i must say I'm a little lost in what you say.....
I tried to correct it in the code but dont know how to start.
Could u help me correct the 2 functions?
Or did you mean the code i've written will never work?
 


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites

So I've added some comments explaining some of the errors.

But mostly it's just comes down to the fact that you need to be case specific so something like "Subcategories" would fail, but "SubCategories" would work

Func XML_change()
;~    Local $LC_XML_file = @ScriptDir & "LocalSettings_forum.xml"
   Local $LC_XML_file = @ScriptDir & "test.xml"
   Local $LC_XML_obj = ObjCreate("Microsoft.XMLDOM")
   $LC_XML_obj.load($LC_XML_file)
;~    Local $LC_hits = $LC_XML_obj.selectNodes("//Configuration/Categories/Category/SubCategories/SubCategory[name='Initialization']")
;~    Local $LC_hits = $LC_XML_obj.selectNodes("SubCategory[name='comp1']")
   Local $LC_hits = $LC_XML_obj.selectNodes("//Configuration//Categories//Category[@name='default']//SubCategory[name='comp1']")
   If $LC_hits.length = 0 Then
      ConsoleWrite("hit = 0" & @CRLF)
   ElseIf $LC_hits.length = 1 Then
      ConsoleWrite("hit = 1 " & @CRLF)
      For $i = 0 To $LC_hits.length - 1
         $LC_hits.Item($i).SelectSingleNode(".//Setting[@name='PosId']").SetAttribute("Value","1")
      Next
      ConsoleWrite("value should be changed" & @CRLF)
   ElseIf $LC_hits.length > 1 Then
      ConsoleWrite("hit = more then 1" & @CRLF)
   EndIf
EndFunc
Func XML_search_or_make()
;~    Local $LC_XML_file = @ScriptDir & "LocalSettings_forum.xml"
   Local $LC_XML_file = @ScriptDir & "\test.xml"
   Local $LC_XML_obj = ObjCreate("Microsoft.XMLDOM")
   $LC_XML_obj.load($LC_XML_file)
;~    Local $LC_hits = $LC_XML_obj.selectNodes("//Configuration/Categories/Category/SubCategories/SubCategory[name='Initialization']")
   Local $LC_hits = $LC_XML_obj.selectNodes("SubCategory[name='comp3']")
   If $LC_hits.length = 0 Then
      ConsoleWrite("hit = 0" & @CRLF)
      Local $LC_hit = $LC_XML_obj.selectNodes("//Category[@Name='default']//SubCategory[@Name='defaultsettings']");the @Name must be case specific
      If Not ($LC_hit.Length>0) Then Return; Escape the function if no match is found
      Local $LC_XML_node = $LC_hit.Item(0).CloneNode( True )
;~       $LC_XML_node.SetAttribute["Name","Comp3"]; This should be called with parenthesis, not square brackets ^^'
      $LC_XML_node.SetAttribute("Name","Comp3")
;~       $LC_XML_node.selectSingleNode(".//Setting[@name='cpuspeed']".SetAttribute("Value","false"); you are missing a parenthesis
      $LC_XML_node.selectSingleNode(".//Setting[@Name='cpuspeed']").SetAttribute("Value","false")
      $LC_hit = $LC_XML_obj.selectSingleNode("//Category[@Name='settings']/SubCategories"); Subcategories should be SubCategories
      $LC_hit.AppendChild( $LC_XML_node )
      MsgBox(0,"",$LC_XML_obj.xml)
   ElseIf $LC_hits.length = 1 Then
      ConsoleWrite("hit = 1" & @CRLF)
   ElseIf $LC_hits.length > 1 Then
      ConsoleWrite("hit = more then 1" & @CRLF)
   EndIf
EndFunc

Sorry if i didn't remove all my garbage lines for debugging, I'm off to bed for now :)

Share this post


Link to post
Share on other sites

Thnx @genius257 I got the making part of the unknown "comp3"

unfortanyl i dont think the searching part in "change" function is working.

or is there something i dint see?

sorry to ask again but could you look again?


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
1 hour ago, FMS said:

unfortanyl i dont think the searching part in "change" function is working.

Well

Local $LC_hits = $LC_XML_obj.selectNodes("//Configuration//Categories//Category[@name='default']//SubCategory[name='comp1']")

Should be

Local $LC_hits = $LC_XML_obj.selectNodes("//Configuration//Categories//Category[@Name='default']//SubCategory[@Name='comp1']")

 

I hope you noticed that yourself, and yes i know that's my mistake :)

Second, the xml you posted, I test with does not have anything that would match your query, so it's hard to know if the function succeeds or not.

That's why i said:

On 10/9/2016 at 0:04 AM, genius257 said:

Could you post the xml, if it's different than the original?

 

Share this post


Link to post
Share on other sites

thank you very mush @genius257 , everything is working fine now :)
And no i din't find that typo :S it's mine dyslectia playing around whit me :)

Also I've learned some new things now, many thanks for that.
The final thing I cant work out is tho exaly write it to the XML file :)

I see it now changed in the :

MsgBox(0,"",$LC_XML_obj.xml)

But not in the file itself :S , I think it is a noobisch question but working whit XML is a new thing for me :)
Is there a special function to write it back to the XML itself?

 


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I'm happy everyting is working :)

18 minutes ago, FMS said:

Is there a special function to write it back to the XML itself?

Yes and no :sweating:

It's not just one function, as you will have to overwrite the entire output in the file.

So something like:

$hFile = FileOpen(@ScriptDir & "\test.xml", 2);$FO_OVERWRITE
FileWrite($hFile, $LC_XML_obj.xml)
FileClose($hFile)

I would suggest looking into the help files and add error checking, if you wish to avoid problems. ^_^

They may end up wasting countless hours on debugging (i have that problem a lot :P)

Edited by genius257

Share this post


Link to post
Share on other sites

:lmao:rofl , no that can't be it.....
Stupid of me i din't think of doing that, i thought it was mush harder than that.
But what do you mean whit error checking on this 3 line of code?
maybe i don't understand it right but do u mean only check on fileopen , fileclose and filewrite?
Or do you mean if in the $LC_XML.obj is changed what i want to change?

 


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
Just now, FMS said:

But what do you mean whit error checking on this 3 line of code?

FileOpen may fail for various reasons, i imagine FileWrite is also worth checking, just in case. FileClose however don't need any error checking.

It's just a precaution, to avoid data not being saved before you close down the program, thinking everything is dandy ^_^

Share this post


Link to post
Share on other sites

o is that all :)
that's what i always do but thank you for pointing out :)
(even i check on fileclose , why i should't i don't now)
I probaly check everything i do i must say.
But final question i've got on mine mind if you are up for that.
Do i need also to properly dispose of the $LC_XML_obj because it's now loaded in ?
Or because it's locale in the function it's cleaning up itself?

That was mine final question , many thanks for helping me around this subject.
10.000 points for grifindor!


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

12 minutes ago, FMS said:

Do i need also to properly dispose of the $LC_XML_obj because it's now loaded in ?
Or because it's locale in the function it's cleaning up itself?

Well honestly I'm not 100% sure, i believe the local variables gets cleaned up by the garbage collector when the function ends. Personally i just leave it like that, but that question might be worth searching for in the forum, i believe I've seen it discussed.

12 minutes ago, FMS said:

That was mine final question , many thanks for helping me around this subject.
10.000 points for grifindor!

It was fun for me too :)
Haha! Why thank you :lol:

Edited by genius257
1 person likes this

Share this post


Link to post
Share on other sites

humm I'm very sorry to disturb you again @genius257 but when i thought i got it  , a error was lurking around :>
I hope u can help me once more because i realy don't understand why it gives me this error.
When I was making this "Beta" function :

Func XML_change();hidden button 1
   Local $LC_XML_file = @ScriptDir & "\forum.xml"
   Local $LC_XML_obj = ObjCreate("Microsoft.XMLDOM")
   $LC_XML_obj.load($LC_XML_file)
   Local $LC_hits = $LC_XML_obj.selectNodes("//Configuration//Categories//Category[@Name='settings']//SubCategory[@Name='comp1']")
;~    MsgBox(0,"",$LC_XML_obj.xml)
   If $LC_hits.length = 0 Then
      ConsoleWrite("hit = 0" & @CRLF)
   ElseIf $LC_hits.length = 1 Then
      ConsoleWrite("hit = 1" & @CRLF)
      For $i = 0 To $LC_hits.length - 1
         $LC_hits.Item($i).SelectSingleNode(".//Setting[@name='cmptemp_set']").SetAttribute("Value","1")
      Next
      MsgBox(0,"",$LC_XML_obj.xml)
   ElseIf $LC_hits.length > 1 Then
      ConsoleWrite("hit = more then 1" & @CRLF)
   EndIf
EndFunc

I did got this error :

$LC_hits.Item($i).SelectSingleNode(".//Setting[@name='cmptemp_set']").SetAttribute("Value","1")
$LC_hits.Item($i).SelectSingleNode(".//Setting[@name='cmptemp_set']")^ ERROR

At first I thought it was the <settings> between <subcategory> and <setting> , but in no case it got me another error then this.
If I'm not mistaking it can't find the attribute value? (but can find //SubCategory[@Name='comp1'])


 


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
9 hours ago, FMS said:

I did got this error :

$LC_hits.Item($i).SelectSingleNode(".//Setting[@name='cmptemp_set']").SetAttribute("Value","1")
$LC_hits.Item($i).SelectSingleNode(".//Setting[@name='cmptemp_set']")^ ERROR

 

Yeah no match is returned from you query.

I bet if you notice the attribute name is all lower case, you find your answer. :)

hint:

@name

 

Share this post


Link to post
Share on other sites
10 hours ago, FMS said:

I did got this error :

$LC_hits.Item($i).SelectSingleNode(".//Setting[@name='cmptemp_set']").SetAttribute("Value","1")
$LC_hits.Item($i).SelectSingleNode(".//Setting[@name='cmptemp_set']")^ ERROR

 

You can not use such long onliner, you should pares it for each method to separate lines and check for errors  after each line.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

pfff was that it the uppercase N :)
thanks, all works fine (again) @genius257

also thanks for pointing that out @mLipok , but i must say I'm rather new to XML searches and changes.
And realy don't know where you are talking about.
Could u show me what u mean>?


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
$step1 = $LC_hits.Item($i)
If @error ....
$step2 = $step1.SelectSingleNode(".//Setting[@name='cmptemp_set']")
If @error ....
$step3 = $step2.SetAttribute("Value","1")
If @error ....

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

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

  • Similar Content

    • VaishnaviBUtpat
      By VaishnaviBUtpat
      <!DOCTYPE html> <html lang="en" xml:lang="en" style="height: 100%;" xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style> * { margin: 0; padding: 0; } .th-lk { color: #3665d0; font-family: Arial; font-size: small; text-decoration: none; } .th-lk { vertical-align: 0px; } .th-menu2 .th-lk { line-height: 2em; margin-bottom: 0px; margin-right: 0px; overflow: hidden; padding: 0; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; width: 100%; } .th-menu2 .th-lk { color: black; font-weight: bold; } .th-menu2 > li > .th-lk { display: block; padding-left: 8px; width: auto; } .th-menu2 .th-menu2-sub-item .th-lk, .th-menu2 .th-menu2-sub-item-hov .th-lk { margin-right: 20px; } .th-menu2-sub-item { position: relative !important; } .th-menu2 .th-menu2-item, .th-menu2 .th-menu2-item-hov, .th-menu2 .th-menu2-sub-item, .th-menu2 .th-menu2-sub-item-hov { background-repeat: repeat-x; border-left-style: solid; border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-style: solid; border-top-width: 1px; height: 2em; list-style: none; margin-bottom: 0px; padding: 0; width: 100%; } .th-menu2 .th-menu2-item, .th-menu2 .th-menu2-item-hov, .th-menu2 .th-menu2-sub-item, .th-menu2 .th-menu2-sub-item-hov { background-color: #ECECEC; background-image: url(sap_skins/default/styling/lshape/chg_butt_det_nav.gif); border-left-color: #d3d1ce; border-right-color: #d3d1ce; border-top-color: #d3d1ce; border-top-width: 0px; } .th-menu2 { border: 0 solid black; left: 0px; list-style: none; margin: 0; padding: 0; position: relative; } .th-menu2 { z-index: 10006; } .th-menu2 { background-color: white; } div { zoom: 1; } .th-sc-content { left: 0px; position: absolute; top: 0px; } .th-sc-container { left: 0px; overflow: hidden; position: relative; top: 0px; } .th-sc-top { position: relative; } .th-sc-top, .th-sc-content, .th-sc-container, .th-sc-buttondown, .th-sc-buttonup { width: 172px; } .th-sc-buttonup, .th-sc-container { z-index: 10101; } .th-sc-top { z-index: 10100; } body, td, th { font-family: Arial,Helvetica,sans-serif; font-size: small; } .th-l-navcontainer, .th_l_downcontainer { border-right-style: solid; border-right-width: 1px; width: 172px; } .th-l-navcontainer, .th_l_downcontainer { background-color: white; border-right-color: #d3d1ce; } body, html { margin: 0px; border: 0; margin: 0; } </style> </head> <body><form name="myFormId" id="myFormId" action="/sap(ZT1TVVJEWDFWVFVsOWZYMTlmTWpNNU9UWmZXWTlwZG5telZ1RGhBSUFBQ3Nyc2tBPT0=)/bc/bsp/sap/crm_ui_frame/BSPWDApplication.do?sap-client=100&amp;sap-language=EN&amp;sap-domainrelax=min" method="post" target="WorkAreaFrame2"><div class="th-ajax-area" id="rootAreaDiv"><div id="C1_W1_V2" tgt="" dhe="false"><table width="100%" style="table-layout: fixed;" cellspacing="0" cellpadding="0"><tbody><tr><td><table width="100%" style="table-layout: fixed;" cellspacing="0" cellpadding="0"><tbody><tr valign="top"><td class="th-l-navcontainer" id="th_l_navcontainer"><div class="th-sc-top" id="C1_W1_V2_thescroll" style="height: 786px;"><div class="th-sc-container" id="C1_W1_V2_thescroll_scbox" style="height: 786px;"><div class="th-sc-content" id="C1_W1_V2_thescroll_sccontent"><div class="th-ajax-area" id="C1_W1_V2_$navbar"><div id="C7_W35_V36" tgt="" dhe="true" excevt="" intevt="c:C7_W35_V36:C1_W1_V2_C7_W35_V36_MainNavigationLinks.do;" automode="true"><div class="th-ajax-area" id="C1_W1_V2_C7_W35_V36_MainNavigationLinks.do"><ul class="th-menu2" id="C7_W35_V36_mainmenu" style="width: 171px;"><li class="th-menu2-sub-item"><a title="Sales Cycle" class="th-lk" id="C7_W35_V36_UTL-SLS" onclick="htmlbSubmitLib('htmlb',this,'thtmlb:link:click:0','myFormId','C7_W35_V36_UTL-SLS','UTL\x2dSLS\x2dWC',0);return false" onfocus="thSaveKbFocus(this);" oncontextmenu="return false;" href="javascript:void(0)">Sales Cycle</a></li></ul></div></div></div></div></div></div></td></tr></tbody></table></td></tr></tbody></table></div></div></form></body> </html> How to capture above HTML element using AutoIT
    • cu0x
      By cu0x
      Hello guys,
       
      im trying to solved a problem that I have.
       
      Need to get some chinese text from an old Wise script, and in the wise file says f.e. Ù×÷ϵͳ¡£ ÇëÉý¼¶Ä. Is there any way to convert it to traditional chinese?
       
      Already tryied the following code...
       
      #include <MsgBoxConstants.au3> Example() Func Example() ; Define the string that will be converted later. ; NOTE: This string may show up as ?? in the help file and even in some editors. ; This example is saved as UTF-8 with BOM. It should display correctly in editors ; which support changing code pages based on BOMs. Local Const $sString = "Ù×÷ϵͳ¡£ ÇëÉý¼¶Ä" ; Temporary variables used to store conversion results. $dBinary will hold ; the original string in binary form and $sConverted will hold the result ; afte it's been transformed back to the original format. Local $dBinary = Binary(""), $sConverted = "" ; Convert the original UTF-8 string to an ANSI compatible binary string. $dBinary = StringToBinary($sString) ; Convert the ANSI compatible binary string back into a string. $sConverted = BinaryToString($dBinary) ; Display the resulsts. Note that the last two characters will appear ; as ?? since they cannot be represented in ANSI. DisplayResults($sString, $dBinary, $sConverted, "ANSI") ; Convert the original UTF-8 string to an UTF16-LE binary string. $dBinary = StringToBinary($sString, 2) ; Convert the UTF16-LE binary string back into a string. $sConverted = BinaryToString($dBinary, 2) ; Display the resulsts. DisplayResults($sString, $dBinary, $sConverted, "UTF16-LE") ; Convert the original UTF-8 string to an UTF16-BE binary string. $dBinary = StringToBinary($sString, 3) ; Convert the UTF16-BE binary string back into a string. $sConverted = BinaryToString($dBinary, 3) ; Display the resulsts. DisplayResults($sString, $dBinary, $sConverted, "UTF16-BE") ; Convert the original UTF-8 string to an UTF-8 binary string. $dBinary = StringToBinary($sString, 4) ; Convert the UTF8 binary string back into a string. $sConverted = BinaryToString($dBinary, 4) ; Display the resulsts. DisplayResults($sString, $dBinary, $sConverted, "UTF8") EndFunc ;==>Example ; Helper function which formats the message for display. It takes the following parameters: ; $sOriginal - The original string before conversions. ; $dBinary - The original string after it has been converted to binary. ; $sConverted- The string after it has been converted to binary and then back to a string. ; $sConversionType - A human friendly name for the encoding type used for the conversion. Func DisplayResults($sOriginal, $dBinary, $sConverted, $sConversionType) MsgBox($MB_SYSTEMMODAL, "", "Original:" & @CRLF & $sOriginal & @CRLF & @CRLF & "Binary:" & @CRLF & $dBinary & @CRLF & @CRLF & $sConversionType & ":" & @CRLF & $sConverted) EndFunc ;==>DisplayResults Thanks a lot!
    • nacerbaaziz
      By nacerbaaziz
      Hi dear
      I want create retractable bar using autoit
      I tried creating slider, but there's a problem with screen reader for the blind, so is there another retractable tape?
      It is advisable to not accept dragging with the keybord only with  mouse
      note:
      This bar is needed in the process of raising and lowering the volume
      I hope that there is a solution to do that
      i waiting your responses.
      Thanks in advance to all members and administrators
    • XanzyX
      By XanzyX
      Is there a function out there that will edit an existing file witha a "Save" and "Cancel" at the bottom?
      Example: Funcrion("TestFile.txt")
    • rte7
      By rte7
      Hello. We work with the BMC Remedy site to manage incidents and would like to automate the processes of clicking through this button code:
      <a href="javascript:" class="btn btn3d menu" style="top:21; left:184; width:21; height:21;"> <img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="menu category issue" title=""> </a> I use firefox with mozrepl and autoit with include FF.au3
      I need your help
      I read the topic https://www.autoitscript.com/forum/topic/95595-ffau3-v0601b-10/ but I could not run the code from the listed commands
      ...
      It is necessary to press the button and from the list of the menu of cahorsations to select the item = "zone of trust abonent"
      Screen # 1 http://joxi.ru/52aJK7bh4a7ypA or below.
      1) Press button
      <a href="javascript:" class="btn btn3d menu" style="top:21; left:184; width:21; height:21;"> <img class="btnimg" src="../../../../resources/images/mt_sprites.gif" alt="menu category issue" title=""> </a>
      2) After pressing the button, I need to choose in this menu of 4 items to select an item called "zone of trust abonent", Screen # 2 - http://joxi.ru/p27gwQKHo71VQ2
      html code table items
      <table class="MenuTable" cellpadding="0" cellspacing="0" style="width: 179px;"> <tbody class="MenuTableBody"> <tr class="MenuTableRow"> <td class="MenuEntryName" nowrap="">zone of trust abonent</td> <td class="MenuEntryNoSub" arvalue="zone of trust abonent"></td> </tr> <tr class="MenuTableRow"><td class="MenuEntryName" nowrap="">zone of trust operator</td> <td class="MenuEntryNoSub" arvalue="zone of trust operator"></td> </tr> <tr class="MenuTableRow"><td class="MenuEntryName" nowrap="">zone of trust third operator</td> <td class="MenuEntryNoSub" arvalue="zone of trust third operator"></td></tr> <tr class="MenuTableRow"><td class="MenuEntryNameHover" nowrap="">No settings</td> <td class="MenuEntryNoSubHover" arvalue="No settings"></td> </tr> </tbody> </table>
       
       
      More in detail, I choose from the menu item "zone of trust abonent" Screen # 3 - http://joxi.ru/GrqVq4ZIQEPW4m

       
      3) The choice is made, Screen # 4 http://joxi.ru/v297w6aC3PovLr
      <textarea class="text sr " wrap="off" id="arid_WIN_0_1000002488" cols="20" maxlen="60" style="top:21; left:0; width:179; height:21;" armenu="CFG:PRC:CategoryHPD-Res-T1-Q" mstyle="2" arautoc="1" arautocmb="1" arautocak="0" arautoctt="400" rows="1"> </textarea>
       
      It's all. I would be very grateful to you =) !!!!!!!!!!
      Here are more detailed codes in the attachment. 
      button1.txt
      menu - table.txt
      all.txt