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

#6 ·  Posted (edited)

20 minutes ago, FMS said:

Could u help me correct the 2 functions?

I'll give it a look :)

Edit:

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

Edited by genius257

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.


Wondering who uses AutoIT and what it can be used for ?


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

Last update: 2017-03-27
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 SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 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 *

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."

 

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 ....

 


Wondering who uses AutoIT and what it can be used for ?


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

Last update: 2017-03-27
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 SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 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 *

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."

 

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

    • anub13
      By anub13
      Hi,

      I am having difficulties wondering why my code bugging like this,
      the symptom : I have a form with combo box, and details in bottom of the app, when user choose another option the details changes immediately but when I go to details, it goes up and down endlessly
      here is the code
       
      Global $cChkPatrol, $YES= "YES", $NO = "NO" if GUICtrlRead($combo1) = "YES" Then $cChkPatrol = $YES Else $cChkPatrol = $NO EndIf func StartForm() GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & asdfgSystemInfo()) GUISetState(@SW_SHOW) AdlibRegister("_CheckPatrol") While 1 $nMsg = GUIGetMsg() Select case $nMsg = $txtEmailAddress GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & asdfgSystemInfo()) case $nMsg = $txtPhone GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & asdfgSystemInfo()) case $nMsg = $txtFullName GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & asdfgSystemInfo()) case $nMsg = $cChkPatrol GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & asdfgSystemInfo()) case $nMsg = $cmdScreenShot $gScreenShotFile = SaveScreenShot() case $nMsg = $cmdSubmit if ValidateForm() then if asdfgSubmit() Then UpdateStatus("Your request has been sent successfully") MsgBox(0,"Help Requested","Your request has been sent successfully") ExitLoop Else MsgBox(0,"Help Failed","Something is wrong you request was not sent, please try again") Endif endIf case $nMsg = $cmdAttach $gAttachFile = AttachFile() Case $nMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd AdlibUnRegister("_CheckPatrol") EndFunc func asdfgSystemInfo() dim $asdfgInfo $asdfgInfo = "" & @CRLF if $isAdminVersion=1 then $asdfgInfo = $asdfgInfo & @CRLF & " Ticket Tags:" & @CRLF $asdfgInfo = $asdfgInfo & "~#userphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF $asdfgInfo = $asdfgInfo & "~#submitterphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF dim $MachineID $MachineID = KaseyaIni($gKIniFile,"SERVER COMMUNICATIONS","User_Name","NotFound") $asdfgInfo = $asdfgInfo & "~#machineid='" & $MachineID & "'" & @CRLF dim $OrgGroups $OrgGroups= StringSplit($MachineID,".") dim $OrgGroupIndex $OrgGroupIndex = UBound($OrgGroups) - 1 $asdfgInfo = $asdfgInfo & "~#organization='" & $OrgGroups[$OrgGroupIndex] & "'" & @CRLF dim $EmailUser $EmailUser = GUICtrlRead($txtEmailAddress) $EmailUser = StringMid($EmailUser,1,StringInStr($EmailUser,"@") - 1) & @CRLF & @CRLF $asdfgInfo = $asdfgInfo & "~#username='" & $EmailUser & "'" & @CRLF ;dim ;Call("isChecked") ;$categ = GUICtrlRead($chkPatrol) ;$asdfgInfo = $asdfgInfo & "-#category='" & $categ & "'" & @CRLF EndIf $asdfgInfo = $asdfgInfo & "Email:" & GUICtrlRead($txtEmailAddress) & @CRLF & @CRLF $asdfgInfo = $asdfgInfo & "Full Name:" & GUICtrlRead($txtFullName) & @CRLF & @CRLF $asdfgInfo = $asdfgInfo & "Phone:" & GUICtrlRead($txtPhone) & @CRLF & @CRLF $asdfgInfo = $asdfgInfo & "DateTime:" & _Now() & @CRLF $asdfgInfo = $asdfgInfo & "MachineName:" & @ComputerName & @CRLF $asdfgInfo = $asdfgInfo & "UserName:" & @UserName & @CRLF $asdfgInfo = $asdfgInfo & "OS:" & @OSType & " " & @OSVersion & @CRLF $asdfgInfo = $asdfgInfo & "LogonDomain:" & @OSType & " " & @LogonDomain & @CRLF $asdfgInfo = $asdfgInfo & "LogonDNSDomain:" & @OSType & " " & @LogonDNSDomain & @CRLF $asdfgInfo = $asdfgInfo & "OS:" & @OSType & " " & @OSVersion & @CRLF $asdfgInfo = $asdfgInfo & "IP Address:" & @IPAddress1 & @CRLF $asdfgInfo = $asdfgInfo & "Public IP Address:" & GetPublicIP() &@CRLF ;$asdfgInfo = $asdfgInfo & "Public IP Address:" & _GetIP () &@CRLF $asdfgInfo = $asdfgInfo & "OS:" & NetAdapterInfo() $asdfgInfo = $asdfgInfo & "KaseyaInstalled:" & KaseyaInstalled() & @CRLF $asdfgInfo = $asdfgInfo & "KaseyaRunning:" & KaseyaRunning() & @CRLF $asdfgInfo = $asdfgInfo & "KaseyaAgentGUID:" & KaseyaIni($gKIniFile,"SERVER COMMUNICATIONS","Agent_Guid","NotFound") & @CRLF $asdfgInfo = $asdfgInfo & "asdfgPaid:" & isasdfgIDPaid() & @CRLF if $isAdminVersion=0 then $asdfgInfo = $asdfgInfo & @CRLF & " Ticket Tags:" & @CRLF $asdfgInfo = $asdfgInfo & "~userphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF $asdfgInfo = $asdfgInfo & "~submitterphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF dim $MachineID $MachineID = KaseyaIni($gKIniFile,"SERVER COMMUNICATIONS","User_Name","NotFound") $asdfgInfo = $asdfgInfo & "~machineid='" & $MachineID & "'" & @CRLF dim $OrgGroups $OrgGroups= StringSplit($MachineID,".") dim $OrgGroupIndex $OrgGroupIndex = UBound($OrgGroups) - 1 $asdfgInfo = $asdfgInfo & "~organization='" & $OrgGroups[$OrgGroupIndex] & "'" & @CRLF dim $EmailUser $EmailUser = GUICtrlRead($txtEmailAddress) $EmailUser = StringMid($EmailUser,1,StringInStr($EmailUser,"@") - 1) $asdfgInfo = $asdfgInfo & "~username='" & $EmailUser & "'" & @CRLF dim $categ $categ = $chkPatrol $asdfgInfo = $asdfgInfo & "~category='" & $categ & "'" & @CRLF dim $track $track = $cChkPatrol $asdfgInfo = $asdfgInfo & "~test='" & $cChkPatrol & "'" & @CRLF $asdfgInfo = $asdfgInfo & "~afterhour='" & $AfterHour & "'" & @CRLF endif Return $asdfgInfo endFunc  
      Yes it was same app as previous post in the forum I asked, I also having experience this happening before but I fail to understand the reason why this is happening. Thanks in advance.
      ButtonSupport - Copy.au3
    • Fhelipe
      By Fhelipe
      So I wanted to use my machine as a server for a program that had a unique login system. It can only log in 1 person and the password is in the script itself. I would like to adptar my code or change it completely so that I can create a database and the Script At Time Of Login Get Database Login And Log In
      Experience with Autoit: Basic                      (sorry for bad English)
      Experience with SQL: None                              (translator only)
      Code Currently Used To Login:
      ;=========================================================
      While 1
          $MSG = GUIGetMsg()
          Switch $MSG
          Case $ButtonOk
              If VerifyLogin(GUICtrlRead($USERNAME),GUICtrlRead($PASSWORD)) = 1 Then
                  GUIDelete($Form1)
                  MsgBox(-1,"Logado com Sucesso","Login Sucedido, Para Parar o Aimbot Pressione ESC!")
                  Run ("C:\Program Files (x86)\Steam\steamapps\common\Mitos.is The Game\Mitosis.exe")
                  RunP()
              Else
                  MsgBox(-1,"Error","Usúario ou Senha está incorreto, Ou Ainda Não Pagou!")
               EndIf
          Case -3
              Exit
           Case $ButtonCancel
              Exit
                Case $HelpButton
               MsgBox(-1, "Criadores", "Criadores: Zummey & Ralta")
      Case $Register
         MsgBox(-1, "ERRO", "PROGRAMA EM DESENVOLVIMENTO FUNÇÃO DESABILITADA")
          EndSwitch
      WEnd
      Func VerifyLogin($USERNAME,$PASSWORD)
          If $USERNAME = "Zummey" And $PASSWORD = "xd90fe10" Then
              Return 1
          Else
              Return 0
          EndIf
      EndFunc; End login
      ;=========================================================
    • IamKJ
      By IamKJ
      I am trying to allow the GUI to gather info as to when to execute a function.  I am having trouble doing this.  So far this is what I have.
       
      ;Timer Func timer () If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(36,"Timer","Please format your answer in 00:00:00:000") Select Case $iMsgBoxAnswer = 6 ;Yes Global $infotime = InputBox ('Time', 'What time to execute?') Do $rawtimer = ToolTip(@Hour & ':' & @Min & ':' & @Sec & ':' & _MSec()) until $rawtimer = $infotime if $rawtimer = $infotime Then msgbox (0,'Worked','Worked') Else EndIf Case $iMsgBoxAnswer = 7 ;No Exit EndSelect EndFunc Func _MSec() Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort') DllCall('kernel32.dll', 'none', 'GetSystemTime', 'ptr', DllStructGetPtr($stSystemTime)) $sMilliSeconds = StringFormat('%03d', DllStructGetData($stSystemTime, 8)) $stSystemTime = 0 Return $sMilliSeconds EndFunc I have also tried _GUIToolTip_GetText in order to read the tooltip until the time specified, but it still doesn't work.  Any help would be great.
    • IamKJ
      By IamKJ
      So I have a lot of different functions in the little program I'm making.  Most of them use the Do statement, such as finding images, clicking buttons, etc.
       
      The question I have is how would I be able to both
      1) Create a hotkey to pause whatever I am doing at the moment.  If I have to put something into every function in the program, I don't mind.
      2) Create a hotkey to exit whatever I am doing and stop all loops or commands and bring back the main GUI?
    • Manivel
      By Manivel
      Hi,
      Can any one please share the Connection string for SQL Developer. 
      How to Connect the SQL Developer from AutoIT. We need to execute the query through AutoIt. is that possible ?