Leaderboard
Popular Content
Showing content with the highest reputation on 06/09/2013 in all areas
-
Hi Folks, I'm a great fan of AutoIT. While trying to automate data entry into a java applet based ERP, I found that checking for entry error or success is quite a pain using pixelsearch. Instead, check for a data entry "success" or "failed" image is far simpler. This a feature found in AHK, I've cut out the necessary code and compiled it into a DLL, and written a au3 library around it. I've tested it in various XP and W2k3 machines, and it seems to work fine. It's a quick and dirty hack I did to get a job done, so your mileage may vary ImageSearch.zip (84K) Number of downloads:1 point
-
_HotKeyString_To_AutoitCode
mesale0077 reacted to AZJIO for a topic
; #FUNCTION# ;================================================================================= ; Function Name ...: _HotKeyString_To_AutoitCode ; Description ........: Converts text format recording hotkey to format HotKeySet in Autoit3 ; Syntax................: _HotKeyString_To_AutoitCode ( $sKey ) ; Parameters: ; $sKey - text format recording hot key, such as "Ctrl + s" ; Return values ....: Success - Returns a string in the format function in HotKeySet Autoit3, such as "^s" ; Failure - empty string, @error: ; |1 - empty string ; |2 - with modifiers used in more than one key ; |3 - the same modifier is used more than once ; Author(s) ..........: AZJIO ; Remarks ..........: ; ============================================================================================ Func _HotKeyString_To_AutoitCode($sKey) Local $ch, $k If $sKey = '' Then Return SetError(1, 0, '') $sKey = '{' & StringRegExpReplace(StringStripWS($sKey, 8), '(?<!\+)\+', '}{') & '}' ; удаляем пробелы, используем "+" как разделитель If StringRight($sKey, 3) = '}{}' Then $sKey = StringTrimRight($sKey, 2) ; если заканчивается разделителем справа, вместо клавиши If StringLeft($sKey, 3) = '{}{' Then $sKey = StringTrimLeft($sKey, 2) ; если заканчивается разделителем слева, вместо клавиши $sKey = StringRegExpReplace($sKey, '\{([^!+^#{}])\}', '\1') ; если не метасимволы то убираем обрамляющие фигурные скобки ; Создаёт строку модификаторов Local $sMod = '' Local $aMod = StringRegExp($sKey, '(\{(?:Alt|Shift|Ctrl|Win)\})', 3) ; извлекает модификаторы If Not @error Then For $i = 0 To UBound($aMod) - 1 $sMod &= $aMod[$i] Next $sMod = StringReplace($sMod, '{Alt}', '!') If @extended > 1 Then Return SetError(3, 0, '') $sMod = StringReplace($sMod, '{Shift}', '+') If @extended > 1 Then Return SetError(3, 0, '') $sMod = StringReplace($sMod, '{Ctrl}', '^') If @extended > 1 Then Return SetError(3, 0, '') $sMod = StringReplace($sMod, '{Win}', '#') If @extended > 1 Then Return SetError(3, 0, '') EndIf ; проверка наличие только одной клавиши в сочетании с модификаторами $sKey = StringRegExpReplace($sKey, '\{Alt\}|\{Shift\}|\{Ctrl\}|\{Win\}', '') ; удаляем модификаторы $ch = StringRegExpReplace($sKey, '\{.*?\}', '') ; подсчитываем элементы обрамлённые фигурными скобками $k = @extended $k += StringLen($ch) ; добавляем количество символов без фигурных скобок If $k <> 1 Then Return SetError(2, 0, '') ; возвращает пустую строку при ошибке Return $sMod & $sKey EndFunc ;==>_HotKeyString_To_AutoitCode example #include <_HotKeyString_To_AutoitCode.au3> $sHotKey = _HotKeyString_To_AutoitCode('Ctrl + s') & @LF $sHotKey &= _HotKeyString_To_AutoitCode('Ctrl + Alt+ F1') & @LF $sHotKey &= _HotKeyString_To_AutoitCode('Ctrl + Shift+ +') & @LF $sHotKey &= _HotKeyString_To_AutoitCode('Win + Home') MsgBox(0, 'Yes?', $sHotKey) ; error $sHotKey = _HotKeyString_To_AutoitCode(' + Shift') & @LF ; excess divider $sHotKey &= _HotKeyString_To_AutoitCode('Ctrl + Shift+ ') & @LF ; excess divider $sHotKey &= _HotKeyString_To_AutoitCode(' + Shift+ ') & @LF ; excess divider $sHotKey &= _HotKeyString_To_AutoitCode(' Ctrl + Shift') & @LF ; only modifiers $sHotKey &= _HotKeyString_To_AutoitCode(' Ctrl + d+Shift') & @LF ; non-compliance with order $sHotKey &= _HotKeyString_To_AutoitCode('Ctrl + s + d') ; more than one key with the modifier MsgBox(0, 'Faulty', $sHotKey) To read from an ini-file1 point -
is there a clever way to extract one dimension of a multidim array ?
Blue_Drache reacted to AZJIO for a topic
Edano, $array2 = $array1 ReDim $array2[1][1000]1 point -
Just saying "thank you" again seems inadequate. I greatly appreciate your help and patience in this thread. Maybe it'll save someone else from frustration in the future.1 point
-
mus++
jaberwacky reacted to czardas for a topic
New secrets revealed: Compair the two examples from >post #34 with the following versions which use features introduced in the 4th tutorial. The sections repeat in a typical fashion. Notice how all the sharps (#) have disappeared from the code for 'The Oysterwives Rant'. They are no longer needed because of the key signature. This is much better organised code. ; _MusPlusPlus( _ ; The Oysterwives Rant "<fiddle> 2# 4/4 ;=125 |: $ -A | ;B -B A B E E F | A B A F D E F A | ;B -B A B C' D 'B' | A F D' 'F' Q ;E -E ;=128 :|" & _ ";=131 |: A | B A B C' D E D 'B' | -.A ~B -A F -.A ~B ;=75 ~.A \ ;=131 -F | B A B C' D E D 'B' | A F D' 'F' ;E -E ;=134 :|" & _ ";=137 DS |Q @Tempo ;E -;.E") Sleep(2000) _MusPlusPlus( _ ; O'er The Muir Amang The Heather "<bagp> 4/4 ;=90 -E' |: $ ;'G' -.G ~B ;G -.G ~B | ;A -.A ~B -D' 'G' B G | -.D' ~E -.D ~'B' -.D' ~E -.G ~A| G F -E -.G ~'B' -.A ~B -.A ~G :|" & _ "|: -.G ~B -.G' ~A G F -E | -.G ~D E -.A A ~G ;A | -.A ~E -.G ~A G F -E -.D ~E -.G ~A | G F -E -.G ~'B' Q -.A ~B -.A ~G :| DS |Q ;.A") ; ; And now an example of use with AutoIt - Random Greek Mode generator ; ; An example of using mus++ with AutoIt ; Random Greek Mode generator Local $sKey, $aSequence[7] = [ _ "-C D E F G A B C' 'B' A G F E D -oC", _ "-D E F G A B C' D C 'B' A G F E -oD", _ "-E F G A B C' D E D C 'B' A G F -oE", _ "-F G A B C' D E F E D C 'B' A G -oF", _ "-G A B C' D E F G F E D C 'B' A -oG", _ "-A B C' D E F G A G F E D C 'B' -oA", _ "-B C' D E F G A B A G F E D C -o'B'"] For $i = 1 To 21 If Random(0, 1, 1) Then $sKey = "#" Else $sKey = "b" EndIf _MusPlusPlus(Random(0, 7, 1) & $sKey & " ;=200 " & $aSequence[Random(0, 6, 1)]) Next ;1 point -
I see. The problem is that element 0 doesn't contain the element count. So my code needs to be changed to: For $i = UBound($aArray1, 1) - 1 To 0 Step -1 If $aArray1[$i] = "W100" or $aArray1[$i] = "W101" Then _ArrayDelete($aArray1, $i) Next1 point
-
michaelslamet, I would do it like this: $iCurr_Average= 0 $iPasses = Random(3, 10, 1) For $i = 1 To $iPasses ; Get a timestamp $iBegin = TimerInit() ; A random Sleep Sleep(Random(1000, 5000, 1)) ; How long was that $iThis_Time = Int(TimerDiff($iBegin)) ConsoleWrite("Pass " & $i & " time: " & $iThis_Time & @CRLF) ; Just for display ; Calculate new average If $i > 1 Then $iCurr_Average = Int((($iCurr_Average * $i - 1) + $iThis_Time) / ($i + 1)) Else $iCurr_Average = $iThis_Time EndIf ConsoleWrite("Calc average: " & $iCurr_Average & @CRLF) ; Just for display ; Calculate time remaining $iTime_Remaining = ($iPasses - $i) * $iCurr_Average ConsoleWrite("Remaining: " & $iTime_Remaining & @CRLF) Next All clear? M231 point
-
rapfeak, Glad I could be of assistance. M231 point
-
I meant in programming: RedFlag = False ; ==> Do not charge. I use mental imagery a lot - but perhaps that's just me.1 point