Leaderboard
Popular Content
Showing content with the highest reputation on 01/08/2014 in all areas
-
I'm basing the basics (mostly just the XML structure) of this script off one of FireFox's: '?do=embed' frameborder='0' data-embedContent>> I felt the need to make it more flexible, via the Microsoft.xmldom. Using this object, not only can you create excel XML files, you can also update them. XPaths are used for everything, so it's easy to add additional rows/columns/sheets on the fly...I'll add another function to read in an already present file in a bit (just added in), but that function would be as simple as loading the contents into the object. Multiple internal functions, but all you need are: Func EXml_LoadFile($sCallersFile) Func EXml_CreateFile() Func EXml_AddCell($oCallersXML,$sCallersSheetName,$iCallersCellCol,$iCallersCellRow,$sCallersCellData)...this one creates the cell, or updates it if already present Func EXml_SaveFile($oCallersXML,$sCallersFileName) Example Usage #include "EXml.au3" ; Set for overwrite of variable ;~ Global $gsEXml_DocProp_Author = "someAuthor" ;~ Global $gsEXml_DocProp_LastAuthor = "LastAuthorText" ;~ Global $gsEXml_DocProp_Created = "CreatedText" ;~ Global $gsEXml_DocProp_Company = "CompnayText" ;~ Global $gsEXml_DocProp_Version = "VersionText" $oXML = EXml_CreateFile() ; Can load, if the XML file is already present ;~ $oXML = EXml_LoadFile(@DesktopDir & "\test.xml") ; Add cell params: $oXMl, $sSheetName, $iColumn, $iRow, $sCellContents EXml_AddCell($oXML,"SheetName",5,10,"SomeValue1") EXml_AddCell($oXML,"SheetName",5,9,"SomeValue2") EXml_AddCell($oXML,"SheetNameTWO",1,2,"SomeValue3") EXml_AddCell($oXML,"SheetName",5,10,"SomeValueEDIT") EXml_AddCell($oXML,"SheetName",15,6,"SomeValue4") EXml_SaveFile($oXML,@DesktopDir & "\test.xml") Run(@ComSpec & " /c " & @DesktopDir & "\test.xml") ;~ ConsoleWrite(StringRegExpReplace($oXML.xml, "><",">" & @CRLF & "<") & @CRLF) Exit Notice, that you can add cells in at any order, you are not constrained to add everything in order. Where EXml.au3 is: #include-once #include <File.au3> Global $gsEXml_DocProp_Author = "AuthorText" Global $gsEXml_DocProp_LastAuthor = "LastAuthorText" Global $gsEXml_DocProp_Created = "CreatedText" Global $gsEXml_DocProp_Company = "CompnayText" Global $gsEXml_DocProp_Version = "VersionText" Func EXml_LoadFile($sCallersFile) Local $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.Load($sCallersFile) Return $oXML EndFunc Func EXml_CreateFile() ;~ _FileCreate($sCallersFile) Local $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.LoadXML('<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?><Workbook />') Local $oWorkBook = $oXML.selectSingleNode("/Workbook") Local $oDocumentProperties = EXml_CreateFile_DocumentProperties($oXML,$oWorkBook) Local $oOfficeDocumentSettings = EXml_CreateFile_OfficeDocumentSettings($oXML,$oWorkBook) Local $oExcelWorkbook = EXml_CreateFile_ExcelWorkbook($oXML,$oWorkBook) Local $oStyles = EXml_CreateFile_Styles($oXML,$oWorkBook) With $oWorkBook .setAttribute("xmlns","urn:schemas-microsoft-com:office:spreadsheet") .setAttribute("xmlns:o","urn:schemas-microsoft-com:office:office") .setAttribute("xmlns:x","urn:schemas-microsoft-com:office:excel") .setAttribute("xmlns:ss","urn:schemas-microsoft-com:office:spreadsheet") .setAttribute("xmlns:html","http://www.w3.org/TR/REC-html40") .appendChild($oDocumentProperties) .appendChild($oOfficeDocumentSettings) .appendChild($oExcelWorkbook) .appendChild($oStyles) EndWith Return $oXML EndFunc Func EXml_AddCell($oCallersXML,$sCallersSheetName,$iCallersCellCol,$iCallersCellRow,$sCallersCellData) Local $oWorkBook = $oCallersXML.selectSingleNode("/Workbook") Local $oWorkSheet = $oCallersXML.selectSingleNode("//Worksheet[@ss:Name='" & $sCallersSheetName & "']") If Not IsObj($oWorkSheet) Then ; Create Worksheet, as needed $oWorkSheet = EXml_AddCell_CreateWorkSheet($oCallersXML,$sCallersSheetName) $oWorkBook.appendChild($oWorkSheet) EndIf Local $oTable = $oWorkSheet.selectSingleNode("./Table") Local $oRow = $oTable.selectSingleNode("./Row[@ss:Index='" & $iCallersCellRow & "']") If Not IsObj($oRow) Then ; Create Row, as needed $oRow = EXml_AddCell_CreateRow($oCallersXML,$oTable,$iCallersCellRow) $oRows = $oTable.selectNodes("./Row") If $oRows.length Then For $o In $oRows If Number($o.getAttribute("ss:Index")) > $iCallersCellRow Then $oTable.insertBefore($oRow,$o) ExitLoop EndIf Next Else $oTable.appendChild($oRow) EndIf EndIf Local $oCell = $oRow.selectSingleNode("./Cell[@ss:Index='" & $iCallersCellCol & "']") If Not IsObj($oCell) Then $oCell = EXml_AddCell_CreateCell($oCallersXML,$oTable,$iCallersCellCol,$sCallersCellData) $oCells = $oRow.selectNodes("./Cell") If $oCells.length Then For $o In $oCells If Number($o.getAttribute("ss:Index")) > $iCallersCellCol Then $oRow.insertBefore($oCell,$o) ExitLoop EndIf Next Else $oRow.appendChild($oCell) EndIf Else EXml_AddCell_UpdateCell($oCell,$sCallersCellData) EndIf Return $oCallersXML EndFunc Func EXml_SaveFile($oCallersXML,$sCallersFileName) $oCallersXML.save($sCallersFileName) EndFunc #region INTERNAL Func EXml_CreateFile_DocumentProperties($oCallersXML, $oCallersWorkbook) With $oCallersXML Local $oDocProps = .createElement("DocumentProperties") Local $oAuthor = .createElement("Author") Local $oLastAuthor = .createElement("LastAuthor") Local $oCreated = .createElement("Created") Local $oCompany = .createElement("Company") Local $oVersion = .createElement("Version") EndWith $oAuthor.text = $gsEXml_DocProp_Author $oLastAuthor.text = $gsEXml_DocProp_LastAuthor $oCreated.text = $gsEXml_DocProp_Created $oCompany.text = $gsEXml_DocProp_Company $oVersion.text = $gsEXml_DocProp_Version With $oDocProps .setAttribute("xmlns","urn:schemas-microsoft-com:office:office") .appendChild($oAuthor) .appendChild($oLastAuthor) .appendChild($oCreated) .appendChild($oCompany) .appendChild($oVersion) EndWith Return $oCallersWorkbook.appendChild($oDocProps) EndFunc Func EXml_CreateFile_OfficeDocumentSettings($oCallersXML, $oCallersWorkbook) With $oCallersXML Local $oOfficeDocumentSettings = .createElement("OfficeDocumentSettings") Local $oAllowPNG = .createElement("AllowPNG") EndWith With $oOfficeDocumentSettings .setAttribute("xmlns","urn:schemas-microsoft-com:office:office") .appendChild($oAllowPNG) EndWith Return $oCallersWorkbook.appendChild($oOfficeDocumentSettings) EndFunc Func EXml_CreateFile_ExcelWorkbook($oCallersXML, $oCallersWorkbook) With $oCallersXML Local $oExcelWorkbook = .createElement("ExcelWorkbook") Local $oWindowHeight = .createElement("WindowHeight") Local $oWindowWidth = .createElement("WindowWidth") Local $oWindowTopX = .createElement("WindowTopX") Local $oWindowTopY = .createElement("WindowTopY") Local $oProtectStructure = .createElement("ProtectStructure") Local $oProtectWindows = .createElement("ProtectWindows") EndWith $oWindowHeight.text = 8160 $oWindowWidth.text = 21570 $oWindowTopX.text = 0 $oWindowTopY.text = 0 $oProtectStructure.text = "False" $oProtectWindows.text = "False" With $oExcelWorkbook .setAttribute("xmlns","urn:schemas-microsoft-com:office:excel") .appendChild($oWindowHeight) .appendChild($oWindowWidth) .appendChild($oWindowTopX) .appendChild($oWindowTopY) .appendChild($oProtectStructure) .appendChild($oProtectWindows) EndWith Return $oCallersWorkbook.appendChild($oExcelWorkbook) EndFunc Func EXml_CreateFile_Styles($oCallersXML, $oCallersWorkbook) With $oCallersXML Local $oStyles = .createElement("Styles") Local $oStyle = .createElement("Style") Local $oAlignment = .createElement("Alignment") $oAlignment.setAttribute("ss:Vertical","Bottom") Local $oBorders = .createElement("Borders") Local $oFont = .createElement("Font") $oFont.setAttribute("ss:FontName","Calibri") $oFont.setAttribute("x:Family","Swiss") $oFont.setAttribute("ss:Size","11") $oFont.setAttribute("ss:Color","#000000") Local $oInterior = .createElement("Interior") Local $oNumberFormat = .createElement("NumberFormat") Local $oProtection = .createElement("Protection") EndWith With $oStyle .setAttribute("ss:ID","Default") .setAttribute("ss:Name","Normal") .appendChild($oAlignment) .appendChild($oBorders) .appendChild($oFont) .appendChild($oInterior) .appendChild($oNumberFormat) .appendChild($oProtection) EndWith $oStyles.appendChild($oStyle) Return $oCallersWorkbook.appendChild($oStyles) EndFunc Func EXml_AddCell_CreateWorkSheet($oCallersXML,$sCallersWorkSheetName) With $oCallersXML Local $oWorkSheet = .createElement("Worksheet") Local $oTable = .createElement("Table") EndWith $oWorkSheet.setAttribute("ss:Name",$sCallersWorkSheetName) With $oTable .setAttribute("ss:ExpandedColumnCount",0) .setAttribute("ss:ExpandedRowCount",0) .setAttribute("x:FullColumns",1) .setAttribute("x:FullRows",1) .setAttribute("ss:DefaultColumnWidth",60) .setAttribute("ss:DefaultRowHeight",15) EndWith $oWorkSheet.appendChild($oTable) Return $oWorkSheet EndFunc Func EXml_AddCell_CreateRow($oCallersXML,$oCallersTable,$iCallersCellRow) Local $oRow = $oCallersXML.createElement("Row") With $oRow .setAttribute("ss:AutoFitHeight",0) .setAttribute("ss:Index",$iCallersCellRow) EndWith If Number($oCallersTable.getAttribute("ss:ExpandedRowCount")) < $iCallersCellRow Then $oCallersTable.setAttribute("ss:ExpandedRowCount",$iCallersCellRow) EndIf Return $oRow EndFunc Func EXml_AddCell_CreateCell($oCallersXML,$oCallersTable,$iCallersCellCol,$sCallersData) Local $oCell = $oCallersXML.createElement("Cell") Local $oData = $oCallersXML.createElement("Data") With $oData .setAttribute("ss:Type","String") .text = $sCallersData EndWith With $oCell .setAttribute("ss:Index",$iCallersCellCol) .appendChild($oData) EndWith If Number($oCallersTable.getAttribute("ss:ExpandedColumnCount")) < $iCallersCellCol Then $oCallersTable.setAttribute("ss:ExpandedColumnCount",$iCallersCellCol) EndIf Return $oCell EndFunc Func EXml_AddCell_UpdateCell($oCallersCell,$sCallersCellData) With $oCallersCell.selectSingleNode("./Data") .text = $sCallersCellData EndWith EndFunc #endregion INTERNAL Debugging is still required when working with > 1 Sheets. Things to add...styles on sheets, rows, cells.1 point
-
akroon, In your origianl code snippet: $form = GUICreate("My gui",485, 305) $form2 = GUICreate("My gui2",485, 305) GUISetState(@SW_SHOW) GUISetState(@SW_HIDE,$form2) both of the GUISetState lines refer to $form2. As explained in the Help file, if you do not give a handle as the second parameter the the function acts on the last used window - in this case it is $form2 as you have just created it. So you never apply a state to $form. All clear? M231 point
-
Er, yes I did... Revision: 7456 Author: guinness Date: 10 January 2013 01:46:17 Message: Fixed #2298: Failing to detect when EnumDisplayDevices returns 0. ---- Modified : /trunk/install/Include/WinAPI.au3 But it got reverted when WinAPIEx.au3 was split. Strange, but I did do it KaFu.1 point
-
Delete everything at the top of the script and add this... #include-once #include <APIConstants.au3> #include <Constants.au3> #include <GDIPlus.au3> #include <Memory.au3> _GDIPlus_Startup() #cs Global Const $RT_CURSOR = 1 Global Const $RT_BITMAP = 2 Global Const $RT_ICON = 3 Global Const $RT_MENU = 4 Global Const $RT_DIALOG = 5 Global Const $RT_STRING = 6 Global Const $RT_FONTDIR = 7 Global Const $RT_FONT = 8 Global Const $RT_ACCELERATOR = 9 Global Const $RT_RCDATA = 10 Global Const $RT_MESSAGETABLE = 11 Global Const $RT_GROUP_CURSOR = 12 Global Const $RT_GROUP_ICON = 14 Global Const $RT_VERSION = 16 Global Const $RT_DLGINCLUDE = 17 Global Const $RT_PLUGPLAY = 19 Global Const $RT_VXD = 20 Global Const $RT_ANICURSOR = 21 Global Const $RT_ANIICON = 22 Global Const $RT_HTML = 23 Global Const $RT_MANIFEST = 24 Global Const $SND_RESOURCE = 0x00040004 Global Const $SND_SYNC = 0x0 Global Const $SND_ASYNC = 0x1 Global Const $SND_MEMORY = 0x4 Global Const $SND_LOOP = 0x8 Global Const $SND_NOSTOP = 0x10 Global Const $SND_NOWAIT = 0x2000 Global Const $SND_PURGE = 0x40 #ce1 point
-
That's it. One of this "other files" contains the already defined constants.1 point
-
Can you please post all "#include" statements you have in your script?1 point
-
convert .bat to exe
behdadsoft reacted to Melba23 for a topic
behdadsoft, Do not push your luck. M231 point -
Date.au3
jaberwacky reacted to Richard Robertson for a topic
Would you consider a call to this function to use the Windows' current locale (or any specific locale) for the day of the week? http://msdn.microsoft.com/en-us/library/windows/desktop/dd318088%28v=vs.85%29.aspx1 point -
Means: You assign a value to the variable but never use the variable.1 point
-
and you forgot to write EndIF below EXIT line and OP wrote play-css.exe and firefox.exe instead of 'play-css.exe' and 'play-css.exe' or "play-css.exe" and "firefox.exe" everybody go and take some coffee to go, it's an order if he is after process commands i don't see the point in loop if exit is after that, so just this line should work instead of the loop if constantly running isn't needed in script If ProcessWait ( "processtowait.exe" ,10 ) Then ProcessClose( "processtoclose.exe" );w8 for procces 10 sec, if its there close itif it's needed just remove 10 second parameter and put it in while 1 loop for facebook games i realy dont know, dont use FB1 point
-
I've just had a look and yes with the update the pages have changed. I'll have a look and see what needs to be changed. Hopefully not too much. Stay tuned...1 point
-
msgbox(0, '' , StdoutRead($pID)) first. if there are no contents expect blanks. *or add a seperator and have a visual $t &= $Array[$j] & ":" if you see three colons in a row they were blanks1 point
-
1 point
-
To anybody interested in the final code: HotKeySet('e', 'RHado'); Hadoken to the right HotKeySet('z', 'RTatsu'); Tatsumaki Senpuu Kyaku to the right HotKeySet('f', 'RShoryu'); Sho Ryu Ken to the right HotKeySet('q', 'LHado'); Hadoken to the left HotKeySet('x', 'LTatsu'); Tatsumaki Senpuu Kyaku to the left HotKeySet('r', 'LShoryu'); Sho Ryu Ken to the left While 1 Sleep(100) WEnd Func RHado() Send('{s down}') ;hold down Sleep(10) Send('{d down}') ;hold right Sleep(10) Send('{s up}') ;release down Sleep(10) Send('{NUMPAD6}') ;fierce punch Send('{d up}') ;release right EndFunc; Hadoken to the right Func RTatsu() Send('{s down}') ;hold down Sleep(10) Send('{a down}') ;hold right Sleep(10) Send('{s up}') ;release down Sleep(10) Send('{NUMPAD3}') ;roundhouse kick Send('{a up}') ;release right EndFunc; Tatsumaki to the right Func RShoryu() Send('{d down}') ;hold right Sleep(10) Send('{s down}') ;hold down Sleep(10) Send('{d up}') ;hold right Sleep(10) Send('{d down}') ;release down Sleep(10) Send('{s up}') ;hold down Sleep(10) Send('{NUMPAD6}') ;fierce punch Send('{d up}') ;release right EndFunc; Shoryu to the right Func LHado() Send('{s down}') ;hold down Sleep(10) Send('{a down}') ;hold right Sleep(10) Send('{s up}') ;release down Sleep(10) Send('{NUMPAD6}') ;fierce punch Send('{a up}') ;release right EndFunc; Hadoken to the left Func LTatsu() Send('{s down}') ;hold down Sleep(10) Send('{d down}') ;hold right Sleep(10) Send('{s up}') ;release down Sleep(10) Send('{NUMPAD3}') ;roundhouse kick Send('{d up}') ;release right EndFunc; Tatsumaki to the left Func LShoryu() Send('{a down}') ;hold right Sleep(10) Send('{s down}') ;hold down Sleep(10) Send('{a up}') ;hold right Sleep(10) Send('{a down}') ;release down Sleep(10) Send('{s up}') ;hold down Sleep(10) Send('{NUMPAD6}') ;fierce punch Send('{a up}') ;release right EndFunc; Shoryu to the left1 point
-
Using AutoIt for Street Fighter
bhns reacted to blademonkey for a topic
Brilliant, i completely forgot that the moves had to be legato! Good implementation, very ingenious. {= )1 point