AutoHotkey GitHub Webinar: Become an amazing AHK Programmer in 2020

AutoHotkey Github WebinarWe had an awesome webinar today! Jean Lalonde, author of Quick Access Popup, lead us on a great webinar today regarding how to use GitHub to with our AutoHotkey scripts & programs.  BTW we streamed the webinar live to this AutoHotkey Facebook group.

AutoHotkey Podcasts Highlighted

Ways to make money with around AutoHotkey  

Selling Software Group Discussion   

  • Jackie Sztuk
  • Ryan Wells
  • Jean Lalonde
  • Raptor X
  • Charlie Simmons / Tank
  • Joe Glines

Do people see what needs Automation?

Script Highlight

taskManager by fenchai23

TaskManager

AutoHotkey GitHub Webinar

Video Hour 1: High-level overview
Video Hour 2: Finishing up on GitHub

Here’s the deck shared by Jean Lalonde during the webinar

 

04: Automating Chrome to Set Text & Click a button

Automating Chrome with AutoHotkey

In the fourth session with GeekDude we look at out to Chrome and AutoHotkeyautomate setting text in a search field and then hitting the button to submit the search.

Automating Chrome to Set Text & Click a button


donate to GeekDudeIf you’re loving this, please consider donating to GeekDude!

AutoHotkey script for Automating Chrome to Set Text & Click a button


#Include   ;Remember to put Chrome in your library folder

#SingleInstance,Force
;**************************************
page:=Chrome.GetPageByTitle("AutoHotkey Community","contains") ;This will connect to the second index of a specific tab
If !IsObject(page){
MsgBox % "That wasn' t object / the page wasn't found"
ExitApp
}
page.Evaluate("document.querySelector('#keywords').value ='Chrome.ahk'")
Variable =document.querySelector('#keywords').value ='Chrome.ahk'
page.Evaluate(Variable)
var:="duh"
page.Evaluate("document.querySelector('#keywords').value ='" var "'")
page.Evaluate("document.querySelector('#search > fieldset > button').value ='Chrome.ahk'")

Notes for Automating Chrome to Set Text & Click a button

00:36     Go to AutoHotkey.com/boards/

00:44     Connect to tab using Chrome.GetPageByTitle(“AutoHotkey Community”) ;the default matchtype is “starts with”

01:23     Look at page structure using right-click and Inspect.  This opends Devtools with that element selected.

01:46     It has an ID of “keywords”, copy js path.  Which will give you queryselector(“#keywords”)

02:26     Use the .value to set some text in that box.

03:00     page.Evaluate(“document.querySelector(‘#keywords’).value =’Chrome.ahk'”)

04:01     Make sure inside the JavaScript you use the “=”, not “:=”

04:15     Some people don’t want to have to learn JavaScript.  When using Chrome, you’re going to have to learn JavaScript.

04:56     When using Chrome.ahk, we’re injecting JavaScript.  So best to learn

05:54     The button is right next to the input.  You can go back to the page and right-click the button, then hit Inspect

06:13     Test the new js path.  Instead of using .value, use .click

06:42     Test in Chrome developer tool

07:18     When running an Evaluate method, it waits for the previous Evaluate to finish (so no need to sleep between them).

07:44     If you run into a problem where you think it is happening too quickly, check the forum for some solutions

08:40     Sometimes what you want to input won’t always be a static string.  If you’re trying to reference a variable, you need to use the expression syntax.  In an expression, you’re not just assigning text, you’re doing math or making function calls.

Variable =document.querySelector(‘#keywords’).value =’Chrome.ahk’

page.Evaluate(Variable)

page.Evaluate(“document.querySelector(”#keywords ‘).value ='” variablevar:=”duh”

page.Evaluate(“document.querySelector(‘#keywords’).value ='” var “‘”) “‘”)

10:48     This works because AutoHotkey splits everything up on a given line.   First is a name of a function, then says this is inside the function, then this is text inside a function.  Then builds from left to right as to the string that will be used.

12:15     AutoHotkey proceeds left to right when evaluating an expression

12:40     when you use := you’re in expression assignment mode.

13:25     With just single = you’re in plain-text mode.  It reads it as text

15:00     When automating a site, you don’t know what kind of buffer’s they have to prevent scraping / botting.

15:49     When you start automating, you might start seeing Captcha’s everywhere

16:04     Sites get really good at looking like a normal site to a user, but looking like an impenetrable fortress to code

16:36     If your variable contains a single quote or other special charachters, JavaScript will interpret it as code instead of text.

17:13     JavaScript string escape sequence will replace characters with special escape sequences

Not mentioned in Video but GeekDude wrote me after

You can escape JavaScript code using Coco’s JSON library does actually do that escaping that we discussed when talking about putting data on the page. The syntax for invoking it looks like this:

variable = 123`r`n456’quote”quote

page.Evaluate(“document.querySelector(‘#whatever’).value = ” Chrome.Jxon_Dump(variable))

The dump function will automatically escape anything that needs escaped and add quotes to anything that needs quotes.

 

 

AutoHotkey Webinar- Using AHK string functions in Excel

AHK In this webinar we walked through using AutoHotkey String functions in Excel.

Script Highlight:  Pull data about your computer with WMI by shajul.  Forum post and my link to the zipped files of the separate scripts I wrote

Video Hour 1 & 2 : AHK string functions in Excel

Books on RPA (Robotics Process Automation) that I mentioned in the webinar

Below are links to books I showed during the webinar. I put them into two groups (those I like/recommend and those I don’t). I’m more of a “glass is half-full” kind of guy and think technology is good. The books I don’t recommend were much more negative towards technology. While I don’t recommend them, I think time will tell who is right/wrong.  Personally any of the following you buy I’d try and buy as used.  Many are pretty expensive new (probably because of the small market size)

Recommended Robotics Process Automation books

Service Automation: Robots and the Future of Work 2016 -Great book!
Robotic Process Automation and Risk Mitigation: The Definitive Guide 2017
Robotic Process and Cognitive Automation: The Next Phase 2018 -Great book!
The Singularity Is Near: When Humans Transcend Biology 2019 – very interesting
Life After Google: The Fall of Big Data and the Rise of the Blockchain Economy 2018 – some wild ideas here
The Human Advantage: The Future of American Work in an Age of Smart Machines 2018
The Glass Cage: How Our Computers Are Changing Us 2015
Managing IT as a Strategic Resource 1997
Beyond the IT Productivity Paradox 1999 – old but still interesting

Not recommended but still on the RPA topic

In The Age Of The Smart Machine: The Future Of Work And Power 1989
The Lights in the Tunnel: Automation, Accelerating Technology and the Economy of the Future 2009
A Dangerous Master: How to Keep Technology from Slipping Beyond Our Control 2015
Rise of the Robots: Technology and the Threat of a Jobless Future 2016

 

We also mentioned using ternary operators

and Alternate Data Stream as data storage

Here’s the code Jackie walked through.

#SingleInstance,Force
username := "Jackie"

msgbox % "Name: " username "`nPassword: " password()
return
password(){
  FilePath := A_ScriptFullPath
  IniRead, Var, %FilePath%:Stream:$DATA, Settings, Pass, error
  If (Var="error"){
    InputBox, Var , New, Please enter password, HIDE
    IniWrite, %Var%, %FilePath%:Stream:$DATA, Settings, Pass
  }
  return Var
}

 

AutoHotkey Webinar- Finding presence of text in a large file

AutoHotkey webinarIn this working-session webinar we helped Dimitri with a project he was working on.  In short, he is looking for specific text in a “large” text file.  We discussed various approaches to the solution and created a few example solutions

Script Highlight:  Control panel objects by jNizM

Several things to consider before writing a solution

1.Just how large is/will the text file get?

A.Is the file going to be appended to over time?

2.Do you just need to answer “is the text value in the file” or do you need more information

A.how many occurrences

B.which lines it is on

C.other values related to it (key-value pairs, other fields, etc.)

3.Do you care if the text is found multiple times?

4.How important is speed

5.Would a “fuzzy search” help?

6.Will you be running single or multiple searches?

Possible Approaches for finding text in a large text file

  • Use InString on file read (see below example)
  • Shove it into an Object  (see below example)
  • Use built-in ADO database query by VXE
  • Use SQLite3

Simple InStr solution

Loop,Read, B:\the-automator\Webinar\Scripts\2020-01-Working Session\Dimitri\glbintf3.dat ;loop over data file (line by line)
  if InStr(A_LoopReadLine,"ENP-001213") ;If there is a : in the row, then proceed
    m(A_LoopReadLine,A_Index)

Shoving into an Object

  obj:={} ;Create object for storing data
  Loop,Read, B:\the-automator\Webinar\Scripts\2020-01-Working Session\Dimitri\glbintf3.dat ;loop over data file (line by line)
  {
    if InStr(A_LoopReadLine,":"){ ;If there is a : in the row, then proceed
      RegExMatch(A_LoopReadLine,"(\d+:)(\s+)?(?<Str>\S+.*)",arr_) ;Grab everything to the right of the : and push into Arr_Str
      obj[arr_Str]:=1
    }
  }
;********************Show all in object***********************************
  for k,v in obj
    output.=k "`n"
  MsgBox  %output% 
  
;********************Loop and find your value***********************************
  for k,v in obj{
    if(InStr(k,"ENP-003066"))
      m(k)
  }