Jump to content

Fox2

Active Members
  • Posts

    30
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Fox2's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thanks! Now that I know what to look for, I find others had made such posts themselves. Is there a centralized place where documentation can either be updated by users, or at the least points needing adding to future documentation are collected together for future documentation updates? An AutoIt wiki or something perhaps?
  2. I'm designing a form where I would like the user to be able to navigate using the keyboard (tab) or mouse, as with most windows forms. I am having a couple of issues and can't find documentation on them. Any help appreciated. 1) I have a form with 2 possible "subforms" - basically following tips in other posts, as you can't hide the tabs on a tab control or put two tab controls on one form, I'm using child forms instead. But I can't get tabbing between controls to work in a "natural" way. It doesn't seem to work at all. Eg: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $main_GUI = GUICreate("Form1", 570, 292, 193, 125, BitOr($GUI_SS_DEFAULT_GUI,$WS_CLIPSIBLINGS)) GUISetState() $child1 = GUICreate("", 600, 300, 0, 0, $WS_CHILD,-1,$main_GUI) GUICtrlCreateButton("Button 1", 100, 10, 175, 25, $WS_TABSTOP) GUICtrlCreateButton("Button 2", 100, 40, 175, 25, $WS_TABSTOP) GUICtrlCreateButton("Button 3", 100, 70, 175, 25, $WS_TABSTOP) GUISetState() GUISwitch($child1) While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit Sleep(100) WEnd 2) I would like to include a clickable hyperlink on the form. I can easily do that by (for example) having a label with blue font and an onclick property to open a browser. But I can't make that link, reachable by pressing "tab". If I try to use a button with onclick to create blue text that both responds to clicking, and also can be reached with the tab key, I can't make the button border invisible so it just looks like an in-line blue text hyperlink. Any solutions appreciated.
  3. Resolved - unicode isn't selected by default in the global properties. Should it be?
  4. I'm having trouble with SciTE and unicode. Specifically on a default install, I paste some text into SciTE that contains unicode characters, and they paste as ascii (as best I can tell). At least, they don't paste as the characetr I pasted. I'm writing a script that contains a lot of unicode text that is routinely cut and pasted as time passes, so failing to paste correctly is something I'd like to sort out. I can't find where to get input on this. Can someone advise? Thanks.
  5. Just polishing up the debug output. Because POP can fail in interesting ways when its actually used in someone elses code, the one thing I want is good trace/debug ability. It may slow it down a fraction, but the payoff comes with anyone who can see whats gone on, and fix it, either when trying to collect email and something's wrong at a traffic, network, POP or SSL level etc, or if they accidentally misapply it (eg bad FUNC call) in their own code. Better to give people an ability to see what's happening under the hood. Been away a lot, back on Monday though
  6. This is a working generic set of SSL POP3 functions, ready for use. It's got a lot left to do on it, see below. But anyone should be able to take this, and use this to collect Gmail or other encrypted email via POP3 as needed without extra work. Full information and .au3 below, and credits to mikeytown (for his original script), catchfish for this post which basically solved the main technical issue surrounding use of the usual OpenSSL.exe, this version of the POP3 protocol, and this and this descriptions of how to analyze emails themselves. The rest of this post is background info and what I think needs doing next, so that anyone who wants to build this and existing unencrypted UDF's into a full POP3/SMTP UDF, can basically do so. I'll be doing so anyway but others might get there sooner. Please do. I might not get to it! Fox2 ---- Background: A general POP3/SMTP email UDF requires ability to handle four things: - unencrypted SMTP and POP3, and encrypted ("SSL") versions of each (as used for gmail). To date AutoIt has unencrypted SMTP/POP3, encrypted (gmail) SMTP, but encrypted POP3 has been elusive. There's been a couple of proof of concepts, but no actual, usable, script to handle gmail collection. What this does: It creates commands such as these: _POPConnect($OpenSSL_Executable, $SmtpServer, $SmtpPort, $EmailUsername, $EmailPassword) _POPSendAndGet($Command, $IsMultiline) _POPPurgeBuffer() (shouldn't be needed usually) _POPCheckStderr() (checks stderr; shouldn't be needed usually) _POPDisconnect()A typical session might be: _POPConnect($OpenSSL_Executable, $SmtpServer, $SmtpPort, $EmailUsername, $EmailPassword) If @error then ..... $list = _POPSendAndGet("LIST"); get a list of all emails If @error then ..... $text = _POPSendAndGet("RETR 1", 1); get email 1 If @error then .... else $Results = _POPAnalyze($text) _ArrayDisplay($Results) endif _POPSendAndGet("QUIT") _POPDisconnect() That simple. The internal structure of the attached code should be blindingly obvious. I haven't done 100% error checking, and it's still got loads of debug code "DebugReport()", but it's commented and should be simple to understand and seems 100% reliable. It handles both long emails, and emails with "." in the start of lines, hasn't given me an error yet, and has fairly careful checking of server responses to identify when its okay, when to poll more, and so on. It uses the cygwin compiled version of OpenSSL. It's identical in function to the usual version, but the usual version seems to have a bug that means the first input must be via keyboard, requiring input blocking, an open command window, etc. Messy! Cygwin OpenSSL You will need the cygwin DLL files which can be downloaded from their website and then unzipped. The compiled version of OpenSSL from OpenSSL.org (same source code, same usage) somehow has a bug in it, which means that particular version of OpenSSL.exe doesn't respond unless you send something via console/keyboard first... which as mikeytown's script shows, is messy to manage. The above post doesn't tell you completely what to do though. This is what I found out: You want to unzip and get hold of the /bin folder for cygwin openssl, using the download system on their website (containing typically openssl.exe, cygssl-0.9.8.dll, cygcrypto-0.9.8.dll, c_rehash). You dont need to actually install cygwin or keep the rest - just download and unzip the openssl part of cygwin, which is currently listed under "libraries" in their system. You will also need to find somewhere the file cygwin1.dll (google and download, eg here) and put that in the same folder if not included (openssl.exe uses this). You don't need your script in the same folder as these. It just needs a folder containing the above binaries, for use in the Run() command.No installing is needed for this. What's to come A final POP3 UDF should have the following: _POPConnect (executable_path, address, port, username, password, is_ssl, OPTIONAL buffertimeout, OPTIONAL maintimeout) -- creates a connection, either normal or SSL. Reports if the connection is successful. Optional parameter = buffer timeout and main timeout for this connection. Returns a connection ID > 0 of the relevant process (allows >1 POP server in use). Buffertimeout is how long to allow to check nothing more's coming through the buffer for an ambiguous or malformed message (typically 1 - 4 seconds). Maintimeout is how long to allow before the server itself is deemed to have timed out, and may be considerably longer (20 - 120 seconds). _POPSend(connectionID, command) -- sends a command to the relevant connection. In the background it's remembered whether this is a secure or normal connection. _POPGetResponse(connectionID, OPTIONAL canbemultiline) -- gets a response from a connection. If the +OK response can be multiline (LIST, RETR, etc) then add canbemultiline = 1 to specify to expect a multiline response if successful. _POPSendAndGet(connectionID, command) -- combines both the above (too useful not to have). 'Canbemultiline' is figured out internally from the command. _POPSetTimeout(connectionID, buffertimeout, maintimeout) -- change timeouts. ConnectionID = -1 for all. _POPPurgeBuffer() -- waits till there's (eg) 2 clear seconds with no incoming text, to ensure the buffer is genuinely clear and (apparently) nothing more's being sent in the present transaction. Returns any text sent. _POPClose(connectionID) -- close a connection. ConnectionID = -1 for all. _POPAnalyze(string) -- takes an email raw text as the server provides it, and return an array with predefined arguments in predefined entries ($a[1] is the FROM, $a[2] = TO, ..., $a[19] = main text, $a[20] = number of attachments, $a[21] = first attachment in base 64, etc..... ) _POPEncode64(text or file,flag) -- takes the raw text (or if flag=1, reads the file whose name is in $text), and uses OpenSSL.exe to encode it to base 64, and returns that as a string. _POPDecode64(text or file,flag) -- takes the base 64 text (or if flag=1, reads the file whose name is in $text), and uses OpenSSL.exe to decode it to base 64, and returns that as a string.If anyone wants to have a start at creating the full version of the above, go for it; Ive done the main "SSL POP3" code which was my need, but it would be nice to have this redone by someone who really knew what they were doing, and made into a proper POP3 UDF. [AU3 to be posted up shortly. Bug found in my handling of @error in the example scripts - specifically DebugReport() was overwriting @error before it could be tested. "Oops". The core functionality works though, and is reliable. Fixing that first.]
  7. YAY -- got round the 64k buffer limit and "string stopped being received 1/2 way" errors. I just managed to collect a 300k email I was testing with. I do believe we're going to get Gmail POP3 tamed to more than "proof of concept".....
  8. I've got Mikeytown's gmail pop3 working mostly, but also, I have switched from openssl.org to the cygwin version. Mikeytown's script noted that the first input was not accepted other than from the keyboard. I referred to this post: #161734 which says this is a bug in that compilation of openssl and if needed use cygwin's compilation of openssl instead. I modified the code on that page to use pop3 instead of smtp, which was surprisingly easy. How to do it: You will need the cygwin DLL files which can be downloaded from their website and then unzipped. The above post doesn't tell you completely; this is what I found out: You want to get hold of the /bin folder from cygwin (containing openssl.exe, cygssl-0.9.8.dll, cygcrypto-0.9.8.dll, c_rehash). You dont need to install them - download and unzip the openssl part of cygwin. You will also need to find somewhere the file cygwin1.dll (google and download) and put that in the same folder if not included (openssl.exe uses this). Then grab the AutoIt code for cygwin SMTP from the above post, and modify it to start: $EmailUsername = "myemail" ;if your email is myemail@gmail.com, use "myemail" $EmailPassword = "mypassword"; enter your password $SmtpServer = "pop.gmail.com" $SmtpPort = "995" ; Must use Cygwin OpenSSL in order to implement stdin automation; the Windows build has a bug which makes StdinWrite() fail. $OpensslPath = '"' & @ScriptDir & '\openssl.exe" s_client -quiet -connect ' & $SmtpServer & ':' & $SmtpPort $WorkingDir = @ScriptDir Dim $Conditions[9], $Actions[9] $Conditions[0] = '+OK' $Actions[0] = "USER " & $EmailUsername $Conditions[1] = '+OK' $Actions[1] = "PASS " & $EmailPassword $Conditions[2] = '+OK' $Actions[2] = "STAT" $Conditions[3] = '+OK' $Actions[3] = "RETR 1" $Conditions[4] = '.' $Actions[4] = "QUIT" I'm working on it and plan to get it a little better for UDF style usage. For example it does not retrieve the whole message, nor check for buffer being empty before issuing the next command. I'll see what I can do, but figured others might like this alternative code
  9. The caching method is optimized for speed. Searching an array for a text match is much slower than searching in one string for a text match. The strings you get look like this: $DNS_IPCache: ^IP^IP^...^IP^ Each IP is * padded * to 15 characters. So each (IP+separator) is guaranteed 16 chars. $DNS_LookupCache: ^DNSINFO^DNSINFO^...^DNSINFO^ There is no information on DNSINFO length, but they are ^ separated ("^" is not a valid character in reverse DNS information so far as I know) So if you find a match for ^IP^ at position 1, 33, (16n+1), you know the cached text is between the (1st and 2nd), (2nd and 3rd), (N+1) and (n+2) occurance of "^" in the lookup cache. A bit of StringinStr() and you're there. That's how it works. To make it convert the cache strings to an array, use StringSplit() to split both strings at the "^", ignore the first and last result (null), and remove padding with StringStripWS(). $IPList = StringSplit($DNS_IPCache,"^",1) $DNSList = StringSplit($DNS_LookupCache,"^",1) For $entry = 1 to $IPList[0] $IPList[$entry] = StringStripWS($IPList[$entry],3) Next If $IPList[0] <= 2 then no entries exist, otherwise valid entries start at $IPList[2] and the last entry is one less than $IPList[0]. Macthjing DNS info is in the other table. You can easily rework this to split them into one table with 2 dimensions, or a file.
  10. An update in case you're doing a lot of DNS lookup. This is a quick and dirty way to cache your searches so far and save doing a new command window and PING call for each one. It caches all confirmed hits in "^" separated chunks, and leaves all misses uncached to retry. (A PING that worked, has worked, but one that didn't may work next time) Initializing code: ; Initialize DNS lookup cache Global $DNS_IPCache = "^" Global $DNS_LookupCache = "^" Updated Func: Func ReverseDNS($IP) ; Strip WS - needed for caching and for textual use $IP = StringStripWS($IP,3) ; cached? $x = StringInStr($DNS_IPCache,"^" & StringLeft($IP & " ",15) & "^") if $x > 0 Then $entrynum = ($x - 1) / 16 + 1 $lookupstart = StringInStr($DNS_LookupCache,"^",0,$entrynum) + 1 $lookupend = StringInStr($DNS_LookupCache,"^",0,$entrynum + 1) Return StringMid($DNS_LookupCache, $lookupstart, $lookupend - $lookupstart) EndIf $t = TimerInit() $dnsinfo = "?" $PingCmd = Run(@ComSpec & " /c ping -a -n 1 " & $IP, "C:\", @SW_HIDE, $STDOUT_CHILD) While TimerDiff($t) < 2000 $PingResponseText = StdoutRead($PingCmd) If @error Then ExitLoop $x1 = StringInStr($PingResponseText, "Pinging") $x2 = StringInStr($PingResponseText, "[") If $x1 > 0 Then If $x2 > 0 Then $dnsinfo = StringStripWS(StringMid($PingResponseText, $x1 + 8, $x2 - $x1 - 8),3) ; and add to cache, padded to allow entry number to be found $DNS_IPCache &= StringLeft($IP & " ",15) & "^" $DNS_LookupCache &= $dnsinfo & "^" ExitLoop EndIf Sleep(20) WEnd Return $dnsinfo EndFunc (minor fix posted!)
  11. Func ReverseDNS($IP) $t = TimerInit() $dnsinfo = "?" $PingCmd = Run(@ComSpec & " /c ping -a -n 1 " & $IP, "C:\", @SW_HIDE, $STDOUT_CHILD) While TimerDiff($t) < 2000 $PingResponseText = StdoutRead($PingCmd) If @error Then ExitLoop $x1 = StringInStr($PingResponseText, "Pinging") $x2 = StringInStr($PingResponseText, "[") If $x1 > 0 Then If $x2 > 0 Then $dnsinfo = StringStripWS(StringMid($PingResponseText, $x1 + 8, $x2 - $x1 - 8),3) ExitLoop EndIf Sleep(20) WEnd Return $dnsinfo EndFunc For anyone who wants it Oddly there doesn't seem to be a copy of this lying round. Feel free to adapt and credit.
  12. I'm not sure that's the problem. The situation is, I'm automating a webpage I've loaded, where the checkbox is in an unknown state, and I want to clear it. So I don't know its present value, nor do I know if it's the only checkbox with that value. It may be one of several check boxes, some of which are set, some unset. I'm trying to get the checkbox that's got id+name="myCheckbox" (which uniquely identifies it) and read + set its value. It should be easy, and should be trivial IE manipulation... what's missing in the above attempt?
  13. Update - I've managed to get it (somewhat) to work for me... I'm going to try and shuffle around some of mikeytown's code into a format that's more directly usable than the proof of concept. If I get to the point that gmail etc work reasonably for me, I'll post up the code so others can take it further and maybe merge it into the main POP3 UDF.
  14. Should be easy, but having no success... I've got a form with the following checkbox control definition: <input name="myCheckbox" type="checkbox" value="1" id="myCheckbox" /> I'm trying to read it, and (in this example) set it to unchecked, then submit the form, but I'm having trouble with the checkbox. I've got the form object $myForm and can manipulate text boxes on it and so on, it's just the checkbox that's stubborn. I can't see from HELP, what's missing. $BrowserObjID = _IECreate("about:blank",0,1,1,-1) ; Create a temp window ... _IENavigate($BrowserObjID, $myURL,0) _IELoadWait($BrowserObjID) $BrowserFormID = _IEFormGetObjByName($BrowserObjID, "myForm") $CheckboxID = _IEFormElementGetObjByName($BrowserFormID, "myCheckbox") $SavebuttonID = _IEFormElementGetObjByName($BrowserFormID, "mySavebutton") then I've tried both: _IEFormElementCheckBoxSelect($myForm,"myCheckbox","",0,"byValue",1) and: If _IEFormElementGetValue($CheckboxID)=1 then _IEAction($CheckboxID,"click") _IEAction($SavebuttonID,"click") _IELoadWait($BrowserObjID)
  15. I don't "have" anything.. it worked for me to a point enough to prove the concept but not fully. Testing if I can do more..... may be able to, may not.
×
×
  • Create New...