Jump to content
Sign in to follow this  
ubelong2matt

Possible Send Bug

Recommended Posts

ubelong2matt

I'm hoping someone can help me.  I have a script that grabs the source of an XML page, parses it using _XMLDomWrapper, writes to an INI, and compares that with preparation to use "send" commands to post to a Twitter account.  The problem is, when trying to send the title of the XML, message boxes display it correctly but the sent information omits the first character, posts second, then omits two more before posting the rest of it.
 
For instance, the title is stored in a variable and is displayed as when passing it to a message box:

#Phishing: Phishing: It Help Desk

However, when it is passed to the send command to be typed into a Twitter post, it turns into:

ishing: Phishing: It Help Desk

It sounds confusing so here's my code.  The XML file and INI file will generate automatically.  I would suggest, since that's a live feed of XML that you use the XML provided below and opt NOT to update the XML file when asked.  Also, each time you run the program, you'll want to delete the INI file so it actually runs the functions to send the information.
 
WARNING:  I am not good at coding.  I learn by example and most of the code I write is sloppy and could probably be done in vastly fewer lines of code and easier with different functions or techniques.  You have been warned that this will be ugly.
 
Script:

#include <_XMLDomWrapper.au3>
#include <Inet.au3>

Opt("SendKeyDelay", 10)

;==============================================
;     VARIABLES
;==============================================
Global $xmlFile = @ScriptDir & "\alerts.xml"
Global $alertINI = @ScriptDir & "\alert.ini"
;==============================================

If FileExists($xmlFile) Then
    Switch MsgBox(36,"File Exists","The XML file exists." & @CRLF & "Should it be deleted and a new one downloaded?")
        Case 6 ;yes
            FileDelete($xmlFile)
            _getXML()
            _parseXML()
            _iniCompare()
        Case 7 ;no
            _parseXML()
            _iniCompare()
    EndSwitch
Else
    _getXML()
    _parseXML()
    _iniCompare()
EndIf

;==============================================
;     FUNCTION _getXML
;==============================================
Func _getXML()
    Local $xmlSource = _INetGetSource('http://alerts.illinoisstate.edu/xml/',True)
    FileWrite($xmlFile,$xmlSource)
EndFunc
;==============================================

;==============================================
;     FUNCTION _parseXML
;==============================================
Func _parseXML()
    _XMLFileOpen($xmlFile, 'xmlns:isuoa="http://alerts.illinoisstate.edu/xml/oa.dtd"')

    Local $title = _XMLGetValue("//title")
    Global $alertTitle = "#" & $title[3]
    MsgBox(0,"test",$alertTitle)

    Global $alertLink = _XMLGetValue("//link")
    $alertLink = StringReplace($alertLink[3],"http://","")
    $alertLink = StringReplace($alertLink,"illinoisstate","ilstu")
    $alertLink = StringReplace($alertLink,"#_","")
    ;MsgBox(0,"test",$alertLink)

    Global $alertUpdate = _XMLGetValue("//isuoa:updatecount")
    $alertUpdate = $alertUpdate[1]
    ;MsgBox(0,"test",$alertUpdate)
EndFunc
;==============================================

;==============================================
;     FUNCTION _iniCompare
;==============================================
Func _iniCompare()
    If $alertTitle = IniRead($alertINI,"OPTS","Title",0) And $alertLink = IniRead($alertINI,"OPTS","Link",0) Then
        If $alertUpdate > 0 Then
            If $alertUpdate <> IniRead($alertINI,"OPTS","Update",0) Then
                ;_twitterLogin()
                _postUpdate()
            EndIf
        EndIf
    Else
        ;_twitterLogin()
        _postAlert()
    EndIf
EndFunc
;==============================================

;==============================================
;     FUNCTION _twitterLogin
;==============================================
Func _twitterLogin()
    ;MsgBox(0,"test","lets log into twitter")
    ShellExecute("http://twitter.com")
    Sleep(2000)
    Send("{ENTER}")
    Sleep(5000)
    Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}")
EndFunc
;==============================================

;==============================================
;     FUNCTION _postAlert
;==============================================
Func _postAlert()
    Sleep(2000)
    Send("{ASC 35}" & $alertTitle & @CRLF & $alertLink)
    ;Send($alertTitle & @CRLF & $alertLink)
    IniWrite($alertINI,"OPTS","Title",'"' & $alertTitle & '"')
    IniWrite($alertINI,"OPTS","Link",'"' & $alertLink & '"')
    IniWrite($alertINI,"OPTS","Update",$alertUpdate)
    Sleep(2000)
    ;MsgBox(0,"test",$alertTitle & @CRLF & $alertLink)
EndFunc
;==============================================

;==============================================
;     FUNCTION _postUpdate
;==============================================
Func _postUpdate()
    Sleep(2000)
    Send("[UPDATE] {ASC 35}" & $alertTitle & @CRLF & $alertLink)
    ;Send("[UPDATE] " & $alertTitle & @CRLF & $alertLink)
    IniWrite($alertINI,"OPTS","Update",$alertUpdate) ;make this last
    Sleep(2000)
    ;MsgBox(0,"test",$alertTitle & @CRLF & $alertLink)
EndFunc

;==============================================

XML:

<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0" xmlns:isuoa="http://alerts.illinoisstate.edu/xml/oa.dtd" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Tech Alerts at Illinois State University</title>
        <link>http://alerts.illinoisstate.edu/</link>
        <description>Technology Alerts that affect Illinois State University</description>
        <language>en-us</language>
        <copyright>Copyright 2013, Illinois State University</copyright>
        <webMaster>alerts@illinoisstate.edu (Tech Alerts at Illinois State)</webMaster>
        <atom:link href="http://alerts.illinoisstate.edu/xml/" rel="self" type="application/rss+xml" />
        <image>
            <url>https://alerts.illinoisstate.edu/templates/images/rss-logo.png</url>
            <title>Tech Alerts at Illinois State University</title>
            <link>http://alerts.illinoisstate.edu/</link>
            <description>Tech Alerts</description>
            <width>102</width>
            <height>102</height>
        </image>
        <item>
            <title>Phishing: Phishing: It Help Desk</title>
            <link>http://alerts.illinoisstate.edu/#_2614</link>
            <description><![CDATA[<p>The following phishing email has been reported to the Help Desk. This email was not sent by Illinois State University.</p>
<p><span style="color: rgb(255, 0, 0); font-weight: 700;">Important:</span> If you clicked the link in this email and &quot;logged in&quot; with your ULID and password, you should change your password and security question immediately.</p>
<p>For more information, refer to <a href="http://helpdesk.illinoisstate.edu/kb/1364/">[1364] How to recognize phishing emails targeting Illinois State University</a>.</p><blockquote><p>Your mailbox is almost full.</p><p>465MB&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 500MB</p><p>Current size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Maximum size</p><p>Please increase your mailbox quota size automatically by clicking HERE&lt;http://valmessage.jigsy.com/&gt; and fill-out the necessary requirements to automatically increase your mailbox quota size.</p><p>IMPORTANT NOTE: You won&#39;t be able to send and receive mail messages at 480MB .</p><p>ITS help desk</p><p>ADMIN TEAM</p><p>=A9Copyright 2013 Microsoft</p></blockquote>]]></description>
            <pubDate>Tue, 22 Oct 2013 12:15:00 -0500</pubDate>
            <category>Active</category>
            <isuoa:updatecount>0</isuoa:updatecount>
            <author>alerts@illinoisstate.edu (Tech Alerts at Illinois State)</author>
            <guid isPermaLink="true">http://alerts.illinoisstate.edu/archive/2614/</guid>
        </item>
        <item>
            <title>Network: Network Maintenance</title>
            <link>http://alerts.illinoisstate.edu/#_2343</link>
            <description><![CDATA[<p><span style="color: rgb(0, 0, 0); font-family: Tahoma, sans-serif; ">Telecommunications &amp; Networking have scheduled network maintenance for this date. More details will be posted as they become available.</span></p>]]></description>
            <pubDate>Sun, 17 Nov 2013 00:00:00 -0600</pubDate>
            <category>Upcoming</category>
            <isuoa:updatecount></isuoa:updatecount>
            <author>alerts@illinoisstate.edu (Tech Alerts at Illinois State)</author>
            <guid isPermaLink="true">http://alerts.illinoisstate.edu/archive/2343</guid>
        </item>
    </channel>
</rss>
I scoured the internet and these forums/site for anything that could explain what it's doing.  If this is a stupid question/problem all I ask is that you go easy on me and forgive my ignorance.
 
Thank you for your time,
Matt
Edited by ubelong2matt

Share this post


Link to post
Share on other sites
gruntydatsun

Would like to help you but got this when I tried to download the dependency:

 

403. That’s an error.

Your client does not have permission to get URL /files/_XMLDomWrapper.au3 from this server. (Client IP address: 220.xxx.xxx.xxx)

You are attempting to perform an activity that you have insufficient permissions for. If you feel this is in error, please contact the project administrator. That’s all we know.

 

Share this post


Link to post
Share on other sites
ubelong2matt

Would like to help you but got this when I tried to download the dependency:

 

Hmm, not sure what dependency you're talking about.  If it's the XML file, I said not to use it since it changes.  This script works fine unless the word starts with a PH (for phishing).  There are system and network alerts also.  I've only tested it with system, aside from phishing, and it works fine with that.  You shouldn't use the XML download (say no when prompted).  I provided the XML to test with since, in this particular incident, the bug exists in it.

 

Help file -> "When using 2 digit ASCII codes you must use a leading 0"

 

The ASCII code was added as a "work-around" attempt for this problem.  I thought the use of the hash tag may have been the problem.  Before that, I was using +3 to issue a hash tag.  I also tried slowing down the send speed but it didn't work or I need to slow it down further.

After more testing, I noticed that there is rectangle window that appears, for a split second, over SciTE which I think is the culprit.  It has nothing in it that I can read and doesn't appear long enough to even screen shot.  However, I think it's causing the problem.  I will try to find out what it is.

Thanks for the help so far, guys!

Share this post


Link to post
Share on other sites
ubelong2matt

Ok I get you now.

Try sending the # raw.

Send("#", 1)

EDIT:

Or the whole string as raw, else autoit sees #p as Windows key + p

 

John, you're wonderful.  Thank you so much.  That worked!!!!  I owe you a beer.

EDIT

The window I saw, shape and all, WAS Windows+p.  So simply.  Awesome catch!!!!

Edited by ubelong2matt

Share this post


Link to post
Share on other sites
gruntydatsun

wrong dependency, i'm talking about

_XMLDomWrapper.au3

Share this post


Link to post
Share on other sites
ubelong2matt

Oh.  Grunty, you can just search the web for the AutoIt _XMLDomWrapper.au3 include.  I would post it here but it won't be updated as newer versions get created (possible).

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  

  • Similar Content

    • ijourneaux
      By ijourneaux
      I am trying to read an XML file that looks like the following. I am particularly interested in the ParameterNames and ParameterValues
       
      I was able to read a simplier XML file using
      $oXML.load("DataForwardSettings.xml") Local $oInfos = $oXML.selectnodes("//Database") ; or //Info or //Data//Info or //Values/Info  but have not been able to read
      <?xml version="1.0"?> <Entities> <Entity RecordType="TrendData"> <Property Name="AlarmLimitsSetNumber" IsReadOnly="False" ValueType="System.Int32">8</Property> <Property Name="AnalysisParamaterSetNumber" IsReadOnly="False" ValueType="System.Int32">8</Property> <Property Name="ParameterNames" IsReadOnly="True" IsList="True" ListType="List<string>" ValueType="Array" ArrayType="System.String" Count="12">System.Collections.Generic.List`1[System.String]<Data>OVERALL|PK-PK WAVEFORM|HFD|CREST FACTOR|SYNC 1-6|1X|2X|3X-4X|FTF|BSF|BPFO|BPFI</Data></Property> <Property Name="ParameterValues" IsReadOnly="True" IsList="True" ListType="List<float>" ValueType="Array" ArrayType="System.Single" Count="12">System.Collections.Generic.List`1[System.Single]<Data>0.04706,0.27951,0.02640,4.85608,0.03494,0.01727,0.02256,0.01993,0.00207,0.00060,0.00178,0.00221</Data></Property> <Property Name="NumberOfParameters" IsReadOnly="False" ValueType="System.Int32">12</Property> <Property Name="ModifiedSinceLastDataDump" IsReadOnly="False" ValueType="System.Boolean">False</Property> <Property Name="Load" IsReadOnly="False" ValueType="System.Single">0</Property> <Property Name="RPM" IsReadOnly="False" ValueType="System.Single">140.962</Property> <Property Name="Value" IsReadOnly="False" ValueType="System.Single">-1.1E-20</Property> <Property Name="SampleID" IsReadOnly="False" ValueType="System.Int32">-626794</Property> <Property Name="Timestamp_as_String" IsReadOnly="True" ValueType="System.String">8/18/2018 2:05:33 PM</Property> <Property Name="Timestamp_as_UInt" IsReadOnly="False" ValueType="System.UInt32">1534619133</Property> <Property Name="Timestamp" IsReadOnly="False" ValueType="System.DateTime">8/18/2018 2:05:33 PM</Property> <Property Name="StorageFlag" IsReadOnly="False" ValueType="Enum" EnumType="Emerson.CSI.DataImport.MHM.TrendDataStorageType" EnumValue="2">RPM_And_Overall</Property> <Property Name="Parents" IsReadOnly="False" IsList="True" ListType="List<string>" ValueType="Array" ArrayType="System.String" Count="5">System.Collections.Generic.List`1[System.String]<Data>Database=phmhmdb4ts;C:\RBMdbsrv\CustData\4ts_online_1807.rbm;-99|Area=4TS;-494|Equipment=4THTS;-712|MeasurementPoint=D39;-780|DataCollectionSet=Normal Collection Dryer Rolls;-783</Data></Property> </Entity> </Entities> I tried switching to the XML UDF but was alittle lost in how to use it. I am particularly interested in the ParameterNames and ParameterValues.
    • macran
      By macran
      I want to generating a XML file (test.xml) like as follow:
      <?xml version="1.0" encoding="GBK"?>
      <!DOCTYPE SCHEMA SYSTEM "HGWSPZJK.dtd">  ;I can not generate this line
      <SCHEMA CRC="HGWSPZ201808_9131011571786229XM_CRC.XML" SSSQ="201808" CHSNAME="HGWSDKQD" NAME="HGWSPZ">

      <TAXPAYER CJRMC="sigmagroup" CJRDM="9131011571786229XM" CJLX="DKZK" RECORDCOUNT="411" SBRQ="2018-08-31" NSRMC="sigmagroup" SWSBH="9131011571786229XM">

      <Records>
      <Record BZ="" JKKADM="2244" JKKAMC="shanghai" SE="5907.82" TFRQ="2018-08-23" FPHM="224420181000752586-L02"/>
      <Record BZ="" JKKADM="2244" JKKAMC="shanghai" SE="4742.4" TFRQ="2018-08-21" FPHM="224420181000743016-L01"/>
      <Record BZ="" JKKADM="2244" JKKAMC="shanghai" SE="18720" TFRQ="2018-08-14" FPHM="224420181000719215-L01"/>
      </Records>
      </TAXPAYER>
      </SCHEMA>
      I use XML.UDF  
      Local $oXMLile=_XML_CreateFile(@ScriptDir&"\test.xml","",True) 
      but there is no function CreateDocumentType 
      It is no effort even I test use 
      Local $doct=$oXMLfile.CreateDocumentType("SCHEMA", null, "HGWSPZJK.dtd", null)
            $oXmlfile.appendChild($doct)
      pls help me thanks.
       
       
       
       
       
       
    • Skeletor
      By Skeletor
      Hi All,
      This is purely an XML Language question. I need to understand how I can add a value/element in between another XML element. 
      Code below shows the XML file. The info tag has the elements already inserted.
      <Configuration xmlns="http://schemas.datacontract.org/2004/07/Modules.Reporting.DataContracts.LineItems" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <GenConf> <Info>ID, Site, Name , Site_ID</Info> </GenConf> </Configuration> Now, I want to add a value from a node group into this code. Something like below. But the example below does not work.
      Any suggestions?
       
      <Configuration xmlns="http://schemas.datacontract.org/2004/07/Modules.Reporting.DataContracts.LineItems" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <GenConf> <Info>ID, Site, a/@id, Name , Site_ID</Info> </GenConf> </Configuration> <ProductName> <a id="Windows Server"/> </ProductName>  
    • ternal
      By ternal
      Hi,
      The FAQ proposed as a solution to keys getting stuck  to do this command
      ControlSend("", "", "", "text", 0) However this sends "text" to the last active control if I am not mistaken.I have tried this with
      controlsend("", "", "", "{altup}{shiftup}{ctrlup}", 0) This is already a lot better but still fails 1/10
      I cannot allow the script to send "text" to the last active control, and its a bit silly to let it send to somewhere where its harmless no?
      Are there any other methods of unstucking keys?
    • bhns
      By bhns
      try it for make flyers old games xml + Gdi, i belive many sources had lost 
      AIT-ADRLIST.au3

×