Leaderboard
Popular Content
Showing content with the highest reputation on 07/31/2014 in all areas
-
AutoIt v3.3.13.13 Beta
jaberwacky and 2 others reacted to Jon for a topic
File Name: AutoIt v3.3.13.13 Beta File Submitter: Jon File Submitted: 31 Jul 2014 File Category: Beta 3.3.13.13 (31st July, 2014) (Beta) AutoIt: - Changed: PCRE regular expression engine updated to 8.35. - Added: FileSetEnd() example. - Fixed #2363: Call() with invalid user function was not setting @error correctly when used as an expression within another function call. - Fixed #2364: Call() with CallArgArray and no parameters. - Fixed #2789: With EndWith parameter issue. AutoItX: - Changed: AutoItX3.psd1 renamed to AutoItX.psd. PSModulePath updated on install so that the system will auto-import. Others: - Fixed: Using a static filepath instead of a temporary file. Click here to download this file3 points -
Need help with _IsPressed
moneypulation reacted to olivarra1 for a topic
ComputerGroove has the solution. Think that in programming languages like these, the computer executes the program line by line, one after the other. So your script what does is first check wether the q key is pressed, and store that result in $ispressed (normally it gets to false) And then it will loop until $ispressed gets to true, but that will be never, since you never set the variable $ispressed again inside that loop. But I think ComputerGroove's solution using HotKeySet is what you are looking for. In that case, you tell AutoIt that whenever "q" is pressed, he should run the function "TogglePause", and in that TooglePause function you just set $paused to the value you want. This "feature" is called an interruption, because it "interrupts" the normal flow of the program, that's line by line.1 point -
Need help with _IsPressed
moneypulation reacted to computergroove for a topic
HotKeySet("q","TogglePause") Func go() Local $hDLL = DllOpen("user32.dll") While 1 Send("a") Sleep(500) Send("b") Sleep(500) WEnd EndFunc Func TogglePause() ExitLoop $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',350,0) WEnd ToolTip("") DllClose($hDLL) Go() EndFunc Try this. q pauses the script and reregisters user32.dll Why are you registering the user32.dll instead of just doing this: HotKeySet("q","TogglePause") While 1 go() WEnd Func go() Send("a") Sleep(500) Send("b") Sleep(500) WEnd EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',350,0) WEnd ToolTip("") EndFunc1 point -
Zac's solution seems nice, can be easily adapted to swap more cols It could be done a bit faster though #include <Array.au3> Global $asTestArray[5][10] __Array2DFillWCrap($asTestArray) _ArrayDisplay($asTestArray, "Starting Array") __Array2DColFlip($asTestArray, 8, 5, 1) _ArrayDisplay($asTestArray, "Array Columns 8 , 5 and 1 Flipped") Func __Array2DColFlip(ByRef $avArray, $iColA, $iColB, $iColC) Local $avTemp[UBound($avArray)] For $i = 0 To UBound($avArray) - 1 $avTemp[$i] = $avArray[$i][$iColA] $avArray[$i][$iColA] = $avArray[$i][$iColB] $avArray[$i][$iColB] = $avArray[$i][$iColC] $avArray[$i][$iColC] = $avTemp[$i] Next EndFunc Func __Array2DFillWCrap(ByRef $avArray) For $i = 0 To UBound($avArray) - 1 For $n = 0 To UBound($avArray, 2) - 1 $avArray[$i][$n] = "Row " & $i & " Col " & $n Next Next EndFunc1 point
-
remin, Then something very strange is happening - as for me it reactivates the window that was active immediately before button press, even when it has changed since the example began. M23 Edit: You do have the AdlibRegister("_GetActive") line in there?1 point
-
You can call functions stored as map items if they are enclosed in parenthesis. It means you could make something that looks a bit like oop.1 point
-
controlsend to jsp with frames
YouriKamps reacted to Danp2 for a topic
You mentioned that there were frames involved, but you didn't give any further details and you code doesn't make any attempt to handle them. You will need to get a reference to the desired frame (see _IEFrameGetObjByName) and then use this instead of $oIE when attempting to locate additional objects.1 point -
repeat mouseclick on 2 monitor?
232showtime reacted to Bert for a topic
Well, it is NOT allowed here. The forum rules are specific on this matter. No game automation is to be discussed in this forum. No ifs, ands, or buts.1 point -
Stack UDF - Based on the concept in .NET.
jvanegmond reacted to guinness for a topic
On Monday night I had an idea about creating a Stack UDF as I hadn't seen one on the Forums, but then I did a little searching and came across this. Not to be dismayed, I still created my version as I had already planned how I was going to implement it and decrease the number of redims. Enjoy. Global Const $STACK_GUID = '736DBB18-0DF3-11E4-807A-B46DECBA0006' Global Enum $STACK_COUNT, $STACK_ID, $STACK_INDEX, $STACK_UBOUND, $STACK_MAX #Region Example #include <Array.au3> Example() Func Example() Local $hStack = Stack() ; Create a stack object. For $i = 1 To 20 If Stack_Push($hStack, 'Example_' & $i) Then ConsoleWrite('Push: ' & 'Example_' & $i & @CRLF) ; Push random data to the stack. Next For $i = 1 To 15 ConsoleWrite('Pop: ' & Stack_Pop($hStack) & @CRLF) ; Pop from the stack. If Stack_Push($hStack, 'Example_' & $i * 10) Then ConsoleWrite('Push: ' & 'Example_' & $i * 10 & @CRLF) ; Push random data to the stack. Next ConsoleWrite('Peek: ' & Stack_Peek($hStack) & @CRLF) ConsoleWrite('Peek: ' & Stack_Peek($hStack) & @CRLF) ConsoleWrite('Count: ' & Stack_Count($hStack) & @CRLF) ConsoleWrite('Capacity: ' & Stack_Capacity($hStack) & @CRLF) Stack_ForEach($hStack, AppendUnderscore) ; Loop through the stack and pass each item to the custom function. ConsoleWrite('Contains Example_150: ' & (Stack_ForEach($hStack, Contains_150) = False) & @CRLF) ; It will return False if found so as to exit the ForEach() loop, hence why False is compared ConsoleWrite('Contains Example_1000: ' & (Stack_ForEach($hStack, Contains_1000) = False) & @CRLF) ; It will return False if found so as to exit the ForEach() loop, hence why False is compared Local $aStack = Stack_ToArray($hStack) ; Create an array from the stack. _ArrayDisplay($aStack) Stack_Clear($hStack) ; Clear the stack. Stack_TrimExcess($hStack) ; Decrease the memory footprint. EndFunc ;==>Example Func AppendUnderscore(ByRef $vItem) $vItem &= '_' Return (Random(0, 1, 1) ? True : False) ; Randomise when to return True Or False. The false was break from the ForEach() function. EndFunc ;==>AppendUnderscore Func Contains_150(ByRef $vItem) Return ($vItem == 'Example_150' ? False : True) ; If found exit the loop by setting to False. EndFunc ;==>Contains_150 Func Contains_1000(ByRef $vItem) Return ($vItem == 'Example_1000' ? False : True) ; If found exit the loop by setting to False. EndFunc ;==>Contains_1000 #EndRegion Example ; Functions: ; Stack - Create a stack handle. ; Stack_ToArray - Create an array from the stack. ; Stack_Capacity - Retrieve the capacity of the internal stack elements. ; Stack_Clear - Remove all items/objects from the stack. ; Stack_Count - Retrieve the number of items/objects on the stack. ; Stack_ForEach - Loop through the stack and pass each item/object to a custom function for processing. ; Stack_Peek - Peek at the item/object in the stack. ; Stack_Pop - Pop the last item/object from the stack. ; Stack_Push - Push an item/object to the stack. ; Stack_TrimExcess - Set the capacity to the number of items/objects in the stack. ; #FUNCTION# ==================================================================================================================== ; Name ..........: Stack ; Description ...: Create a stack handle. ; Syntax ........: Stack([$iInitialSize = Default]) ; Parameters ....: $iInitialSize - [optional] Initialise the stack with a certain size. Useful if you know how large the stack will grow. Default is zero ; Parameters ....: None ; Return values .: Handle that should be passed to all relevant stack functions. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Stack($iInitialSize = Default) Local $aStack = 0 __Stack($aStack, $iInitialSize, False) Return $aStack EndFunc ;==>Stack ; #FUNCTION# ==================================================================================================================== ; Name ..........: Stack_ToArray ; Description ...: Create an array from the stack. ; Syntax ........: Stack_ToArray(ByRef $aStack) ; Parameters ....: $aStack - [in/out] Handle returned by Stack(). ; Return values .: Success: A zero based array. ; Failure: Sets @error to non-zero and returns Null. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Stack_ToArray(ByRef $aStack) If __Stack_IsAPI($aStack) And $aStack[$STACK_COUNT] > 0 Then Local $aArray[$aStack[$STACK_COUNT]] Local $j = $aStack[$STACK_COUNT] - 1 For $i = $STACK_MAX To $aStack[$STACK_INDEX] $aArray[$j] = $aStack[$i] $j -= 1 Next Return $aArray EndIf Return SetError(1, 0, Null) EndFunc ;==>Stack_ToArray ; #FUNCTION# ==================================================================================================================== ; Name ..........: Stack_Capacity ; Description ...: Retrieve the capacity of the internal stack elements. ; Syntax ........: Stack_Capacity(ByRef $aStack) ; Parameters ....: $aStack - [in/out] Handle returned by Stack(). ; Return values .: Success: Capacity of the internal stack. ; Failure: None. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Stack_Capacity(ByRef $aStack) Return (__Stack_IsAPI($aStack) ? $aStack[$STACK_UBOUND] - $STACK_MAX : 0) EndFunc ;==>Stack_Capacity ; #FUNCTION# ==================================================================================================================== ; Name ..........: Stack_Clear ; Description ...: Remove all items/objects from the stack. ; Syntax ........: Stack_Clear(ByRef $aStack) ; Parameters ....: $aStack - [in/out] Handle returned by Stack(). ; Return values .: Success: True. ; Failure: None. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Stack_Clear(ByRef $aStack) Return __Stack($aStack, Null, False) EndFunc ;==>Stack_Clear ; #FUNCTION# ==================================================================================================================== ; Name ..........: Stack_Count ; Description ...: Retrieve the number of items/objects on the stack. ; Syntax ........: Stack_Count(ByRef $aStack) ; Parameters ....: $aStack - [in/out] Handle returned by Stack(). ; Return values .: Success: Count of the items/objects on the stack. ; Failure: None. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Stack_Count(ByRef $aStack) Return (__Stack_IsAPI($aStack) And $aStack[$STACK_COUNT] >= 0 ? $aStack[$STACK_COUNT] : 0) EndFunc ;==>Stack_Count ; #FUNCTION# ==================================================================================================================== ; Name ..........: Stack_ForEach ; Description ...: Loop through the stack and pass each item/object to a custom function for processing. ; Syntax ........: Stack_ForEach(ByRef $aStack, $hFunc) ; Parameters ....: $aStack - [in/out] Handle returned by Stack(). ; $hFunc - A delegate to a function that has a single ByRef input and a return value of either True (continue looping) or False (exit looping). ; Return values .: Success: Return value of either True or False from the delegate function. ; Failure: Null ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Stack_ForEach(ByRef $aStack, $hFunc) Local $bReturn = Null If __Stack_IsAPI($aStack) And IsFunc($hFunc) Then For $i = $STACK_MAX To $aStack[$STACK_INDEX] $bReturn = $hFunc($aStack[$i]) If Not $bReturn Then ExitLoop EndIf Next EndIf Return $bReturn EndFunc ;==>Stack_ForEach ; #FUNCTION# ==================================================================================================================== ; Name ..........: Stack_Peek ; Description ...: Peek at the item/object in the stack. ; Syntax ........: Stack_Peek(ByRef $aStack) ; Parameters ....: $aStack - [in/out] Handle returned by Stack(). ; Return values .: Success: Item/object in the stack. ; Failure: Sets @error to non-zero and returns Null. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Stack_Peek(ByRef $aStack) Return __Stack_IsAPI($aStack) And $aStack[$STACK_INDEX] >= $STACK_MAX ? $aStack[$aStack[$STACK_INDEX]] : SetError(1, 0, Null) EndFunc ;==>Stack_Peek ; #FUNCTION# ==================================================================================================================== ; Name ..........: Stack_Pop ; Description ...: Pop the last item/object from the stack. ; Syntax ........: Stack_Pop(ByRef $aStack) ; Parameters ....: $aStack - [in/out] Handle returned by Stack(). ; Return values .: Success: Item/object popped from the stack. ; Failure: Sets @error to non-zero and returns Null. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Stack_Pop(ByRef $aStack) If __Stack_IsAPI($aStack) And $aStack[$STACK_INDEX] >= $STACK_MAX Then $aStack[$STACK_COUNT] -= 1 ; Decrease the count. Local $vData = $aStack[$aStack[$STACK_INDEX]] ; Save the stack item/object. $aStack[$aStack[$STACK_INDEX]] = Null ; Set to null. $aStack[$STACK_INDEX] -= 1 ; Decrease the index by 1. ; If ($aStack[$STACK_UBOUND] - $aStack[$STACK_INDEX]) > 15 Then ; If there are too many blank rows then re-size the stack. ; __Stack($aStack, Null, True) ; EndIf Return $vData EndIf Return SetError(1, 0, Null) EndFunc ;==>Stack_Pop ; #FUNCTION# ==================================================================================================================== ; Name ..........: Stack_Push ; Description ...: Push an item/object to the stack. ; Syntax ........: Stack_Push(ByRef $aStack, $vData) ; Parameters ....: $aStack - [in/out] Handle returned by Stack(). ; $vData - Item/object. ; Return values .: Success: True. ; Failure: False. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Stack_Push(ByRef $aStack, $vData) Local $bReturn = False If __Stack_IsAPI($aStack) Then $bReturn = True $aStack[$STACK_INDEX] += 1 ; Increase the stack by 1. $aStack[$STACK_COUNT] += 1 ; Increase the count. If $aStack[$STACK_INDEX] >= $aStack[$STACK_UBOUND] Then ; ReDim the internal stack array if required. $aStack[$STACK_UBOUND] = Ceiling(($aStack[$STACK_UBOUND] - $STACK_MAX) * 2) + $STACK_MAX ReDim $aStack[$aStack[$STACK_UBOUND]] EndIf $aStack[$aStack[$STACK_INDEX]] = $vData ; Set the stack element. EndIf Return $bReturn EndFunc ;==>Stack_Push ; #FUNCTION# ==================================================================================================================== ; Name ..........: Stack_TrimExcess ; Description ...: Set the capacity to the number of items/objects in the stack. ; Syntax ........: Stack_TrimExcess(ByRef $aStack) ; Parameters ....: $aStack - [in/out] Handle returned by Stack(). ; Return values .: Success: True. ; Failure: None. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Stack_TrimExcess(ByRef $aStack) Return __Stack($aStack, Null, True) EndFunc ;==>Stack_TrimExcess ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __Stack ; Description ...:Create a new stack object or re-size a current stack object. ; Syntax ........: __Stack(ByRef $aStack, $iInitialSize, $bIsCopyObjects) ; Parameters ....: $aStack - [in/out] Handle returned by Stack(). ; $iInitialSize - Initial size value. ; $bIsCopyObjects - Copy the previous stack items/objects. ; Return values .: True ; Author ........: guinness ; =============================================================================================================================== Func __Stack(ByRef $aStack, $iInitialSize, $bIsCopyObjects) Local $iCount = (__Stack_IsAPI($aStack) ? $aStack[$STACK_COUNT] : ((IsInt($iInitialSize) And $iInitialSize > 0) ? $iInitialSize : 0)) Local $iUBound = $STACK_MAX + (($iCount > 0) ? $iCount : 4) ; STACK_INITIAL_SIZE Local $aStack_New[$iUBound] $aStack_New[$STACK_INDEX] = $STACK_MAX - 1 $aStack_New[$STACK_COUNT] = 0 $aStack_New[$STACK_ID] = $STACK_GUID $aStack_New[$STACK_UBOUND] = $iUBound If $bIsCopyObjects And $iCount > 0 Then ; If copy the previous objects is true and the count is greater than zero then copy. $aStack_New[$STACK_INDEX] = $STACK_MAX - 1 + $iCount $aStack_New[$STACK_COUNT] = $iCount For $i = $STACK_MAX To $aStack[$STACK_INDEX] $aStack_New[$i] = $aStack[$i] Next EndIf $aStack = $aStack_New $aStack_New = 0 Return True EndFunc ;==>__Stack ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __Stack_IsAPI ; Description ...: Determine if the variable is a valid stack handle. ; Syntax ........: __Stack_IsAPI(ByRef $aStack) ; Parameters ....: $aStack - [in/out] Handle returned by Stack(). ; Return values .: Success: True. ; Failure: False. ; Author ........: guinness ; =============================================================================================================================== Func __Stack_IsAPI(ByRef $aStack) Return UBound($aStack) >= $STACK_MAX And $aStack[$STACK_ID] = $STACK_GUID EndFunc ;==>__Stack_IsAPI1 point -
Queue UDF - Based on the concept in .NET.
jvanegmond reacted to guinness for a topic
Mat gave me this idea from my >Stack UDF thread. It works like a stack, but instead of being LIFO (last in first out), it's FIFO (first in first out). Enjoy. Global Const $QUEUE_GUID = 'BB09E988-0DF3-11E4-846E-B46DECBA0006' Global Enum $QUEUE_COUNT, $QUEUE_FIRSTINDEX, $QUEUE_LASTINDEX, $QUEUE_ID, $QUEUE_UBOUND, $QUEUE_MAX #Region Example #include <Array.au3> Example() Func Example() Local $hQueue = Queue() ; Create a queue object. For $i = 1 To 20 If Queue_Enqueue($hQueue, 'Example_' & $i) Then ConsoleWrite('Enqueue: ' & 'Example_' & $i & @CRLF) ; Push random data to the queue. Next For $i = 1 To 15 ConsoleWrite('Dequeue: ' & Queue_Dequeue($hQueue) & @CRLF) ; Pop from the queue. If Queue_Enqueue($hQueue, 'Example_' & $i * 10) Then ConsoleWrite('Enqueue: ' & 'Example_' & $i * 10 & @CRLF) ; Push random data to the queue. Next ConsoleWrite('Peek: ' & Queue_Peek($hQueue) & @CRLF) ConsoleWrite('Peek: ' & Queue_Peek($hQueue) & @CRLF) ConsoleWrite('Count: ' & Queue_Count($hQueue) & @CRLF) ConsoleWrite('Capacity: ' & Queue_Capacity($hQueue) & @CRLF) Queue_ForEach($hQueue, AppendUnderscore) ; Loop through the stack and pass each item to the custom function. ConsoleWrite('Contains Example_150: ' & (Queue_ForEach($hQueue, Contains_150) = False) & @CRLF) ; It will return False if found so as to exit the ForEach() loop, hence why False is compared ConsoleWrite('Contains Example_1000: ' & (Queue_ForEach($hQueue, Contains_1000) = False) & @CRLF) ; It will return False if found so as to exit the ForEach() loop, hence why False is compared Local $aQueue = Queue_ToArray($hQueue) ; Create an array from the queue. _ArrayDisplay($aQueue) Queue_Clear($hQueue) ; Clear the queue. Queue_TrimToSize($hQueue) ; Decrease the memory footprint. EndFunc ;==>Example Func AppendUnderscore(ByRef $vItem) $vItem &= '_' Return (Random(0, 1, 1) ? True : False) ; Randomise when to return True Or False. The false was break from the ForEach() function. EndFunc ;==>AppendUnderscore Func Contains_150(ByRef $vItem) Return ($vItem == 'Example_150' ? False : True) ; If found exit the loop by setting to False. EndFunc ;==>Contains_150 Func Contains_1000(ByRef $vItem) Return ($vItem == 'Example_1000' ? False : True) ; If found exit the loop by setting to False. EndFunc ;==>Contains_1000 #EndRegion Example ; Functions: ; Queue - Create a queue handle. ; Queue_ToArray - Create an array from the queue. ; Queue_Capacity - Retrieve the capacity of the internal queue elements. ; Queue_Clear - Remove all items/objects from the queue. ; Queue_Count - Retrieve the number of items/objects on the queue. ; Queue_Dequeue - Pop the first item/object from the queue. ; Queue_Enqueue - Push an item/object to the queue. ; Queue_ForEach - Loop through the queue and pass each item/object to a custom function for processing. ; Queue_Peek - Peek at the item/object in the queue. ; Queue_TrimToSize - Set the capacity to the number of items/objects in the queue. ; #FUNCTION# ==================================================================================================================== ; Name ..........: Queue ; Description ...: Create a queue handle. ; Syntax ........: Queue([$iInitialSize = Default]) ; Parameters ....: $iInitialSize - [optional] Initialise the queue with a certain size. Useful if you know how large the queue will grow. Default is zero ; Parameters ....: None ; Return values .: Handle that should be passed to all relevant queue functions. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Queue($iInitialSize = Default) Local $aQueue = 0 __Queue($aQueue, $iInitialSize, False) Return $aQueue EndFunc ;==>Queue ; #FUNCTION# ==================================================================================================================== ; Name ..........: Queue_ToArray ; Description ...: Create an array from the queue. ; Syntax ........: Queue_ToArray(ByRef $aQueue) ; Parameters ....: $aQueue - [in/out] Handle returned by Queue(). ; Return values .: Success: A zero based array. ; Failure: Sets @error to non-zero and returns Null. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Queue_ToArray(ByRef $aQueue) If __Queue_IsAPI($aQueue) And $aQueue[$QUEUE_COUNT] > 0 Then Local $aArray[$aQueue[$QUEUE_COUNT]] Local $j = 0 For $i = $aQueue[$QUEUE_FIRSTINDEX] To $aQueue[$QUEUE_LASTINDEX] $aArray[$j] = $aQueue[$i] $j += 1 Next Return $aArray EndIf Return SetError(1, 0, Null) EndFunc ;==>Queue_ToArray ; #FUNCTION# ==================================================================================================================== ; Name ..........: Queue_Capacity ; Description ...: Retrieve the capacity of the internal queue elements. ; Syntax ........: Queue_Capacity(ByRef $aQueue) ; Parameters ....: $aQueue - [in/out] Handle returned by Queue(). ; Return values .: Success: Capacity of the internal queue ; Failure: None. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Queue_Capacity(ByRef $aQueue) Return (__Queue_IsAPI($aQueue) ? $aQueue[$QUEUE_UBOUND] - (($aQueue[$QUEUE_FIRSTINDEX] >= $QUEUE_MAX) ? $aQueue[$QUEUE_FIRSTINDEX] - 1 : $QUEUE_MAX) : 0) EndFunc ;==>Queue_Capacity ; #FUNCTION# ==================================================================================================================== ; Name ..........: Queue_Clear ; Description ...: Remove all items/objects from the queue. ; Syntax ........: QueueClear(ByRef $aQueue) ; Parameters ....: $aQueue - [in/out] Handle returned by Queue(). ; Return values .: Success: True. ; Failure: None. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Queue_Clear(ByRef $aQueue) Return __Queue($aQueue, Null, False) EndFunc ;==>Queue_Clear ; #FUNCTION# ==================================================================================================================== ; Name ..........: Queue_Count ; Description ...: Retrieve the number of items/objects on the queue. ; Syntax ........: Queue_Count(ByRef $aQueue) ; Parameters ....: $aQueue - [in/out] Handle returned by Queue(). ; Return values .: Success: Count of the items/objects on the queue. ; Failure: None. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Queue_Count(ByRef $aQueue) Return (__Queue_IsAPI($aQueue) And $aQueue[$QUEUE_COUNT] >= 0 ? $aQueue[$QUEUE_COUNT] : 0) EndFunc ;==>Queue_Count ; #FUNCTION# ==================================================================================================================== ; Name ..........: Queue_ForEach ; Description ...: Loop through the queue and pass each item/object to a custom function for processing. ; Syntax ........: Queue_ForEach(ByRef $aQueue, $hFunc) ; Parameters ....: $aQueue - [in/out] Handle returned by Queue(). ; $hFunc - A delegate to a function that has a single ByRef input and a return value of either True (continue looping) or False (exit looping). ; Return values .: Success: Return value of either True or False from the delegate function. ; Failure: Null ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Queue_ForEach(ByRef $aQueue, $hFunc) Local $bReturn = Null If __Queue_IsAPI($aQueue) And IsFunc($hFunc) Then For $i = $aQueue[$QUEUE_FIRSTINDEX] To $aQueue[$QUEUE_LASTINDEX] $bReturn = $hFunc($aQueue[$i]) If Not $bReturn Then ExitLoop EndIf Next EndIf Return $bReturn EndFunc ;==>Queue_ForEach ; #FUNCTION# ==================================================================================================================== ; Name ..........: Queue_Peek ; Description ...: Peek at the item/object in the queue. ; Syntax ........: Queue_Peek(ByRef $aQueue) ; Parameters ....: $aQueue - [in/out] Handle returned by Queue(). ; Return values .: Success: Item/object in the queue. ; Failure: Sets @error to non-zero and returns Null. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Queue_Peek(ByRef $aQueue) Return (__Queue_IsAPI($aQueue) And $aQueue[$QUEUE_FIRSTINDEX] >= $QUEUE_MAX ? $aQueue[$aQueue[$QUEUE_FIRSTINDEX]] : SetError(1, 0, Null)) EndFunc ;==>Queue_Peek ; #FUNCTION# ==================================================================================================================== ; Name ..........: Queue_Dequeue ; Description ...: Pop the first item/object from the queue. ; Syntax ........: Queue_Dequeue(ByRef $aQueue) ; Parameters ....: $aQueue - [in/out] Handle returned by Queue(). ; Return values .: Success: Item/object popped from the queue. ; Failure: Sets @error to non-zero and returns Null. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Queue_Dequeue(ByRef $aQueue) If __Queue_IsAPI($aQueue) And $aQueue[$QUEUE_LASTINDEX] >= $QUEUE_MAX Then $aQueue[$QUEUE_COUNT] -= 1 ; Decrease the count. Local $vData = $aQueue[$aQueue[$QUEUE_FIRSTINDEX]] ; Save the queue item/object. $aQueue[$aQueue[$QUEUE_FIRSTINDEX]] = Null ; Set to null. $aQueue[$QUEUE_FIRSTINDEX] += 1 ; If ($aQueue[$QUEUE_FIRSTINDEX] - $QUEUE_MAX) > 15 Then ; If there are too many blank rows then re-size the queue. ; __Queue($aQueue, Null, True) ; EndIf Return $vData EndIf Return SetError(1, 0, Null) EndFunc ;==>Queue_Dequeue ; #FUNCTION# ==================================================================================================================== ; Name ..........: Queue_Enqueue ; Description ...: Push an item/object to the queue. ; Syntax ........: Queue_Enqueue(ByRef $aQueue, $vData) ; Parameters ....: $aQueue - [in/out] Handle returned by Queue(). ; $vData - Item/object. ; Return values .: Success: True. ; Failure: Sets @error to non-zero and returns Null. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Queue_Enqueue(ByRef $aQueue, $vData) If __Queue_IsAPI($aQueue) Then $aQueue[$QUEUE_LASTINDEX] += 1 ; Increase the queue by 1. $aQueue[$QUEUE_COUNT] += 1 ; Increase the count. If $aQueue[$QUEUE_LASTINDEX] >= $aQueue[$QUEUE_UBOUND] Then ; ReDim the internal queue array if required. $aQueue[$QUEUE_UBOUND] = Ceiling(($aQueue[$QUEUE_UBOUND] - $QUEUE_MAX) * 2) + $QUEUE_MAX ReDim $aQueue[$aQueue[$QUEUE_UBOUND]] EndIf $aQueue[$aQueue[$QUEUE_LASTINDEX]] = $vData ; Set the queue element. Return True EndIf Return SetError(1, 0, Null) EndFunc ;==>Queue_Enqueue ; #FUNCTION# ==================================================================================================================== ; Name ..........: Queue_TrimToSize ; Description ...: Set the capacity to the number of items/objects in the queue. ; Syntax ........: Queue_TrimToSize(ByRef $aQueue) ; Parameters ....: $aQueue - [in/out] Handle returned by Queue(). ; Return values .: Success: True. ; Failure: None. ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Queue_TrimToSize(ByRef $aQueue) Return __Queue($aQueue, Null, True) EndFunc ;==>Queue_TrimToSize ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __Queue ; Description ...:Create a new queue object or re-size a current queue object. ; Syntax ........: __Queue(Byref $aQueue, $iInitialSize, $bIsCopyObjects) ; Parameters ....: $aQueue - [in/out] Handle returned by Queue(). ; $iInitialSize - Initial size value. ; $bIsCopyObjects - Copy the previous queue items/objects. ; Return values .: True ; Author ........: guinness ; =============================================================================================================================== Func __Queue(ByRef $aQueue, $iInitialSize, $bIsCopyObjects) Local $iCount = (__Queue_IsAPI($aQueue) ? $aQueue[$QUEUE_COUNT] : ((IsInt($iInitialSize) And $iInitialSize > 0) ? $iInitialSize : 0)) Local $iUBound = $QUEUE_MAX + (($iCount > 0) ? $iCount : 4) ; QUEUE_INITIAL_SIZE Local $aQueue_New[$iUBound] $aQueue_New[$QUEUE_FIRSTINDEX] = $QUEUE_MAX $aQueue_New[$QUEUE_LASTINDEX] = $QUEUE_MAX - 1 $aQueue_New[$QUEUE_COUNT] = 0 $aQueue_New[$QUEUE_ID] = $QUEUE_GUID $aQueue_New[$QUEUE_UBOUND] = $iUBound If $bIsCopyObjects And $iCount > 0 Then ; If copy the previous objects is true and the count is greater than zero then copy. $aQueue_New[$QUEUE_LASTINDEX] = $QUEUE_MAX - 1 + $iCount $aQueue_New[$QUEUE_COUNT] = $iCount Local $j = $aQueue[$QUEUE_FIRSTINDEX] + 1 For $i = $QUEUE_MAX To $aQueue_New[$QUEUE_COUNT] + $QUEUE_MAX - 1 $aQueue_New[$i] = $aQueue[$j] $j += 1 Next EndIf $aQueue = $aQueue_New $aQueue_New = 0 Return True EndFunc ;==>__Queue ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __Queue_IsAPI ; Description ...: Determine if the variable is a valid queue handle. ; Syntax ........: __Queue_IsAPI(ByRef $aQueue) ; Parameters ....: $aQueue - [in/out] Handle returned by Queue(). ; Return values .: Success: True. ; Failure: False. ; Author ........: guinness ; =============================================================================================================================== Func __Queue_IsAPI(ByRef $aQueue) Return UBound($aQueue) >= $QUEUE_MAX And $aQueue[$QUEUE_ID] = $QUEUE_GUID EndFunc ;==>__Queue_IsAPI1 point -
remin, You can do it this way: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> AdlibRegister("_GetActive") Global $hActive $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("Test", 10, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton ConsoleWrite("Button pressed" & @CRLF) ; Reactivate last known active window WinActivate($hActive) EndSwitch WEnd Func _GetActive() $hCurrent = WinGetHandle("[ACTIVE]") If $hCurrent <> $hGUI Then $hActive = $hCurrent EndIf EndFunc Any use? M231 point
-
Close list of processes
232showtime reacted to JLogan3o13 for a topic
You can use a variable with case, but in this instance AutoIt sees your variable as calc.exe, notepad.exe, winword.exe. This will never match a process name, obviously, so you would have to split it. If you want a list of three or four processes, and want them in variables, you would have to do something like this: $calc = "calc.exe" $notepad = "notepad.exe" $word = "winword.exe" $aList = ProcessList() For $i = 1 To $aList[0][0] Switch $aList[$i][0] Case $calc ProcessClose($calc) Case $notepad ProcessClose($notepad) Case $word ProcessClose($word) EndSwitch Next1 point -
Array.au3 - Final Beta - Testing required
marsEvolve reacted to Melba23 for a topic
Thread closed Here is what I hope will be the final Beta version of the new Array.au3. This zip includes the new include file, proposed Help file examples and pages for all new/changed functions: Please let me know of any bugs, spelling mistakes or other inaccuracies that you can find - I am seeing at least double after a couple of days checking them myself! And I do NOT want any more feature requests - you have had long enough let me know if you wanted any more new additions. Note: You need the Beta 3.3.11.3 to run this code - it is Beta itself after all. Current public functions and any changes made: _ArrayAdd: Now supports 2D arrays and multiple additions. Data for addition can be a single value, a delimited string or another array. The delimiters and the column in which the insertion is to start for 2D arrays can be user-defined. _ArrayBinarySearch: Now supports 2D arrays searching in columns. _ArrayColDelete: New function to delete a column from an array. Optional to convert to 1D if only 1 column left. _ArrayColInsert: New function to insert a column into an array. Converts 1D to 2D automatically. _ArrayCombinations: Unchanged _ArrayConcatenate: Will concatenate 2D arrays with the same number of columns. _ArrayDelete: Now supports 2D arrays. Will also delete multiple rows if passed either a range string detailing the rows ("3:7-9:15-25;56") or a 1D array of all the rows to be deleted with a count in the [0] element. _ArrayDisplay: Added option to hide the buttons _ArrayExtract: New function to return a section of the 1D/2D source array as defined by the user. _ArrayFindAll: Unchanged _ArrayInsert: Now supports 2D arrays. Will also insert multiple rows if passed either a range string detailing the rows ("3:7-9:15-25;56") or a 1D array of all the rows to be inserted with a count in the [0] element. Multiple inserts are made above the specified row of the original array. Data for insertion into 2D arrays can be a single value, a delimited string or another 1D array. The delimiter and the column in which the insertion is to start can be user-defined. _ArrayMax: Now supports 2D arrays _ArrayMaxIndex: Now supports 2D arrays _ArrayMin: Now supports 2D arrays _ArrayMinIndex: Now supports 2D arrays _ArrayPermute: Unchanged _ArrayPop: Unchanged _ArrayPush: Unchanged _ArrayReverse: Unchanged _ArraySearch: Now supports searching rows as well as columns _ArraySort: Unchanged _ArraySwap: Completely rewritten and now swaps entire or part row/columns within the array. SCRIPT BREAKING!!!!! _ArrayToClip: Now a simple wrapper for _ArrayToString - so default delimiter is no longer @CR. SCRIPT BREAKING!!!!! _ArrayToString: Now supports 2D arrays - user-defined delimiters between items and rows. SCRIPT BREAKING!!!!! _ArrayTranspose: New and improved jchd code. Automatically changes from 1D to 2D and vice versa if needed _ArrayTrim: Now supports 2D arrays _ArrayUnique: Column number now 0-based not 1-based - this is for consistency with all other array functions. SCRIPT BREAKING!!!!! Remember that it is YOU who will be using this library in the future - please help make it as bug-free as possible. Over to you! M23 P.S. Do not be surprised if I do not respond immediately to your post even if I am online - I am taking a break from this library for a little while.1 point -
_WordDocFindReplace issue
KEHT reacted to MrMitchell for a topic
Yes. From your For loop: For $i = 1 to 100 ; IF THIS NUMBER IS CHANGED FROM 10 TO 100 _WordDocFindReplace DOES NOT WORK FileWrite($file, "Line " & $i) Next FileClose($file) FileOpen("a.txt") $String_to_replace = Fileread($file) ClipPut($String_to_replace) ;Put it on the clipboard $oFind = _WordDocFindReplace($oDoc, "this", "^c") ;Per MSDN documentation use this ^c to paste from the clipboard. Reference: http://msdn.microsoft.com/en-us/library/....word.find.execute%28v=office. Scroll down to ReplaceWith to see where I got this from. They stated this is how you would use it for a picture but it seems to work fine with text too. To answer your original question, I have no idea if there's a limit to the number of characters, couldn't figure that out. But at least you have a workaround.1 point -
IE.au3 scroll down page help
matwachich reacted to DaleHohm for a topic
Something like this: #include <IE.au3> $oIE = _IECreate("http://freshmeat.net/") $oIE.document.parentwindow.scroll(0, $oIE.document.body.scrollHeight/2) Dale1 point -
Window question
232showtime reacted to mike1305 for a topic
Who ever thought there could be so much drama on a forum about a scripting program. I feel like I just watched an episode of "The Real World: AutoIt Forums Extreme".1 point -
Window question
232showtime reacted to Paulie for a topic
hey, don't call me off-topic, i was simply saying that the attitude you took toward someone(who gave you the answer you were looking for) SUCKED. (and thats not to say that even if he tried to help you, but you didn't find his post helpful, you then have the right to insult him) I don't see why you feel so threatened as to feel a need to throw insults at me, when i never even insulted you when i talked on behalf of the forum, i feel it was in good taste, you must agree, if every thread was replied to, just to correct grammatical/spelling errors, the forum would be a mad house with billions of posts, (i'm sure i have several spelling/grammar errors in this post alone). As long as you can understand the sentence, it doesn't merit correction. and YOUR the one spamming posts just to say you spelled "Then" wrong I don't consider my post count high at all, and even if i did, it means nothing, which is another reason that i felt that your post spamming accusation was pointless, anyway, i have nothing personal against you, i just don't think those attitudes are necessary on this forum, which is centered around people helping other people, not insulting them i simply didn't contribute to the post, because firstly, i could hardly understand the question, secondly, i feel that being supported on this forum is a privilege, not a right, and if someone acts up, what better way to reprimand them? Again, nothing personal just me1 point