Windows AutoHotKey Dynamic Compile Procedure Content Tutorial

Windows AutoHotKey Dynamic Compile Procedure Content Tutorial

Windows AutoHotKey Dynamic Compile Procedure Content Tutorial

Yesterday’s Windows AutoHotKey Self Compile Procedure Content Tutorial had us …

  • with an underlying Windows operating system …
  • with a Windows MAMP environment installed and activated …
  • with the PHP (now changed) send_over.php web application both on the public RJM Programming domain web server (Document Root) and at the localhost Windows MAMP Apache/PHP/MySql web server (Document Root) …
  • with AutoHotKey scripting, to create Windows executable programs and desktop applications, installed …
  • with compileahk.ahk self compiler AutoHotKey scripting downloaded to user home directory on MAMP environment …

… we ended up with a Windows executable for that compileahk.ahk self compiler AutoHotKey script be created from that “online public world” web application in that “Intranet feeling” way we’ve been looking for.

But today we extend that to other AutoHotKey script (scenarios) entered into that “online public world” web application‘s textarea, along with a base filename different to “compileahk.ahk” we’re hoping (with users who are using this software seriously) to …

  1. dynamically “chunk” send that content to the Windows MAMP environment’s place of choice with the name of choice …
  2. choose a Windows executable filename (not the hardest bit of the project) …
  3. use the AutoHotKey compiler (via PHP exec) to compile the script into an executable …
  4. as required, take any user entered arguments into account, as we use PHP exec to execute that AutoHotKey derived executable …
  5. which we did using the Calculator AutoHotKey script of a few days ago in today’s tutorial picture

… to open the Windows Calculator desktop application with those button press logics.


Previous relevant Windows AutoHotKey Self Compile Procedure Content Tutorial is shown below.

Windows AutoHotKey Self Compile Procedure Content Tutorial

Windows AutoHotKey Self Compile Procedure Content Tutorial

Yesterday’s Windows AutoHotKey Self Compile Procedure Tutorial set up a second step …

feed the work above a prearranged Windows localhost user’s getenv(‘USERPROFILE’) (ie. HOME directory) script filename that has been populated, in parts as necessary via popup localhost calls from a public domain webpage (ours being the RJM Programming domain) using PHP code at both ends

… as a unit of work making the (Windows) AutoHotKey scripting a dynamically compiling concept, even from the “online world” view.

And today addresses a starting point, an Intranet based one, in that “online world” interfacing, with our new “proof of concept” send_over.php web application lives on …

  • the Document Root of RJM Programming domain’s Apache/PHP/MySql web server … and what makes things interesting …
  • we’d like you to download the send_over.php PHP code to (the Document Root of) a macOS or Windows MAMP local Apache/PHP/MySql web server environment

… as an “Intranet feeling” way for the online world (in the form of an HTML textarea element) formulate the “content” of the AutoHotKey scripting part of the jigsaw.

So, try all this out, and we’ll be thinking of the next best way proceeding to create Windows executables via AutoHotKey scripting, at the very least.


Previous relevant Windows AutoHotKey Self Compile Procedure Tutorial is shown below.

Windows AutoHotKey Self Compile Procedure Tutorial

Windows AutoHotKey Self Compile Procedure Tutorial

We have aims to involve the online world, in an Intranet way, in our, so far, just Windows, desktop focussed Windows AutoHotKey Procedure with Button Presses TutorialAutoHotKey musings”. There are two steps, at least, getting to where we want to go …

  1. get AutoHotKey scripting accept an AutoHotKey script and compile the script dynamically into a Windows executable (*.exe) program …
  2. feed the work above a prearranged Windows localhost user’s getenv(‘USERPROFILE’) (ie. HOME directory) script filename that has been populated, in parts as necessary via popup localhost calls from a public domain webpage (ours being the RJM Programming domain) using PHP code at both ends

… and today’s progress matches up with step 1 above.

We ended up this work today, such that …

Call ( after cd C:\MAMP\htdocs ) to get us to Windows MAMP Document Root as we can execute a DOS command line command …
compileahk “run calculator(])(])ExitApp”
Calling on ( AutoHotKey compiled compileahk.exe (Windows executable) via script compileahk.ahk ) to get us a getenv(‘USERPROFILE’) (ie. HOME directory) x.exe Windows executable, on the fly, to start up the Windows Calculator application …

EnvGet, vUserProfile, USERPROFILE

param := ""
paramtwo := "x.ahk"
paramthree := "x.exe"
yeslf := ""
dq := Chr(34)

Loop, %0% ; For each parameter:
{
if A_Index = 1
ZZ_Index = "%1%"
else
if A_Index = 2
ZZ_Index = "%2%"
else
if A_Index = 3
ZZ_Index = "%3%"

If ZZ_Index contains ".ahk"
{
paramtwo = "%ZZ_Index%"
paramthree := StrReplace(paramtwo, ".ahk", ".exe")
}
else
{
If ZZ_Index contains ".AHK"
{
paramtwo = "%ZZ_Index%"
paramthree := StrReplace(paramtwo, ".AHK", ".exe")
}
else
{
yeslf := StrReplace(ZZ_Index, "(])", "`r`n")
If StrLen("%yeslf%") = StrLen("%ZZ_Index%")
{

If ZZ_Index contains "."
{
FileDelete, %vUserProfile%\%paramtwo%
FileCopy, %ZZ_Index%, %vUserProfile%\%paramtwo%
}
else
{
If SubStr(yeslf, 1, 1) = Chr(34)
yeslf := SubStr(yeslf, 2, (Strlen(yeslf) - 2))

param := "yes"
}
}
else
If SubStr(yeslf, 1, 1) = Chr(34)
yeslf := SubStr(yeslf, 2, (Strlen(yeslf) - 2))

param := "yes" ; Fetch the contents of the variable whose name is contained in A_Index.
}
}
}

If StrLen(param) != 0
{
FileDelete, %vUserProfile%\%paramtwo%
FileAppend, %yeslf%, %vUserProfile%\%paramtwo%
}

IfWinExist Ahk2Exe.exe for AutoHotKey
WinActivate
else
{
Run c:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe /in %vUserProfile%\%paramtwo% /out %vUserProfile%\%paramthree%
WinActivate Ahk2Exe.exe for AutoHotKey
}

Run %vUserProfile%\%paramthree%

return

Stay tuned for more pieces of the jigsaw to be resolved!


Previous relevant Windows AutoHotKey Procedure with Button Presses Tutorial is shown below.

Windows AutoHotKey Procedure with Button Presses Tutorial

Windows AutoHotKey Procedure with Button Presses Tutorial

We want to focus, today, on …

  • underlying operating system (today, Windows) …
  • desktop application … that addresses …
  • repeatable procedure … that involves …
  • button presses … at a position on that desktop application window

. Were you “all in” until that last limitation? Yes, it makes the idea of turning such a task into a programmable (scriptable) procedure that bit more difficult.

But what about if we think about a great Windows third party “procedure scripting tool” called AutoHotKey, as with the recent Windows AutoHotKey Communication Opener Tutorial?

Let’s start with a concept that one word is enough for a lot of us to imagine the issues and possibilities …


Calculator

Now writing this AutoHotKey calculator.ahk script that needs “button press positioning smarts” without the wonderful “Recorder” functionality of the past (boo, hoo) you can turn to AutoHotKey’s Windows Spy application as a reasonable alternative. You can see it in action with today’s tutorial animated GIF that helped us create …


IfWinExist Calculator
WinActivate
else
Run calculator://
WinActivate calculator

// 75 / 8 =

CoordMode, Mouse, Window
Click 208,228
Sleep, 2500
Click 48,338
Sleep, 500
Click 129,397
Sleep, 500
Click 286, 282
Sleep, 500
Click 129, 338
Sleep, 500
Click 286, 496
return

… to open (as required) the Windows Calculator desktop application and press buttons so as to solve …

75 ➗ 8 =

?


Previous relevant Windows AutoHotKey Communication Opener Tutorial is shown below.

Windows AutoHotKey Communication Opener Tutorial

Windows AutoHotKey Communication Opener Tutorial

We wanted to work on the AutoHotKey scripting of yesterday’s Windows AutoHotKey Mail Opener Tutorial in a few functionality improvements …

  • set up to be #SingleInstance to make it that one Hot Key call equals one AutoHotKey program execution …
  • be able to create a temporary file maintenance (via Ctrl+Alt+n) via call of Notepad to be able to edit a user defined email body content, optionally …
  • that Notepad content be read and if first record integer content only … understand it as …
  • SMS, rather than email … but, alas, the sms:[SMSnumber]&body=[BodyContent] (URL) only worked on this Windows 10 with Microsoft Messenger just to open that app but not fill in either of [SMSnumber] nor [BodyContent] … but who’s to say is doesn’t work for your Windows setup?!

Here’s the changed AutoHotKey script called StartMail.ahk that achieves this progress, once compiled that is


#SingleInstance

^!n::
FormatTime timestamp, A_Now, yyyyMMdd
IfWinExist Untitled - Notepad
WinActivate
else
Run, Notepad "%TEMP%\bodyidea_%timestamp%.txt"
return

^!g::
VerbVar := "mailto:rmetcalfe15@gmail.com?subject=Which Old Thing..."
FormatTime timestamp, A_Now, yyyyMMdd
Ale := "%0A"
GetArg := "&"
ZeroOne := 0
HBodyVar =
BodyVar =
ifExist, %TEMP%\bodyidea_%timestamp%.txt
FileReadLine, HBodyVar, %TEMP%\bodyidea_%timestamp%.txt, 1
if HBodyVar is integer
{
VerbVar = sms:%HBodyVar%
ZeroOne := "1"
GetArg := "&"
}

Loop, read, %TEMP%\bodyidea_%timestamp%.txt
{
IfEqual, ZeroOne, 0
{
BodyVar = %BodyVar%%A_Space%%Ale%%A_LoopReadLine%
}

ZeroOne := 0
}

IfWinExist Mail
WinActivate
else
Run, "%VerbVar%%GetArg%body=%BodyVar%"
return

^!r::
VerbVar := "mailto:rmetcalfe@rjmprogramming.com.au.com?subject=That Old Thing..."
FormatTime timestamp, A_Now, yyyyMMdd
Ale := "%0A"
GetArg := "&"
ZeroOne := 0
HBodyVar =
BodyVar =
ifExist, %TEMP%\bodyidea_%timestamp%.txt
FileReadLine, HBodyVar, %TEMP%\bodyidea_%timestamp%.txt, 1
if HBodyVar is integer
{
VerbVar = sms:%HBodyVar%
ZeroOne := "1"
GetArg := "&"
}

Loop, read, %TEMP%\bodyidea_%timestamp%.txt
{
IfEqual, ZeroOne, 0
{
BodyVar = %BodyVar%%A_Space%%Ale%%A_LoopReadLine%
}

ZeroOne := 0
}

IfWinExist Mail
WinActivate
else
Run, "%VerbVar%%GetArg%body=%BodyVar%"
return

We hope you try this out!


Previous relevant Windows AutoHotKey Mail Opener Tutorial is shown below.

Windows AutoHotKey Mail Opener Tutorial

Windows AutoHotKey Mail Opener Tutorial

Just as you can revisit web applications, you might often revisit whole concepts, because as the years and software versions change, so might these whole concepts. Today’s case in point is a great Windows tool for programmers called AutoHotKey we’ve talked a lot about at this blog

AutoHotkey is a free, open-source scripting language for Windows that allows users to easily create small to complex scripts for all kinds of tasks such as: form fillers, auto-clicking, macros, etc.

Are you always in the “online woooorrrllldd” or are you on Windows and still find desktop jobs you want to automate? If you are in the latter category, AutoHotKey could be your way to associate your own Hot Key combinations with whole sequences of a task, or just the starting bits, as with our entry level opening of Windows Mail with a To emailee and subject associated in the one AutoHotKey compiled *.exe for two Hot Key creations via the AutoHotKey script we’ve called StartMail.ahk


^!g::
IfWinExist Mail
WinActivate
else
Run, "mailto:rmetcalfe15@gmail.com?subject=Which Old Thing..."
return

^!r::
IfWinExist Mail
WinActivate
else
Run, "mailto:rmetcalfe@rjmprogramming.com.au?subject=That Old Thing..."
return

… the Hot Key associated with today’s tutorial picture being Ctrl+Alt+g (ie. that first, of two, Hot Key definitions in the AutoHotKey script above, whereas the second could be executed via Ctrl+Alt+r).

This, to me, is like “looking under the hood” of Windows, especially if you start up AutoHotKey’s excellent “Window Spy” tool (that can help you glean a focussed window of interest’s details that you might be interested in). Can you believe in years gone past you used to be able to Record your actions, though that is not offered free anymore, or not feasible anymore (the latter a reason that would not surprise us … but a little hard graft … “bliss” … I can hear you say?!)? These Windows *.exe you can create via AutoHotKey used to be a less security restricted idea, but AutoHotKey can help you quickly realize that joy creating desktop programs can give you.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Operating System, Software, Tutorials and tagged , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

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