Jump to content

greenmachine

Active Members
  • Posts

    1,246
  • Joined

  • Last visited

Everything posted by greenmachine

  1. Here, try this: #include <Array.au3> $NumColors = 3 $Color_1 = 21989 $Color_2 = 15526360 $Color_3 = 13421772 $Color_Array = _ArrayCreate($NumColors, $Color_1, $Color_2, $Color_3) $ReturnArray = _PixelSearchX(1, 1, (@DesktopWidth-1), (@DesktopHeight-1), $Color_Array) $msg = "" For $i = 1 To $ReturnArray[0][0] $msg &= $ReturnArray[$i][0] & ", " & $ReturnArray[$i][1] & @CRLF Next MsgBox (0, $ReturnArray[0][0] & " colors seached, " & $ReturnArray[0][1] & " colors found", $msg) Func _PixelSearchX($left, $top, $right, $bottom, $ColorArray, $ShadeVar = 0, $step = 1) If Not IsArray($ColorArray) Then Return (PixelSearch($left, $top, $right, $bottom, $ColorArray, $ShadeVar, $step)) Dim $ToBeReturned[$ColorArray[0]+1][2] = [[$ColorArray[0], 0]] Local $tmp[2] For $x = 1 To $ColorArray[0] $tmp = PixelSearch($left, $top, $right, $bottom, $ColorArray[$x], $ShadeVar, $step) If Not @error Then $ToBeReturned[$x][0] = $tmp[0] $ToBeReturned[$x][1] = $tmp[1] $ToBeReturned[0][1] += 1 Else $ToBeReturned[$x][0] = -1 $ToBeReturned[$x][1] = -1 EndIf Next If ($ToBeReturned[0][1] = 0) Then SetError(1) Return $ToBeReturned EndFunc;==>_PixelSearchX Requires beta for += and &=, but that can be changed if required.
  2. Hmm I had forgotten to look at memory/CPU usage. That was bad.... It appears that GUICtrlSetGraphic adds each piece of the graphic to an array (or something similar) and then draws each piece of the array onto the graphic control. That would be why the memory keeps going up - more and more things are trying to be drawn each round. That would also explain the "memory effect" of overlapping windows. Deleting the graphic control each time solves this issue because it creates a new, fresh array for the graphics to be stored. It all makes sense now. I wonder, what about closing the drawing each time instead of deleting and recreating it? But then, the helpfile says it can only be attached to a line or bezier curve drawing, so maybe not.
  3. It means it's a beta function. Use beta check, beta run, and/or beta compile and you'll be fine.
  4. Low self esteem? Mental health problems? Who knows.
  5. I combined two support questions together and formed a third. Here's the code: #include <GUIConstants.au3> HotKeySet ("{ESC}", "quitme") $MyGui = GUICreate(" My GUI") $g1 = GUICtrlCreateGraphic(20, 50, 200, 200) GUICtrlSetColor($g1, 3763621) GUICtrlCreateCheckbox ("checkerest", 200, 300) GUICtrlSetColor (-1, 0xff0000) GUISetState() While 1 _CopyArea() Sleep(10) WEnd Func _CopyArea() TrayTip ("copy", "starting", 1) $x1 = 10 $y1 = 10 For $i = $x1 to $x1+100 for $j = $y1 To $y1+100 $PixColour = PixelGetColor($i,$j) GUICtrlSetGraphic($g1, $GUI_GR_COLOR, $PixColour) GUICtrlSetGraphic($g1, $GUI_GR_PIXEL, $i,$j) Next Next GUICtrlSetGraphic($g1, $GUI_GR_REFRESH) TrayTip ("copy", "done", 1) EndFunc ;==>_CopyArea Func quitme() Exit EndFunc Here are the questions: Why does the GUI lag so much after a few rounds of drawing? I could definitely notice a slowdown of the drawing, among other things. Why does the checkbox disappear when the graphic control is drawing? I'm pretty sure that isn't supposed to happen, but should it be considered a bug?
  6. Well... I've gotten a lot of information about DLLs from the forums - Larry tends to do a lot of interesting things with DllCalls, and then I always go to the MSDN library and start looking up all the functions he uses and the ones that are similar to them. In addition, there's a handy program - DLL Export Viewer - that lists all the exported DLL functions and where they came from. You can use that to see a list of functions, and then look up the ones that sound interesting. That's how I found a lot of the functions. http://www.nirsoft.net/utils/dll_export_viewer.html
  7. Bah the one time I didn't reread my post. I should have just copy/pasted it, but instead decided to type it out. Whatever, it's the point that counts. Plus I can edit.... Oh, and it's not that I wasn't thinking (I was), it's that I mistyped. Big difference.
  8. How about this? #include <GUIConstants.au3> $MyGui = GUICreate(" My GUI") Global $SRCCOPY = 0x00CC0020 GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect _CopyArea() Sleep(5) WEnd Func _CopyArea() $x1 = 10 $y1 = 10 $DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0) $GUIHDC = DLLCall("user32.dll","int","GetDC","hwnd",$MyGui) If Not @error Then DLLCall("gdi32.dll", "int", "StretchBlt", "int", $GUIHDC[0], "int", _ 10, "int", 10, "int", 100, "int", 100, "int", $DeskHDC[0], "int", _ $x1, "int", $y1, "int", 100 ,"int", 100, _ "long", $SRCCOPY) DLLCall("user32.dll","int","ReleaseDC","int",$DeskHDC[0],"hwnd",0) DLLCall("user32.dll","int","ReleaseDC","int",$GUIHDC[0],"hwnd",$MyGui) EndIf EndFunc;==>_CopyArea I used StretchBlt because I just borrowed it from my magnification script. I think BitBlt is better for copying, but StretchBlt lets you do stuff with the copy (make it bigger or smaller, etc). Either way, they're much quicker than pixel-by-pixel copies.
  9. That's a typo. It should read: "remote mouse control to get you fired, anyone?" Sometimes you just have to think about what you're saying before you go and say it....
  10. I see what you were trying to do there, but in case you didn't notice, the upper bound of a For loop doesn't change while the loop is in progress. In other words, this will only show 2 msgboxes and then exit.
  11. I don't think it happened in the last beta... which means that you need to make sure you're RUNNING the programs with beta (Scite helps to make sure of this). Just having the beta doesn't do you any good if you still run programs with the production version. Scite here in case you need it: http://www.autoitscript.com/autoit3/scite/downloads.php In Scite, use Alt+F5 to run with beta; outside of Scite, use the AutoIt3.exe file in the beta dir.
  12. If you have beta, look in the TCP section of the helpfile - specifically TCPNameToIP.
  13. The optional second parameter is a beta change. You can get it here if you want: http://www.autoitscript.com/autoit3/files/beta/autoit/ Otherwise, use this method: FileRead ("test.txt", FileGetSize ("test.txt")) Using a definite number usually isn't the right method.
  14. People aren't slaves - they don't stick around at all times of the day just to do your bidding. However, I happened to stop by and notice your issue, so I'll go ahead and solve your problem. Your FileRead is reading 0 bytes, which means that when it opens the file in mode 2 (erase all contents), it doesn't write anything to the file. Simply get rid of the 0 param and you'll be fine. Change: $file = FileRead("test.txt",0) to $file = FileRead("test.txt")
  15. Reading the helpfile under MsgBox would do that too. Then you could try the specific values.
  16. MouseMove to a certain position is a simple method. _MouseTrap (I believe it's a beta function, check the helpfile) keeps it in a certain area.
  17. Does anyone remember how GUIGetMsg() and GUIOnEventMode don't get along? #include <GuiConstants.au3> opt("GUIOnEventMode",1) GuiCreate("My Screen", 600, 600) $MyButton1 = GuiCtrlCreateButton("my dll", 126, 240, 200, 20) GuiCtrlSetOnEvent($MyButton1, "dll") GuiSetOnEvent($GUI_EVENT_CLOSE,"_exit") GuiSetState() While 1 Sleep (100) Wend Func dll() DllCall("user32.dll", "int", "MessageBox", "hwnd", 0, "str", "Some text", "str", "Some title", "int", 0) EndFunc func _exit() Exit EndFunc That's all you need.
  18. Find me one that does exactly what you want and show it to me. If it has enough information about how it works, I'll figure out a way to code it in AutoIt.
  19. Use String() to change a number to a string, use Number() to change a string to a number.
  20. @HotKeyPressed is simply the exact string used to set the hotkey function. In other words, if I have these two hotkeys: HotKeySet ("+9", "somefunc") or HotKeySet ("(", "somefunc") that point to this function: Func somefunc() MsgBox (0, "key pressed", @HotKeyPressed) EndFunc Both set the same key, but the message box of the first one shows "+9", and the second one "(" - exactly how the keys are set up. Therefore, if you want to key a piece of the key, use string functions on it. Example - suppose I have Ctrl+Alt+Shift+a and Ctrl+Alt+Shift+b as hotkeys, and I only want to know if a or b was pressed: HotKeySet ("^!+a", "somefunc2") HotKeySet ("^!+b", "somefunc2") While 1 Sleep (100) WEnd Func somefunc2() If StringRight (@HotKeyPressed, 1) = "a" Then MsgBox (0, "key", "a was pressed") ElseIf StringRight(@HotKeyPressed, 1) = "b" Then MsgBox (0, "key", "b was pressed") Else ; if you have more hotkeys.... EndIf EndFunc
  21. Have you thought about what you're saying? If you want the magnified version of the area directly on top of the normal area, that becomes the new area for the magnification function. In other words, you'll get an endless magnification, which won't help at all. Go back to the first link - the one you posted - and run it. Try moving your mouse near the magnified square, and then go to the middle of the square. Do you see a magnified portion of the screen under the square? No, you see a solid color - the last color that was on the square before it infinitely magnified. Look at the Windows magnifier. It doesn't put the square on top of the area being magnified either.
  22. http://www.autoitscript.com/forum/index.php?showtopic=24154 I believe that is closer to what you want.
  23. You were right, it is a stupid question. And this is even stupider... why in the world would you want to find a pixel color in a certain location if you're just going to mouseclick wherever the hell the mouse currently is? You might as well leave out the pixel search and the "If IsArray($coord) = 1 Then" line, because you never use $coord in that snippet. The $coord array has the location of the pixel that you just searched for.. so you WANT to specify the X and Y coordinates, otherwise you're not doing anything productive by searching. Plus, you're confused - what color are you really searching for? The pixelSearch command says you're searching for 0xC2DADE, but your comment says 0x000000. Which one is it? Is it only going to be a single pixel that color, or is there going to be a small area (say, 3x3 or 10x10) with the same color? While 1 sleep(3000); if you want it to go as fast as possible, why have it sleep in the loop? $coord = PixelSearch(0,0,@DesktopWidth,@DesktopHeight,0xC2DADE); put a step to improve speed. If IsArray($coord) = 1 Then MouseClick("left", $coord[0], $coord[1], 10 , 0) ; you do want x and y because you need it.... ExitLoop EndIf WEnd Exit
  24. Run this and see what it returns. StringInStr returns a number value for the location of the beginning of the string (if it is found), so it will never be equal to a string. $body = _IEBodyReadHTML($o_IE) $tester = StringInStr($body, "login") MsgBox (0, "tester", $tester) What you should have is: $body = _IEBodyReadHTML($o_IE) If StringInStr($body, "login") Then ... Haven't looked at the rest of it, but give that a try for now.
  25. If you run it externally (not through Scite), I'm pretty sure you have to have "toggle beta" on. If you run it through Scite, you have to use Beta Run or Beta Compile (Alt+F5 or Alt+F7 respectively).
×
×
  • Create New...