«

»

Feb 15 2010

Adventures in Scripting: AUTOHOTKEY


AHKautohotkeyicon thumb Adventures in Scripting: AUTOHOTKEYEveryone has pointless entry and clicking tasks that they have to do on a regular basis; whether it be for work or at home you can associate with this statement.

The point to using scripting to remove or reduce that crap for you, make the computer do what you want it to do. I think AutoHotKey embodies that spirit fairly well.

This is what I mean..

Let’s say you’ve a HTML page or another document that you needed to get information from and place it in to an EXCEL document. And from there let’s assume that there’s a lot of them. Selecting and copying this information is extremely time consuming, but if there’s a process, something repetitive that could be automated; it can be done with AHK.

Below is an example of what I’m talking about and it’s fairly simple. I’m basically assigning 3 keys to get 3 pieces of information. Once the information is collected, it performs a function and then resets the position in Excel.

 

Note: This can be done in either a browser or application type environment. If the keyboard and mouse can do it; it can be scripted.

 

AHK Code:

SetTitleMatchMode 2

SetKeyDelay,10

Here I setup the 3 keys and define them as to what I want them to do.

s::

send, {CTRLDOWN}c{CTRLUP}

system=%clipboard%

TrayTip, Status, Copied System,,1000

return

d::

send, {CTRLDOWN}c{CTRLUP}

description=%clipboard%

sleep, 50

return

f::

send, {CTRLDOWN}c{CTRLUP}

price=%clipboard%

sleep, 100

This is where we switch to EXCEL and start pasting the information I copied.

;;— Enter the data in Excel

WinWait, Microsoft Excel,

IfWinNotActive, Microsoft Excel, , WinActivate, Microsoft Excel,

WinWaitActive, Microsoft Excel,

clipboard=%system%

send, {CTRLDOWN}v{CTRLUP}

send, {right}

sleep, 50

clipboard=%description%

send, {CTRLDOWN}v{CTRLUP}

send, {right}{right}{right}

sleep, 50

clipboard=%price%

send, {CTRLDOWN}v{CTRLUP}

send, {enter}{left}{left}{left}{left}

sleep, 50

clipboard=

return

x::exitapp

return

 

The code/script is simple and if you’ve a few minutes, or if you’ve repetitive processes that could be automated, you should try to do so, because while the initial process of setting up the script and testing, and adjusting it could take while; the end result is time saved, more productive and the results are consistent.

For instance if you needed to find a way to do something when a webpage opens/loaded, but it’s never a consistent load time, you’d need a way to find out when that page loaded. I did something like this.

The request is made to open a web page, I find something on the page to reference to [a trigger]; something consistent and something that’s on that page every time. The process is set to check for the trigger 10x. Once it finds the trigger it can move on. During the detection phrase the script, pops a tray tip to tell you what it’s doing.

 

AHK Code:

Run, Http://www.google.com

SetTitleMatchMode 2

SetKeyDelay,10

This is just a section to rope off basically to say this is the area I need to check for when the page has finished loading.

pagechk:

loop, 10

{

WinWait, SlimBrowser ,

IfWinNotActive, SlimBrowser , , WinActivate, SlimBrowser,

WinWaitActive, SlimBrowser,

clipboard=

Mousemove,240 , 243

MouseClick, left, , , 2

send, {ctrldown}c{ctrlup}

sleep, 100

check=%clipboard%

Information [text] is COPIED from the webpage. I compare the information copied to what I’m looking for. If the items match, I found it and the site is ready for me to move forward.

if check = TRIGGERPHRASE

{

traytip, Status, > %check% < found,5

sleep, 150

break

}

if a_index > 5

{

traytip, Status, STOPPING,5

sleep, 2000

exitapp

}

else

{

traytip, Status, > %check% < NOT found – Try %a_index%,5

sleep, 2000

}

}

Anything after this point could be anything; it’s whatever else you want it to do.

MouseClick, left,  242,  398

statusbarwait, done, 2

 

So, if you can find out what parts of your day can be automated, download the program, read the HELP file and simplify your life.

Hope this helps.

 

Thanks,
LHenryJr.
www.lehsys.com



cancel Adventures in Scripting: AUTOHOTKEY
AHKautohotkeyicon thumb Adventures in Scripting: AUTOHOTKEY

Adventures in Scripting: AUTOHOTKEY

Share this with Family and Friends:

social facebook box blue 16 Adventures in Scripting: AUTOHOTKEY Share
social twitter box blue 16 Adventures in Scripting: AUTOHOTKEY Tweet
pinterest 16 Adventures in Scripting: AUTOHOTKEY PinIt
gplus 16 Adventures in Scripting: AUTOHOTKEY Share
pixel Adventures in Scripting: AUTOHOTKEY

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>