Jump to content

lark

Active Members
  • Posts

    46
  • Joined

  • Last visited

Profile Information

  • Location
    Not where Melba23 is

Recent Profile Visitors

169 profile views

lark's Achievements

Seeker

Seeker (1/7)

1

Reputation

  1. I'm surprised no one has mentioned prime sieves yet. Prime sieves work by filtering out non-primes, instead of checking whether each number is prime. The fastest sieve I've heard of is the sieve of atkin, which uses quadratics to determine prime numbers. Pseudo code on the wikipedia page is here: http://en.wikipedia.org/wiki/Sieve_of_Atkin Another popular prime sieve is the sieve of eratosthenes- its much simpler, but not quite as fast. Here is an implementation of the sieve of atkin in autoit: #include <Array.au3> Func getPrimes($limit) Local $isPrime[$limit] Local $i, $x, $y, $n For $i = 0 To $limit-1 $isPrime[$i] = False Next For $x = 1 To Sqrt($limit) For $y = 1 To Sqrt($limit) $n = 4*$x*$x + $y*$y If ($n <= $limit) And (Mod($n, 12) == 1 Or Mod($n, 12) == 5) Then $isPrime[$n] = Not $isPrime[$n] EndIf $n = 3*$x*$x + $y*$y If ($n <= $limit) And (Mod($n, 12) == 7) Then $isPrime[$n] = Not $isPrime[$n] EndIf $n = 3*$x*$x - $y*$y If ($x > $y) And ($n <= $limit) And (Mod($n, 12) == 11) Then $isPrime[$n] = Not $isPrime[$n] EndIf Next Next For $n = 5 To Sqrt($limit) If $isPrime[$n] Then $i = 1 $j = $i * $n * $n While $j < $limit $isPrime[$j] = False $i += 1 $j = $i * $n * $n WEnd EndIf Next Local $size = 2 For $i = 5 To UBound($isPrime)-1 If $isPrime[$i] Then $size += 1 Next Local $primes[$size] $primes[0] = 2 $primes[1] = 3 $i = 2 $j = 0 While $i < UBound($primes) If $isPrime[$j] Then $primes[$i] = $j $i += 1 EndIf $j += 1 WEnd Return $primes EndFunc Local $timer = TimerInit() Local $primes = getPrimes(100000) ConsoleWrite("Time taken: " & TimerDiff($timer) & @CRLF) _ArrayDisplay($primes) It took ~780 milliseconds to compute the first 100,000 primes on my computer, compared to ~45 seconds with the code above. -earthlark
  2. AutoEvent application, to do your tasks so you don't have to! I decided to take an autoclicker / typer one step further. Really, this is just me putting the Windows automation tools (as provided by autoit) into a nice GUI and then giving a way to automatically run them. This requires the includes: Melba23's scrollbar UDFA GUIOnEvent UDF that I made (below) which allows me to set events for controls while still being able to use GUIGetMsg()The human-like mouse movement functionality comes from the UDF which I edited slightly. Any comments, suggestions, etc are appreciated. Lark AutoEvent.au3 _GUISetOnEvent.au3
  3. WinSetOnTop() is just what I needed. Thanks bogQ
  4. Hello everyone. I have run into a problem that is somewhere along the lines of GUISetStyle() does not really function as it should. In one of my programs, I had $WS_EX_TOPMOST as the extended style of the GUI. When I added functionality for a tray item to change whether or not the GUI had this style applied, I found that GUISetStyle did not do anything. Maybe I did something wrong? But then, I set up a test program and found that if I created the GUI without setting the style, and then using GUISetStyle() right afterwards, nothing happened (the GUI did not stay on top of the other windows). Here is the test program that I used. Did I use the function wrong, or why is the style not being set? Thanks. Here is the program: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> Opt("TrayMenuMode", 1) Opt("TrayOnEventMode", 1) TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "trayExit") TrayCreateItem("Keep GUI On Top of Other Windows") TrayItemSetState(-1, $TRAY_CHECKED) TrayItemSetOnEvent(-1, "trayKeepGUIOnTop") Global $boolKeepGUIOnTop = True Global $hForm = GUICreate("Lark Autoclicker", 580, 550) ConsoleWrite(GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_TOPMOST, $hForm) & @CRLF & @CRLF) GUISetState() Do Until GUIGetMsg() = -3 Func trayKeepGUIOnTop() If $boolKeepGUIOnTop Then; if its true then set it to false and get rid of the style of the GUI ConsoleWrite("true" & @CRLF) $boolKeepGUIOnTop = False ConsoleWrite(GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU), 0) & @CRLF & @CRLF); set the GUI to its default style Else ConsoleWrite("false" & @CRLF) $boolKeepGUIOnTop = True; its false so set it to true GUISetStyle(-1, $WS_EX_TOPMOST); set the GUI to stay on top EndIf EndFunc Func trayExit(); for the tray item "Exit" Exit EndFunc
  5. It might be a problem with WinWaitNotActive, but here is a way to work around it; assuming that you to manually put in the sleep(250) to avoid high CPU usage, you could do something like Local $wintitle While 1 $wintitle = WinGetTitle("[ACTIVE]") If $wintitle Then Do Sleep(250) Until Not WinActive($wintitle) EndIf Sleep(250) WEnd
  6. Since you have ~40 pictures, it might be easier to loop through all the pictures. This creates all the pictures in the same position on the gui, and hides all but one of the pictures. There are 2 buttons for you to set which picture you are viewing: #include <Array.au3> #include <GUIConstantsEx.au3> Global $hForm = GUICreate("Pictures", 280, 200) Global $iPicCount = 40; Global $avHPics[$iPicCount] For $i = 1 To $iPicCount $avHPics[$i-1] = GUICtrlCreatePic(@ScriptDir & "pic" & $i & ".png", 100, 50, 100, 100) GUICtrlSetState(-1, $GUI_HIDE) Next Global $hButtonLeft = GUICtrlCreateButton("<-----", 20, 50, 60, 25) Global $hButtonRight = GUICtrlCreateButton("----->", 220, 50, 60, 25) Global $iCurrentPic = 1; 1-based index of the currently shown picture GUICtrlSetState($avHPics[0], $GUI_SHOW) GUISetState() Global $msg While 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit Case $avHPics[0] To $avHPics[$iPicCount-1] ShellExecute(@ScriptDir & "pic" & $avHPics[_ArraySearch($avHPics, $msg) + 1] & ".png") Case $hButtonLeft GUICtrlSetState($avHPics[$iCurrentPic-1], $GUI_HIDE) $iCurrentPic -= 1 If $iCurrentPic < 1 Then $iCurrentPic = $iPicCount GUICtrlSetState($avHPics[$iCurrentPic-1], $GUI_SHOW) Case $hButtonRight GUICtrlSetState($avHPics[$iCurrentPic-1], $GUI_HIDE) $iCurrentPic += 1 If $iCurrentPic > $iPicCount Then $iCurrentPic = 1 GUICtrlSetState($avHPics[$iCurrentPic-1], $GUI_SHOW) EndSwitch WEnd
  7. Could you post the code? Might find something.
  8. I must have misinterpreted you, I apologize. Yes, it takes all inputs. But if you look at the third parameter of _IETagNameGetCollection, you specify the index of the element. So if it were the third input on the webpage, then you could specify the index to be 2. Also, suppose there were like 38 or so inputs before it. But then, maybe there is a form (or some other less common tag) right before your element. Instead of counting how many elements there are before the one you want, you could make use of the anarchy structure of the DOM by taking that form. Then your element might be only the 5th or so input after that form. Here is an example that retrieves the latest post of the AutoIt General Help and Support forum. #include <IE.au3> Global $oBrowser = _IECreate("http://www.autoitscript.com/forum/") Global $oHighTable = _IETagNameGetCollection($oBrowser, "table", 1) Global $oMidTR = _IETagNameGetCollection($oHighTable, "tr", 1) Global $oLowTD = _IETagNameGetCollection($oMidTR, "td", 3) Global $oA = _IETagNameGetCollection($oLowTD, "a", 1) ConsoleWrite("Latest Post in General Help and Support: " & $oA.title & @CRLF) So instead of counting how many elements there are with a tag name 'a', I took other elements lower in the DOM and built my way up to the element I wanted to work with.
  9. I find that taking the body text and using lots of string manipulation is over complicated. Another thing you could do would be to get the tag name of the button, which would be "input". well here is how you could retrieve the text in the button: #include <IE.au3> Global $oBrowser = _IECreate("http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro"); open IE Global $oButton = _IETagNameGetCollection($oBrowser, "input", 0); get the object of the button MsgBox(0,'', $oButton.value); display the data in the value tag of our object, which is the text we wanted to see In your case, you can find what instance your text would be under the tag name 'u', and access its "innertext" tag or whatever. Eh? Can't you just inspect the element? If you are using google chrome, right-click the element and select "Inspect Element". Otherwise, find an add-on (such as firebug) and install that. I think IE has a built in DOM inspector thing as well. Edit: but then i would recommend just getting its tag name and stuff, not finding strings around it to use with _StringBetween or something.
  10. It seems as if you took away the part $iCounter += 1. When you do GUICtrlSetData($hCountLabel, "Counter total: " & $iCounter + 1) that does not change the value stored in the variable. That just takes the value stored inside the variable, adds 1 to it, and displays that. You need to do: $iCounter += 1 GUICtrlSetData($hCountLabel, "Counter total: " & $iCounter)
  11. Can't you just get the object of where the text is and then use $oText.Innertext? So the code you posted above was for the link, but isn't that what you need for just a sentence?
  12. It's kind of hard to help you with your code if you don't post what you tried to use. But really, for GUICtrlSetData? It should be something like: GUICtrlSetData($hCountLabel, "Counter total: " & $iCounter)
  13. Just to point it out, it would be much more simple to use a for...next loop instead of a do...until. For $i = 0 To 10 WinActivate("SeriCon - New") WinWaitActive("SeriCon - New", "Send") Send("{ENTER}") WinActivate("SonyIIDC - [No Sony camera in system]") WinWaitActive("SonyIIDC - [No Sony camera in system]") ControlClick("SonyIIDC - [No Sony camera in system]", "SAVE", 1170) WinWaitActive("Save As") Send("{" & $i & "}") Send("{ENTER}") Sleep(1000) Next
  14. Try using the ControlClick function. Use the AutoIt Window Info tool to gather the information about the control, and use something like ControlClick("Phoner", "Destination Number", "[CLASS:Button]", "secondary") But then again, I have never tried to use that on the right-click menu button of a control. So you could find out how far up and over the menu button is from the actual control, and use ControlGetPos to get the x and y coords of the control. Let's say the menu button is 20 pixels over (x + 20) and 40 pixels up (y - 40). So you could try something like: Global $avControl = ControlGetPos("Phoner", "Destination Number", "[CLASS:Button]", "secondary") Global $iXPos = $avControl[0] + Floor($avControl[2] / 2) Global $iYPos = $avControl[1] + Floor($avControl[3] / 2) MouseClick("secondary", $iXPos, $iYPos) Sleep(300) MouseClick("primary", $iXPos + 20, $iYPos - 40)
×
×
  • Create New...