ScriptInfo(): Get ListLines/ListVars/ListHotkeys/KeyHistory text

Post your working scripts, libraries and tools
lexikos
Posts: 5831
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

ScriptInfo(): Get ListLines/ListVars/ListHotkeys/KeyHistory text

28 Sep 2015, 05:43

ScriptInfo(Command)

Returns the text that would have been shown in AutoHotkey's main window if you had called Command, but without actually showing or activating the window.

Command must be "ListLines", "ListVars", "ListHotkeys" or "KeyHistory".

Example usage:

Code: [Select all] [Download] GeSHi © Codebox Plus

#InstallKeybdHook
InputBox t,, Press some keys to fill the key history.
MsgBox % ScriptInfo("KeyHistory")
ExitApp


Code: [Select all] [Expand] [Download] (ScriptInfo.ahk)GeSHi © Codebox Plus


Caveats:
  • You have to parse the text yourself to extract whatever information you want.
  • If the main window is already visible, its content will be changed.
  • ListLines shows the lines inside ScriptInfo().
  • ListVars shows ScriptInfo()'s local variables (but also global variables).

It's based on ListGlobalVars.

I'm not interested enough to do more with it.
User avatar
joedf
Posts: 6214
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: ScriptInfo(): Get ListLines/ListVars/ListHotkeys/KeyHistory text

28 Sep 2015, 13:50

Quite interesting! I remember of something i posted in the past where i suggested someone to go access ahk's ram (or using a hidden window of some kind) to get this kind of info.
And here it is! :+1:
User avatar
Nextron
Posts: 1102
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win7 x64 AHK: Unicode x32

Re: ScriptInfo(): Get ListLines/ListVars/ListHotkeys/KeyHistory text

28 Sep 2015, 21:02

Definitely something to keep around.

Until something better comes along, this brings some structure to the key history output:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


For example:

Code: [Select all] [Download] GeSHi © Codebox Plus

$F1::
KeyHistory:=ParseKeyHistory()
MsgBox % "Time since last keypress: " KeyHistory[KeyHistory.MaxIndex()]["Elapsed"] " s."
return
F2::
MsgBox % "The keyboard hook is " (ParseKeyHistory()[0]["K-hook"] ? "enabled." : "disabled.")
Hotkey,$F1,Off
MsgBox % "The keyboard hook is " (ParseKeyHistory()[0]["K-hook"] ? "enabled." : "disabled.")
Hotkey,$F1,On
return
The more I know:
The more I know,
I know nothing.
just me
Posts: 5300
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: ScriptInfo(): Get ListLines/ListVars/ListHotkeys/KeyHistory text

29 Sep 2015, 01:52

IMO, it would be much better to have it as a built-in function without the need to overwrite the contents of user32.dll (and without the example how this can be done).
lexikos
Posts: 5831
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: ScriptInfo(): Get ListLines/ListVars/ListHotkeys/KeyHistory text

29 Sep 2015, 03:34

overwrite the contents of user32.dll
Perhaps you're being lazy with words; I'm fairly certain you understand that it is not overwriting a DLL file. It does not even affect processes other than the script's own process, since AutoHotkey 1.1 does not run on Win9x...

(and without the example how this can be done).
What do you mean? Assuming you are referring to "the example" of disabling a dll function within the script's memory space, AutoHotkey.exe and the documentation is and always will be "without the example". The example has been posted in several places over the years, and will stay regardless of whether this function is built-in.


I'm not very interested in using the information this function provides, as I indicated in the top post. Now that the information is easy to access (with this function), there is opportunity for users to prove that the information is actually useful, which might increase my motivation to provide some built-in way to access it.
User avatar
Trogluddite
Posts: 8
Joined: 23 Mar 2018, 06:42

Re: ScriptInfo(): Get ListLines/ListVars/ListHotkeys/KeyHistory text

23 Mar 2018, 07:15

Apologies for re-animating such an old thread (and with my first post too :roll: ), but this was exactly the function that I've been trying to work out for myself for about a week now!
Thankyou very much Lexicos! :D

lexikos wrote:there is opportunity for users to prove that the information is actually usefu

Now that I have this function to work from, I shall take you up on that! :mrgreen:

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 21 guests