Leaderboard
Popular Content
Showing content with the highest reputation on 07/18/2015 in all areas
-
Hey I made this to convert data to PHP's serialize() function return format. This is for those who, somewhy [?], can't use JSON, for example. Just two simple functions: Serialize() and Unserialize(). Data may be all accepted types in PHP (array, float, int, string), except objects. Examples (included in package): #include 'serialize.au3' Dim $otherArray[4] = ["hai", "halo", "apa", "kabar"] Dim $aArray[7] = ['test', 'lol', 'cool', 'amazing', 123, $otherArray, 2.50] $sSerialized = Serialize($aArray) MsgBox(0, "", $sSerialized)It will show: a:7:{i:0;s:4:"test";i:1;s:3:"lol";i:2;s:4:"cool";i:3;s:7:"amazing";i:4;i:123;i:5;a:4:{i:0;s:3:"hai";i:1;s:4:"halo";i:2;s:3:"apa";i:3;s:5:"kabar";}i:6;d:2.5;}Now, if we want to do the contrary, which is, converting from serialized string back to original data: #include 'serialize.au3' #include <Array.au3> ; Needed only to use _ArrayDisplay. Not required to use serialize. $aUnserialized = Unserialize('a:7:{i:0;s:4:"test";i:1;s:3:"lol";i:2;s:4:"cool";i:3;s:7:"amazing";i:4;i:123;i:5;a:4:{i:0;s:3:"hai";i:1;s:4:"halo";i:2;s:3:"apa";i:3;s:5:"kabar";}i:6;d:2.5;}') _ArrayDisplay($aUnserialized) _ArrayDisplay($aUnserialized[6])As _ArrayDisplay doesn't support multidimensional array (and, in the previous example, we converted a multidimensional array to serialized data), we must use it twice. So we will see: Please notice the differences between AutoIt and PHP's approach of arrays. It is different. Be careful, mainly when getting arrays from PHP and putting into AutoIt. I really recommend using only integer array keys, or switching to JSON. License: CC BY 4.0 Download: https://www.autoitscript.com/forum/files/file/348-unserialize-in-autoit-php-compatible/1 point
-
vPaint - GDI+ image editor
Luigi reacted to scintilla4evr for a topic
This time there are no source releases, but I'd like to announce some new functions: Layer locking V4I image format Revert function Automatic updates (this feature will be added before the full release of vPaint 4)1 point -
$oIE = _IECreate("http://www.google.com") $hIE = _IEPropertyGet($oIE, "hwnd") WinActivate($hIE)1 point
-
WinWaitActive($hdlIeWindow, "", 5)1 point
-
mLipok, Enjoy that time - it passes far too quickly. M231 point
-
I would do it like this. If anything, it's not "shaky": ; $sXML = BinaryToString(InetRead(...)) $sXML = '-<availability>' & _ '-<members date="2015-07-18" daytag="Today" count="11" day="8" night="9" ooa="0" s44="" na="0">' & _ '<qualification abbrev="2YR" name="2 Years Experience" category="Ability" count="4" day="3" night="3" ooa="0" s44="0"na="0"/>' & _ '<qualification abbrev="BA" name="Breathing Apparatus Operator" category="Operator" count="4" day="3" night="4" ooa="0"s44="0" na="0"/>' & _ '</members>' & _ '-<members date="2015-07-19" daytag="Tomorrow" count="11" day="8" night="11" ooa="0" s44="0" na="0">' & _ '<qualification abbrev="2YR" name="2 Years Experience" category="Ability" count="4" day="4" night="4" ooa="0" s44="0"na="0"/>' & _ '<qualification abbrev="BA" name="Breathing Apparatus Operator" category="Operator" count="6" day="6" night="4" ooa="0"s44="0" na="0"/>' & _ '</members>' & _ '<availability>' MsgBox(4096, "bzz...", "daytag = Today, abbrev = BA, day = " & ThatThingFromXML($sXML, "Today")) MsgBox(4096, "bzz...", "daytag = Tomorrow, abbrev = BA, day = " & ThatThingFromXML($sXML, "Tomorrow")) Func ThatThingFromXML($sXML, $sDayTag, $sAbbrev = "BA", $sAttrib = "day") ; Clean the XML $sXML = StringRegExpReplace($sXML, "(?s)<!--.*?-->", "") ; removing comments $sXML = StringRegExpReplace($sXML, "(?s)<!\[CDATA\[.*?\]\]>", "") ; removing CDATA ; Find all members Local $aMembers = StringRegExp($sXML, "(?si)<\s*members(?:[^\w])\s*(.*?)(?:(?:<\s*/members\s*>)|\Z)", 3) If @error Then Return SetError(1, 0, "") ; There are no members available Local $sMember, $sAttributes, $aDesc ; Loop through members For $iMemberOrdinal = 0 To UBound($aMembers) - 1 $sMember = $aMembers[$iMemberOrdinal] ; currently examined member $sAttributes = StringRegExp($sMember, "(?s)(.*?)>", 3) If Not @error Then $sAttributes = $sAttributes[0] If AttribVal($sAttributes, "daytag") = $sDayTag Then $aDesc = StringRegExp($sMember, "(?si)<\h*(?:qualification|whatever)\h*(.*?)/*\h*>", 3) For $i = 0 To UBound($aDesc) - 1 If AttribVal($aDesc[$i], "abbrev") = $sAbbrev Then Return AttribVal($aDesc[$i], $sAttrib) ExitLoop 2 EndIf Next ExitLoop EndIf Next Return SetError(2, 0, "") ; Conditions not met EndFunc Func AttribVal($sIn, $sAttrib) Local $aArray = StringRegExp($sIn, '(?i).*?' & $sAttrib & '\h*=(\h*"(.*?)"|' & "\h*'(.*?)'|" & '\h*(.*?)(?: |\Z))', 3) ; e.g. id="abc" or id='abc' or id=abc If @error Then Return "" Return $aArray[UBound($aArray) - 1] EndFunc1 point
-
Change the regular expression for $BA from (?is).* to (?is).*? (/edit: because currently it picks up the last members instead of the first one.) That's the quickfix. But I agree with using a real XML parser if you want this to be more robust. Parsing xml with regex is just shaky.1 point
-
If you use string format when registering a handler, you will get result as string. If you pass function when registering, you will get result as that function. Latter probably confuses you. Here's an example of that case: ; Register COM Error Handler $oErrorHandler = ObjEvent("AutoIt.Error", Abcd) Func Abcd() ConsoleWrite("Error Handler Invoked" & @CRLF) EndFunc ; Some Object which is not $oNonObject = Null ; Call method to invoke error handler $oNonObject.DummyCall() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Get the function that was used for registering $vTheErrorFunction = ObjEvent("AutoIt.Error") ; Invoke it manually $vTheErrorFunction() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;...You should get two lines of "Error Handler Invoked" printed as the result of that snippet.1 point
-
JohnOne, In the old forum there was a combo selection on the page on which you wrote a post which would automatically lock the thread when you submitted it. In this "new, improved" POS it has to be a separate action and it seems the "old dog, new tricks" syndrome keeps popping up. Thanks for the reminders. M231 point
-
Ignore it/ allow it.1 point
-
Maybe this is what you need. Saludos1 point
-
Ah thank you that would work great.1 point
-
This one never errors ;$sname= "" ;$sname= "Nameonly " $sname= "Karl Jochen Wuesthof" $lastname = stringregexp($sName , "(\w*)\s*$" , 3)[0] $firstname = stringreplace($sName , $lastname , "") msgbox (0, '' , $firstname & @CRLF & $lastname)1 point
-
You can use WinGetClassList to list all control classes in a window1 point
-
one more, no split ;~ $sname= "Axel Volmer" $sname= "Karl Jochen Wuesthof" $firstname = stringregexp($sName , "\D+\s" , 3)[0] $lastname = stringreplace($sName , $firstname , "") msgbox (0, '' , $firstname & @CRLF & $lastname)1 point
-
Simple logic $sname= "Karl Jochen Wuesthof" $aName = stringsplit($sname , " ") $lastname = $aName[$aName[0]] $firstname = StringReplace($sname, " " & $lastname, "") msgbox(0, '' , $firstname & @CRLF & $lastname)1 point
-
#include <Array.au3> ;~ $sname= "Axel Volmer" $sname= "Karl Jochen Wuesthof" ;~ $sname= "Karl Udo Juentgen" ;~ $sname= "Hans Guenter Leuther" $aName = stringsplit($sname , " " , 2) $lastname = $aName[ubound($aName) - 1] $firstname = _ArrayToString($aName , " " , default , ubound($aName) - 2) msgbox(0, '' , $firstname & @CRLF & $lastname)1 point
-
Try this... For $i = 0 To UBound($array) - 1 $namen = StringSplit($array[$i][0], " ") $vorname = $namen[1] $nachname = $namen[$namen[0]] MsgBox(0, "",$vorname) MsgBox(0, "",$nachname) NextOR change this line so that you only grab one column Global $array = _Excel_RangeRead($oWorkbook, "Tabelle1", "A2:A704")1 point
-
Quick question, does the data look like this: space,first,space,last,space,first,space,last ... ? I would be great to see what is in _arrayDisplay($array) if you could screen shot that ...1 point
-
I'm not sure, but you can try _WinAPI_DwmExtendFrameIntoClientArea #include <GUIConstantsEx.au3> #include <WinAPIGdi.au3> #include <WindowsConstants.au3> If Not _WinAPI_DwmIsCompositionEnabled() Then MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.') Exit EndIf Local $hForm = GUICreate('Test', 400, 400) GUICtrlCreateLabel("", 0, 82, 400, 318, -1, $WS_EX_CLIENTEDGE) GUICtrlSetBkColor(-1, 0xffffff) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateButton("Button", 10, 100, 200, 25) GUISetBkColor(0) _WinAPI_DwmExtendFrameIntoClientArea($hForm, _WinAPI_CreateMargins(0, 0, 82, 2)) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE1 point
-
GUICreate("GUI", 200, 200, 100, 100, 0x80880000) ; 0x80880000 = $WS_POPUPWINDOW GUICtrlCreateLabel("Title Bar", 0, 0, 160, 40, -1, 0x00100000) ; 0x00100000 = $GUI_WS_EX_PARENTDRAG GUICtrlSetBkColor(-1, 0x0000FF) GUICtrlSetColor(-1, 0xFFFFFF) $Close = GUICtrlCreateButton("X", 160, 0, 40, 40) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlSetColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) While 3 Switch GUIGetMsg() Case -3 Exit Case $Close Exit EndSwitch WEndYou wanted easy. Alternatively, use a picture instead of a label and or button.1 point
-
Modify by your taste: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #Include <File.au3> ;written by taietel ;Example - modify to fit >>YOUR<< needs GUICreate("3D Text", 650, 550) GUISetBkColor(0x996600) $arStyle=StringSplit("u|i|n|u|i|n","|",2) For $i=0 To 5 _3DText("AutoIt - 3D Text", 10, 20+80*$i, -1, -1, 14 + $i*10, "b", $arStyle[$i]) Next GUISetState(@SW_SHOW) While 1 Sleep(10) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _3DText($sText,$iX, $iY, $iW=-1, $iH=-1, $iFontSize = 14, $sWeight="b", $sStyle = "n", $sFont="Arial") If $iW = -1 Or $iW = Default Then $iW = Int(StringLen($sText)*$iFontSize/1.2) If $iH = -1 Or $iH = Default Then $iH = Int(1.5*$iFontSize) If $iFontSize = -1 Or $iFontSize = Default Then $iFontSize = 14 If $sWeight = -1 Or $sWeight = Default Then $sWeight = "b" If $sStyle = -1 Or $sStyle = Default Then $sStyle = "n" If $sFont = -1 Or $sFont = Default Then $sFont = "Arial" Local $f = 0x111111 Switch $sWeight Case "b" $iWeight = 800 Case "n" $iWeight = 400 EndSwitch Switch $sStyle Case "n" $iStyle = 0 Case "i" $iStyle = 2 Case "u" $iStyle = 4 EndSwitch Local $iZ = $iFontSize/10 For $i=0 To $iZ Step 0.5 GUICtrlCreateLabel($sText, $iX-$i, $iY+$i, $iW, $iH) GUICtrlSetColor(-1,$f*($i+1)/0.5) GUICtrlSetFont(-1, $iFontSize, $iWeight, $iStyle, $sFont) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) Next EndFunc [edit] forgot to clean...1 point
-
I don't like the XMLDomWrapper, so I use the COM-object directly. I think, this is better structured. Global Const $oCOMError = ObjEvent("Autoit.Error", "_COMError") Func _COMError() ConsoleWrite("! COM Error: " & $oCOMError.number & @LF) EndFunc $oXML = ObjCreate("MSXML2.DOMDocument") ;~ $oXML.loadXML(ClipGet()) $oXML.load(@ScriptDir & "\Test1.xml") $oXML.setProperty("SelectionLanguage", "XPath") ConsoleWrite("!-----------------------------------------------------------------------------------" & @LF & @LF) For $oDirectoryRef In $oXML.selectNodes("/root/DirectoryRef") $sDirRefID = $oDirectoryRef.getAttribute("Id") ConsoleWrite("> Directory " & $sDirRefID & @LF) For $oComponent In $oDirectoryRef.selectNodes("Component") $sCompID = $oComponent.getAttribute("Id") ConsoleWrite("++> Component " & $sCompID & @LF) For $oFile In $oComponent.selectNodes("File") $sFileID = $oFile.getAttribute("Id") $sFileSource = $oFile.getAttribute("Source") ConsoleWrite("----> File " & $sFileID & " : " & $sFileSource & @LF) Next Next ConsoleWrite(@LF) Next ConsoleWrite("!-----------------------------------------------------------------------------------" & @LF & @LF)1 point