Leaderboard
Popular Content
Showing content with the highest reputation on 10/30/2020 in all areas
-
Array Loop Help
seadoggie01 and one other reacted to TheXman for a topic
REALLY?!? You have a 5 second sleep inside the loop. If you plan to go through the loop 200,000 times, that is over 277 hours of sleep time.2 points -
Array Loop Help
seadoggie01 and one other reacted to water for a topic
I would remove the Sleep statement. 5 Seconds x 200,000 times equals to about 278 hours2 points -
Advice on using numbers as variables...
JockoDundee and one other reacted to Gianni for a topic
My 2 Cents: you could also create a small function to convert "chess notation" to "array coordinates" for the 8x8 array. in this small example script I wrote: the _ConvertCoords() function which accepts a chess notation and returns a 2-element array with the corresponding row and column coordinates for the 8x8 array the _BoardSet() and _BoardGet() functions to show how you can use it. The _Example() function uses the 3 functions above to initialize the 'chessboard' (the array) at the starting position. Just for fun I used Unicode symbols (for black chess) but of course you can insert whatever string is more appropriate into the array #include <Array.au3> ; For _ArrayDisplay() #include <StringConstants.au3> Global $board[8][8] Global Enum $iRow, $iCol ; 0, 1 Global Enum $iFile, $iRank Global $WhiteChess = ObjCreate("Scripting.Dictionary") $WhiteChess.add('King', ChrW(9812)) $WhiteChess.add('Queen', ChrW(9813)) $WhiteChess.add('Rook', ChrW(9814)) $WhiteChess.add('Bishop', ChrW(9815)) $WhiteChess.add('Knight', ChrW(9816)) $WhiteChess.add('Pawn', ChrW(9817)) Global $BlackChess = ObjCreate("Scripting.Dictionary") $BlackChess.add('King', ChrW(9818)) $BlackChess.add('Queen', ChrW(9819)) $BlackChess.add('Rook', ChrW(9820)) $BlackChess.add('Bishop', ChrW(9821)) $BlackChess.add('Knight', ChrW(9822)) $BlackChess.add('Pawn', ChrW(9823)) _Example() Func _Example() _BoardSet('a8', $BlackChess.item('Rook')) _BoardSet('b8', $BlackChess.item('Knight')) _BoardSet('c8', $BlackChess.item('Bishop')) _BoardSet('d8', $BlackChess.item('Queen')) _BoardSet('e8', $BlackChess.item('King')) _BoardSet('f8', $BlackChess.item('Bishop')) _BoardSet('g8', $BlackChess.item('Knight')) _BoardSet('h8', $BlackChess.item('Rook')) _BoardSet('a7', $BlackChess.item('Pawn')) _BoardSet('b7', $BlackChess.item('Pawn')) _BoardSet('c7', $BlackChess.item('Pawn')) _BoardSet('d7', $BlackChess.item('Pawn')) _BoardSet('e7', $BlackChess.item('Pawn')) _BoardSet('f7', $BlackChess.item('Pawn')) _BoardSet('g7', $BlackChess.item('Pawn')) _BoardSet('h7', $BlackChess.item('Pawn')) _BoardSet('a2', 'Pawn') ; $WhiteChess.item('Pawn')) _BoardSet('b2', 'Pawn') ; $WhiteChess.item('Pawn')) _BoardSet('c2', 'Pawn') ; $WhiteChess.item('Pawn')) _BoardSet('d2', 'Pawn') ; $WhiteChess.item('Pawn')) _BoardSet('e2', 'Pawn') ; $WhiteChess.item('Pawn')) _BoardSet('f2', 'Pawn') ; $WhiteChess.item('Pawn')) _BoardSet('g2', 'Pawn') ; $WhiteChess.item('Pawn')) _BoardSet('h2', 'Pawn') ; $WhiteChess.item('Pawn')) _BoardSet('a1', 'Rook') ; $WhiteChess.item('Rook')) _BoardSet('b1', 'Knight') ; $WhiteChess.item('Knight')) _BoardSet('c1', 'Bishop') ; $WhiteChess.item('Bishop')) _BoardSet('d1', 'Queen') ; $WhiteChess.item('Queen')) _BoardSet('e1', 'King') ; $WhiteChess.item('King')) _BoardSet('f1', 'Bishop') ; $WhiteChess.item('Bishop')) _BoardSet('g1', 'Knight') ; $WhiteChess.item('Knight')) _BoardSet('h1', 'Rook') ; $WhiteChess.item('Rook')) _ArrayDisplay($board) MsgBox(0, 'a1', "in a1 there is: " & _BoardGet('a1')) EndFunc ;==>_Example ; set a 'piece' on the board ; -------------------------- Func _BoardSet($sSquare, $vPiece) Local $xy = _ConvertCoords($sSquare) $board[$xy[$iRow]][$xy[$iCol]] = $vPiece EndFunc ;==>_BoardSet ; get the content of a square ; --------------------------- Func _BoardGet($sSquare) Local $xy = _ConvertCoords($sSquare) Return $board[$xy[$iRow]][$xy[$iCol]] EndFunc ;==>_BoardGet ; convert chess notation to Array coordinates ; =========================================== Func _ConvertCoords($sSquare) Local $aTemp = StringSplit($sSquare, "", $STR_NOCOUNT) Local $aRowCol[2] $aRowCol[$iCol] = StringInStr("abcdefgh", $aTemp[$iFile]) - 1 $aRowCol[$iRow] = 8 - Number($aTemp[$iRank]) Return $aRowCol EndFunc ;==>_ConvertCoords2 points -
Something like this ?? #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <IE.au3> #include <WinAPI.au3> Local $AlphaKey = 1 ; the transparent color of your choice $hMain = GUICreate("Transparency Window", 600, 400, -1, -1, -1, $WS_EX_LAYERED) GUISetBkColor($AlphaKey, $hMain) _WinAPI_SetLayeredWindowAttributes($hMain, $AlphaKey, 0, $LWA_COLORKEY) Local $oIE = _IECreateEmbedded() $55 = GUICtrlCreateObj($oIE, 10, 40, 300, 350) _IENavigate($oIE, @ScriptDir & ".\sample.html") $oIE.document.body.style.backgroundColor = $AlphaKey GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd1 point
-
System for a small business
igana reacted to Confuzzled for a topic
Beware you don't automate yourself out of a job! Bread on the table is always more important than a nice layout on a financial report.1 point -
Need help with executing angularjs in internet explorer
ComradVlad reacted to seadoggie01 for a topic
Yes, build it incrementally. I'm not sure about IE, but in Chrome, it returns the HTML object in the console, which you can check to see if it's the right div1 point -
Child Window with TabStops and Scroll
pixelsearch reacted to Melba23 for a topic
pixelsearch, Here is my hobbyist understanding of the situation. DLLs are "loaded" as required but are not necessarily immediately "unloaded" once the call is over. They remain in memory with an internal counter value showing that the DLL is in use. If the same DLL is called by another process then the same code is used and the counter increased to show that there are now 2 processes using it. If one of these processes "closes" the DLL, then all that happens is that the counter is reduced and the code remains in memory as long as there is at least one process still using the code. This would imply that you should indeed open and close the DLL when using it, but with the more common DLLs there is a pretty good chance that the code is already in memory and so there is no penalty for not doing so. There is also the fact that Windows is very likely to do some caching if the same DLL is constantly used, so the DLL code may well be kept in memory for a while even with a zero count, but I am unsure whether this actually happens. The situation regarding file handles is not really analogous as there is no "loading" of the file into memory in the same manner - just the creation of an index in a "small" finite sized array of "open" filenames. I hope that helps. And if anyone wants to expand, or completely change, what I have written above please feel free to do so. M231 point -
Yes, I updated my previous post to agree with Dan_555. The way you are accessing rows, by using $i+x, makes the assumption that those lines exist. For example, if you had only 1 row in the array, you can see how you would try to reference rows that are outside the bounds of the array. You would have to be lucky for your code not to get that error. The number of rows would have to align perfectly with the expected bounds. If you are going to do it that way, you should add code to make sure that you are not exceeding the bounds of the array. Something like: If $i+x < ubound($aArray) Then Do something with $aArray[$i+x][y]1 point
-
Hmm looks like the array can go out of bounds. at least logically for $i = 1 to UBound($aArray)-1 step 1 $origRow = $aArray[$i][3] & $aArray[$i][7] & $aArray[$i][12] $1Row = $aArray[$i+1][3] & $aArray[$i+1][7] & $aArray[$i+1][12] $2Row = $aArray[$i+2][3] & $aArray[$i+2][7] & $aArray[$i+2][12] $3Row = $aArray[$i+3][3] & $aArray[$i+3][7] & $aArray[$i+3][12] $4Row = $aArray[$i+4][3] & $aArray[$i+4][7] & $aArray[$i+4][12] $5Row = $aArray[$i+5][3] & $aArray[$i+5][7] & $aArray[$i+5][12] You are using the for loop to check to the upper bound -1, but you are increasing the $i up to +5 in the 5th row. Here, the number should be, at least, defined as Ubound($aArray)-6 The other source of array error may be that the first lines from the text are not separated enough by the delimiter, so that the array is created with less than needed number of delimiters. I'm reffering to $aArray[lines][delimiters]1 point
-
Create Tables in Excel
HerrAltunpek reacted to water for a topic
Everything you can do with AutoIt you can do with VBA as well - both use the same API to interact with Excel.1 point -
@NguyenDuc Sorry, but your question isn't clear to me. If you want to learn xpath, then take a look here. Also, see the Tools section of the webdriver wiki page. If I misunderstood, then please elaborate.1 point
-
WebDriver UDF - Help & Support (II)
Laurynelis reacted to Danp2 for a topic
Change this to the following and it works as expected -- _WD_Option('Driver', 'drivers\geckodriver.exe')1 point -
Create Tables in Excel
HerrAltunpek reacted to GokAy for a topic
It depends I believe. If you will be around the file, we can do this. - Create a template.xlsm file, with the above sub but change it so it will work regardless of filename. Maybe add parameters for selecting options like sort column and whatnot. Then in AutoIt, you would first make a copy of the template.xlsm, and open that, copy stuff, and run the macro with preferred options. And save the copied file as whatever or overwrite an already created one. A lot of options available. - Will be more robust too. I can help with VBA part if you can not come up with a better solution. Edit: I see @water has provided the AutoIt part. Let's see how that goes.1 point -
Create Tables in Excel
HerrAltunpek reacted to water for a topic
First try: #include <Excel.au3> Global $oExcel = _Excel_Open() Func Table_Test() ; Define variables Local $oWorkbook, $oWorksheet, $oRange, $oTable Local $xlSrcRange = 1 ; https://docs.microsoft.com/en-us/office/vba/api/excel.xllistobjectsourcetype Local $xlPinYin = 1 ; Phonetic Chinese sort order for characters (default). https://docs.microsoft.com/en-us/office/vba/api/excel.xlsortmethod ; Set variables for Workbook, Worksheet and Data Range $oWorkbook = $oExcel.Workbooks("YourWorkbookNameHere.xlsm") $oWorksheet = $oWorkbook.Sheets("WorkSheetNameHere") $oRange = $oWorksheet.Range("A1").CurrentRegion ; ?? ; Check if Data Range is already a table If Not IsObj($oRange.ListObject) Then ; If not a table, add range as new table $oTable = $oWorksheet.ListObjects.Add($xlSrcRange, $oRange, Default, $xlYes, Default, "TableStyleLight11") Else ; If already a table, set variable for it $oTable = $oRange.ListObject EndIf ; Sort all, with column header = "SamAccountName" With $oTable.Sort .SortFields.Clear .SortFields.Add($oWorksheet.Range($oTable.Name & "[[#All],[SamAccountName]]"), _ $xlSortOnValues, $xlAscending, Default, $xlSortNormal) .Header = $xlYes .MatchCase = False .Orientation = Default ; $xlTopToBottom. Could not find this value .SortMethod = $xlPinYin .Apply EndWith ; Clean up, set variables $oWorkbook = 0 $oWorksheet = 0 $oRange = 0 $oTable = 0 EndFunc ;==>Table_Test1 point -
@NguyenDuc Did you try the version I posted in the other thread? Just curious if it works as well.1 point
-
#include <GDIPlus.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() $hImgBack = _GDIPlus_ImageLoadFromFile("back.png") If @error Then Exit MsgBox(0, "Error", "Can't load back.png") $hImgNeedle = _GDIPlus_ImageLoadFromFile("needle.png") If @error Then Exit MsgBox(0, "Error", "Can't load needle.png") _GDIPlus_BitmapSetResolution($hImgBack, 96, 96) _GDIPlus_BitmapSetResolution($hImgNeedle, 96, 96) $aSize = _GDIPlus_ImageGetDimension($hImgBack) $hGUI = GUICreate("", $aSize[0], $aSize[1], -1, -1, -1, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_CONTROLPARENT)) GUISetState() $hImgBuff = _GDIPlus_BitmapCreateFromScan0($aSize[0], $aSize[1]) $hGraphBuff = _GDIPlus_ImageGetGraphicsContext($hImgBuff) $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $aSize[0] / 2, $aSize[1] / 2) AdlibRegister("Update", 100) Do Until GUIGetMsg() = -3 ; $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hImgBack) _GDIPlus_ImageDispose($hImgNeedle) _GDIPlus_ImageDispose($hImgBuff) _GDIPlus_GraphicsDispose($hGraphBuff) _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_Shutdown() Func Update() _GDIPlus_GraphicsClear($hGraphBuff, 0x00000000) _GDIPlus_GraphicsResetTransform($hGraphBuff) _GDIPlus_GraphicsDrawImage($hGraphBuff, $hImgBack, 0, 0) _GDIPlus_MatrixRotate($hMatrix, 5) _GDIPlus_GraphicsSetTransform($hGraphBuff, $hMatrix) _GDIPlus_GraphicsDrawImage($hGraphBuff, $hImgNeedle, -$aSize[0] / 2, -$aSize[1] / 2) $hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImgBuff) _WinAPI_UpdateLayeredWindowEx($hGUI, -1, -1, $hBMP, 255, True) EndFunc1 point
-
I would personally first try to use the query tool to interact with the DB (like SQL*Plus for Oracle). It is quite simple to script it with AutoIt. Will save you quite some time if that approach would work (even tho it is not the greatest way to automate a DB connection).1 point
-
Because you're deleting an item, you don't want to increment the counter so use ContinueLoop, see example below: #RequireAdmin #include <File.au3> Local $sLogPath = "C:\Temp\RemoveProfile.log", $pguid, $guid, $plist, $s_keyval = "xyz" Local $sProfileList = (@OSArch = "x64" ? "HKLM64" : "HKLM") & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" Local $i = 1, $sSubKey While 1 $sSubKey = RegEnumKey($sProfileList, $i) If @error Then ExitLoop If StringInStr($sSubKey, $s_keyval) Then MsgBox (64, " CORP.FOX Profile Cleanup", "Delete " & $sProfileList & "\" & $sSubKey) _FileWriteLog ( $sLogPath, "Running RegDelete " & " (" & $sProfileList & "\" & $sSubKey & ")") RegDelete($sProfileList & "\" & $sSubKey) ContinueLoop EndIf $i += 1 WEnd1 point
-
You need error checking. $i = 0 Do $i += 1 $sSubKey = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList", $i) If StringInStr($sSubKey, $s_keyval) Then MsgBox (64, " CORP.FOX Profile Cleanup", "Delete " & $pguid & $guid) _FileWriteLog ( $sLogPath, "Running RegDelete " & " (" & $plist & $sSubKey & ")") RegDelete($plist & $sSubKey) ConsoleWrite($i&@CRLF) EndIf Until $i = 50 This way you are more flexible for debugging. I think the problem is the logic. The return value is not an array. May a string split with carriage return. Then you check for each row. Because when you check string you don't delete anything from the first return. We don't have all your code but I think it is something like that. #include <MsgBoxConstants.au3> #include <Array.au3> Example() Func Example() Local $sSubKey = "", $sEnumKey = "" & @CRLF & @CRLF ; Loop from 1 to 50 times, recording registry keys into $sSubKey. For $i = 1 To 50 $sSubKey = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE", $i) If @error Then ExitLoop $sEnumKey &= $sSubKey & @CRLF Next ; Cheking the results. MsgBox($MB_SYSTEMMODAL, "RegEnumKey Example", $sEnumKey) ; Spliting the result into an array $sEnumKey = StringSplit ( $sEnumKey , @CRLF ) If Not IsArray ( $sEnumKey ) Then MsgBox(64,"ERROR","") Exit Else ; Cheking the results. _ArrayDisplay ($sEnumKey) ; Loop from 1 to $sEnumKey Rows, deleting registry keys. For $i = 1 To UBound ($sEnumKey) -1 MsgBox (64, " CORP.FOX Profile Cleanup", "Delete " & $pguid & $guid) _FileWriteLog ( $sLogPath, "Running RegDelete " & " (" & $plist & $sEnumKey[$i] & ")") RegDelete($plist & $sEnumKey[$i]) ConsoleWrite($i&@CRLF) Next EndIf EndFunc ;==>Example1 point
-
SoulA modified helpfile example without any checking for menu handles. use the GuiMenu.au3 UDF to make menus you can check for the handles of using wparam in _WM_CONTEXTMENU(). see helpfile GuiMenu UDF section example for _GUICtrlMenu_CreatePopup () Edit: added comment on helpfile example #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Local $contextmenu, $button, $buttoncontext, $buttonitem, $msg, $iFlag = 0 Local $newsubmenu, $textitem, $fileitem, $saveitem, $infoitem ;right click on gui to bring up context Menu. ;right click on the "ok" button to bring up a control specific context menu. ;click on the "ok" button to disable contextmenus GUICreate("My GUI Context Menu", 300, 200) $button = GUICtrlCreateButton("Context Menu Enabled", 75, 100, 150, 20) $buttoncontext = GUICtrlCreateContextMenu($button) $buttonitem = GUICtrlCreateMenuItem("About button", $buttoncontext) $contextmenu = GUICtrlCreateContextMenu() $newsubmenu = GUICtrlCreateMenu("new", $contextmenu) $textitem = GUICtrlCreateMenuItem("text", $newsubmenu) $fileitem = GUICtrlCreateMenuItem("Open", $contextmenu) $saveitem = GUICtrlCreateMenuItem("Save", $contextmenu) GUICtrlCreateMenuItem("", $contextmenu) ; separator $infoitem = GUICtrlCreateMenuItem("Info", $contextmenu) GUIRegisterMsg($WM_CONTEXTMENU, "_WM_CONTEXTMENU") GUISetState() While 1 Switch GUIGetMsg() Case $button $iFlag = Not $iFlag If $iFlag Then GUICtrlSetData($button, "Context Menu Disabled") Else GUICtrlSetData($button, "Context Menu Enabled") EndIf Case $GUI_EVENT_CLOSE GUIDelete() Exit EndSwitch WEnd Func _WM_CONTEXTMENU($hwnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam If $iFlag Then Return 0 Return $GUI_RUNDEFMSG EndFunc1 point
-
Advice on using numbers as variables...
seadoggie01 reacted to JockoDundee for a topic
Fwiw, another example of unintended consequences of remapping Enums to Integer identifiers just came up... so we had: Local Enum $a, $b, $c, $d, $e, $f, $g, $h Local Enum $8, $7, $6, $5, $4, $3, $2, $1 Local $board[8][8] Now, when I try to use something normal like: For $rank = $1 To $8 it doesn’t work because $1 > $8. Of course there’s always: Local Enum $One=-1 For $rank = $1 To $8 Step $One but maybe things are getting out of hand here...0 points