
Xandl
Active Members-
Posts
89 -
Joined
-
Last visited
Everything posted by Xandl
-
Hello, this sounds like a dos commandline job. You could use cd /d c:\path\to\textfiles copy * c:\another\path\all.txt ciao Xandl
-
Manually arrange array in listview?
Xandl replied to JesseBarnett's topic in AutoIt GUI Help and Support
Hello, for manually rearranging an array via listview, you might want to try this: http://www.autoitscript.com/forum/index.php?showtopic=61504 It can be used like an UDF, look at the two examples for 1D and 2D arrays. ciao Xandl -
Hello inet, there is a setting in autoit to avoid such a pain searching for a typo in the future. Simply put AutoItSetOption('MustDeclareVars',1) at the start of your scripts. Look up the detailed explanation in the help file, it will take care that every variable is declaired prior to use. I prefer to use this in my scripts, it might seem to be more work at start, but all in all, it really helps more then it costs. ciao Xandl
-
Divide by Zero -1.#INF error correction
Xandl replied to andybiochem's topic in AutoIt Example Scripts
Hello, I am not sure if I understand you correctly, but what about making your own Div() function? You would have to replace parts of your formulas, but can handle div/0 easily. Here is an example, its best to start it in SciTE, to see the ConsoleWrite() output. ConsoleWrite('example 1'&@LF) $x = 10 $y = 2 $r = Div($x*$x*3.141,$y) If @error Then ConsoleWrite('division by zero error handling'&@LF) Else ConsoleWrite('result: '&$r&@LF) EndIf ConsoleWrite('example 2'&@LF) $x = 10 $y = 0 $r = Div($x*$x*3.141,$y) If @error Then ConsoleWrite('division by zero error handling'&@LF) Else ConsoleWrite('result: '&$r&@LF) EndIf Func Div($v1,$v2) If $v2 = 0 Then Return SetError(1,0,0) Return $v1/$v2 EndFunc ciao Xandl -
Hello, this sounds harmful, I would not want to be nuked, as our name implies. ciao Xandl
-
Enable/disable controls within a GUICtrlGroup
Xandl replied to Xandl's topic in AutoIt Example Scripts
Hello, thanks for testing this. @rasim: yes, I already saw this solution on the forums, and I like the surprising idea of using dummy controls. But it would require more attention in writing the main script code, i.e. you cannot use that with 'strayed' controls which are not created in sequence. What I do not like about my solution, is the sloppyness of the 'brute force' trying to get the control ids (1-500). While it seems to be fast enough, it would be more elegant to have a list of ids in your window. But to avoid this a little, one could pass the last created control id as $iMaxCtrlId, which could of course be a dummy control :-) ciao Xandl -
Hello, here is another solution: http://www.autoitscript.com/forum/index.php?showtopic=74612 ciao Xandl
-
Hello, its now the second time I see people asking to enable/disable controls within a group control. So I liked to try it. The function can use any state used with GUICtrlSetState() on controls within the pixel range of another control. The script searches for the controls, so you dont need to specify which control IDs to work on. Simply copy/paste/try the example below. #include <GUIConstants.au3> GUICreate('test',430,160) Global $g1=GUICtrlCreateGroup('Test group - check/uncheck',10,10,200,100) Global $c11=GUICtrlCreateCheckbox('11111',20,30) Global $c12=GUICtrlCreateCheckbox('22222',20,50) Global $c13=GUICtrlCreateCheckbox('33333',20,70) Global $r1=GUICtrlCreateRadio('test',100,50,60) Global $b1Off=GUICtrlCreateButton('off',40,120,60) Global $b1On=GUICtrlCreateButton('on',120,120,60) Global $g2=GUICtrlCreateGroup('Test group - enable/disable',220,10,200,100) Global $c21=GUICtrlCreateCheckbox('11111',230,30) Global $c22=GUICtrlCreateCheckbox('22222',230,50) Global $c23=GUICtrlCreateCheckbox('33333',230,70) Global $b2=GUICtrlCreateButton('test',310,50,60) Global $b2Off=GUICtrlCreateButton('off',250,120,60) Global $b2On=GUICtrlCreateButton('on',330,120,60) GUISetState() While 1 Sleep(20) Switch GUIGetMsg() Case $b1Off _GUICtrlGroup_SetState($g1,$GUI_UNCHECKED,'test') Case $b1On _GUICtrlGroup_SetState($g1,$GUI_CHECKED) Case $b2Off _GUICtrlGroup_SetState($g2,$GUI_DISABLE,'test') Case $b2On _GUICtrlGroup_SetState($g2) Case -3 Exit EndSwitch WEnd ; #FUNCTION# ========================================================================================= ; Name...........: _GUICtrlGroup_SetState ; Description ...: Set state of controls within another control, typically a GUICtrlGroup. ; Syntax.........: _GUICtrlGroup_SetState($hGroup,$iState = $GUI_ENABLE,$sWinTitle = '',$iMaxCtrlId = 500) ; Parameters ....: $hGroup - The control identifier (controlID) as returned by a GUICtrlCreate... function. ; $iState - Can be any value working with GUICtrlSetState, i.e. $GUI_ENABLE and $GUI_DISABLE. ; Default is $GUI_ENABLE. ; $sWinTitle - The title of the GUI window. ; Default is '', referring to the current active window. ; $iMaxCtrlId - Maximum controlID number to search for, starting from 1. ; Default is 500. ; Return values .: Success - Returns 1 ; Failure - Returns 0, and sets @error: ; |1 - Invalid $hGroup identifier, its not a control of the window ; ================================================================================================== Func _GUICtrlGroup_SetState($hGroup,$iState = $GUI_ENABLE,$sWinTitle = '',$iMaxCtrlId = 500) Local $aPosGrp = ControlGetPos($sWinTitle,'',$hGroup) If @error Then Return SetError(1,0,0) Local $aPosCtrl For $i = 1 To $iMaxCtrlId $aPosCtrl = ControlGetPos($sWinTitle,'',$i) If Not @error Then If ($aPosCtrl[0] > $aPosGrp[0]) And ($aPosCtrl[1] > $aPosGrp[1]) And _ ($aPosCtrl[0]+$aPosCtrl[2] < $aPosGrp[0]+$aPosGrp[2]) And ($aPosCtrl[1]+$aPosCtrl[3] < $aPosGrp[1]+$aPosGrp[3]) Then GUICtrlSetState($i,$iState) EndIf EndIf Next Return 1 EndFunc You will only need _GUICtrlGroup_SetState() in your script. I would be interested if it works for you as expected. ciao Xandl
-
Hello, I know that writing own scripts is fun and educational, but if you need to split laaarge files, you could use the winrar command line tool to split/rejoin these files. It can be found at http://www.win-rar.com/download.html. Here is an example batch file to split files with rar.exe: @echo off :: -------------------------------------------------------------------------- :: file path\name to split set file=%1 :: filename only, dont touch set fName=%~n1 :: output directory, path to put rar split files set out=.\out :: rar binary set rar=.\bin\rar.exe :: output split size, in rar size format set size=32000k ::set size=12000k :: 0-5, 0=store set compression=0 : --------------------------------------------------------------------------- if "%file%"=="" goto noparam if not exist %file% goto nofile call :log start split on file %~n1, size: %size% %rar% a -v%size% -m%compression% %out%\%fName% %file% call :log done split file %~n1 goto end :noparam call :log Error: no path\file name parameter given to splice goto end :nofile call :log Error: file %file% not found goto end :log echo %DATE% %TIME% - %* goto :EOF :end Usage: scp_rarSplit.cmd drive:\path\to\bigfile.ext The split files go to %out%, configured in the batch file. Just look at the first few lines in the batch, to configure it for your purposes. ciao Xandl
-
$WS_SIZEBOX size (stretch min/max value)
Xandl replied to sandin's topic in AutoIt General Help and Support
The array has to be global Use initMinMax() to set the bounds. GUIRegisterMsg() does the rest #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $aUtil_MinMax[4] GUICreate('WM_GETMINMAXINFO',400,400,-1,-1,$WS_SIZEBOX) GUISetState() initMinMax(100,100,600,600) Do Sleep(20) Until GUIGetMsg() = -3 Func initMinMax($x0,$y0,$x1,$y1) Local Const $WM_GETMINMAXINFO = 0x24 $aUtil_MinMax[0]=$x0 $aUtil_MinMax[1]=$y0 $aUtil_MinMax[2]=$x1 $aUtil_MinMax[3]=$y1 GUIRegisterMsg($WM_GETMINMAXINFO,'MY_WM_GETMINMAXINFO') EndFunc Func MY_WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) Local $minmaxinfo = DllStructCreate('int;int;int;int;int;int;int;int;int;int',$lParam) DllStructSetData($minmaxinfo,7,$aUtil_MinMax[0]); min X DllStructSetData($minmaxinfo,8,$aUtil_MinMax[1]); min Y DllStructSetData($minmaxinfo,9,$aUtil_MinMax[2]); max X DllStructSetData($minmaxinfo,10,$aUtil_MinMax[3]); max Y Return $GUI_RUNDEFMSG EndFunc ciao Xandl -
$WS_SIZEBOX size (stretch min/max value)
Xandl replied to sandin's topic in AutoIt General Help and Support
Hello, I once found this here in the forum: Global $aUtil_MinMax[4] Func initMinMax($x0,$y0,$x1,$y1) Local Const $WM_GETMINMAXINFO = 0x24 $aUtil_MinMax[0]=$x0 $aUtil_MinMax[1]=$y0 $aUtil_MinMax[2]=$x1 $aUtil_MinMax[3]=$y1 GUIRegisterMsg($WM_GETMINMAXINFO,'MY_WM_GETMINMAXINFO') EndFunc Func MY_WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) Local $minmaxinfo = DllStructCreate('int;int;int;int;int;int;int;int;int;int',$lParam) DllStructSetData($minmaxinfo,7,$aUtil_MinMax[0]); min X DllStructSetData($minmaxinfo,8,$aUtil_MinMax[1]); min Y DllStructSetData($minmaxinfo,9,$aUtil_MinMax[2]); max X DllStructSetData($minmaxinfo,10,$aUtil_MinMax[3]); max Y Return 0 EndFunc ciao Xandl -
I really miss the linux 'grep' commandline utility...
Xandl replied to SadBunny's topic in AutoIt Example Scripts
Hello, your script looks very nice, I like it - notably the elegant reading of stdin. In case you need to grep very large files, you might want to use windows grep from unix tools, found at http://unxutils.sourceforge.net/. There are a lot more command line tools included, if you are accustomed to unix, you probably will like them. ciao Xandl -
Hello, you could embed an IE html control into a gui window, enabling you to use html features like font, img and so on. If you already have the doc file, you can export it to ugly html, but a well looking page. There are numerous examples at the forum, just search for them. ciao Xandl
-
Hello, I tried the Levenshtein distance algorithm, taken from wikipedia. Seems to work as expected. $s1='test' $s2='jesT' $r=LevenshteinDistance($s1,$s2) ConsoleWrite($s1&'<->'&$s2&'='&$r&@LF) $s1='test' $s2='crest' $r=LevenshteinDistance($s1,$s2) ConsoleWrite($s1&'<->'&$s2&'='&$r&@LF) $s1='test' $s2='manifest' $r=LevenshteinDistance($s1,$s2) ConsoleWrite($s1&'<->'&$s2&'='&$r&@LF) $s1='test' $s2='***e' $r=LevenshteinDistance($s1,$s2) ConsoleWrite($s1&'<->'&$s2&'='&$r&@LF) Func LevenshteinDistance($s1,$s2) Local $d[StringLen($s1)+1][StringLen($s2)+1] Local $cost For $i=0 To StringLen($s1) $d[$i][0] = $i Next For $i=0 To StringLen($s2) $d[0][$i] = $i Next For $i=1 To StringLen($s1) For $j=1 To StringLen($s2) If StringMid($s1,$i,1) == StringMid($s2,$j,1) Then $cost = 0 Else $cost = 1 EndIf $d[$i][$j] = minimum($d[$i-1][$j] + 1, _ ;deletion $d[$i][$j-1] + 1, _ ;insertion $d[$i-1][$j-1] + $cost) ;substitution Next Next Return $d[StringLen($s1)][StringLen($s2)] EndFunc Func minimum($i1,$i2,$i3) Local $min If $i1 <= $i2 Then $min = $i1 Else $min = $i2 EndIf If $min > $i3 Then $min = $i3 Return $min EndFunc It returns the number of changes to get from string1 to string2. Maybe this can help you. ciao Xandl
-
Hello, this would be the regex way to extract/reverse the number: $s="The Sum is 10.21" $sr=StringRegExpReplace($s,'^([\w ]+) ([0-9.])([0-9.])?([0-9.])?([0-9.])?([0-9.])?([0-9.])?([0-9.])?([0-9.])?([0-9.])?([0-9.])?$, _ '\1 \11\10\9\8\7\6\5\4\3\2') If @error Then ConsoleWrite('err:'&@error&@LF) ConsoleWrite('res :'&$sr&@LF) This works with number parts < 11 chars (including the dot), just expand it if you need more. But I do wonder, why I was not able to successfully use this variant, to make it shorter/more versatile: $sr=StringRegExpReplace($s,'^([\w ]+) ([0-9.])([0-9.])+?$,'\1 \11\10\9\8\7\6\5\4\3\2') It seems as one needs a sufficient number of opening parenthesis for the capture, but can use a lot of backrefs, as they are empty per default. Maybe someone can shade some light on this please? ciao, Xandl
-
Hello, try to set the combobox style to $CBS_DROPDOWNLIST. ciao Xandl
-
I see, thank you. ciao Xandl
-
Ooops, the problem with my reproduction example was just a matter of seize (seize of the main window) This might even work more correct as the release version, but the window placement is different: $GMainWin = GUICreate('$sAppTitle',600,400,-1,-1) GUISetState(@SW_SHOW,$GMainWin) ;$GcnpGui = GUICreate('$sCtrlTitle',240,160,-1,-1,-1,-1) ; does work $GcnpGui = GUICreate('$sCtrlTitle',240,160,-1,-1,-1,-1,$GMainWin) ; does not work GUISetState(@SW_SHOW,$GcnpGui) While GUIGetMsg() <> -3 Sleep(30) WEndWith the current release version, the child window is centered, on the contrary, using the current beta version, the child window is displayed more far at the right bottom of the screen. I must be having a slightly different problem in my script, using different styles, as I can tab through the controls there and hovering over the buttons with the mouse shows them up, which I was not able to reproduce with these examples. So all in all for the moment, the window placement differs, but I dont remember to read something about it in Jon's beta post (http://www.autoitscript.com/forum/index.php?showtopic=19717&view=findpost&p=532941). ciao Xandl
-
String Management [Another problem encountered]
Xandl replied to Yata's topic in AutoIt General Help and Support
Hello, just the numbers, like this? $s='http://username.deviantart.com/art/art-name-82878556' $a = StringRegExp($s,'.+-(\d+)',3) If Not @error Then ConsoleWrite($a[0]) EndIf ciao Xandl -
Hello Zedna, I tried using '-1', but it does not work for me either. These examples should show what I mean. Does work with current beta(13): $GMainWin = GUICreate('$sAppTitle',300,200,-1,-1) GUISetState(@SW_SHOW,$GMainWin) $GcnpGui = GUICreate('$sCtrlTitle',240,160,-1,-1,-1,-1) ; does work GUISetState(@SW_SHOW,$GcnpGui) While GUIGetMsg() <> -3 Sleep(30) WEnd Does not work with current beta: $GMainWin = GUICreate('$sAppTitle',300,200,-1,-1) GUISetState(@SW_SHOW,$GMainWin) $GcnpGui = GUICreate('$sCtrlTitle',240,160,-1,-1,-1,-1,$GMainWin) ; does not work GUISetState(@SW_SHOW,$GcnpGui) While GUIGetMsg() <> -3 Sleep(30) WEnd Both examples do work as expected with the current release(12). The OS is Win XP SP2, no themes used. ciao Xandl
-
Hello, I have an issue with the new beta(13). Assigning a parent to a GUICreate'ed window seems not to work correct, or I am doing something wrong. The same code works with the new release(12) version. The problem is, that the second window does not show up with the beta, but it gets created invisible. Just try it by comment/uncomment the lines flagged as 'does not/work'. #include <WindowsConstants.au3> $GMainWin = GUICreate('$sAppTitle',300,200,Default,Default) GUISetState(@SW_SHOW) ;$GcnpGui = GUICreate('$sCtrlTitle',240,160,Default,Default,Default,Default) ; does work $GcnpGui = GUICreate('$sCtrlTitle',240,160,Default,Default,Default,Default,$GMainWin) ; does not work GUISetState(@SW_SHOW) While GUIGetMsg() <> -3 Sleep(30) WEnd So please tell me, is there something wrong with my code? ciao Xandl
-
it's in ButtonConstants.au3 now.
-
Problem with send("{key up/down}")
Xandl replied to Xandl's topic in AutoIt General Help and Support
Yes, thats possible for five modifier keys, but what if I want the i.e. DEL key to be pressed, for a period of time?In this case, the events come from a gamepad device, from its buttons. What I want to do, is pressing/ holding/releasing keys corresponding to the buttons pressed/held/released on the gamepad. ciao xandl -
Problem with send("{key up/down}")
Xandl replied to Xandl's topic in AutoIt General Help and Support
Hello, yes this is what I did first as you can see in my post. But why does the other method not work? I was hoping to be able to handle all keys the same way. ciao xandl -
Problem with send("{key up/down}")
Xandl replied to Xandl's topic in AutoIt General Help and Support
Thank you, but I am not sure this is exactly my problem.The point is, that I wonder why the explicit sent "up" does not work. I used "SHIFTUP/DOWN" first, this worked reliable. So I was hoping that the up/down options in send would work with "LSHIFT" or other keys, too. From the help: To hold a key down (generally only useful for games) Send("{a down}") ;Holds the A key down Send("{a up}") ;Releases the A key ciao xandl