Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Plagued by Inconsistency and Unpredictability


  • Please log in to reply
7 replies to this topic
rjschilling
  • Members
  • 16 posts
  • Last active: Feb 13 2013 07:45 PM
  • Joined: 20 Dec 2012

My first use of autohotkey was to write a program to assist me in filling one database (an access db)  A with data from a second database B, which I accessed online.  The program simply copied a field from B, alt-tab to A and pasted content of clipboard to a field of A.  Then repeat.  I am satisfied at this time to do one row/record at a time.

 

My first experimentation at this was done by accessing B through Internet Explorer.  I met with terrible inconsistency and predictability.  My program would work for 2 or 3 records and then on the next record, something strange would happen.  I spent hours trying to guess what may be causing the  various several strange things that took place and experimenting with changes to my program based on my latest guess.  The problems were so disruptive that there was no significant gain in time over doing things by ordinary cutting and pasting.

 

I set up my program for another employee where I work and he wanted to use Firefox to access B.

I made a few changes to my a program, to account for minor differences in tab sequences between

IE and Firefox.   The program worked perfectly!  All those hours of experimentation with my program under IE were a waste of time because my basic original program, which is simple and very straight forward, worked perfctly under Firefox, no strange inconsistencies and upredictable behavior.  We more than tripled the rate at which we could accomplish our task.

 

My question is this.  What's up with IE?  Are there compatiblity issues between it and Autohotkey?

Are there settings that have to be changed to make a browser work with AHK?

 

I'm motivated and willing to work, read and learn.  References appreciated.  I am an experienced C++ programmer (well, experience = two courses).  It would be nice to know what parts of the AHK documentation might be important and in what order all the various topics should be taken.

 

Thanks and grateful to have this forum, Randy

 

 

 

 



guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

i dont know what problems there might be with IE. but if AHK is just sending keystrokes, then it should just mimic human behavior. you would need to debug what those "strange things" were to try to solve it.

 

the AHK docs are excellent, but this is really a compatibility problem with IE so you are unlikely to find anything in there. 

 

an alternative would be to use COM to access the webpage directly and use some type of DB interface to interact programmatically with the database. that approach would be much more reliable, but much more work obviously



Leef_me
  • Moderators
  • 8510 posts
  • Last active: Sep 10 2015 05:50 AM
  • Joined: 08 Apr 2009

Hi Randy, welcome to the forum.

 

Using AHk to control IE using is a really problematic way of doing things.

 

For a programming standpoint, it is like trying to operate the same website blindfolded.

 

I say 'blindfolded' because the script has absolutely no feedback of where the cursor is in the webpage.

And using the cursor location for copy & paste is the fundamental way of getting data in or out.

 

If you are using various keyboard 'tabs' to get to the desired file, I suggest >not< using Alt-tab.

Not because they interfere, but because switching between 2 program windows can be done more accurately using

the command Winactivate for each window, in turn.

 

guest3456 suggested COM, which I agree is a good idea. I have started learning. and from one perspective, is like using VBA

 

COM, once you get over the learning curve (I'm still in the curve :sigh: ) promises to be a great way to control webpages.

And even other programs (ex: Excel, PowerPoint)

 

 

Here are a few links I found with the google search "site:autohotkey.com COM"  (w/o the "")

 

Basic Ahk_L COM Tutorial for Webpages
http://www.autohotke...l-for-webpages/

 

 

COM Object Reference [AutoHotkey_L]

http://www.autohotke...e-autohotkey-l/

 

Basic Ahk_L COM Tutorial for Excel

http://www.autohotke...rial-for-excel/

 

 

[AHK_L] ADO/MS Access Data Base Functions
http://www.autohotke...base-functions/

 

 

This link isn't pertinent to your goal, but might be interested to look at

 

Create/Convert to PDF w/ PDFCreator [COM] [AHK_L]
http://www.autohotke...ator-com-ahk-l/

 



rjschilling
  • Members
  • 16 posts
  • Last active: Feb 13 2013 07:45 PM
  • Joined: 20 Dec 2012

Great response, just the kind of thing I need to know.  Thanks thanks, thanks!

It will take some time for me to follow up on your suggestions.



rjschilling
  • Members
  • 16 posts
  • Last active: Feb 13 2013 07:45 PM
  • Joined: 20 Dec 2012

I understand too that AHK is really just a sort of superficial or "quick solution" to a problem that should be handled thru programming.

I understand C++ and, though its been a while, I think I could be tuned into Visual Basic in a short time.

Could you please briefly outline the steps, the things that I would need to know, to deal programatically with two different databases.

A good reference, a book or website, would do just fine.

Thanks - Randy



Leef_me
  • Moderators
  • 8510 posts
  • Last active: Sep 10 2015 05:50 AM
  • Joined: 08 Apr 2009

>>I understand too that AHK is really just a sort of superficial or "quick solution" to a problem that should be handled thru programming.

 

I would disagree in part with your "understanding"

 

While the answers to a problem can be quick, I disagree with the uninformed opinion "just a sort of superficial"

 

It is a scripting language which is interpreted at run-time.  Other scripting languages include VBA, WScript and javascript.

 

C++ and C are languages that are compiled, and use machine code at run-time (and yet make calls to various subroutines in Windows)

 

 

Since you access one database locally and the other through a web interface, I don't believe the number of programming reference sources will be very large.



rjschilling
  • Members
  • 16 posts
  • Last active: Feb 13 2013 07:45 PM
  • Joined: 20 Dec 2012

Leef_me -

 

My apologies.  The word "superficial" does not fit what I wanted to convey.  It has a negative connotation and I did not want to use it for that reason,  but I couldn't come up with the right word. 

 

I have an Access database A of which I know a little, but not enough, and another database B, which is built with an oracle product.  I would like to "connect" with each of these databases and access their tables directly using a programming language such as C++, Java or VB.  I've done this with MySQL dbs.  I cannot access B's tables; instead, I'm limited by what I get from the webpages.  Besides that, to do things the "preferred" way would require that I know much more than I do about whatever Oracle product B is built upon.  AutoHotKey gives me another approach, not the preferred approach but certainly not a superficial approach.

 

Your suggestion, to use WinActivate in place of Alt-Tab, has proven to be reliable.  Also, I've learned to identify windows

by their titles.  Now I wonder if the fields of a window, in particular, the windows within Firefox provided me by database B, have similar identifiers?  Further, is there a command which can be used in conjunction with these identifiers to direct the mouse to a position with the field?  This would help because both tabbing and click x,y have not proven to be reliable.  This is because of the nature of the field and the window within Firefox (not an issue with AHK), its not easy navigated to and selected, even manually.  Its position x,y depends on the record, further complicating things.

 

Thank you so much and please stay with me for just awhile longer (in spite of my poor choice of words).  Randy



Sarah G
  • Members
  • 1 posts
  • Last active: Feb 20 2013 03:30 AM
  • Joined: 20 Feb 2013

I just wanted to add that doing something like scraping values out of a web page is the area where a language like Perl often shines like no other language. AHK can certainly do the job here, but for quick text manipulation, Perl is without peer.

 

The tortuous path to Perl 6 notwithstanding, Perl still very much deserves its place on the list of languages every hacker should know, and I can pretty much promise that the Camel Book is the most fun you'll ever have reading technical writing. If you work much with text files, every minute spent learning Perl will be a great investment. Its regex system has been copied and integrated into most languages, though Perl is entirely built around it. Perl is like a little mini Leatherman you keep on your key chain or in your purse: you wouldn't want to build a house with one but it'll come in handy a thousand times even for people who would never even dream of carrying around an actual screwdriver.

 

(Don't get me wrong, AHK is probably on that list too for people who spend a lot of time in Windows.)

 

How far to take something like this depends on the project. If what you already have does the job as effectively as you need, you should leave well enough alone. If you're only copying over selected entries, an AHK to copy & paste is a really solid approach. If you want every entry, I would probably use Perl. Otherwise, you could do well either with regexes or XPath for this task. XPath is more resilient against changes in minor document details, as regexes can't truly parse XML or HTML. (Do yourself a favor and read that link.) Regexes are the ultimate "good enough" tool, and are often perfectly adequate to real-world situations where you just need to pull some data from predictable HTML.

 

I wouldn't recommend one of the traditional big three imperative, compiled languages of C, C++ or Java for something like this. They can certainly do the job but they're slow to develop in and increasingly outdated for general-purpose programming. Scala would be a reasonable approach, as in many ways it gives the expressiveness of a dynamic scripting language even though it is compiled and strongly typed. (C, C++ and Java were all groundbreaking languages, and they all still have compelling applications, but you won't find many new start-ups using any of them as their primary language these days.)