
WideBoyDixon
Active Members-
Posts
379 -
Joined
-
Last visited
-
Days Won
1
Everything posted by WideBoyDixon
-
Nice work! You just know someone's going to try and make a bot for it right?
-
Not enough parameters: MsgBox (0, "Feedback", "You wrote: " & $msg) WBD
-
I've had this kicking around for some time now. My original intention was to write a WinDiff style application in AutoIt but my enthusiasm for it was waned dramatically over the last couple of months. I've attached two files here. The first one contains the _ArrayCompare function which can be used to compare two one-dimensional arrays. My first reason for writing this was to use it after _FileReadToArray() to compare two similar files. However, I subsequently realised that I could use it to do other array comparisons from any of the AutoIt functions that return an array (WinList() for example). The second file contains some example code for how it could be used; together with a very basic WinDiff style dialog which has swathes of missing functionality The basic premise is this. Call _ArrayCompare() with two one-dimensional arrays $aLeft and $aRight. It works best if they're at least similar. The return is an array of arrays which has two elements. The first element is the script for $aLeft and the second element is the script for $aRight. The scripts themselves are arrays with the same dimensions as the original arguments but with a zero or one in each entry to indicate whether the array entry at that point is unchanged (zero) or changed (one). By processing these scripts intelligently you can determine whether entries have been deleted/changed/inserted as appropriate. Of course, I realise as I'm typing this that it all sounds rather complex. However, it should be straightforward so I'll try to explain a scenario: Global $aLeft[9] = ["The", "big", "black", "cat", "sat", "on", "the", "mat", "again."] Global $aRight[8] = ["The", "dog", "sat", "on", "the", "white", "cat", "ouch!"] Glboal $aRet = _ArrayCompare($aLeft, $aRight)From this code you should get: $aRet[0] = [0, 1, 1, 1, 0, 0, 0, 1, 1] $aRet[1] = [0, 1, 0, 0, 0, 1, 1, 1]The zeroes show where the two arrays "line up" which is on ["The"] (element zero) and ["sat", "on", "the"] (elements 4-6 in $aLeft and 2-4 in $aRight). I hope someone finds this useful in some way. My code is based on the diff algorithm from GNU but is much simplified for AutoIt implementation. The code can be found HERE. As always, have fun. WBD
-
I WANT TO JOIN! Are you the founding member? Is there a constitution etc.? When's the AGM? Someone once suggested to me that we could measure productivity of developers by the number of lines of code that they write. I pointed out that this was just going to reward people for writing bloated code. I'm always looking for optimisations and doing stuff in the fewest possible lines. WBD
-
The code that I provided earlier in this topic: [a] Doesn't cause the mouse to jump back and forth Handles properly multiple monitors with different resolutions [c] Handles properly multiple monitors with any configuration set-up (side-by-side, one on top of the other etc.) WBD
-
Question about programming/scripting languages
WideBoyDixon replied to Cusem's topic in AutoIt Technical Discussion
If you have some intensive processing to do then I'd be tempted to write it in C++ (or similar) and use the plug-in framework to incorporate your functions in to AutoIt. WBD -
Newbie need help with a loop
WideBoyDixon replied to TraumFabriK's topic in AutoIt General Help and Support
Eek. Recursion alert! If your check is true then set a flag and exit the loop. Outside of the loop, check the flag to know whether to re-start the function or not. Probably needs another While/Wend to check it. WBD -
Read URL from running browser
WideBoyDixon replied to wolfbartels's topic in AutoIt General Help and Support
Unless you're using a proxy server (and therefore can get the information from there) then I can't see how you can do this unless you write methods for retrieving the information from all the popular browsers ... WBD -
It may be that the lookbehind expression has to be a fixed width. That's the case for some implementations of PCRE. WBD
-
if Not working incorrectly possible bug?
WideBoyDixon replied to Yeik's topic in AutoIt General Help and Support
Perhaps you should lookup Operator Precedence in the help. WBD -
DllStruct and Array memory handling?
WideBoyDixon replied to wraithdu's topic in AutoIt Technical Discussion
So is there some sort of garbage collector that runs at the end of a script which frees up all the allocated memory? -
Is this a bad time to point out that the third one only loops twice? The original post was about not having to use a variable. I know it's not really important but none of these address the original proposal since they all use a variable. As an aside, the documentation says that the variable in a for loop will be created with local scope even if MustDeclareVars is turned on. Does anyone know if the scope is local to the for loop or local to the function? EDIT: Strike that, I just downloaded the source code from V3.1.0.0 and I see that it's created local to the function. WBD
-
I think I've got my logic right but, as usual, I'm prepared to be wrong. I've used MonitorFromPoint and GetMonitorInfo to determine when and where to wrap especially with multiple monitors. Let me know what you think. HotKeySet("{ESC}", "_Quit") Global $hDLL = DllOpen("user32.dll") Global $rDesktop = WinGetPos("Program Manager") Global $gMonitorInfo = DllStructCreate("int;int[4];int[4];int;char[32]") DllStructSetData($gMonitorInfo, 1, DllStructGetSize($gMonitorInfo)) _Main() Exit Func _Main() Local $aMP, $hMonitor, $rMonitor, $sText While 1 Sleep(10) $aMP = MouseGetPos() $hMonitor = _GetMonitorFromPoint($aMP[0], $aMP[1]) If $hMonitor <> 0 Then $rMonitor = _GetMonitorRect($hMonitor) ; Left If ($aMP[0] - $rMonitor[0]) = 0 Then If _GetMonitorFromPoint($aMP[0] - 1, $aMP[1]) = 0 Then If _GetMonitorFromPoint($aMP[0] + $rDesktop[2] - 2, $aMP[1]) = 0 Then MouseMove($aMP[0] + $rMonitor[2] - 2, $aMP[1], 0) Else MouseMove($aMP[0] + $rDesktop[2] - 2, $aMP[1], 0) EndIf EndIf EndIf ; Top If ($aMP[1] - $rMonitor[1]) = 0 Then If _GetMonitorFromPoint($aMP[0], $aMP[1] - 1) = 0 Then If _GetMonitorFromPoint($aMP[0], $aMP[1] + $rDesktop[3] - 2) = 0 Then MouseMove($aMP[0], $aMP[1] + $rMonitor[3] - 2, 0) Else MouseMove($aMP[0], $aMP[1] + $rDesktop[3] - 2, 0) EndIf EndIf EndIf ; Right If ($aMP[0] - $rMonitor[0]) = $rMonitor[2] - 1 Then If _GetMonitorFromPoint($aMP[0] + 1, $aMP[1]) = 0 Then If _GetMonitorFromPoint($aMP[0] - $rDesktop[2] + 2, $aMP[1]) = 0 Then MouseMove($aMP[0] - $rMonitor[2] + 2, $aMP[1], 0) Else MouseMove($aMP[0] - $rDesktop[2] + 2, $aMP[1], 0) EndIf EndIf EndIf ; Bottom If ($aMP[1] - $rMonitor[1]) = $rMonitor[3] - 1 Then If _GetMonitorFromPoint($aMP[0], $aMP[1] + 1) = 0 Then If _GetMonitorFromPoint($aMP[0], $aMP[1] - $rDesktop[3] + 2) = 0 Then MouseMove($aMP[0], $aMP[1] - $rMonitor[3] + 2, 0) Else MouseMove($aMP[0], $aMP[1] - $rDesktop[3] + 2, 0) EndIf EndIf EndIf EndIf WEnd EndFunc ;==>_Main Func _GetMonitorFromPoint($iX, $iY) Local $aRet = DllCall($hDLL, "hwnd", "MonitorFromPoint", "int", $iX, "int", $iY, "int", 0) Return $aRet[0] EndFunc ;==>_GetMonitorFromPoint Func _GetMonitorRect($hMonitor) Local $aRet = DllCall($hDLL, "int", "GetMonitorInfo", "hwnd", $hMonitor, "ptr", DllStructGetPtr($gMonitorInfo)) Local $aRect[4] For $i = 1 To 4 $aRect[$i - 1] = DllStructGetData($gMonitorInfo, 2, $i) Next $aRect[2] -= $aRect[0] $aRect[3] -= $aRect[1] Return $aRect EndFunc ;==>_GetMonitorRect Func _Quit() DllClose($hDLL) Exit EndFunc ;==>_Quit EDIT: Some script tidying and removed wrapping line WBD
-
There's no doubt about it, sandin is king of the AutoIt GUI! It's such a good start that someone *should* develop from here. WBD
-
I would imagine this is quite involved and tricky with AutoIt. You could take a look here and see if it already meets your needs: http://www.nirsoft.net/utils/shell_menu_view.html WBD
-
http://www.bloodshed.net/devcpp.html
-
Maybe there's scope in some distant future version for: Repeat 3 ; Do some stuff EndRepeat WBD
-
I think your "friend" didn't have it stolen from him. I think he's stolen it from you. Go beat him up until he gives it back.
-
ERROR: Subscript used with non-Array variable.:
WideBoyDixon replied to meowbits's topic in AutoIt General Help and Support
I'll say it again. YOU'RE NOT SETTING UP $Ginfo IN YOUR CODE. -
Variable and Random Number
WideBoyDixon replied to Plxply's topic in AutoIt General Help and Support
Try: Global $aCommand[20] $aCommand[0] = {Whataever you were previously setting up as $command1} ... $aCommand[19] = {Whataever you were previously setting up as $command20}oÝ÷ Ù8^*.q©ìjeÉ«¢+ÙM¹ ÀÌØí ½µµ¹mI¹½´ İÈÀ°Ä¤´Åt¤ WBD -
ERROR: Subscript used with non-Array variable.:
WideBoyDixon replied to meowbits's topic in AutoIt General Help and Support
You might want to assign a value to $Ginfo somewhere in your code ... -
So you want someone to write a script for you, for free and in return you get a free iPod? I can see "bot-makers" chomping at the bit as I type.
-
When you copy text to the clipboard, it's entirely up to the source application as to what it puts on there. You could have "monkeys" highlighted in the source application, press Ctrl+C and find that it's placed "giraffes" on the clipboard. Just because the text is quoted after it's copied doesn't mean that it's not supposed to be.
-
Well, I searched but couldn't find this function nor anything quite exactly what I wanted. Please feel free to point me in the right direction if it's previously been done. Apologies for wrapping lines which you'll probably need to correct after copy/paste. ; #FUNCTION# ===================================================================================================================== ; Name...........: _FileReplaceText ; Description ...: Replaces text in a file. ; Syntax.........: _FileReplaceText($sFile, $sSearchText, $sReplaceText[, $fRegExp = 0[, $fReplaceLine = 0[, $fWriteBlanks = 1]]]) ; Parameters ....: $sFile - The file to write to ; $sSearchText - The text to search for ; $sReplaceText - The text to replace ; $fRegExp - If set to 0 will use StringReplace ; |If set to 1 will use StringRegExpReplace ; $fReplaceLine - If set to 0 will not replace the entire line with $sReplaceText ; |If set to 1 will replace the entire line with $sReplaceText ; $fWriteBlanks - If set to 0 will write blank lines to the file ; |If set to 1 will suppress blank lines from the file ; Return values .: Success - 1 ; Failure - 0 ; @Error - 0 = No error ; |1 = File does not exist ; |2 = Error when opening file ; |3 = $fRegExp is invalid ; |4 = $fWriteBlanks is invalid ; |5 = $fReplaceLine is invalid ; |6 = $sSearchText is invalid ; |7 = $sReplaceText is invalid ; Author ........: WideBoyDixon ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; No ; ================================================================================================================================ Func _FileReplaceText($sFile, $sSearchText, $sReplaceText, $fRegExp = 0, $fReplaceLine = 0, $fWriteBlanks = 1) If Not FileExists($sFile) Then Return SetError(1, 0, 0) If $fRegExp <> 0 And $fRegExp <> 1 Then Return SetError(3, 0, 0) If $fWriteBlanks <> 0 And $fWriteBlanks <> 1 Then Return SetError(4, 0, 0) If $fReplaceLine <> 0 And $fReplaceLine <> 1 Then Return SetError(5, 0, 0) If Not IsString($sSearchText) Then Return SetError(6, 0, 0) If Not IsString($sReplaceText) Then Return SetError(7, 0, 0) Local $filtxt = FileRead($sFile, FileGetSize($sFile)) $filtxt = StringSplit($filtxt, @CRLF, 1) Local $fil = FileOpen($sFile, 2) If $fil = -1 Then Return SetError(2, 0, 0) Local $sLine For $i = 1 To $filtxt[0] If $fRegExp = 0 Then If $fReplaceLine = 0 Then $sLine = StringReplace($filtxt[$i], $sSearchText, $sReplaceText) If @error Then $sLine = $filtxt[$i] Else If StringInStr($filtxt[$i], $sSearchText) Then $sLine = $sReplaceText Else $sLine = $filtxt[$i] EndIf EndIF Else If $fReplaceLine = 0 Then $sLine = StringRegExpReplace($filtxt[$i], $sSearchText, $sReplaceText) If @error Then $sLine = $filtxt[$i] Else If StringRegExp($filtxt[$i], $sSearchText) Then $sLine = $sReplaceText Else $sLine = $filtxt[$i] EndIf EndIf EndIf If $fWriteBlanks = 1 Or $sLine <> "" Then FileWrite($fil, $sLine & @CRLF) Next FileClose($fil) Return 1 EndFunc ;==>_FileReplaceTextoÝ÷ ØLZ^~º&²¶§²Z()àj×®X«¢+Ù}¥±IÁ±QáÐ ÅÕ½ÐíèÀäÈíAɽɴ¥±ÌÀäÈíÕѽ%ÐÌÀäÈíM¥QÀäÈíAɽÁÉÑ¥ÌÀäÈíÔ̹ÁɽÁÉÑ¥ÌÅÕ½Ðì°ÅÕ½ÐíÕѽ¥ÐÍ¥ÈôÅÕ½Ðì°ÅÕ½ÐíÕѽ¥ÐÍ¥ÈõèÀäÈíQµÀÀäÈíÕѽ%ÐÌÅÕ½Ðì°À°Ä WBD
-
Anyone knows environmental variable for this ?
WideBoyDixon replied to microbious's topic in AutoIt General Help and Support
It partially depends on your operating system but the registry key you're so desperate to read may well be the same as HKEY_CURRENT_USER. For example: #Include <Security.au3> $aAcct = _Security__LookupAccountName(@ComputerName & "\" & @UserName) ConsoleWrite(RegRead("HKEY_USERS\" & $aAcct[0] & "\Software\AutoIt v3\AU3Info", "LastTab") & @CRLF) ConsoleWrite(RegRead("HKEY_CURRENT_USER\Software\AutoIt v3\AU3Info", "LastTab") & @CRLF) HKEY_CURRENT_USER is just an alias for HKEY_USERS\[Current User SID] WBD