-
Posts
138 -
Joined
-
Last visited
Zinthose's Achievements
Adventurer (3/7)
7
Reputation
-
Trong reacted to a post in a topic:
Hex Edit Functions
-
Danyfirex reacted to a post in a topic:
Hex Edit Functions
-
mLipok reacted to a post in a topic:
MSI Return Codes UDF
-
Leo1906 reacted to a post in a topic:
Hex Edit Functions
-
marcoauto reacted to a post in a topic:
Simple KeepAlive Function
-
Hey all! It's been a while since I've posted but here is a simple little function I thought I'd share that allows you to keep a script process active for a minimum amount of time. I use this to ensure the process is active to ensure any TrayTips remain visible. But I'm sure there is far more interesting uses for this. How it Works The coder calls the KeepAlive function with the number of seconds he/she wants to ensure the process will remain active for the next n seconds. Let's say you just called the TrayTip function with 15 seconds display time. You might call KeepAlive with 18 seconds to ensure the process stays active for the next 18 seconds. If the process is closed after that, then the process will close normally. #Region - KeepAlive Functions ;## Function used to ensure the process stays active for the next n seconds. This is useful to ensure ToolTips ect remain visible. #cs - Example TrayTip(@ScriptName, "This Tip will be called just prior to exit of process.", 5) KeepAlive(8) Exit #ce - Example Func KeepAlive($Seconds = 5) Global $KeeyAlive_IsActive = False Global $KeeyAlive_Init = 0 Global $KeeyAlive_Timeout = 0 ;## Check if there is a previously set timer and only set the new value if it is more than the previously set value. If $KeeyAlive_Timeout - TimerDiff($KeeyAlive_Init) < $Seconds * 1000 Then $KeeyAlive_Init = TimerInit() $KeeyAlive_Timeout = $Seconds * 1000 EndIf ;## If the callback is not yet regerister to execute on exit, register it now. If Not $KeeyAlive_IsActive Then $KeeyAlive_IsActive = True OnAutoItExitRegister("__KeepAlive_OnExit") EndIf EndFunc ;## Private On Exit Function used to ensure program remains active for a previously defined number of seconds. Func __KeepAlive_OnExit() ;## If closeing due to Loffoff or shutdown. Allow it without Delay. If @exitMethod > 2 Then Return ;## Check for reasons that process should be clsoed immediatly without delay. If @exitMethod > 2 Or Not IsDeclared("KeeyAlive_IsActive") Or Not IsDeclared("KeeyAlive_Init") Or Not IsDeclared("KeeyAlive_Timeout") Or TimerDiff($KeeyAlive_Init) > $KeeyAlive_Timeout Then Return ;## Pause Process for the time remaining. ConsoleWrite("Keeping Alive for " & Int($KeeyAlive_Timeout - TimerDiff($KeeyAlive_Init)) & "ms" & @CRLF) Sleep($KeeyAlive_Timeout - TimerDiff($KeeyAlive_Init)) EndFunc #EndRegion Enjoy!
-
FindFile but what about the absolute path?
Zinthose replied to Zinthose's topic in AutoIt General Help and Support
Ideally I would like to feed the search handle into a function so I would return the current path it is searching. Something like... $hndFileFind = FileFindFirstFile("C:\Windows\Temp\*") $searchPath = _FileFindGetWorkingDirectory($hndFileFind) ;--> $searchPath = "C:\Windows\Temp" -
FindFile but what about the absolute path?
Zinthose replied to Zinthose's topic in AutoIt General Help and Support
Tested.. It only returns the same data fed into by the user "C:\Windows\Temp\*" = "C:\Windows\Temp\*" -
FindFile but what about the absolute path?
Zinthose replied to Zinthose's topic in AutoIt General Help and Support
It's a command line option for automation. Comma delimited list for processing each one. I'm still trying to work around the problem.. just was hoping to find a more elegant solution than what I fear I'll have to implement. -
I have no issues using FileFirstFile and it's evil step cousin FileFindNextFile. But.. Has anyone figured out a way to get the path from the search handle or through some other tricks? Assume I don't know what the user is giving me for the path but lets say for an example, "C:\Windows\Temp\*" Now I don't know what the path is.. just the full search string provided. Without what I feel is unnecessary path string manipulations, how can I get the path from the File Search if the search only returns ONLY the name and not the path? Yes, I know I could use _PathSplit but it seam overkill.
-
Soundex and levenstein distance algorithms
Zinthose replied to Eusebio's topic in AutoIt General Help and Support
Shame... Looks like the _StringClean function got corrupted at some point. I was looking forward to playing around with this. Anyone happen to have retained a copy that wasn't garbled by the site? -
_Service_UDF v4 : Build your own service with autoit code
Zinthose replied to arcker's topic in AutoIt Example Scripts
Just an FYI: I added the ability to add the description in the "_Service_Create" function. I just added a new optional param "$sDescription = Default" and plopped this bit of code in the function. ;## Set Description If $sDescription <> Default Then Local $serviceDescription = DllStructCreate("ptr") Local $caDescription = DllStructCreate("char[260]") DllStructSetData($caDescription, 1, $sDescription) DllStructSetData($serviceDescription, 1, DllStructGetPtr($caDescription)) DllCall($hAdvapi32_DLL, "int", "ChangeServiceConfig2", "long", $avSC[0], "long", 1, "long", DllStructGetPtr($serviceDescription)) EndIf CloseServiceHandle($avSC[0]) ;<-- Line that already exists in function Works great for me. ^u^ -
mLipok reacted to a post in a topic:
Hex Edit Functions
-
mLipok reacted to a post in a topic:
Hex Edit Functions
-
AutoIt Error - Unable to open the script file.
Zinthose replied to mdwerne's topic in AutoIt General Help and Support
Sorry for waking an old thread but I had a similar issue and identified the problem. I was compiling a 32 bit version of the script and placing it in the system32 folder. Once executed it would open fine but then fail to load the script file as the IO redirection would point to the SysWOW64 and not system32 thus... File not found. To correct, either recompile as a native 64 bit exe or move the file to a location that doesn't suffer from folder redirection. TTFN -
28 downloads... either it works perfectly or is complete crap an no one wants to hurt my feelings...
-
I wanted to be able to parse .reg files for inclusion into my own scripts or trans-coding into other scripting formats. I've found the regular expressions in AutoIt to be a perfect fit. I tried to make this match as closely to a manual .reg file import as possible. The library has one public function and will use callbacks to let you know what it found. Features Supports both the "REGEDIT4" and "Window's Registry Editor Version 5.00" file formats.Accepts 3 different file list formats:Single file - "C:\MyPath\RegToImport_HKLM.reg"FileOpenDialog - Ex. "C:\MyPath|RegToImport_HKLM.reg|RegToImport_HKCU.reg"Comma Delimited - Ex. "C:\MyPath\RegToImport_HKLM.reg,C:\MyPath\RegToImport_HKCU.reg"Supports all the following registry types:REG_NONEREG_SZREG_EXPAND_SZREG_BINARYREG_DWORDREG_DWORD_BIG_ENDIANREG_LINKREG_MULTI_SZREG_RESOURCE_LISTREG_FULL_RESOURCE_DESCRIPTORREG_RESOURCE_REQUIREMENTS_LISTREG_QWORDCallBack Functions:_RegFileParser_FileOpen_RegFileParser_FileClose_RegFileParser_KeyDelete_RegFileParser_KeyNew_RegFileParser_ValueDelete_RegFileParser_ValueWriteExample: #include <Array.au3> #include "RegFileParser.au3 $Files = FileOpenDialog("Import Registry Files", @WorkingDir, "Windows Registry Files (*.reg)", 7) Dim $return = _RegFileParser_RegParse($Files, 5) Dim $err[2] = [@error, @extended] MSG("$return=" & $return, "!") MSG("@error=" & $err[0], "!") MSG("@extended=" & $err[1], "!") ;## CallBack Functions Func _RegFileParser_DEBUG($Message) MSG($Message, "!") EndFunc Func _RegFileParser_FileOpen($File_Path, $File_Type) MSG('_RegFileParser_FileOpen') MSG(' $File_Path := "' & $File_Path & '"', ">") MSG(' $File_Type := ' & $File_Type, ">") EndFunc Func _RegFileParser_FileClose($File_Path) MSG('_RegFileParser_FileClose') MSG(' $File_Path := "' & $File_Path & '"', ">") EndFunc Func _RegFileParser_KeyDelete($HKEY_Path) If IsArray($HKEY_Path) Then $HKEY_Path = _ArrayToString($HKEY_Path, "\") MSG('_RegFileParser_KeyDelete') MSG(' $HKEY_Path := "' & $HKEY_Path & '"', ">") EndFunc Func _RegFileParser_KeyNew($HKEY_Path) If IsArray($HKEY_Path) Then $HKEY_Path = _ArrayToString($HKEY_Path, "\") MSG('_RegFileParser_KeyNew') MSG(' $HKEY_Path := "' & $HKEY_Path & '"', ">") EndFunc Func _RegFileParser_ValueDelete($HKEY_Path, $ValueName) If IsArray($HKEY_Path) Then $HKEY_Path = _ArrayToString($HKEY_Path, "\") MSG('_RegFileParser_ValueDelete') MSG(' $HKEY_Path := "' & $HKEY_Path & '"', ">") MSG(' $ValueName := "' & $ValueName & '"', ">") EndFunc Func _RegFileParser_ValueWrite($HKEY_Path, $ValueName, $Value, $ValueType) If IsArray($HKEY_Path) Then $HKEY_Path = _ArrayToString($HKEY_Path, "\") If IsArray($Value) Then $Value = _ArrayToString($Value, "|") MSG('_RegFileParser_ValueWrite') MSG(' $HKEY_Path := "' & $HKEY_Path & '"', ">") MSG(' $ValueName := "' & $ValueName & '"', ">") MSG(' $Value := "' & $Value & '"', ">") MSG(' $ValueType := "' & $ValueType & '"', ">") EndFunc ;## Just a wrapper for ConsoleWriteError Func MSG($Message, $Level = "+") ConsoleWriteError($Level & " " & $Message & @CRLF) EndFunc This is my Alpha Release and it might have bugs but my tests look good so far. 2011-05-12 19:07 - Corrected a few bugs, renamed main function from "_RegParse" to "_RegFileParser_RegParse" to closer match common naming conventions., added a new function "_RegFileParser_BinaryToValue" to permit decoding binary values into intend REG_* data types.RegFileParser.au3
-
Excellent work Jackchen & All! Ran some tests and here are my observations... Minor... Renaming a monitored folder is not triggered as a change although the changes within the renamed folder are retained. IMO This is both a good and bad thing.If the folder NTFS permissions change in a way that prevent access to the folder after the monitor was started, the changes are triggered.If the folder NTFS permissions change in a way that prevent access to the folder before the monitor was started, the changes are not triggered.If the folder NTFS permissions change in a way that allow access to the folder after the monitor was started, the changes are not triggered.If a sub-folder is a NTFS Junction to another folder not within the sub structure of the monitored folder, the changes are not triggered.If a sub-folder is a NTFS source junction to a folder not within the sub structure of the monitored folder, the changes are triggered.Major... Removing of the folder causes the event trigger to enter an apparent infinite loop, repeating the last change.For my purposes, the minor issues are not going to be a problem. However, the folder deletion issue is an defiantly a problem. I'm going to dig into the code and see if I can resolve it myself but I'm also calling the crowd to take a look as well.
-
First of all I want to apologize for resurrecting an old thread but I didn't find the answer on the formns and wanted to share my snippet/solution for the Googlers that find this post. #include <GuiTreeView.au3> Dim $hTreeView = ControlGetHandle("Job Scheduling Wizard", "What computers should the job(s) apply to?", 1175) TreeViewMultiSelect($hTreeView, "ComputerName_1") TreeViewMultiSelect($hTreeView, "ComputerName_2") TreeViewMultiSelect($hTreeView, "ComputerName_3") Func TreeViewMultiSelect($hTreeView, $ThingToSelect) Dim $hItem = _GUICtrlTreeView_FindItem($hTreeView, $ThingToSelect) If Not _GUICtrlTreeView_GetSelected($hTreeView, $hItem) Then Send("{CTRLDOWN}") _GUICtrlTreeView_SelectItem($hTreeView, $hItem) Send("{CTRLUP}") EndIf EndFunc
-
Code updated to address a bug with the 64bit implementation. For the Altiris junkies out there. I'm working of developing an NS 7 dataclass/collector. Allot of this data can be acquired using App Metering , but this method allows for another data source for comparisons.
-
Opps... All Fixed..
-
This is just what I'm working on at the moment .. feel free to pick it apart and add to your scripts. Global Const $curHarvest[2][3] = [[27,18,0x13A89E], [19,31,0xD1D2D4]] Global Const $curMarket[3][3] = [[10,10,0xC49A6C], [16,32,0xEF4036], [25,28,0xFCB040]] Global Const $curHoe[3][3] = [[26,17,0x39B54A], [19,28,0xD1D2D4], [12,38,0xC9CACC]] Global Const $curShovel[3][3] = [[29,14,0xEF4036], [20,29,0xD1D2D4],[16,28,0x939598]] Global $WorkingArea[4] = [162,223,162+760,223+612] Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("MouseCoordMode",0) Opt("PixelCoordMode",0) HotKeySet("{Esc}", "captureEsc") If WinWait("FarmVille on Facebook - Mozilla Firefox","", 5) = 0 Then ShellExecute("http://apps.facebook.com/onthefarm/index.php?ref=tab") EndIf WinWait("FarmVille on Facebook - Mozilla Firefox","", 30) $hWnd = WinGetHandle("FarmVille on Facebook - Mozilla Firefox","") If Not WinActive("FarmVille on Facebook - Mozilla Firefox","") Then WinActivate("FarmVille on Facebook - Mozilla Firefox","") WinWaitActive("FarmVille on Facebook - Mozilla Firefox","") While 1 If WinWait("FarmVille on Facebook - Mozilla Firefox","", 30) = 0 Then ShellExecute("http://apps.facebook.com/onthefarm/index.php?ref=tab") ContinueLoop EndIf $hWnd = WinGetHandle("FarmVille on Facebook - Mozilla Firefox","") If Not WinActive("FarmVille on Facebook - Mozilla Firefox","") Then WinActivate("FarmVille on Facebook - Mozilla Firefox","") WinWaitActive("FarmVille on Facebook - Mozilla Firefox","") ;## Zoom to max Sleep(15000) MouseClick("primary",835,709,4,0) For $i = 1 to 3 HarvestSearch() HarvestSearch() HarvestSearch() PlowSearch() PlowSearch() AnimalSearch() AnimalSearch() MarketSearch() MarketSearch() Sleep(10000) Next WinClose("FarmVille on Facebook - Mozilla Firefox","") $Wait = Random(1800000, 7200000, 1) LogEvent("Waiting for " & $Wait / 1000 / 60 & " minutes for next cycle.") Sleep($Wait) WEnd ;## TODO: Function currently only assumes you planted tomatos Func HarvestSearch($hWnd = Default) Local Const $PlotColor = 0xD03212; <-- Red part of Tomatoes Local $Coord Local $x = 0 Local $y = 0 Local $SearchArea LogEvent("Searching for plots that need harvested.") ;## Multi Tool MouseClick("primary",808,753,2,1) For $y = $WorkingArea[1] To $WorkingArea[3] For $x = $WorkingArea[0] To $WorkingArea[2] $Coord = PixelSearch($x,$y,$WorkingArea[2],$y,$PlotColor,5,1,$hWnd) If @error Then ExitLoop MouseMove($Coord[0], $Coord[1], 1) Sleep(300) If CheckPixelPattern($Coord, $curHarvest) Then LogEvent("+> Plot ready for harvest!") ;## Click Plot MouseClick("primary", $Coord[0], $Coord[1],1,2) ;## Multi Tool MouseClick("primary",808,753,2,2) EndIf $x = $Coord[0] + 1 Next Next EndFunc Func PlowSearch($hWnd = Default) Local Const $PlotColor = 0x7A6311 Local $Coord Local $x = 0 Local $y = 0 Local $SearchArea LogEvent("Searching for plots that need plowed.") ;## Multi Tool MouseClick("primary",808,753,2,1) For $y = $WorkingArea[1] To $WorkingArea[3] For $x = $WorkingArea[0] To $WorkingArea[2] $Coord = PixelSearch($x,$y,$WorkingArea[2],$y,$PlotColor,5,5,$hWnd) If @error Then ExitLoop MouseMove($Coord[0], $Coord[1], 1) Sleep(300) If CheckPixelPattern($Coord, $curHoe) Then LogEvent("+> Plot ready for plowing!") ;## Click Plot MouseClick("primary", $Coord[0], $Coord[1],1,2) ;## Multi Tool MouseClick("primary",808,753,2,2) EndIf $x = $Coord[0] + 1 Next Next EndFunc Func MarketSearch($hWnd = Default) Local Const $PlotColor = 0x843b10 Local $Coord Local $x = 0 Local $y = 0 Local $SearchArea $SearchArea = $WorkingArea LogEvent("Searching for plots that need planted.") MouseClick("primary",808,753,2,1) For $y = $WorkingArea[1] To $WorkingArea[3] For $x = $WorkingArea[0] To $WorkingArea[2] $Coord = PixelSearch($x,$y,$WorkingArea[2],$y,$PlotColor,0,1,$hWnd) If @error Then ExitLoop MouseMove($Coord[0], $Coord[1], 1) Sleep(300) If CheckPixelPattern($Coord, $curMarket) Then LogEvent("+> Plot ready for Planting!") ;## Click Plot MouseClick("primary", $Coord[0], $Coord[1],1,1) Sleep(500) ;## Select Tomatoes MouseClick("primary",838,582,1,30) Sleep(200) MouseClick("primary",838,582,1,2) Sleep(500) MouseClick("primary",546,740,1,5) ;;## Select Strawberries ; MouseClick("primary",402,587,1,20) ; Sleep(250) ;## Multi Tool MouseClick("primary",808,753,2,0) Sleep(1000) EndIf $x = $Coord[0] + 1 Next Next EndFunc Func AnimalSearch($hWnd = Default) Const $AnimalGlow = 0xFFCFF0 Local $x = $WorkingArea[0], $y = $WorkingArea[1] Local $Coord LogEvent("Searching for animals that need collected/harvested.") While 1 $Coord = PixelSearch($x, $y, $WorkingArea[2], $WorkingArea[3], $AnimalGlow, 0, 1, $hWnd) If @error Then Return MouseMove($Coord[0], $Coord[1] + 2, 1) Sleep(300) If CheckPixelPattern($Coord, $curHarvest) Then LogEvent("+> Animal ready for harvest!") MouseClick("primary", $Coord[0], $Coord[1] + 2,1, 1) MouseClick("primary", $Coord[0] + 16, $Coord[1] + 54,1, 10) Else ;LogEvent($Coord[0] & " " & $Coord[1] & " !! Not Harvestable!!") ;Sleep(5000) EndIf $y = $Coord[1] + 1 WEnd EndFunc Func CheckPixelPattern($Coord, $Pattern, $hWnd = Default) Local $i For $i = 0 To UBound($Pattern, 1) - 1 If PixelGetColor($Coord[0] + $Pattern[$i][0], $Coord[1] + $Pattern[$i][1], $hWnd) <> $Pattern[$i][2] Then LogEvent("Failed: " & $i & " - 0x" & Hex(PixelGetColor($Coord[0] + $Pattern[$i][0], $Coord[1] + $Pattern[$i][1], $hWnd),6)) Return False EndIf Next Return True EndFunc Func LogEvent($Message) ConsoleWrite("+> " & @YEAR & @MON & @MDAY & @HOUR & @SEC & "." & @MSEC & @TAB & $Message & @CRLF) EndFuncFYI: They updated the game again so some of these function are broken untill I can update them. http://facebook2.farmville.static.zynga.com/current/v4633/gameSettings.xml