Jump to content

ericnail

Active Members
  • Posts

    70
  • Joined

  • Last visited

Everything posted by ericnail

  1. Hey, I mean Timeline.
  2. I am creating a script to check craigslist for new posts based on my search parameters. I want it to check for new posts and then if any are new then run a function. Currently I have this: #include <INet.au3> Global $postTitle, $postDate, $postPrice, $postLink, $postNumber, $updateTimer, $count = 0 Global $intervalTime = 900000 ;15 Minutes Global $stackQueue[1] = [0] ;Queue for found ads Global $stackOverflow[1] = [0] ;Queue for matched ads Dim $iStack[1][5] $iStack[0][0] = '<font size=5>Title</font>' $iStack[0][1] = '<font size=5>Price</font>' $iStack[0][2] = '<font size=5>Date</font>' $iStack[0][3] = '<font size=5>Phone Number</font>' $iStack[0][4] = '<font size=5>URL</font>' $check_numbers = 0 GetSearchResults("iPhone 4", "150", "250", 1) Func GetSearchResults($a, $b, $c, $d = 1) fillStack($a, $b, $c) $html = _ArrayToHTML($iStack) $html = '<html>' & @CRLF & $html & '</html>' $html = StringReplace($html, "Title", "<b>Title</b>") $html = StringReplace($html, "Date", "<b>Date</b>") $html = StringReplace($html, "Price", "<b>Price</b>") $html = StringReplace($html, "URL", "<b>URL</b>") $html = StringReplace($html, 'http://atlanta.craigslist.org/', '<a href="http://atlanta.craigslist.org/') $html = StringReplace($html, '.html', '.html">Link</a>') If $d = 1 Then FileSaveAndOpen("index.html", $html) EndFunc Func fillStack($iQuery, $iMin, $iMax) Local $iData[4][1] $iQuery = StringReplace($iQuery, " ", "+") $iURL = "http://atlanta.craigslist.org/search/sss?maxAsk="&$iMax&"&amp;minAsk="&$iMin&"&amp;query="&$iQuery&"&amp;srchType=A" $source = _INetGetSource($iURL) $postTitle = StringRegExp($source, '<a href="http://atlanta.craigslist.org/[^0-9][^0-9][^0-9]/[^0-9][^0-9][^0-9]/...........html">(.*?)-</a>', 3) $postDate = StringRegExp($source, ";</span>\n [^0-9][^0-9][^0-9] [0-9][0-9] - <a", 3) $postPrice = StringRegExp($source, '\n[^a-z][^a-z][^a-z](.*?)href="/[^0-9][^0-9][^0-9]/"', 3) $postLink = StringRegExp($source, '<a href="http://atlanta.craigslist.org/[^0-9][^0-9][^0-9]/[^0-9][^0-9][^0-9]/...........html">', 3) ReDim $iData[5][UBound($postTitle)] For $i = 0 to UBound($postTitle) -1 Step 1 $iData[0][$i] = StringTrimRight(StringTrimLeft($postTitle[$i], 0), 0) Next For $i = 0 to UBound($postDate) -1 Step 1 $iData[1][$i] = StringTrimRight(StringTrimLeft($postDate[$i], 17), 5) Next For $i = 0 to UBound($postPrice) -1 Step 1 $iData[2][$i] = "$"&StringTrimLeft(StringLeft($postPrice[$i], 5), 2) Next For $i = 0 to UBound($postLink) -1 Step 1 $iData[4][$i] = StringTrimRight(StringTrimLeft($postLink[$i], 9), 2) Next Local $iTemp_a = UBound($postPrice)-1 Local $iTemp_b = UBound($postTitle)-1 If $check_numbers Then ProgressOn("Eric's Craigslist App", "Collecting Phone Numbers...") For $i = 0 to $iTemp_b Step 1 If $check_numbers Then ProgressSet(($i / $iTemp_b) * 100, Round(($i / $iTemp_b) * 100) & "%") If $i > $iTemp_a Then ExitLoop If StringInStr($postTitle, "want") Then ContinueLoop If StringInStr($postTitle, "trade") Then ContinueLoop If $postTitle = "" Then ContinueLoop AddToStack($iStack, $iData[0][$i], $iData[2][$i], $iData[1][$i], $iData[4][$i], $iQuery) Next If $check_numbers Then ProgressOff() Global $Count = 0 EndFunc Func AddToStack(ByRef $iStack, $iTitle, $iPrice, $iDate, $iLink, $iQuery) Local $iNumber = "-" $iQuery = StringReplace($iQuery, "+", " ") If Not StringInStr($iTitle, $iQuery) Then Return ;~ If $History Then ;~ If ManageArchive("Check", $iLink) Then Return ;~ ManageArchive("Write", $iLink) ;~ EndIf $count+= 1 ReDim $iStack[$count+1][5] If $check_numbers Then $src = _INetGetSource($iLink) $iTemp = StringRegExp($src, "[0-9][0-9][0-9][^0-9][0-9][0-9][0-9][^0-9][0-9][0-9][0-9][0-9]", 3) If IsArray($iTemp) Then $iTemp = StringRegExpReplace($iTemp[0], '(\d{3}).(\d{3}).(\d{4})', ' $1-$2-$3 ') $iNumber = $iTemp Else $iTemp = StringRegExpReplace($iTemp, '(\d{3}).(\d{3}).(\d{4})', ' $1-$2-$3 ') $iNumber = $iTemp EndIf If $iNumber = 1 Then $iNumber = "-" EndIf $iStack[$count][0] = $iTitle $iStack[$count][1] = $iPrice $iStack[$count][2] = $iDate $iStack[$count][3] = $iNumber $iStack[$count][4] = $iLink EndFunc Func _ArrayToHTML(Const ByRef $avArray, $attrib = 'border="2"', $iStart = 0, $iEnd = 0) If Not IsArray($avArray) Then Return SetError(1, 0, "") If UBound($avArray, 0) <> 2 Then Return SetError(2, 0, "") Local $sResult, $iUBound = UBound($avArray) - 1 Local $row, $sDelimCol = "</td>" & @CRLF, $sDelimRow = '</tr>' & @CRLF ; Bounds checking If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound If $iStart < 0 Then $iStart = 0 If $iStart > $iEnd Then Return SetError(3, 0, "") $sResult = '<table ' & $attrib & '>' & @CRLF ; Combine For $i = $iStart To $iEnd ; rows $row = '<tr>' & @CRLF For $j = 0 To UBound($avArray,2) - 1 ; columns If $j <> 0 Then $row &= '<td><font size=2>' & '<center>' & $avArray[$i][$j] & $sDelimCol & '</center>' & '</font>' Else $row &= '<td><font size=2>' & $avArray[$i][$j] & $sDelimCol & '</font>' EndIf Next $sResult &= $row & $sDelimRow Next Return $sResult & '</table>' & @CRLF EndFunc Func FileSaveAndOpen($file, $content) $file = @TempDir & '\' & $file FileDelete($file) FileWrite($file, $content) ShellExecute($file) EndFunc Func ManageArchive($a, $b) If $a = "Write" Then IniWrite("archive.ini", "archived", "viewed", IniRead("archive.ini", "archived", "viewed", "") & "|" & $b) EndIf If $a = "Remove" Then IniWrite("archive.ini", "archived", "viewed", StringReplace(IniRead("archive.ini", "archived", "viewed", ""), $b & ",", "")) EndIf If $a = "Check" Then $iTemp = IniRead("archive.ini", "archived", "viewed", "") $iTemp = StringSplit($iTemp, "|") For $i = 1 to $iTemp[0] Step 1 If $b = $iTemp[$i] Then Return True Next Return False EndIf EndFunc Which will search for the terms and find specified info and then make and open an HTML File. I want to be able to make it search for only new posts. I cannot come up with a way to do this in my head. Maybe there is a simple solution but I have yet to figure it out. Any help here would be great! Thanks, Eric
  3. I might try.. What do you mean brave enough??
  4. Is it possible to save variables after exit and recall them on the next run? I am currently just saving vars to an INI File, however, I would like to do this without saving a file. Is there any way to do this? I've looked at EnvSet(), however, it deletes the env var after autoit exit. Thanks, Eric
  5. I am trying to figure out ways to label/declare/read variables without using their "$Name" handles. For instance: I know you can read a variable like so: $check1 = GUICtrlCreateCheckbox("1",15, $const_top) $check2 = GUICtrlCreateCheckbox("2",50, $const_top) $check3 = GUICtrlCreateCheckbox("3",85, $const_top) $check4 = GUICtrlCreateCheckbox("4",120, $const_top) For $i = 1 to 4 Step 1 MsgBox(1, "", "The value of Checkbox " & $i & " is " & Eval("check"$i) & "." & @CRLF & "Note: 4 = Unchecked, 1 = Checked") Next This will of course create a Message Box of each checkbox's state/numeral. I also know that you can label variables like so: $Var1 = 0 $Var2 = 0 $Var3 = 0 $Var4 = 0 For $i = 1 to 4 Step 1 Assign("Var"&$i, $i) Next And this will lable each variable with it's number. However, I can't seem to find other ways to do things such as this. For instance, what about Setting the State, or disabling, etc.? I've tried both For $i = 1 to 4 Step 1 Assign("check"&$i, $GUI_CHECKED, 2) Next and For $i = 1 to 4 Step 1 Assign("check"&$i, $GUI_UNCHECKED, 2) Next and although this SHOULD set the states by setting the variables to said state numbers (1 being checked and 4 being unchecked), it doesn't. I've tried the Assign() function with a couple other situations and still no. So are there any other ways that I dont know about besides the Assign() & Eval() functions, or is there a special way to make it work, or is there simply no way to do special operations with string defined variables? Thanks in Advance! All the best, Eric
  6. Okay, So I am having an issue. I have a While loop that checks for network spikes and if it finds any, it sends the network ID to a function. In the second function I have a TimerInit() and then in the While loop I check to make sure it has been at least a second since the last spike was recorded via TimerDiff() on the started timer. My issue is that AutoIt seems to be continuing the While Loop while the Record() function is running which results in multiple sends to the Record() function before the timer is started and therefore fails to limit the amount of records made within a second. Here is the bare version of my script: Global $Net1, $Net2, $Net3, $Net4 Global $LastRecord = 1000 While 1 While $on GetNetworksData($Net1, $Net2, $Net3, $Net4) For $i = 1 to 4 $temp = Eval("Net"&$i) If $temp >= $NetworkSpikeAmount Then If TimerDiff($LastRecord) >= 1000 Then Record($LastRecord, $temp) EndIf Next WEnd WEnd Func Record(ByRef $LastRecord, $data) $fileHandle = FileOpen($File) FileWrite($fileHandle, $data & @CRLF) FileClose($fileHandle) $LastRecord = TimerInit() Return EndFunc I'm wondering how I can stop the multiple attempts and how autoit works with functions (whether it stops until the function returns or what). Thanks!
  7. The simple one here by bugfix works: Func _GetMin($n1, $n2, $n3=Default, $n4=Default, $n5=Default, $n6=Default, $n7=Default, $n8=Default, $n9=Default, $n10=Default) Local $min = $n1, $val For $i = 2 To 10 $val = Eval('n' & $i) If IsKeyword($val) Then ExitLoop If $val < $min Then $min = $val Next Return $min EndFunc However I found out that something is wrong w/ the _ArrayMinIndex function as it is never right :/ Thanks Guys!
  8. Awesome! That works. For what it's worth, since I don't need micro seconds, i found that this actually worked: SleepLocal(1) Func SleepLocal($time) $a = TimerInit() Do $b = TimerDiff($a) Until $b >= $time Return EndFunc But thanks a ton! I am saving that microsecond thing it could be super useful!
  9. I just found out that when you use: Sleep(1) This results in sleep defaulting to 10ms. Is there a way around this?? Is there a way to sleep for only 1ms? Like maybe something like this: $Timer = TimerInit() Do $a = TimerDiff($Timer) Until $a = 1 Anyone have any ideas/knowledge on this? Thanks, Eric
  10. Okay, So i have 10 variables coming in and I need to find out which is the lowest in autoIT Is there a way to do this without using '_ArrayMinIndex' because the variables are all different rather than packed into on variable as an array. so in order to use the arrayminindex method i need to pack them all into a single array and I feel this wastes time and cpu power. Also, you cant use '_arrayMinIndex' with 2D arrays so even if I use it, I cant create a label for each array so when I get the min index i dont know what it is :/ Thanks, Eric
  11. I couldnt figure it out, so i just used multiple arrays.
  12. IDK i found the function in another script, I'm not using it for games and cheating, I'm using it as a network monitor, it's complicated.
  13. Here is my KeySend Function: Func KeySend($inkey, $evt = "pressed", $kdown = 2) ;System coded to send the actions to an inactive window ; send single keyboard event to non active window ; event = pressed, down, up ; kdown = key down delay ; note: supports only lower case keys + NUMx, Fx, some special keys and @ $user32 = DllOpen("user32.dll") If $user32 = -1 Then ToolTip("User32 = -1!",0,0,"System Error", 1) return EndIf ; handling for special keys Switch StringUpper($inkey) Case "@" $skey = 0x40 $lparam = 0x00100001 DllCall($user32, 'int', "PostMessage", "hwnd", $hwnd, 'int', $WM_KEYDOWN, 'int', 0x71, "long", $lparam) DllCall($user32, 'int', "PostMessage", "hwnd", $hwnd, 'int', $WM_CHAR, 'int', $skey, "long", $lparam) Sleep(20) DllCall($user32, 'int', "PostMessage", "hwnd", $hwnd, 'int', $WM_KEYUP, 'int', 0x71, "long", BitOR($lparam, 0xC0000000)) Case "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12" $skey = 0x6f + Int(StringMid($inkey, 2)) ContinueCase Case "NUM0", "NUM1", "NUM2", "NUM3", "NUM4", "NUM5", "NUM6", "NUM7", "NUM8", "NUM9" If StringUpper(StringLeft($inkey, 3)) = "NUM" Then $skey = 0x60 + Int(StringMid($inkey, 4)) EndIf ContinueCase Case "RETURN", "SPACE", "TAB", "BACK", "END", "HOME", "SNAPSHOT", "INSERT", "DELETE", "LEFT", "RIGHT", "UP", "DOWN", "ESC" Switch StringUpper($inkey) Case "SPACE" $skey = 0x20 Case "TAB" $skey = 0x09 Case "BACK" $skey = 0x08 Case "END" $skey = 0x23 Case "HOME" $skey = 0x24 Case "SNAPSHOT" $skey = 0x2c Case "INSERT" $skey = 0x2d Case "DELETE" $skey = 0x2e Case "LEFT" $skey = 0x25 Case "RIGHT" $skey = 0x27 Case "UP" $skey = 0x26 Case "DOWN" $skey = 0x28 Case "ESC" $skey = 0x1B EndSwitch $ret = DllCall($user32, 'int', "MapVirtualKey", 'int', $skey, 'int', 0) $lparam = BitShift($ret[0], -16) $lparam = BitOR($lparam, 1) DllCall($user32, 'int', "PostMessage", "hwnd", $hwnd, 'int', $WM_KEYDOWN, 'int', $skey, "long", $lparam) Sleep($kdown) DllCall($user32, 'int', "PostMessage", "hwnd", $hwnd, 'int', $WM_KEYUP, 'int', $skey, "long", BitOR($lparam, 0xC0000000)) Case Else ; default lower case key handling $key = DllCall($user32, 'int', "VkKeyScan", 'int', Asc(StringLower($inkey))) $skey = $key[0] $ret = DllCall($user32, 'int', "MapVirtualKey", 'int', $skey, 'int', 0) $lparam = BitShift($ret[0], -16) $lparam = BitOR($lparam, 1) Select Case $evt = "pressed" DllCall($user32, 'int', "PostMessage", "hwnd", $hwnd, 'int', $WM_KEYDOWN, 'int', $skey, "long", $lparam) Sleep($kdown) DllCall($user32, 'int', "PostMessage", "hwnd", $hwnd, 'int', $WM_KEYUP, 'int', $skey, "long", BitOR($lparam, 0xC0000000)) Case $evt = "down" DllCall($user32, 'int', "PostMessage", "hwnd", $hwnd, 'int', $WM_KEYDOWN, 'int', $skey, "long", $lparam) Case $evt = "up" DllCall($user32, 'int', "PostMessage", "hwnd", $hwnd, 'int', $WM_KEYUP, 'int', $skey, "long", BitOR($lparam, 0xC0000000)) EndSelect EndSwitch DllClose($user32) EndFunc I have tried it a million times; no-go
  14. You said 27 = AA, which I find weird because i would thing 27 = (26 + 1) AKA "ZA". But, I assumed you wanted to have the excess multiplied onto the origional. Anyway, here: #include <Array.au3> HotKeySet("{F6}", "CalculateNum") Global $char_string Dim $Value[1], $String[1], $values[1] While 1 Sleep(20) WEnd Func CalculateNum() $Num = InputBox("Input Number", "Enter Number:") $Answer = GetNumber($Num) MsgBox(1, "Done!", "Your Calculated String: " & $Answer) EndFunc Func GetNumber($Num) Local $count = 0 If $Num > 26 Then Do $Num_Count = $Num - 26 $count =+1 Until $Num_Count < 27 $sub = 26 * $count $send_val = $Num - $Sub $remainder = AlphGet($send_val) $values[0] = $remainder For $i = 1 to $count ReDim $values[$count +1] $values[$i] = $remainder Next $String = _ArrayToString($values,"") Return $String Else Return AlphGet($Num) EndIf EndFunc Func AlphGet($Num) Switch $Num Case 1 Return "A" Case 2 Return "B" Case 3 Return "C" Case 4 Return "D" Case 5 Return "E" Case 6 Return "F" Case 7 Return "G" Case 8 Return "H" Case 9 Return "I" Case 10 Return "J" Case 11 Return "K" Case 12 Return "L" Case 13 Return "M" Case 14 Return "N" Case 15 Return "0" Case 16 Return "P" Case 17 Return "Q" Case 18 Return "R" Case 19 Return "S" Case 20 Return "T" Case 21 Return "U" Case 22 Return "V" Case 23 Return "W" Case 24 Return "X" Case 25 Return "Y" Case 26 Return "Z" EndSwitch EndFunc
  15. I have a function which is going to handle the process of selecting my target application and press the key I tell it to press. Its "KeySend" which is run like so: KeySend("Key", "pressed") Which tells it to WinActive() the target application (designated via a Global) and send the "Key" as a "pressed" key (As opposed to a held/multiple key press). The function also handles some other things which are not of importance; Nevertheless, I need to use it over the built in autoit CtrlSend() function. My issue is this: My function sends numbers which are read as just that, numbers (i.e. KeySend(1, "pressed")). However, It processes other keys differently (i.e. Escape = "Esc" or "Escape", Space = "Space", etc.). In my script, I have the KeySend function inside of a For/Next loop which I use the Var as the key in order to send a number to the Number Pad. It looks like so: For $i = 0 to 4 If $True Then KeySend("Num" & $i, "pressed") EndIf NextUnfortunately, this does not work. It never sends the full "NUM$i" to the KeySend Function. Basically, I need a way to append the number on the end of the text that is sent to my KeySend Function. Currently, I have it going to an external function with a switch to return the full var, like so: For $i = 0 to 4 If $True Then $Ptr = GetKeyData($i) KeySend($Ptr, "pressed") EndIf Next Func GetKeyData($Num) Switch $Num Case 0 Return "NUM0" Case 1 Return "NUM1" Case 2 Return "NUM2" Case 3 Return "NUM3" Case 4 Return "NUM4" EndSwitch EndFunc While this does in fact work, I feel as though it's a very rudimentary and inefficient way of doing this simple task. I have been having issues with my script sucking down too much CPU (About 40%-50%) and I'm trying to simplify everything. Also, in the future, I may need more than just the 5 numbers (0-4) and may need to do a bunch more (i.e. If $i = 200 Then Return "NUM2"). Any help is greatly appreciated!
  16. Ohh Nvm. I figured it out (using the "Call" Function).
  17. Is there a way to use a variable as a function? I'm using "GUICtrlRead($input_1)" to read an input box from my GUI. I want to then be able to do this: $FunctionName = GUICtrlRead($input_1) $Parameter = GUICtrlRead($input_2) $ReturnValue = $FunctionName($Parameter) How can I do this?
  18. Hey, Thanks for the reply! I already tried InetGet however, It didn't seem to work :/
  19. Is there a way to make AutoIt read a .txt file from the internet. I know there is a way to do this with an ini file, however, the ini file is restricted to a specific number of titles. I would like to be able to read a text file from the internet, and use srtinginstring functions to get what I need. I have the script working locally (as in it can read the .txt file on my computer), but I would REALLY like to have it work over the internet. Is there a way to do this? Thanks, Eric
  20. Is is possible to set multiple Arrays like so: For $i = 0 to 7 $var[$i] = $ReturnVar ;$ReturnVar would return 10 different results Next Where $var[$i] would be cycling through 8 variables (Arrays) and (Hopefully) adding 10 returns to the second array. I would like it to essentially result in this: $var[0][0] = return 1 $var[0][1] = return 2 $var[0][2] = return 3 $var[0][3] = return 4 etc, etc.. $var[1][0] = return 1 $var[2][1] = return 2 $var[3][2] = return 3 $var[4][3] = return 4 etc, etc.. I currently am set like this: $var0 = $ReturnVar $var1 = $ReturnVar $var2 = $ReturnVar $var3 = $ReturnVar etc, etc.. Which of course returns this: $var0[0] = return 1 $var0[1] = return 2 $var0[2] = return 3 $var0[3] = return 4 And I continue that with all 8 variables.. Thanks Guys, Eric
  21. Hey Guys, So I'm writing a lot of Autoit these days (NERD! -- haha I know), and there are LOTS of tricks I have learned over time, just small things that save me multitudes of time (i.e. F5=Run, Ctrl+F5=Syntax Check Prod., etc). I know you can highlight a couple lines/sections and press 'TAB' to tab them forward. My question is this: Is there away to select multiple lines/sections and un-tab (i guess that's what I'd call it ). This would really help me out, as I like to keep scripts neat for future editing purposes. Also, if you know any other small tips like that, I would love to hear 'em! Thanks again guys, Eric
  22. WOW! Thank you! I have been trying to get it to work for hrs. I was about to give up!
  23. Finding Orientation. Okay, So for a math project, I am trying to do this with Autoit: I am given the coordinates of three locations (A, B, and C) on an XY plane (2D), and I have to find the orientation of A. I am essentially trying to create a calculator via AutoIt where I can input coordinates and find the orientation. Here's how I'm going to play this out in the presentation: I am assuming the Coords are GPS Coords, and the Locations (A,B,C) are Vehicles. Vehicle A (Location A) is going to crash into either B or C and the system (Theoretical, My Script) is attempting to find which vehicle, B or C, is going to be struck based on the orientation of Vehicle A. Here's what I have so far (But i dont know if it's right): I have to calculate the vectors between locations B and A, and C and A. Then I have to find the angle between those vectors and the X axis, compare the angle's to the orientation of Location A and the closest match will most likely be the Vehicle about to be struck. i'm trying this: $alpha = ACos(($Tx-$Mx)/(Sqrt(($Tx-$Mx)^2 + ($Ty-$My)^2))) If ($Ty-$My) < 0 Then $alpha *= -1 Endif With V1 = T1 - M1 (Ax,Ay = coordinates of the A Location, Bx,By = coordinates of the B Location) and V2 = X-Axis = [1,0] So Basically, can someone help me find the orientation of these points.
  24. Ahhh that's it! Thanks!
×
×
  • Create New...