Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/08/2013 in all areas

  1. Shocker, Perhaps something like this: ; Add count to array If @error Then ; No files returned - so set value to 0 $aCount[$i] = 0 Else ; Set value to number of files returned $aCount[$i] = $aFolderList[0] EndIf M23
    1 point
  2. Annonyreeder, If that happens, change to the basic editor using the button at top-left. M23
    1 point
  3. AdemSezgin, Perhaps like this: #include <GuiconstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ; Flag to show if GUI was moved Global $fMoved = False HotKeySet("{ESC}", "On_Exit") $hGUI = GUICreate("X", 100, 100, -1, -1, $WS_POPUP) _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF) $cButton = GUICtrlCreateButton("Test", 0, 0, 100, 100) GUISetState() While 1 Switch GUIGetMsg() Case $cButton On_Button() Case $GUI_EVENT_PRIMARYDOWN ; Check mouse is over button $cInfo = GUIGetCursorInfo($hGUI) If $cInfo[4] = $cButton Then ; Clear the flag $fMoved = False ; Get initial positions of mouse and GUI $aInit_Pos = MouseGetPos() $aWin_Pos = WinGetPos($hGUI) ; Wait until mouse button released Do ; Check if mouse still pressed $cInfo = GUIGetCursorInfo($hGUI) ; Get current mouse position $aCurr_Pos = MouseGetPos() ; How far has mouse moved $iDiff_X = $aInit_Pos[0] - $aCurr_Pos[0] $iDiff_Y = $aInit_Pos[1] - $aCurr_Pos[1] ; Move GUI WinMove($hGUI, "", $aWin_Pos[0] - $iDiff_X, $aWin_Pos[1] - $iDiff_Y) Until Not $cInfo[2] ; See if mouse moved while it was pressed - allow for 5 pixel margin If (Abs($aCurr_Pos[0] - $aInit_Pos[0]) > 5) Or (Abs($aCurr_Pos[1] - $aInit_Pos[1]) > 5) Then ; If moved then set flag $fMoved = True EndIf EndIf EndSwitch WEnd Func On_Button() ; Check flag If $fMoved Then MsgBox(0, "Button", "Moved") Else MsgBox(0, "Button", "Clicked") Exit EndIf EndFunc ;==>On_Button Func On_Exit() Exit EndFunc ;==>On_Exit M23
    1 point
  4. Here, this is probably more to your liking. #include <Constants.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <WindowsConstants.au3> ; Global Const $SC_DRAGMOVE = 0xF012 HotKeySet('{ESC}', '_Exit') Example() Func Example() Local $hGUI = GUICreate('', 100, 100, Default, Default, $WS_POPUP) Local $iButton = GUICtrlCreateButton('Drag me', 0, 0, 100, 100) GUISetState(@SW_SHOW, $hGUI) Local $aCtrlCursor = 0, $aMousePos = 0, _ $fMove = False, _ $iBefore = 0 While 1 Switch GUIGetMsg() Case $iButton MsgBox($MB_SYSTEMMODAL, '', 'Button click') ; ExitLoop Case $GUI_EVENT_PRIMARYDOWN $aCtrlCursor = GUIGetCursorInfo($hGUI) $aMousePos = MouseGetPos() $fMove = False $iBefore = $aMousePos[0] + $aCtrlCursor[0] + $aMousePos[1] + $aCtrlCursor[1] ; Detect the co-ordinates before. While _IsPressed(01) WinMove($hGUI, '', $aMousePos[0] - $aCtrlCursor[0], $aMousePos[1] - $aCtrlCursor[1]) ; _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, False) ; If the co-ordinates are different then it moved. $fMove = Not ($aMousePos[0] + $aCtrlCursor[0] + $aMousePos[1] + $aCtrlCursor[1] = $iBefore) $aMousePos = MouseGetPos() If @error Then ExitLoop WEnd ; If it moved clear the button message. If $fMove Then Do ; Clear the button message. Until GUIGetMsg() = 0 EndIf EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example Func _Exit() Exit EndFunc ;==>_Exit
    1 point
  5. Why not use turn that text file into an Ini file? You're pretty much 75% there, unless it's not your config file.
    1 point
  6. This will work pressuming the opening square bracket is not included in the text you wish to replace. I have solved this before, but I forget how. It will come to me again, no doubt. Here's the code as it stands. Local $sText = "[xbeginx]some text between[xendx] outside" & @CRLF & _ "[xbeginx]more text[xendx] more stuff" Local $sStart = "(\[xbeginx\])" Local $sEnd = "(\[xendx\])" Local $sReplace = "clean" $sText = StringRegExpReplace($sText, "(?i)" & $sStart & "([^\[]*)" & $sEnd , "$1" & $sReplace & "$3") MsgBox(0, "", $sText)
    1 point
  7. $sText = StringReplace($sText, "$aFound", "clean") $sText = StringReplace($sText, $aFound[0], "clean"). Don't quote the variable otherwise it is passed as a string. Simultaneously as Xandy said the return of _stringbetween is an array therefore $aFound[0] would be the first match. Regards
    1 point
  8. How about this little workaround I use in SMF too ? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GuiImageList.au3> Local $hGUI = GUICreate("ListView example", 300, 250) Local $hListView = _GUICtrlListView_Create($hGUI, "SubItems|Items", 10, 10, 280, 230, $LVS_REPORT, $WS_EX_CLIENTEDGE) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_INFOTIP)) GUICtrlSendMsg($hListView, $LVM_SETCOLUMNWIDTH, 1, 60) GUICtrlSendMsg($hListView, $LVM_SETCOLUMNWIDTH, 0, 250) Local $iImageSquareSize = 30 Local $hImage = _GUIImageList_Create($iImageSquareSize, $iImageSquareSize, 5, 3) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131) _GUICtrlListView_SetImageList($hListView, $hImage, 1) _GUICtrlListView_AddItem($hListView, "SubItem test 1", 0) _GUICtrlListView_AddSubItem($hListView, 0, "Test item 1", 1) _GUICtrlListView_AddItem($hListView, "SubItem test 2", 2) _GUICtrlListView_AddSubItem($hListView, 1, "Test item 2", 1) _GUICtrlListView_AddItem($hListView, "SubItem test 3", 1) _GUICtrlListView_AddSubItem($hListView, 2, "Test item 3", 1) _GUICtrlListView_SetColumnOrder($hListView, "1|0") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd
    1 point
  9. iamtheky

    Import Text to Excel

    #Include <Excel.au3> #Include <Array.au3> #Include <File.au3> Global $aCSV _FileReadToArray("csv_import.txt" , $aCSV) $oExcel = _ExcelBookNew(1) $L = 1 for $i = 1 to $aCSV[0] $aLine = stringsplit($aCSV[$i] , ",") _ExcelWriteArray($oExcel , $L , 1 , $aLine , 0 , 1) $L += 1 next _ExcelBookSaveAs($oExcel , @ScriptDir & "\parse_test.xls") _ExcelBookClose($oExcel)
    1 point
  10. czardas

    How to exit in the loop

    I believe the sleep function is preventing messages sent from the GUI. Reducing the sleep time to 10ms may be one possible solution - you can still ping every two seconds if you think about it. I strongly recommend reading the following excellent article in wiki: http://www.autoitscript.com/wiki/Interrupting_a_running_function
    1 point
  11. As I mentioned, RecFileListToArray is in the Examples section - see here As for the FileListToArrayRecursive, try a forum search for that one.
    1 point
  12. Hi, Shocker. I would suggest using Melba's RecFileListToArray from the Examples section of this forum. You could easily do something like this: #include <Array.au3> #include <RecFileListToArray.au3> Local $aArray = _RecFileListToArray("C:\MyProg", "File*.zip", 1, 1, 1) _ArrayDisplay($aArray) You could then loop through the array and delete them: For $i = 1 To $aArray[0] FileDelete($aArray[$i]) Next and finally, display your message box: MsgBox(0, "File Delete", "Deleted " & $i & " files.")
    1 point
  13. SmOke_N

    Game Bot - Builder

    You could start here: http://www.autoitscript.com/forum/index.php?app=forums&module=extras&section=boardrules
    1 point
  14. sivaranamn, Here's a couple of routines that may interest you. local $arr1[5] = ['a1','a2','a3','a4','a5'] local $arr2[3] = ['b1','b2','b3'] local $arr3[9] = ['c1','c2','c3','c4','c5','c6','c7','c8','c9'] ; find largest of the three arrays local $max $max = ubound($arr1) if ubound($arr2) > $max then $max = ubound($arr2) if ubound($arr3) > $max then $max = ubound($arr3) ; redim all arrays to the match the size of the largest redim $arr1[$max] redim $arr2[$max] redim $arr3[$max] ; display the values of the arrays consolewrite(stringformat(' %8s %8s %8s','$arr1','$arr2','$arr3') & @lf) ConsoleWrite(@LF) for $1 = 0 to $max - 1 consolewrite(stringformat('CELL[' & $1 & '] %8s %8s %8s',$arr1[$1],$arr2[$1],$arr3[$1]) & @lf) next #include <array.au3> local $a1[20] = [1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0] local $a2[10] = [1,2,3,4,5,6,7,8,9,0] local $a3[50] = ['','',3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0] local $a4[5] = [1,2,3,4,5] local $a5[7] = [1,2,3,4,5,6,7] local $a10 = _array_combine($a1,$a2,$a3,$a4,$a5) _arraydisplay($a10) func _array_combine($arr1,$arr2,$arr3=0,$arr4=0,$arr5=0,$arr6=0,$arr7=0,$arr8=0,$arr9=0,$arr10=0) ;----------------------------------------------------------------------------------------------------------------- ; combine 2 to 10 array into 1 2D array ;----------------------------------------------------------------------------------------------------------------- ; ensure at least two arrays if not IsArray($arr1) or not IsArray($arr2) then return seterror(1,0,0) ; find # of array passed ($1 = # of arrays) for $1 = 1 to 10 if not isarray(eval("arr" & $1)) then ExitLoop Next ; set # of cols variable to # of arrays in parameter local $num_cols = $1 - 1 local $max_elements = 0 ; set # elements to largest array passed for $1 = 1 to $num_cols if ubound(eval("arr" & $1)) - 1 > $max_elements then $max_elements = ubound(eval("arr" & $1)) next ConsoleWrite('Formatting target array as ' & $num_cols & ' columns and ' & $max_elements & ' elements.' & @LF) ; define result array local $aTarget[$max_elements][$num_cols], $aTemp ; populate result array for $1 = 0 to $num_cols -1 $aTemp = eval("arr" & $1+1) for $2 = 0 to ubound($aTemp) - 1 $aTarget[$2][$1] = $aTemp[$2] Next next return $aTarget endfunc kylomas
    1 point
  15. Something like this? (not exactly sure what you are trying to output) Local $aArray[2] $aArray[0] = "aaa" $aArray[1] = "bbb" Local $bArray[2] $bArray[0] = "ccc" $bArray[1] = "ddd" If UBound($aArray) = UBound($bArray) Then For $i = 0 To UBound($aArray) - 1 ConsoleWrite($aArray[$i] & " " & $bArray[$i] & @CRLF) Next EndIf output: aaa ccc bbb ddd not exactly what you asked for (for...in loop) put a workaround
    1 point
  16. You can't do it that way, you might be able to do it with a nested for loop inside the other for loop, but you can't do it with 2 arrays like the way you tried.
    1 point
×
×
  • Create New...