
coles
Active Members-
Posts
27 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
coles's Achievements

Seeker (1/7)
1
Reputation
-
HI All, I can press a button in tablet to bring up the software using the script below This is saved as a button script which gets called by button press.There is a main script which starts with windows startup so we can just multiple tasks with different key press's AS you can see the script maximizes the window is winexists and if the the window is not present then runs it after deleting few folders. If WinExists("MobilePublic") Then WinActivate("MobilePublic") WinSetState("MobilePublic", "", @SW_MAXIMIZE) Else FileDelete("C:\Users\test01\appdata\local\Intergraph Corporation, Inc\MobilePublicSafety\*.*") Run("C:\Program Files\Intergraph\MobilePublicSafety\bin\ingrviewer.exe /application:MobilePublicSafety /wsgSearchPath:customEms", "C:\Program Files\Intergraph\MobilePublicSafety\bin\", @SW_MAXIMIZE) EndIf What i am trying to do is i need to press the same button and If WinExists("[CLASS:IEFrame]") Then IEFrame {The reason i used Class is title do keeps on changing} becomes the main window @sw_maximize. and if i press again it will take me to the previous window, in this case it is ingrviewer.exe @sw_maximize. Thus no other user input rather then just a mere push of the button{Main reason why i am not sending ALT+Tab} If wanted i can get the process status by Func FixIngrViewer() Global $aPL = ProcessList("ingrviewer.exe") For $iCC = 1 To $aPL[0][0] ProcessClose($aPL[$iCC][1]) Next sleep(500) DirRemove("C:\Program Files\Intergraph\MobilePublicSafety\wsgapplicationdata\data\",1) FileDelete("C:\Users\test01\appdata\local\Intergraph Corporation, Inc\MobilePublicSafety\*.*") Run("C:\Program Files\Intergraph\MobilePublicSafety\bin\ingrviewer.exe /application:MobilePublicSafety /wsgSearchPath:customEms", "C:\Program Files\Intergraph\MobilePublicSafety\bin\", @SW_MAXIMIZE) endFunc tried this but only getting from IEFrame to Mobilepublic but not going back to IEFrame If WinExists("[CLASS:IEFrame]") Then Local $state = WinGetState("[CLASS:IEFrame]","") if BitAND($state,16) then WinSetState("[CLASS:IEFrame]", "", @SW_RESTORE); elseif BitAND($state,2) and BitAND($size[1],300) then WinSetState("[CLASS:IEFrame]", "", @SW_HIDE); Elseif BitAND($state,2) and BitAND($size[1],1) then WinActivate("MobilePublic") else WinSetState("[CLASS:IEFrame]", "", @SW_SHOW) EndIf Else Run("C:\Program Files\Intergraph\MobilePublicSafety\bin\ingrviewer.exe /application:MobilePublicSafety /wsgSearchPath:customEms", "C:\Program Files\Intergraph\MobilePublicSafety\bin\", @SW_MAXIMIZE) EndIf Easiest way i can do the above requirement is by sending a ALT+ ESC as shown below, which does the job for me send ("!+{ESC}") But there is a small mandatory window which runs in the background, comes in the middle of ALT+ESC press.Not that is a big deal, i just wanted to create a script which does the job perfectly. Oh yea forgot to mention i even tried Z-listing Can get change the active window from IEFrame to mobilepublic but not the other way {ie, when window Mobilepublic is active going back to IEFrame } Func _WinPrevious($z = 1) If $z < 1 Then Return SetError(1, 0, 0) ; Bad parameter Local $avList = WinList() For $n = 1 to $avList[0][0] ; Test for non-blank title, and is visible If $avList[$n][0] <> "" And BitAND(WinGetState($avList[$n][1]), 2) Then If $z Then $z -= 1 Else WinActivate($avList[$n][1]) Return 1 EndIf EndIf Next Return SetError(2, 0, 0) ; z-depth exceeded EndFunc Hope someone can help me out with this, as i been working on this for quiet time i just ran out of ideas and interest , Just let me know if you didn't understand the requirement, i can try my level best to explain.
-
coles reacted to a post in a topic: {CAPSLOCK OFF} and {CAPSLOCK TOGGLE} not toggling caps lock off
-
coles reacted to a post in a topic: [Solved] Help sort the directory tree under the level. _FileListToArrayRec()
-
Copying an XML file & Editing it and copying back
coles replied to coles's topic in AutoIt General Help and Support
Thank you @Subz, i didn't know that if a character was out of place _ReplaceStringInFile will fail. Thanks @jdelaney yes i will try more examples with well formed xpaths, so that next time it will be easier. I would mark this topic as fixed, as @Subz solution have been working awesome for me. His way of getting the results were far better and dynamic than mine. -
Copying an XML file & Editing it and copying back
coles replied to coles's topic in AutoIt General Help and Support
Thank you @Subz, i didn't know that if a character was out of place _ReplaceStringInFile will fail. Thanks @jdelaney yes i will try more examples with well formed xpaths, so that next time it will be easier. -
coles reacted to a post in a topic: Copying an XML file & Editing it and copying back
-
coles reacted to a post in a topic: Copying an XML file & Editing it and copying back
-
coles reacted to a post in a topic: Copying an XML file & Editing it and copying back
-
Copying an XML file & Editing it and copying back
coles replied to coles's topic in AutoIt General Help and Support
@Subz Thank you so much for the effort to write it down and test it for me. I guess it was one of your sleepless bored nights , but really beneficial for me. Once again thanks for your help After going through help file just out of curiosity wanted to know, why you choose the above method. Instead of going with _ReplaceStringInFile -
Copying an XML file & Editing it and copying back
coles replied to coles's topic in AutoIt General Help and Support
@FrancescoDiMuro Hi i am adding a sample of source file. what i am expecting from my script is changes in line 71 existing[<ReferenceInformationAction>"C:\Program Files\Internet Explorer\iexplore.exe" -k "c:\temp\temp.html"</ReferenceInformationAction>] to [<ReferenceInformationAction>"C:\Program Files\Internet Explorer\iexplore.exe" -k "http:\\10.1.1.1\temp.html"</ReferenceInformationAction>] Line 375 existing[<col header="Location" width="30%" dataFld="location" style="" preprocesser="" template="formatUnitLocation(location, unid)" hidden="1"/>]to[<col header="Location" width="30%" dataFld="location" style="" preprocesser="" template="formatUnitLocation(location, unid)" hidden="0"/>] Line 376 existing [<col header="DGroup" width="10%" dataFld="dgroup" style="" preprocesser="" template="" hidden="0"/>] to [<col header="DGroup" width="10%" dataFld="dgroup" style="" preprocesser="" template="" hidden="1"/>] at the moment with the above script [in orginal post & reply to subz] i am able to change by over writing the specific lines. Looking for a dynamic approach to do the changes by not depending on the line numbers. Sample.xml -
coles reacted to a post in a topic: Copying an XML file & Editing it and copying back
-
Copying an XML file & Editing it and copying back
coles replied to coles's topic in AutoIt General Help and Support
Thank you @Subz for the quick reply. Yes i have checked the number of lines of both target and source, both are same. Thanks for that tip regarding Single quote as i was having trouble initially. Easiest code i can think of is FileCopy( "G:\Program Files\test.xml", "C:\sample\test.xml", 1); -FileWritetoline... -FileWritetoline... -FileWritetoline... Sleep(2000) FileCopy( "C:\sample\test.xml", "G:\Program Files\test.xml", 1); ConsoleWrite('Copying Updated File: ' & $address & @CRLF); $hFileIndexHTML = FileOpen("C:\sample\test.txt", 1) FileWrite($hFileIndexHTML, $address & @CRLF) FileClose($hFileIndexHTML) This works perfectly fine and functioning as needed. Only thing is now i think about the source file, it may not be same in all machines. As i might have edited may be 5-10% of them every now and then with no thoughts about such a need will arise in the future. Is there a way where the text change's can be made to the xml file to those specific lines, irrespective of the line number. Any help will be appreciated -
coles reacted to a post in a topic: Copying an XML file & Editing it and copying back
-
Hi All, Need a help with Autoit task, I am trying to copy an XML file and edit that XML file and copy it back The script i have attached if the script we use to copy files to client from server, so basically what it does is Going through a Set of IP address and Map the drive Copy the file Write copy process was success Goes on a loop through IP's to check all machines have updated files #include <File.au3> #include <iNet.au3> #include <_XMLDomWrapper.au3> func latestUpdate($address, $name) Local $result Local $hFileIndexHTML DriveMapDel ( "G:" ) ConsoleWrite('Trying: ' & $address & "/" & $name & @CRLF); $result = DriveMapAdd ( "G:", "\\" & $address & "\C$", 0, $name & "\adminname","adminpswd") ;Copying the file from Mapped drive to local if $result = 1 Then FileCopy( "G:\Program Files\test.xml", "C:\sample\test.xml", 1); ConsoleWrite('Copying Updated File: ' & $address & @CRLF); $hFileIndexHTML = FileOpen("C:\sample\test.txt", 1) FileWrite($hFileIndexHTML, $address & @CRLF) FileClose($hFileIndexHTML) EndIf EndFunc func done($file, $address) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) if ( $address = $line ) Then ConsoleWrite('Already done: ' & $file & " " & $address & @CRLF); return true EndIf Next return false EndFunc func getMachineName($ipaddress) return _TCPIpToName($ipaddress) EndFunc func process($address) local $machineName $machineName = getMachineName($address) if ($machineName = "") Then ConsoleWrite("No machine found at:" & $address & @CRLF) Else ConsoleWrite("Machine found at:" & $address & " - " & $machineName & @CRLF) if ( done( "C:\sample\test.txt", $address) = false ) then if ( $machineName <> "" ) then latestUpdate($address, $machineName) else endif endif EndIf EndFunc TCPStartup() while 1=1 PROCESS("10.10.1.1") sleep( 1000 * 60 * 10) wend The XML file i am trying to copy is unique and different in all machines (Machine name,ID's etc), But whole structure is the same (ie, the num of lines ) [That's the reason i can't copy a single file to all the machines]. I was thinking of using _FileWriteToLine to replace 3 lines with new data eg: _FileWriteToLine("c:\sample\test.xml", 71, "<RIA>"http://goog.html"</RIA>", True) _FileWriteToLine("c:\sample\test.xml", 350, "<col header="Status" width="7%" dataFld="status_code" style="" preprocesser="processES" template="" hidden="0"/>", True) _FileWriteToLine("c:\sample\test.xml", 650, "<col header="Units" width="11%" dataFld="units" style="" preprocesser="" template="fU(units)" hidden="0"/>", True) These lines inside XML 340<em> 341<gd 342-360 is similar as blah blah <col header="Status" width="7%" dataFld="status_code" style="" preprocesser="processES" template="" hidden="0"/> same goes for 650th line also I would like to get opinion of copying this file as this is a highly critical file needed to keep machines running Do you think using _file write to line is risky?. Do you think i have to copy the file from parent folder to another folder after replacing the lines and then copy from there back to client system. This is all what i can think now, Any comments/suggestions will be much appreciated.
-
@alien4u Thanks for your input and comment. Yes this will be run automatically with help of Task sheduler(actually i am thinking of putting a {1000 * 60 * 24} so that it does every 24 hours) i do have multiple files for to check whether it needs update, so was thinking instead of putting it up as func latestIndexHTML($address, $name) Local $result Local $hFileIndexHTML DriveMapDel ( "G:" ) ConsoleWrite('Trying: ' & $address & "/" & $name & @CRLF); $result = DriveMapAdd ( "G:", "\\" & $address & "\C$", 0, $name & "\admin","adminpswd") if Number(FileGetTime("C:\a\index.html", $FT_CREATED, 1)) > Number(FileGetTime("G:\Program Files\L\LC\", $FT_CREATED, 1)) And $result = 1 Then FileCopy( "C:\a\index.html", "G:\Program Files\L\LC\", 1); ConsoleWrite('Copying Index.html file: ' & $address & @CRLF); $hFileIndexHTML = FileOpen("C:\a\indexhtml.txt", 1) FileWrite($hFileIndexHTML, $address & @CRLF) FileClose($hFileIndexHTML) EndIf EndFunc func latestIndexHTML2($address, $name) Local $result Local $hFileIndexHTML2 DriveMapDel ( "G:" ) ConsoleWrite('Trying: ' & $address & "/" & $name & @CRLF); $result = DriveMapAdd ( "G:", "\\" & $address & "\C$", 0, $name & "\admin","adminpswd") if Number(FileGetTime("C:\a\index2.html", $FT_CREATED, 1)) > Number(FileGetTime("G:\Program Files\L\LC\", $FT_CREATED, 1)) And $result = 1 Then FileCopy( "C:\a\index2.html", "G:\Program Files\L\LC\", 1); ConsoleWrite('Copying Index2.html file: ' & $address & @CRLF); $hFileIndexHTML = FileOpen("C:\a\indexhtml2.txt", 1) FileWrite($hFileIndexHTML2, $address & @CRLF) FileClose($hFileIndexHTML2) EndIf EndFunc will it be good to do multiple IFELSE
-
Can Autoit gurus please have a look at this script and let me know what all changes or improvements i need to make it more effective or faster or shorter. Any new ideas are welcomed also What the script does is " from Main computer maps a drive(from a list of IP's provided in a text file) and it checks whether the file is newer in main computer. IF yes then it will copies the file.once it's done it opens a txt file and writes the IP address func latestIndexHTML($address, $name) Local $result Local $hFileIndexHTML DriveMapDel ( "G:" ) ConsoleWrite('Trying: ' & $address & "/" & $name & @CRLF); $result = DriveMapAdd ( "G:", "\\" & $address & "\C$", 0, $name & "\admin","adminpswd") if Number(FileGetTime("C:\a\index.html", $FT_CREATED, 1)) > Number(FileGetTime("G:\Program Files\L\LC\", $FT_CREATED, 1)) And $result = 1 Then FileCopy( "C:\a\index.html", "G:\Program Files\L\LC\", 1); ConsoleWrite('Copying Index.html file: ' & $address & @CRLF); $hFileIndexHTML = FileOpen("C:\a\indexhtml.txt", 1) FileWrite($hFileIndexHTML, $address & @CRLF) FileClose($hFileIndexHTML) EndIf EndFunc Thank you
-
How to call functions in If statements?
coles replied to Swoonkify's topic in AutoIt General Help and Support
can i update this zombie post with my query? -
what is the best way to compare files
coles replied to coles's topic in AutoIt General Help and Support
Thanks @RickB75 @mikell for the replies. @mikell with just 1 line of code you just showed how little i know about Autoit.. Many thanks as it works perfectly -
coles reacted to a post in a topic: what is the best way to compare files
-
coles reacted to a post in a topic: what is the best way to compare files
-
what is the best way to compare files
coles replied to coles's topic in AutoIt General Help and Support
@RickB75 Thank you I think i will use Filegettime if versioncompare has to be used,don't we have to add a version number in files?? i cannot edit existing files. -
What i am trying to do is compare date of destination and source, and if source file is newer than destination it copies the file to source. Just posting a sample code of what i am trying to achieve #include <Date.au3> ; Include Date constants #include <File.au3> #include <iNet.au3> #include <_XMLDomWrapper.au3> Global $xml1, $xml1monthday, $xml1year, $xml1format, $xml2, $xml2monthday, $xml2year, $xml2format, $xmldate ; Runs the XmlDate() function to determine the age of the Xml file ;===================================================================== XmlDate() Func XmlDate() $Xml1 = RegRead("C:\Temp\m1.xml","XmlDate") ; pulls registry $xml1monthday = StringTrimRight($xml1, 5) ; takes the month $xml1year = StringTrimLeft($xml1, 6) ; takes the year out $xml1format = ($xml1monthday & "/" & $xml1year) ; reorders the date $Xml2 = RegRead("C:\Temp\m2.xml","XmlDate") ; pulls registry $xml2monthday = StringTrimRight($xml2, 5) ; takes the month and $xml2year = StringTrimLeft($xml2, 6) ; takes the year out $xml2format = ($xml2monthday & "/" & $xml2year) ; reorders if $Xml1 = "" And $Xml2 = "" Then FileCopy( "C:\temp\a1.txt", "C:\temp\anokh", 1); Else FileDelete("c:\temp\a1/txt") EndIf EndFunc Any comments will be appreciated Thank you
-
coles reacted to a post in a topic: Help with a .bat file
-
Thanks @alien4u @MaxPlankpar @spudw2k for replying for my query. I ended up using Autoit instead of a Batch file.
-
jincy reacted to a post in a topic: Help with a .bat file
-
@spudw2k can you please help me with one more query i have a.txt file with (only) content <vehicle>100</vehicle>, is it possible to remove <vehicle></vehicle> and just keep the 100 .