Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/10/2017 in all areas

  1. The alternative is to use a sorting function where you can use a user defined comparison function. In the attachement is an udf for doing this. With this the result can look like this: #include <DynArray.au3> $ss=StringSplit("yec21ds|yesyyesqyedsdd|yesye987ddyes|yexxss|yesyesg9999yesyesyeseydddddds",'|', 2) _ArrayDisplay($ss, "reasult randome") _ArraySortFlexible($ss, _MyCompare) _ArrayDisplay($ss, "sorted result") ; user defined compare function for individual sorting Func _MyCompare(ByRef $A, ByRef $B) Local $dA = StringLen($A), $dB = StringLen($B) Return $dA > $dB ? -1 : $dA < $dB ? 1 : 0 EndFunc DynArray.au3
    2 points
  2. This is one way of doing it: #include <Array.au3> $ss=StringSplit("yec21ds|yesyyesqyedsdd|yesye987ddyes|yexxss|yesyesg9999yesyesyeseydddddds",'|') _ArrayDisplay($ss, "reasult randome") _ArrayColInsert($ss, 1) _ArrayDisplay($ss, "column inserted") ;put the string length of each string in the 2nd column for $i = 1 to $ss[0][0] $ss[$i][1] = StringLen($ss[$i][0]) Next _ArrayDisplay($ss, "length of all strings added") _ArraySort($ss, 1, 1, 0, 1) ;sort the second column _ArrayDisplay($ss, "sorted result by string length") _ArrayColDelete($ss, 1) ; remove second column _ArrayDisplay($ss, "final result") Basicly you add a column to your array, store the length of each string in this new column then use this column to sort the array then delete the column!
    2 points
  3. You'll have to try it and see if you get what you're expecting; my main machine is a 2012 server with 4 NICs, so it would not be correct for me.
    1 point
  4. If the modem is your default gateway, you can do this: #include <Array.au3> Local $aIPs[1][3] = [["IP Address", "Default Gateway", "DNS"]] Local $oWMI = ObjGet("winmgmts:\\.\root\CIMV2") Local $oNics = $oWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True") For $NIC In $oNics _ArrayAdd($aIPs, $NIC.IPAddress(0) & "|" & $NIC.DefaultIPGateway(0) & "|" & $NIC.DNSHostName) Next _ArrayDisplay($aIPs) If it is not, we'll have to do some sniffing on the network.
    1 point
  5. Make a test with such an array with 300 Elements. With your solution the user have to wait 17s. With my 0.04s. And this discrepance increases exponential with the number of elements. But i am not alowed to point at this behavoir because nobody use AutoIt for speed of execution - right? Then thanks for the clarification of what i am allowed to talk about here.
    1 point
  6. I also encountered this bug previously using excel list also. In that script, autoit kept losing excel object after looping 216 times. And yes, I remember this number correctly because it frustrated me as hell. I completed what I had to do then just by relaunching the script and continuing from where the script crashed. But for this one it was not an option because it crashes way to early. And of course I will not think autoit is bad it has many great inbuilt functions and even more UDF which simplifies what would otherwise be quite complicated. + the community is great it motivates to learn and return the favours by adding something to it.
    1 point
  7. Holy crap, it works now. Thanks for the help, mate, you made my day
    1 point
  8. As I said in my previous post (i made 2 of them ) uninstall autoit 3.3.14.x and try with autoit 3.3.12
    1 point
  9. It will work if you use the BitXOR function on the two copy parameters: FileCopy("c:\users\ckuser\documents\pixelwix pixelwarp evo\logs\*.*", "c:\ck\system_info\pw_logs\", BitXOR($FC_OVERWRITE, $FC_CREATEPATH))
    1 point
  10. or just walk the array yourself? #include <Array.au3> $Ass=StringSplit("yec21ds|yesyyesqyedsdd|yesye987ddyes|yexxss|yesyesg9999yesyesyeseydddddds",'|' , 2) For $i = ubound($Ass) - 1 to 1 step -1 If StringLen($Ass[$i]) < StringLen($Ass[$i - 1]) Then _ArraySwap($Ass , $i , $i - 1) $i = ubound($Ass) EndIf Next _ArrayDisplay($Ass)
    1 point
  11. Hello @rayane888 There you go: #include <Array.au3> $ss=StringSplit("yesyes|yesyesyesyes|yesyesyes|yes|yesyesyesyesyeseys",'|') _ArrayDisplay($ss, "reasult randome") _Arraysort($ss, 1) _ArrayDisplay($ss, "sorted result") Enjoy
    1 point
  12. timmalos

    [UDF] CasparCG AMCP 2.1

    Hello all. In case this is interesting few of you, I share my AMCP 2.1 protocol UDF in AutoIT. This protocol is used by CasparCG server, which is a Windows and Linux software used to play out professional graphics, audio and video to multiple outputs as a layerbased real-time compositor. It has been in 24/7 broadcast production since 2006. It's free and opensource. The UDF I share allows communication between an AutoIt based client and the CasparCG, based on following documentation : http://casparcg.com/wiki/CasparCG_2.1_AMCP_Protocol If you want more details on CasparCG : official WebSite or have a look to this video I'm currently building a full Client based on AutoIt, with many features like drag-and-drop layers, but sadly I can't share it right now, might come later. Don't hesitate to ask questions if you have any or need a basic example. The only requirement for this UDF is the other Event-driven TCP UDF by Kip AMCP_shared.au3 TCP.au3
    1 point
  13. It just shows you the optional parameters you can use: The device in the first parameter and the remote share in the second are mandatory, the flags, username and password parameters are optional.
    1 point
  14. Hi, Sparlou, welcome to the forum. You don't need the brackets; try something like this: ;Requesting User input to create username and password variables $username = InputBox("Enter your username", "Enter your username") $password = InputBox("Enter your password", "Enter your password", "", "*") ;Creating yearlevel variable $firsttwochar = StringMid ( $username, 1, -2) $yearlevel = "20" & $firsttwochar ;Mounting drives $HDrivePath = "\\file-r2.giad.local\users\" & $yearlevel & "\" & $username DriveMapAdd ( "H:", $HDrivePath, 0, $username, $password) DriveMapAdd ( "S:", "\\file-r2.giad.local\student\", 0, $username, $password)
    1 point
  15. version: 1.0.2 "__keys" added "arguments" property added to AccessorObject. see documentation above for more info. Example to show one way to use the arguments property and to show it works with things such as ScriptControl: #include "AutoItObject_Internal.au3" #AutoIt3Wrapper_Run_Au3Check=N $AutoItError = ObjEvent("AutoIt.Error", "ErrFunc") ; Install a custom error handler Func ErrFunc($oError) ConsoleWrite("!>COM Error !"&@CRLF&"!>"&@TAB&"Number: "&Hex($oError.Number,8)&@CRLF&"!>"&@TAB&"Windescription: "&StringRegExpReplace($oError.windescription,"\R$","")&@CRLF&"!>"&@TAB&"Source: "&$oError.source&@CRLF&"!>"&@TAB&"Description: "&$oError.description&@CRLF&"!>"&@TAB&"Helpfile: "&$oError.helpfile&@CRLF&"!>"&@TAB&"Helpcontext: "&$oError.helpcontext&@CRLF&"!>"&@TAB&"Lastdllerror: "&$oError.lastdllerror&@CRLF&"!>"&@TAB&"Scriptline: "&$oError.scriptline&@CRLF) EndFunc ;==>ErrFunc Example01() Example02() Func Example01() Local $o=IDispatch() $o.__defineGetter("a", _MsgBox) Local $oSC=ObjCreate("ScriptControl") $oSC.language = "JScript" ($oSC.Eval("Function('e','return e.a;')"))($o) EndFunc Func Example02() Local $oWindow = IDispatch() $oWindow.hwnd = GUICreate("title", 700, 320) $oWindow.__defineGetter("Show", Wnd_Show) $oWindow.__defineGetter("Hide", Wnd_Hide) $oWindow.__defineGetter("bkColor", Wnd_bkColor) $oWindow.__defineGetter("width", Wnd_width) $oWindow.__defineGetter("height", Wnd_height) $oWindow.__defineGetter("title", Wnd_title) $oWindow.__defineGetter("onExit", Wnd_onExit) $oWindow.Show.width(300).bkColor(0xC2E34E).height(300).title("Example 2").onExit(_MyExit) While 1 Sleep(10) WEnd EndFunc Func _MsgBox() Return MsgBox(0, "_MsgBox", "test") EndFunc Func Wnd_Show($oSelf) GUISetState(@SW_SHOW, $oSelf.parent.hwnd) Return $oSelf.parent EndFunc Func Wnd_Hide($oSelf) GUISetState(@SW_HIDE, $oSelf.parent.hwnd) Return $oSelf.parent EndFunc Func Wnd_bkColor($oSelf) If Not ($oSelf.arguments.length==1) Then Return SetError(1, 1, $oSelf.parent GUISetBkColor($oSelf.arguments.values[0], $oSelf.parent.hwnd) Return $oSelf.parent EndFunc Func Wnd_width($oSelf) If Not ($oSelf.arguments.length==1) Then Return SetError(1, 1, $oSelf.parent Local $aPos = WinGetPos(ptr($oSelf.parent.hwnd), "") WinMove(ptr($oSelf.parent.hwnd), "", $aPos[0], $aPos[1], $oSelf.arguments.values[0], $aPos[3], 0) Return $oSelf.parent EndFunc Func Wnd_height($oSelf) If Not ($oSelf.arguments.length==1) Then Return SetError(1, 1, $oSelf.parent Local $aPos = WinGetPos(ptr($oSelf.parent.hwnd)) WinMove(ptr($oSelf.parent.hwnd), "", $aPos[0], $aPos[1], $aPos[2], $oSelf.arguments.values[0], 0) Return $oSelf.parent EndFunc Func Wnd_title($oSelf) If Not ($oSelf.arguments.length==1) Then Return SetError(1, 1, $oSelf.parent) WinSetTitle(ptr($oSelf.parent.hwnd), "", $oSelf.arguments.values[0]) Return $oSelf.parent EndFunc Func Wnd_onExit($oSelf) If Not ($oSelf.arguments.length==1) Then Return SetError(1, 1, $oSelf.parent) opt("GuiOnEventMode", 1) GUISetOnEvent(-3, $oSelf.arguments.values[0], ptr($oSelf.parent.hwnd)) EndFunc Func _MyExit() Exit EndFunc
    1 point
  16. These two worked: FileCopy("c:\users\ckuser\documents\pixelwix pixelwarp evo\logs\*", "c:\ck\system_info\pw_logs\", 9 ) FileCopy("c:\users\ckuser\documents\pixelwix pixelwarp evo\logs\", "c:\ck\system_info\pw_logs\", 9) Thank you all for your help. With people like you around, I feel there's still hope for the world
    1 point
  17. welcome HanselGarvey, For your first quest, here is one way, Considering the recipient is always to the right of the string $string = "123-555-2838 mom" If Not Number(StringRight($string, 1)) Then ;checks if the rightmost character of the string is a number Do $string = StringTrimRight($string, 1) Until Number(StringRight($string, 1)) EndIf MsgBox(0, "", $string) Manipulating a whole list : #include <Array.au3> $sFile = @DesktopDir & "\PhoneBook.txt" $aFile = FileReadToArray($sFile) For $i = 0 To UBound($aFile) - 1 If Not Number(StringRight($aFile[$i], 1)) Then ;checks if the rightmost character of the string is a number $string = $aFile[$i] Do $string = StringTrimRight($string, 1) Until Number(StringRight($string, 1)) Or @error $aFile[$i] = $string EndIf Next _ArrayDisplay($aFile) Or even strip everything except numbers : #include <Array.au3> $sFile = @DesktopDir & "\PhoneBook.txt" $aFile = FileReadToArray($sFile) For $i = 0 To UBound($aFile) - 1 $aFile[$i] = StringRegExpReplace($aFile[$i], "\D", "") ;https://www.autoitscript.com/forum/topic/145381-text-remove-all-but-numbers/?do=findComment&comment=1328591 Next _ArrayDisplay($aFile)
    1 point
  18. Found the way to do it _GUICtrlMenu_SetItemType(_GUICtrlMenu_GetMenu($hYourGUI), 1, $MFT_RIGHTJUSTIFY)
    1 point
  19. The argument 9 as Neutro posted should work. However its important to understand WHY. Did you view the help page for the command? https://www.autoitscript.com/autoit3/docs/functions/FileCopy.htm And generally when sharing its best to show the variable instead of the magic number. FileCopy("c:\users\ckuser\documents\pixelwix pixelwarp evo\logs\*", "c:\ck\system_info\pw_logs\", $FC_OVERWRITE + $FC_CREATEPATH) If you do not have it working, I would check permissions. Perhaps elevate your script and run it as admin. The largest glaring issue I see, and what is probably your problem is you have your arguments encapsulated in quotes, they should not be, as then your not resolving the variable and instead just telling autoit that its a string.
    1 point
  20. monoceres

    AutoIt Chess

    Hi! This is a project I've been working on for quite some time and I'm happy to finally being able to release something that almost works as a complete chess game. Features: - A working PvP mode that detects both Check, Checkmate and Stalemate. - Game engine written completely in C++ for maximum speed. - Clean looking GDI+ Graphics - In game assistance that help you see where you can move your piece. - Animated menus and info screens - High scores ToDo: - Bot (Need more testing of the game play so there is no weird bugs that undermine the bot before I can start working on it) - Rotation of board when players switch turns. - Castling - Better looking info when winning/draw occurs - Optimize for better speed - An icon (have any?) Screenies: Download: autoit_chess.zip IMPORTANT! If you cannot move the pieces or get an subscript error that means that the Game Engine couldn't be initialized, please download the VC++ 2008 Redist to install the libraries necessary for the game to function correctly. Have fun!
    1 point
  21. Great stuff, Thanx the help. UPDATE: I got it working. Thanx for the help. Kama
    1 point
  22. you can loop through the collection (use .getElementsByTagName()), or use my signature to use the xpath to get the object. where xpath = "//input[contains(@id,'Next_')]" the return is an array http://www.w3schools.com/htmldom/dom_methods.asp
    1 point
×
×
  • Create New...