-
Posts
248 -
Joined
-
Last visited
Geir1983's Achievements
-
guestscripter reacted to a post in a topic: Poker Hand evaluator plugin
-
Writing a Function, inside a Function?
Geir1983 replied to HelpfulToasty's topic in AutoIt General Help and Support
"Note that function declarations cannot appear inside other function declarations." From the help on functions -
Isnt Case better suited to test an Integer value? "IF" more suited to this sort of boolean test?
-
You can use this:
-
Hex - Add together for Checksum
Geir1983 replied to lbw87's topic in AutoIt General Help and Support
Look at what Dec() does, it takes a hexadecimal string and turns it into a number that you can do mathematical operations on. The string is not really an ascii string it is meant to represent data in hex. The _StringToHex will return the hex representation of every ascii charachter in it, for example if you enter _StringToHex("FF") it will return 4646, the Dec("FF") will return 255. Edit: I see you are using _HexToString, this is returning a string, not an integer. You cannot do mathematical operations on a string the same way as you would do a int variable. Dec Returns a numeric representation of a hexadecimal string. -
ill a byte array from DllStructGetData($lpBuffer, 1)
Geir1983 replied to weirddave's topic in AutoIt General Help and Support
Something like this? I think the empty array in autoit is a problem, it has no datatype.. #include <Array.au3> #include <File.au3> $lpBuffer = DllStructCreate('BYTE[256]') $data=DllStructGetData($lpBuffer, 1) $MyFile = "C:\a.bin" _FileCreate($MyFile) $hFileOpen = FileOpen($MyFile, BitOr($FO_OVERWRITE, $FO_CREATEPATH, $FO_BINARY )) $MyArray = _BinaryToArray($data) FileWrite($hFileOpen, DllStructGetData($lpBuffer, 1)) FileClose($hFileOpen) ;_ArrayDisplay($MyArray) Func _BinaryToArray($bData) Local $iCount = BinaryLen($bData) ConsoleWrite("Count := " &$iCount&@CRLF) Local $aRet[$iCount] For $i = 1 To $iCount $aRet[$i - 1] = BinaryMid($bData, $i, 1) Next Return $aRet EndFunc -
ill a byte array from DllStructGetData($lpBuffer, 1)
Geir1983 replied to weirddave's topic in AutoIt General Help and Support
you do call your other function that send data to that array? The example you posted will not have any data... -
ill a byte array from DllStructGetData($lpBuffer, 1)
Geir1983 replied to weirddave's topic in AutoIt General Help and Support
remove the $FO_READ? -
ill a byte array from DllStructGetData($lpBuffer, 1)
Geir1983 replied to weirddave's topic in AutoIt General Help and Support
Why not just enter data to a normal array directly (from your serial port) instead of putting it in a dllstruct and then convert it to an autoit array? -
Hex - Add together for Checksum
Geir1983 replied to lbw87's topic in AutoIt General Help and Support
You want to exclude the header(AA) and the crc(55) in the string you pass to the checksum function i think: Edit, i think you use the _StringToHex function wrong, your string is already a Hex representation? $test = "FF0103411100" Checksum($test) Func Checksum($String) $checksum = 0 For $idx=1 to StringLen($String) Step 2 $checksum += Dec(StringMid($String, $idx, 2)) Next ConsoleWrite("Checksum: "& Hex($checksum,2) &@CRLF) Return Hex($checksum,2) EndFunc -
Very slow performance after the first run!
Geir1983 replied to Znuffie's topic in AutoIt General Help and Support
So do you restart the 3rd party app or do you restart your autoit script to make the problem disappear? -
Very slow performance after the first run!
Geir1983 replied to Znuffie's topic in AutoIt General Help and Support
Did you try it? Its part of your main loop and its called recursively.. -
Very slow performance after the first run!
Geir1983 replied to Znuffie's topic in AutoIt General Help and Support
You have a loop without sleep (line 229), maybe this is your problem? #NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Array.au3> #include <MsgBoxConstants.au3> #include <Date.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $program = "C:\Program Files\Smart Player\Smart Player.exe" Opt("MouseCoordMode", 0) Opt("WinTitleMatchMode", 4) Opt("SendKeyDelay", 25) Opt("TrayIconHide", 1) $count = 0 Func GetFile() $file = RecursiveFileSearch("Z:\Surv\_swap", "\.(dav)", ".", 1, True) If $file[0] > 0 Then ConsoleWrite("There are " & $file[0] & " files left" & @CRLF) Return $file[1] Else Return False EndIf EndFunc ;==>GetFile Func _log($string) $time = _Date_Time_GetSystemTime() $time = _Date_Time_SystemTimeToDateTimeStr($time) ConsoleWrite("[" & $time & "] " & $string & @CRLF) Sleep(15) EndFunc ;==>_log Func ConvertFile($file) _log("Do: " & $file); If ProcessExists("Smart Player.exe") Then _log("Exit Program") ProcessClose("Smart Player.exe") EndIf _log("Run Program") Run($program & " " & $file) _log("Waiting for activation...") WinWaitActive("Smart Player") Sleep(500) _log("Closing preview...") ; close preview MouseMove(629, 83, 0) MouseClick("left", 629, 83, 1, 0) Sleep(50) MouseMove(627, 110, 50) Sleep(250) MouseClick("left", 627, 110, 1, 0) ;ControlClick("Smart Player", "", "[CLASS:QWidget; INSTANCE:119]", "left", 1, 296, 11) _log("Clicking export...") ; click to export ;MouseMove(336,36) Sleep(75) MouseClick("left", 336, 36, 1, 0) _log("Checkmark on the file") ; check file ;MouseMove(644, 157) Sleep(75) MouseClick("left", 644, 157, 1, 0) ; stopping preview ;MouseMove(184, 475) Sleep(150) ;MouseClick("left", 184, 475, 1, 0) ControlClick("Smart Player", "", "[CLASS:QWidget; INSTANCE:32]") Sleep(1000) _log("Clicking on Format") ; click on format ;MouseMove(788, 442, 0) Sleep(500) ;MouseClick("left", 788, 442, 1, 0) ControlClick("Smart Player", "", "[CLASS:QWidget; INSTANCE:11]") _log("Selecting AVI") ; Select AVI MouseMove(770, 538, 0) Sleep(250) MouseClick("left", 770, 538, 1, 0) Sleep(250) _log("Exporting now...") ; Click EXPORT MouseMove(487, 544, 0) Sleep(250) MouseClick("left", 487, 544, 1, 10) ControlClick("Smart Player", "", "[CLASS:QWidget; INSTANCE:27]") ; get directory $dir = GetDir($file) _log("Typing Directory: " & $dir) ; type directory Sleep(2500) WinWaitActive("Find Directory") Send($dir & "{ENTER}") Sleep(15000) _log("Checking if there are JPG files in here") $findjpg = RecursiveFileSearch($dir, "\.(jpg)", ".", 1, False) If $findjpg[0] > 0 Then _log("Found JPG files... we failed :-(") ProcessClose("Smart Player.exe") FileChangeDir($dir) FileDelete("*.jpg") Sleep(1000) Return True EndIf _log("Waiting to finish export...") ; now waiting to finish export... WinWaitActive("[W:301; H:136]") _log("Clicking OK") ; clicking "OK" ;MouseMove(159, 111) Sleep(75) MouseClick("left", 159, 111, 1, 0) _log("Exit Program") ProcessClose("Smart Player.exe") Sleep(500) ;DONE $newfile = StringReplace($file, ".dav", ".done") _log("Moving file to: " & $newfile) FileMove($file, $newfile) _log("--- --- --- DONE --- --- --") EndFunc ;==>ConvertFile While True ConvertFile(GetFile()) Sleep(1000) $count = $count + 1 If $count >= 5 Then ConsoleWrite(@CRLF & "Allowing VM to catch up..." & @CRLF) Sleep(20000) $count = 0 EndIf WEnd Func GetDir($sFilePath) Local $aFolders = StringSplit($sFilePath, "\") Local $iArrayFoldersSize = UBound($aFolders) Local $FileDir = "" If (Not IsString($sFilePath)) Then Return SetError(1, 0, -1) EndIf $aFolders = StringSplit($sFilePath, "\") $iArrayFoldersSize = UBound($aFolders) For $i = 1 To ($iArrayFoldersSize - 2) $FileDir &= $aFolders[$i] & "\" Next Return $FileDir EndFunc ;==>GetDir #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: WeaponX Updated: 2/21/08 Script Function: Recursive file search 2/21/08 - Added pattern for folder matching, flag for return type 1/24/08 - Recursion is now optional Parameters: RFSstartdir: Path to starting folder RFSFilepattern: RegEx pattern to match "\.(mp3)" - Find all mp3 files - case sensitive (by default) "(?i)\.(mp3)" - Find all mp3 files - case insensitive "(?-i)\.(mp3|txt)" - Find all mp3 and txt files - case sensitive RFSFolderpattern: "(Music|Movies)" - Only match folders named Music or Movies - case sensitive (by default) "(?i)(Music|Movies)" - Only match folders named Music or Movies - case insensitive "(?!(Music|Movies)\:)\b.+" - Match folders NOT named Music or Movies - case sensitive (by default) RFSFlag: Specifies what is returned in the array 0 - Files and folders 1 - Files only 2 - Folders only RFSrecurse: TRUE = Recursive, FALSE = Non-recursive RFSdepth: Internal use only #ce ---------------------------------------------------------------------------- Func RecursiveFileSearch($RFSstartDir, $RFSFilepattern = ".", $RFSFolderpattern = ".", $RFSFlag = 0, $RFSrecurse = True, $RFSdepth = 0) ;Ensure starting folder has a trailing slash If StringRight($RFSstartDir, 1) <> "\" Then $RFSstartDir &= "\" If $RFSdepth = 0 Then ;Get count of all files in subfolders for initial array definition $RFSfilecount = DirGetSize($RFSstartDir, 1) ;File count + folder count (will be resized when the function returns) Global $RFSarray[$RFSfilecount[1] + $RFSfilecount[2] + 1] EndIf $RFSsearch = FileFindFirstFile($RFSstartDir & "*.*") If @error Then Return ;Search through all files and folders in directory While 1 Sleep(10) $RFSnext = FileFindNextFile($RFSsearch) If @error Then ExitLoop ;If folder and recurse flag is set and regex matches If StringInStr(FileGetAttrib($RFSstartDir & $RFSnext), "D") Then If $RFSrecurse And StringRegExp($RFSnext, $RFSFolderpattern, 0) Then RecursiveFileSearch($RFSstartDir & $RFSnext, $RFSFilepattern, $RFSFolderpattern, $RFSFlag, $RFSrecurse, $RFSdepth + 1) If $RFSFlag <> 1 Then ;Append folder name to array $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext $RFSarray[0] += 1 EndIf EndIf ElseIf StringRegExp($RFSnext, $RFSFilepattern, 0) And $RFSFlag <> 2 Then ;Append file name to array $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext $RFSarray[0] += 1 EndIf WEnd FileClose($RFSsearch) If $RFSdepth = 0 Then ReDim $RFSarray[$RFSarray[0] + 1] Return $RFSarray EndIf EndFunc ;==>RecursiveFileSearch -
You need to specify wich element in the array: Local $aArray_Base[16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15] Local $aArray = $aArray_Base _ArrayShuffle($aArray) _ArrayDisplay($aArray, "1D - Shuffled", Default, 16) GUICtrlSetData($input1,$aArray[0])
-
czardas reacted to a post in a topic: Having a Problem with some calculations (inaccuracies)
-
;Send Pause Send("{PAUSE}") ;Get some coordinates $y = Random(0, @DesktopDepth) $x = Random(0, @DesktopWidth) ;And left Click it! MouseClick("left", $x, $y)