Leaderboard
Popular Content
Showing content with the highest reputation on 10/13/2015 in all areas
-
Well maybe it's me (it surely is) but I like my AutoIT code when it's FAST. So here's a little program I whipped up in about an hour. AutoIT_Speed.au3 Updated 19Aug2007 with more comments and more test results It will execute commands of your choice through two loops, 20 packs of 9999 iterations to be precise. Making two loops increased the reliability of the reading (since it seems the first iteration is really slow because of cache issues and what not). For example, you could compare $Val = $Val +1to ... $Val += 1(in this case, the obvious winner is $Val += 1 but it isn't always so evident) The code is as simple as can be, I guess if you don't get it than it's not for you In any case, the results you get might make you change your programming habits! If you do a lot of looping then I suggest you try out the commands in those loops and see what's better. Good luck! EDIT: It's been brought to my attention by chris95219 that GetTickCount() cannot be properly timed. Also if you use the $i and $j variables in your code (both loop counters) you will obviously get incorrect results! TESTED BY YOURS TRUELY: 1. For/Next loops are champions. Try not to use While/Wend or Do/Until 2. If $Val is faster than If $Val = 1 or $Val = TRUE 3. If $Val = 1 is faster than $Val = TRUE 4. If Not $Val is faster than If $Val = 0 or $Val = FALSE 5. If $Val = 0 is faster than If $Val = FALSE 6. < and > are faster than =, >= or <= (Wow!) 7. $i += 1 is faster than $i = $i + 1 $i -= 1 is faster than $i = $i - 1 $i *= 1 is faster than $i = $i * 1 $i /= 1 is faster than $i = $i / 1 8. If doing a lot of verifications on a single variable: Switch is fastest, Select is second (but slow) and If is slowest. 9. If $Val is a string, If Not $Val is faster than If $Val = "" If $Val is faster than If $Val <> "" 10. When doing binary operations, If $Val -128 > 0 is twice as fast as If BitAnd($Val, 128). 11. Using Hex numbers is faster than using decimal numbers 12 Replacing dec/hex numbers by variables slows down execution. Use hex/dec numbers when possible 13. Longer variable names = longer execution time. Keep variable names short and clear! 14. StringRegExpReplace() is slower than StringReplace(). Use it only if necessary! 15. StringRegExp() is slower than StringInStr(). Use only if necessary! 16. Opt("ExpandEnvStrings",1) makes $Val = "%TEMP%" faster than $Val = EnvGet("temp") or $Val = @TempDir 17. $Val = @TempDir is faster than $Val = EnvGet("temp") 18. Opt("ExpandVarStrings",1) makes $Val = "$String$" slightly faster than $Val = $String 19. However $Val = "@TempDir@" is slower than $Val = @TempDir (go figure!)1 point
-
As the help file says: "When setting $bVisible = False when opening a Workbook make sure to set the Workbook to visible again before saving the Workbook. Use $oExcel.Windows($oWorkbook.Name).Visible = True to make the Workbook visible again. Else the Workbook will not be shown when you manually open it using Excel. Most of the time this parameter is not needed. Using $bVisible = False in _Excel_Open is the preferred way." This is not being reset when the workbook gets saved.1 point
-
zxtnt09, You have been here long enough to know not to bump your own threads within 24 hours. Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. M231 point
-
Don't use _GDIPlus_GraphicsDrawEllipse($hCtxt , $iW / 2 , $iH / 2 , 1 ,1 , _GDIPlus_PenCreate(0x99FF0000 , 2))in a loop. This will cause a memory leak because a pen object will be created permantely! #include <GDIplus.au3> #include <GUIConstantsEx.au3> AutoItSetOption("MouseCoordMode", 0) AutoItSetOption("GUIOnEventMode", 1) Global Const $iW = 400, $iH = 400, $iBgColor = 0xF0F0F0 Global Const $hGUI = GUICreate("", $iW, $iH) GUISetBkColor($iBgColor, $hGUI) GUISetState() _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hPen = _GDIPlus_PenCreate() $hPen2 = _GDIPlus_PenCreate(0xFFFF0000, 2) $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 4) _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, 4) Global Const $iPosX = 50, $iPosY = 50, $iWidth = 300, $iHeight = 300 Global $iMPosX, $iMPosY Local Const $fDeg = ACos(-1) / 180, $iRadius = 32, $iWh1 = $iW / 2, $iHh1 = $iH / 2 Local $fAngle = 0 GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") Do _GDIPlus_GraphicsClear($hCtxt, 0xFF000000 + $iBgColor) _GDIPlus_GraphicsDrawRect($hCtxt, $iPosX, $iPosY, $iWidth, $iHeight, $hPen) ;~ _GDIPlus_GraphicsDrawLine($hCtxt, 0, 0, $iW, $iH, $hPen) ;~ _GDIPlus_GraphicsDrawLine($hCtxt, $iW, 0, 0, $iH, $hPen) $hPos = GUIGetCursorInfo($hGUI) _GDIPlus_GraphicsDrawEllipse($hCtxt , $iWh1, $iHh1 , 1 ,1, $hPen2 ) ; circle1 _GDIPlus_GraphicsDrawEllipse($hCtxt , $iWh1 - 15, $iHh1 - 15, 30 , 30 , $hPen) ; circle2 _GDIPlus_GraphicsDrawEllipse($hCtxt , $iWh1 - 15 + Cos($fAngle * $fDeg) * $iRadius ,$iHh1 + - 15 + Sin($fAngle * $fDeg) * $iRadius , 30 , 30 , $hPen) $fAngle += 3 _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH) Until Not Sleep(10) Func _Exit() _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPen2) _GDIPlus_Shutdown() GUIDelete() Exit EndFunc1 point
-
Try this: #include <GDIplus.au3> AutoItSetOption("MouseCoordMode", 0) Global Const $iW = 400, $iH = 400, $iBgColor = 0xF0F0F0 Global Const $hGUI = GUICreate("", $iW, $iH) GUISetBkColor($iBgColor, $hGUI) GUISetState() _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hPen = _GDIPlus_PenCreate() $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 4) Global Const $iPosX = 50, $iPosY = 50, $iWidth = 300, $iHeight = 300 Global $iMPosX, $iMPosY Do _GDIPlus_GraphicsClear($hCtxt, 0xFF000000 + $iBgColor) _GDIPlus_GraphicsDrawRect($hCtxt, $iPosX, $iPosY, $iWidth, $iHeight, $hPen) $hPos = GUIGetCursorInfo($hGUI) $iMPosX = $hPos[0] < $iPosX ? $iPosX : $hPos[0] > $iPosX + $iWidth ? $iPosX + $iWidth : $hPos[0] $iMPosY = $hPos[1] < $iPosY ? $iPosY : $hPos[1] > $iPosY + $iHeight ? $iPosY + $iHeight : $hPos[1] _GDIPlus_GraphicsDrawLine($hCtxt, $iW / 2, $iH / 2, $iMPosX, $iMPosY, $hPen) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH) Until GUIGetMsg() = -3 _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_PenDispose($hPen) _GDIPlus_Shutdown() GUIDelete()1 point
-
Take a look at using Au3Stripper with the MergeOnly option: https://www.autoitscript.com/wiki/AutoIt3Wrapper_Directives You can examine the resulting file to see exactly which line is causing your error.1 point
-
There was no problem friend. Good script, will help people.1 point
-
This excellent UDF served me well ...1 point
-
An other one using _WinAPI_CreateIconIndirect, as described in the helpfile and here : http://www.codeguru.com/cpp/w-p/win32/cursors/article.php/c4529/Creating-a-Color-Cursor-from-a-Bitmap.htm #include <GUIConstantsEx.au3> #include <WinAPIGdi.au3> #include <WinAPIRes.au3> $hold_cursor = _WinAPI_CopyCursor(_WinAPI_LoadCursor (0, $OCR_NORMAL)) ; Create XOR bitmap Local $hDC = _WinAPI_GetDC(0) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hXOR = _WinAPI_CreateCompatibleBitmapEx($hDC, 32, 32, 0) Local $hSv = _WinAPI_SelectObject($hMemDC, $hXOR) _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_BRUSH)) _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($NULL_PEN)) Local $tRECT = _WinAPI_CreateRectEx(0, 1, 22, 22) _WinAPI_SetDCBrushColor($hMemDC, 0x0000FF) _WinAPI_Ellipse($hMemDC, $tRECT) _WinAPI_OffsetRect($tRECT, 11, 0) _WinAPI_SetDCBrushColor($hMemDC, 0x00FF00) _WinAPI_Ellipse($hMemDC, $tRECT) _WinAPI_OffsetRect($tRECT, -6, 9) _WinAPI_SetDCBrushColor($hMemDC, 0xFF0000) _WinAPI_Ellipse($hMemDC, $tRECT) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_SelectObject($hMemDC, $hSv) _WinAPI_DeleteDC($hMemDC) ; Create AND bitmap $hDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hAND = _WinAPI_CreateBitmap(32, 32, 1, 1) $hSv = _WinAPI_SelectObject($hMemDC, $hAND) _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_BRUSH)) _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($NULL_PEN)) _WinAPI_SetDCBrushColor($hMemDC, 0xFFFFFF) $tRECT = _WinAPI_CreateRectEx(0, 0, 33, 33) _WinAPI_Rectangle($hMemDC, $tRECT) _WinAPI_SetDCBrushColor($hMemDC, 0) $tRECT = _WinAPI_CreateRectEx(0, 1, 22, 22) _WinAPI_Ellipse($hMemDC, $tRECT) _WinAPI_OffsetRect($tRECT, 11, 0) _WinAPI_Ellipse($hMemDC, $tRECT) _WinAPI_OffsetRect($tRECT, -6, 9) _WinAPI_Ellipse($hMemDC, $tRECT) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_SelectObject($hMemDC, $hSv) _WinAPI_DeleteDC($hMemDC) ; Create cursor Local $hnew_Cursor = _WinAPI_CreateIconIndirect($hXOR, $hAND, 0, 0, False) ; Free bitmaps _WinAPI_DeleteObject($hXOR) _WinAPI_DeleteObject($hAND) ; Create GUI $hGUI = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 128, 128) GUISetState(@SW_SHOW) _WinAPI_SetSystemCursor($hnew_Cursor, $OCR_NORMAL, 1) Do Until GUIGetMsg() = -3 _WinAPI_SetSystemCursor($hold_Cursor, $OCR_NORMAL, 1)1 point
-
Don't think about the Mod function. I used it in my example to figure out whether a number is even or odd. Set the disabled state in the usual way. Since the menu is created from scratch every time you right click a list view item, you just have to set the disabled states. All menu items are enabled as default. The menu doesn't remember the states between two function calls.1 point
-
Hi Fredricz, maybe it can be useful for your purpose also this "SNMP Ping" that I've written some time ago: it can scan a range of device and it should check if those devices are snmp enabled or not, and if so, it should also report if those devices are responding to snmp v1 or v2.1 point
-
UritOR Welcome to the AutoIt forums. In future please do not resurrect threads from this far back - the language has changed so much that it is likely that the functionality has already been incorporated and the previously posted code will almost certainly not run in the current version of AutoIt without modification. And does this help? #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("Test", 10, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton MsgBox($MB_SYSTEMMODAL, "Pressed", "LEFT") Case $GUI_EVENT_SECONDARYUP $aCInfo = GUIGetCursorInfo($hGUI) If $aCInfo[4] = $cButton Then MsgBox($MB_SYSTEMMODAL, "Pressed", "RIGHT") EndIf EndSwitch WEndM231 point
-
Are you writing statements or seeking help? If seeking help, then help is a two way thing .... you help us to help you, else it is like trying to get blood from a stone. We, the unpaid volunteers, are not here for your pleasure, we are here to support and promote AutoIt, which we cherish. One or two very short sentences, are about as useful as teets on a bull.1 point
-
This is a function I made when I found the Battlefield 1984 didn't use the desktop cursor, rather it had it's own. There's no easy way to explain this but I'm gonna try. _MouseMovePlus() uses the "mouse_event", a low level mouse simulator. What's that mean? It means that whatever you pass to it, the computer treats it as though it came from the mouse. MOST PEOPLE WILL NEVER NEED THIS. I'm not gonna lie. If you're not looking for this, you probably won't use it. If, on the other hand, you're trying to bot in a game but a supposedly simple MouseMove() has a result of about 63 times more than what you expected, you came to the right place. Here's the function: Func _MouseMovePlus($X, $Y,$absolute = 0) Local $MOUSEEVENTF_MOVE = 1 Local $MOUSEEVENTF_ABSOLUTE = 32768 DllCall("user32.dll", "none", "mouse_event", _ "long", $MOUSEEVENTF_MOVE + ($absolute*$MOUSEEVENTF_ABSOLUTE), _ "long", $X, _ "long", $Y, _ "long", 0, _ "long", 0) EndFuncIt takes an X and a Y and an option parameter. The $absolute parameter specifies when or not to use relative or absolute coords. Relative is the default. In relative mode, X and Y is the distance you want to move relative to the current mouse position. In absolute mode, X and Y are values from 0 to 65535 where (65535,65535) is the bottom right corner. To use this the same way as MouseMove(), this is what you'd do: _MouseMovePlus($X*(65535/@DesktopWidth), $Y*(65535/@DesktopHeight),1)Here is the MSDN of the function. Like I said, if you're not looking for this, you'll probably never use it. Feel free to ask questions about it if I didn't explain well enough. ***NOTE: I just got a nice wake up IM with someone needing help using this. I haven't been active on these forums in over a year due to school and the like but if you need help, just hit me up on AIM: Oxin8 and I'll be more than willing to help as long as you have a valid question and know what you're talking about. None of that "Can you make me an Aimbot for <insert game>?" crap.***1 point
-
@IPAddress1 IP address of first network adapter. Tends to return 127.0.0.1 on some computers. @IPAddress2 IP address of second network adapter. Returns 0.0.0.0 if not applicable. @IPAddress3 IP address of third network adapter. Returns 0.0.0.0 if not applicable. @IPAddress4 IP address of fourth network adapter. Returns 0.0.0.0 if not applicable.1 point