-
Posts
48 -
Joined
-
Last visited
Koder's Achievements

Seeker (1/7)
0
Reputation
-
The Au3Check.exe output in latest build has changed in a way that breaks jumping to the specified error using TextPad. Previously, I was able to double click the error line and TextPad would jump to file, line and column of the error. Now, the output has quotes around the file, which breaks the error jumping. Does anyone know how to configure TextPad to recognize the quotes in the output? I've played with the "Regular expression to match output" from TextPad but it seems to have no effect, even if I purposely break the expression. Or maybe that change in Au3Check.exe could be rolled back? Thanks! Rick
-
Same UPX error over here "Unable to execute upx.exe to compress stub file". Virus scanner disabled. Aut2Exe.exe and AutoIt3Wrapper.exe both get the error... I just found it! It's the icon. Whenever the icon path is set, the upx.exe error message is displayed. Rick
-
Should Binary() return the same value as BinaryString()?
Koder replied to Koder's topic in AutoIt General Help and Support
Problem solved... I guess the functions do return the same value. I was working with magic packets (I forget who originally posted the code, but big thanks) and the new build would no long generate a proper packet. The problem was the MAC was not formed properly (probably due to changes in binary string handling)... Anyway, I've reworked it and simplified the magic packet function and can now power on my machines... This will work in older versions too by using BinaryString() instead of Binary()... ; Should always return a value of length 102 Func GenerateMagicPacket ( $sMAC) Local $MagicPacket = Binary("0xFFFFFFFFFFFF"), $MACData = Binary("0x" & $sMAC) For $i = 1 To 16 $MagicPacket &= $MACData Next Return $MagicPacket EndFunc -
Inetget() Works Differently In V3.1.1.119 (beta)
Koder replied to Koder's topic in AutoIt General Help and Support
Hey, thanks for the info, I would have kept using @error and never nocticed a download problem until later. Shouldn't @InetGetBytesRead return -1 only when an error has occurred? and return 0 while the connection is still being negotiated? If the connection later fails, -1 would be informative. Otherwise @InetGetBytesRead = -1 means different things during the course of the download. I could check for -1 at the start of the loop, but then what if it's a real error? Does @InetGetActive change to 0 at the same time? With @InetGetBytesRead = 0 until the connection starts, there is no special case required and @InetGetBytesRead can be used directly without being cleaned up from -1. So the real question is, what does a real error look like (if it occurs during a download that starts normally)? Ok, I've coded the answer to my question below and yes, this does work. But I still have no way of knowing what a real error will look like. Do I know that @InetGetActive wil change to 0 when my network cable is pulled out? $rc = InetGet($URL, $Local & "\" & $Files[$i], 0, 1) while @InetGetActive $LastBytes = @InetGetBytesRead if @InetGetActive == 1 AND $LastBytes == -1 Then ; Not an Error? ; server still connecting? $LastBytes = 0; prevents progress bar from using -1 ElseIf @InetGetActive == 0 AND $LastBytes == -1 Then ; Real error? ; Hard to test, pull the NIC cable on a large file? exitloop Endif ProgressSet(($LastBytes / $size) * 100, "", "") wend if @InetGetBytesRead == -1 Then ; Real error endif By the way this code fragment is intentionally, unnecessarily complicated. Valik, your example is better. I'm only complaining a bit about -1 not being a real error. Thanks! Rick -
I wrote a 'pre-search' for mine flags ages ago. I went nuts and made it random so it would look cool. I think it cheats too much... It can finish any grid in 1 second. I wrote another script that will 'play' without cheating. It actually won a game in about 10 seconds, unfortunately it was all luck. The algorithm gives me a headache just thinking about it. I like the un-sort function (ArrayRandomize2). Should be standard #CS Rick W Computer Cheats at Minesweeper # 2 Works on any size grid (without reason) Computer plays minesweeper extremely fast - 1 second on expert #CE Opt("MouseClickDelay", 0) Opt("MouseClickDownDelay", 0) Opt("WinTitleMatchMode", 3) ; Exit via Ctrl-Alt-X HotKeySet("^!x", "MyExit") global $title = "Computer Cheats at Minesweeper" global $win = "Minesweeper" global $Width, $Height, $wX, $wY, $X, $Y, $X1, $Y1, $X2, $Y2 global $i, $j, $color, $color1, $Cols, $Rows, $size If WinExists($win) = 0 then Run(@SystemDir & "\winmine.exe") Sleep(500) endIf WinActivate($win) Sleep(50) ; Get Minesweeper info $size = WinGetPos($win) $wX = $size[0] $wY = $size[1] $Width = $size[2] $Height = $size[3] ; Start coords of mine grid -relative to window $X1 = 16 $Y1 = 97 ; End coords of mine grid -relative to window $X2 = $Width - 11 $Y2 = $Height - 11 ; size of each box;W=16;H=16 ; Determine Grid size from window size $Cols = int(($X2 - $X1 + 1) / 16) $Rows = int(($Y2 - $Y1 + 1) / 16) if MsgBox(4, $title, "Ready?" & @CR & @CR & "Cols: " & $Cols & @CR & "Rows: " & $Rows & @CR ) <> 6 then exit Opt("MouseCoordMode", 0) Opt("PixelCoordMode", 1) WinActivate($win) ;MouseMove($Width / 2, 69) MouseClick("left", $Width / 2, 69, 1, 0); click new game ; Send happy fun code Send("xyzzy{RSHIFT}{ENTER}") ; Pre calculate X Y cordinates and save to an array (for random looping later on) global $aXY[$Rows * $Cols][2] global $k = 0 For $i = 0 to $Rows - 1 $Y = int($Y1 + (($Y2 - $Y1) / $Rows * ($i + 1)) - 8) For $j = 0 to $Cols - 1 $X = int($X1 + (($X2 - $X1) / $Cols * ($j + 1)) - 8) $aXY[$k][0] = $X $aXY[$k][1] = $Y $k += 1 Next Next sleep(300) ; Must be 1, this version will not work without pre-search global $PreSearch = 1 ; Find Mines & remove from array - does not count against time if $PreSearch Then For $i = 0 to ($Rows * $Cols) - 1 $X = $aXY[$i][0] $Y = $aXY[$i][1] Opt("PixelCoordMode", 1) MouseMove($X, $Y, 0) $color = PixelGetColor(0, 0) If $color = 16777215 Then continueloop ElseIf $color = 0 Then MouseClick("right") $aXY[$i][0] = -1; Remove mines from array $aXY[$i][1] = -1; mucho faster EndIf Next Endif ; Random is not just cool looking it helps! just barely faster.. ArrayRandomize2($aXY) Opt("PixelCoordMode", 0) For $i = 0 to ($Rows * $Cols) - 1 $X = $aXY[$i][0] if $X == -1 then ContinueLoop $Y = $aXY[$i][1] $color1 = PixelGetColor($X - 7, $Y) ; Unclicked/Unknown color If $color1 = 16777215 then MouseMove($X, $Y, 0) MouseClick("left") MouseClick("middle") EndIf Next ; Send happy fun code again to reset the 'mode' Send("xyzzy{RSHIFT}{ENTER}") Exit(0) ; Exit via Ctrl-Alt-X Func MyExit() Exit EndFunc ; UN-sorts a 2 dimensional array - 2 passes Func ArrayRandomize2 ( ByRef $a) local $Idx1, $Idx2 local $Ubound = UBound($a, 1), $i, $tmp For $i = 0 to $Ubound * 2 $Idx1 = Random(0, $Ubound - 1) $Idx2 = Random(0, $Ubound - 1) $tmp = $a[$Idx1][0] $a[$Idx1][0] = $a[$Idx2][0] $a[$Idx2][0] = $tmp $tmp = $a[$Idx1][1] $a[$Idx1][1] = $a[$Idx2][1] $a[$Idx2][1] = $tmp Next EndFunc
-
InetGet() never needed a long pause before @InetGetBytesRead would work properly, I normally use 50 milliseconds. Now it needs at about 500. Why would @InetGetBytesRead return -1 if @InetGetActive is 1? In my script I check the files size (for a progress bar), then download the file. This works with NO problems whatsoever in build 118. Increasing the Sleep() fixes the problem, but how do I know it will work on other machines? A timing problem could be different on different machines. Would a slower Inet connection need a longer sleep time? Here's a cleaned up fragment. The error occurs at $LastBytes = @InetGetBytesRead, which in beta 119 reports -1 (if not paused long enough). For $i = 1 to $count $URL = "FTP:\\Ftp.URL.net\path\" & $Files[$i] $size = InetGetSize($URL) If @error == 1 Then ; report error msg(0,0,"Error: " & $Files[$i]) ExitLoop EndIf ProgressSet(0, "", "") ; Send FTP command to download file $rc = InetGet($URL, $Local & "\" & $Files[$i], 0, 1) If @error == 1 Then msg(0,0,"Error: " & $Files[$i]) Exit(1) EndIf Sleep(50); Error occurs if this sleep is too short... never needed to be any longer than 0 (zero) While @InetGetActive Sleep(10) $LastBytes = @InetGetBytesRead ; Reports -1 if sleep() is too short, but not in 118 If @InetGetBytesRead == -1 Then MsgBox(16, 0, "Download error!" & @CR & @InetGetBytesRead & @CR & $Files[$i]) ExitLoop EndIf ProgressSet((@InetGetBytesRead / $size) * 100, "", "") Wend Next Thanks! Rick
-
ANSI compare strings (for sort array)
Koder replied to Zedna's topic in AutoIt General Help and Support
I brought this up ages ago. Sorting should always be case sensitive otherwise the resulting sort is 'undefined'. _ArraySort() returns a differently sorted list depending on the original order because it is not case sensitive. I already have a string compare function but the DLLcall might be faster, Ill have to try that out, thanks. -
Good idea! A CMD hotkey should be mandatory! AutoIt hotkeys can interfere with other programs so I just use start menu hotkeys. This script puts a hotkey onto the default shortcut for these apps. It only runs once with no need to leave an AutoIt app running. ; ; Hot keys on shortcuts ; dim $a_Lnks[5][2] ; DOS Ctrl+Alt+D $a_Lnks[0][0] = @StartMenuDir & "\Programs\Accessories\Command Prompt.lnk" $a_Lnks[0][1] = "^!d" ; Notepad Ctrl+Alt+N $a_Lnks[1][0] = @StartMenuDir & "\Programs\Accessories\Notepad.lnk" $a_Lnks[1][1] = "^!n" ; Wordpad Ctrl+Alt+W $a_Lnks[2][0] = @StartMenuCommonDir & "\Programs\Accessories\WordPad.lnk" $a_Lnks[2][1] = "^!w" ; Calulator Ctrl+Alt+Shift+3 $a_Lnks[3][0] = @StartMenuCommonDir & "\Programs\Accessories\Calculator.lnk" $a_Lnks[3][1] = "^!+3" ; Paint Ctrl+Alt+P $a_Lnks[4][0] = @StartMenuCommonDir & "\Programs\Accessories\Paint.lnk" $a_Lnks[4][1] = "^!p" For $i = 0 to ubound($a_Lnks, 1) - 1 If FileExists($a_Lnks[$i][0]) == 1 then $det = FileGetShortcut($a_Lnks[$i][0]) If StringInStr($det[3],"-HK") == 0 then; Skip shortcuts that have already been modified FIleCopy($a_Lnks[$i][0], $a_Lnks[$i][0] & ".bak", 0) FileSetAttrib($a_Lnks[$i][0] & ".bak", "+H") FileCreateShortcut($det[0],$a_Lnks[$i][0], $det[1], $det[2], $det[3] & "-HK", $det[4], $a_Lnks[$i][1], $det[5], $det[6]) EndIf EndIf Next I also have a context menu for folders. This will open a DOS prompt, even to UNC paths using pushd. ; Open a Command Prompt to current folder RegWrite("HKEY_CLASSES_ROOT\Directory\shell\cmd", "", "REG_SZ", "Open CMD Here") ; This will open the command prompt on UNC shares RegWrite("HKEY_CLASSES_ROOT\Directory\shell\cmd\command", "", "REG_SZ", 'cmd.exe /k "pushd %L"')
-
How to get terminal services client IP address?
Koder replied to Rece's topic in AutoIt General Help and Support
Ok, I remangled my code to work with alternate RDP ports and multiple connections. It will now report all terminal services connected IP address. Tested on a TS server with multiple connections... Use this command line in a script to be transparent to the user. RDP_Client -ip -s I use BGInfo so this script writes to a registry location that BGInfo uses. BGinfo then collects this datum (among others) and writes to a SQL server. The script can be easily modified to write to a file or do anything else with the data... RDP_Client.au3 -
BF2 uses Punkbuster which *I think* can detect memory access from other programs. If online, it could label you as a cheater, so be careful.
-
How to get terminal services client IP address?
Koder replied to Rece's topic in AutoIt General Help and Support
@IPAddress1 in my code is used only for parsing the netstat results. That's how it can tell it's an incoming connection. I didn't account for the possiblity of incoming connections on other NICs or multiple connections for that matter. @CyberSlug: Hey that's a good idea. Just pull the port from the registry. I do use alternate ports for forwarding to multiple machines, so this could help right away. -
How to get terminal services client IP address?
Koder replied to Rece's topic in AutoIt General Help and Support
Yeah, this kicked my butt a while back. Here's the script that I whipped up once I figured it out. This script does a netstat.exe -TCP and parses the output, looking for port 3389. Then it displays a message and writes the results to the registry for use with BGInfo. There are command line parameters for use in a BAT file... ; --------------------------------------------------------------------------- ; AutoIt Version: 3.1.1.+ beta ; Author: Rick Weber ; ; Script Function: ; Displays the current RDP user IP or Name and Writes it to the registry for BGInfo ; ; Command line stuff ; -? Help ; -s Silent mode - to use in a start up script ; -ip use IP rather than name ; --------------------------------------------------------------------------- dim $TempF, $TFile, $cmd dim $value, $pos1, $pos2, $silent = 0 dim $ComputerName=@ComputerName dim $RDP=":3389" dim $Key = "HKLM\SOFTWARE\BGInfo" dim $KeyU = "HKCU\SOFTWARE\BGInfo" dim $ValName = "RDPclient" dim $IP = "" dim $title = "RDP Client Address" dim $IsClient = "the client" ; Extended command line paramerters If $CmdLine[0] > 0 then For $i = 1 to $CmdLine[0] Switch $CmdLine[$i] Case "-s", "/s" $silent = 1 Case "-ip", "/ip" $IP = "-n " $ComputerName=@IPAddress1 Case "-?", "/?" MsgBox (0, $title,"Writes the RDP client address to the Registry" & @CR & _ $KeyU & "\" & $ValName & @CR & @CR & _ "-? Help" & @CR & _ "-s Silent mode - for BAT files" & @CR & _ "-ip Use IP Address rather than Computer Name") exit(0) EndSwitch Next EndIf $TempF = EnvGet("TEMP") & "\rdpclient.txt" ; Run netstat $cmd = @SystemDir & "\netstat.exe -p TCP " & $IP & "|find """ & $ComputerName & $RDP & """>" & $TempF RunWait(@ComSpec & " /c " & $cmd, "", @SW_HIDE) ; Parse the results of netstat $TFile = FileOpen($TempF, 0) $value = FileReadLine($TFile) $pos1 = StringInStr($value,":") + 1 $pos2 = StringInStr($value,":",0,2) - $pos1 $value= StringMid($value, $pos1, $pos2) if StringLeft($value, 4) = "3389" then $IsClient = "remote desktop client" elseif $value = "" then $IsClient = "unknown (probably the local host, RDP not in use)" else $IsClient = "the local host" endif $pos1 = StringInStr($value," ") + 1 $value= StringStripWS(StringMid($value, $pos1),1) if $value = "" then $value="NA"; this happens when run locally ; Write results to registry RegWrite($Key, $ValName, "REG_SZ", $value) RegWrite($KeyU, $ValName, "REG_SZ", $value) ; Display results - or not if $silent = 1 then exit(0) Inputbox($title,"Remote Desktop client address:" & @CR & @CR & "address = " & $IsClient, RegRead($KeyU, $ValName),"",400,-1) -
Does AutoIt do static local variables?
Koder replied to Koder's topic in AutoIt General Help and Support
A static variable is not a constant. A static retains it's value between calls to a function and can only be changed within that function. Useful for keeping track of stuff like recursion depth. -
I can't seem to find anything about static local variables in AutoIt. Static locals are much more convenient than using globals. With gloabls you must scan for variable names that happen to match in different functions. Right now I tend to use ByRef variables in place of globals... Statics are good for recursion and various data structures. Anyway, I was just curious...