[Archived, Locked] Suggestions on documentation improvements

Share your ideas as to how the documentation can be improved.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Suggestions on documentation improvements

20 Sep 2016, 05:27

just me wrote:I said "on Win XP". You might want to try my test script:
Thank you for this just me, it turned out to be interesting, also, I guess I didn't understand your querry at first (possibly, I still don't). I was a little surprised by the results from your script at first, but I hadn't realised that the A_TickCount had a precision of ~10ms, I assumed it was ~1ms. So that's was a good discovery.

I get sleeps in the range ~(1,20) ms measuring with the QPC function, measuring Sleep,1, so there doesn't seem to be any rounding the delay to 10 or 15.6 as the docs suggests (may happen).

Code: Select all

Sleep, 1 ; to 'sync' the script with A_TickCount
This didn't seem to sync the script, does it for you?. Note this:
MSDN wrote:After the sleep interval has passed, the thread is ready to run. If you specify 0 milliseconds, the thread will relinquish the remainder of its time slice but remain ready. Note that a ready thread is not guaranteed to run immediately. Consequently, the thread may not run until some time after the sleep interval elapses.

Sleep
This seems to give more consitent sleeps:

Code: Select all

S := A_TickCount
While (S=A_TickCount){
}
DllCall("QueryPerformanceCounter", "Int64P", C1)
Sleep, %SL%
DllCall("QueryPerformanceCounter", "Int64P", C2)
It gives me a range of ~(15,20). I suppose there is a variation between systems.
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Suggestions on documentation improvements

20 Sep 2016, 15:57

Helgef wrote:

Code: Select all

Sleep, 1 ; to 'sync' the script with A_TickCount
This didn't seem to sync the script, does it for you?
I get durations around 15.6 ms here after the Sleep, 1.
User avatar
lmstearn
Posts: 688
Joined: 11 Aug 2016, 02:32
Contact:

Re: Suggestions on documentation improvements

20 Sep 2016, 16:47

One wish (edit: or two):
This topic be (meta)-tagged "help file" "help file inclusions" or "help file additions" etc. Don't know if the forum S/W supports this.

Love the help file!
Don't know if these are possible for HTMLhelp in use.
Find_again (typically F3) in the right pane would be nice.
Search in the left pane highlights the terms nicely, but they won't be un-highlighted until another search or a search for " ".
Would the use of a more recent version of HTMLhelp make any difference?

Also please include Lexikos's snippet from this thread into the Sendmessage topic with a little explanation- possibly linked to/from combobox/dropdown/listbox as it is not easy to find with the usual methods.
Couldn't find HWND<variablename> for "Gui, Add" in help. If not there, worth a mention?
If it's of use to anyone another bunch of Windows Messages with codes here. :)

Thanks!
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
User avatar
WAZAAAAA
Posts: 88
Joined: 13 Jan 2015, 19:48

Re: Suggestions on documentation improvements

05 Nov 2016, 15:26

I feel like the A_IsAdmin documentation should not include the following code:

Code: Select all

if not A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+
   ExitApp
}
When I try to launch any script with such code while having no admin rights, the script will quickly re-launch itself forever in an endless unstoppable loop because administrator privileges will never be detected. Doing this will also slow down the entire computer tremendously. This GIF I made should sum it up pretty well:
Image

I personally have UAC 100% disabled, it doesn't affect me, so I had to test the code under 3 different situations:
- launching a compiled .EXE through Process Hacker's "Run as limited user..." with my main Administrator UAC-disabled account
- using Windows 7 default Guest user
- using a Windows 7 Standard user
...in each case, the insane loop shown in the GIF would start, forcing me to either restart the computer, log off the affected user or forcefully delete the EXE using Unlocker.

Countless of user-created scripts use that code. My idea would be to replace it with an informative message box like this, and let the user take care of it manually (OR NOT, since not every AHK script really needs admin rights):

Code: Select all

if not A_IsAdmin
{
	MsgBox, You are running this script with no administrator rights, so it may or may not work correctly. In case of issues, locate your AutoHotkey executable, grant it admin rights and restart this script.
}
YOU'RE NOT ALEXANDER
lexikos
Posts: 9559
Joined: 30 Sep 2013, 04:07
Contact:

Re: Suggestions on documentation improvements

05 Nov 2016, 18:57

That's disappointing. On XP, which obviously didn't have UAC, *RunAs shows a dialog requesting alternative credentials.

Preventing the runaway loop is very simple: pass a command line switch.

Code: Select all

if not (A_IsAdmin || %false%)
{
   Run *RunAs "%A_ScriptFullPath%" 1  ; Requires v1.0.92.01+
   ExitApp
}
There are other ways, like detecting whether UAC is enabled.

Running taskkill /FI "IMAGENAME eq AutoHotkey.exe" /F a few times is usually sufficient to kill a runaway restart loop.

I will make some changes to the documentation.
TAC109
Posts: 1099
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Suggestions on documentation improvements

05 Nov 2016, 22:27

'StrReplace' does not appear in the index of commands/functions, nor does it appear in the list of built in functions.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
User avatar
WAZAAAAA
Posts: 88
Joined: 13 Jan 2015, 19:48

Re: Suggestions on documentation improvements

06 Nov 2016, 07:47

lexikos wrote:That's disappointing. On XP, which obviously didn't have UAC, *RunAs shows a dialog requesting alternative credentials.

Preventing the runaway loop is very simple: pass a command line switch.

Code: Select all

if not (A_IsAdmin || %false%)
{
   Run *RunAs "%A_ScriptFullPath%" 1  ; Requires v1.0.92.01+
   ExitApp
}
There are other ways, like detecting whether UAC is enabled.

Running taskkill /FI "IMAGENAME eq AutoHotkey.exe" /F a few times is usually sufficient to kill a runaway restart loop.

I will make some changes to the documentation.
That seems to be a good solution, love it. Tested again on a W7 Guest account, W7 Standard user and Process Hacker's "Limited user". On each of them the process restarted only once.
I'm personally going to the change the top of some of my scripts with that, together with a MsgBox.

Code: Select all

REDACTED
EDIT: actually, it doesn't work well, I never tested noncompiled scripts
Last edited by WAZAAAAA on 07 Nov 2016, 14:17, edited 1 time in total.
YOU'RE NOT ALEXANDER
User avatar
WAZAAAAA
Posts: 88
Joined: 13 Jan 2015, 19:48

Re: Suggestions on documentation improvements

07 Nov 2016, 14:14

lexikos, I have tested the recent Run-Script.ahk on Windows 7 and found that it has still a few issues under different conditions

The tested code:

Code: Select all

full_command_line := DllCall("GetCommandLine", "str")

if not (A_IsAdmin or InStr(full_command_line, " /restart "))
{
    try
    {
        if A_IsCompiled
            Run *RunAs "%A_ScriptFullPath%" /restart
        else
            Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
    }
    ExitApp
}

MsgBox A_IsAdmin: %A_IsAdmin%`nCommand line: %full_command_line%
The outcomes:

Code: Select all

Administrator account UAC OFF:
-Compiled	> A_IsAdmin=1
-Script		> A_IsAdmin=1

Administrator account UAC ON:
-Compiled	UAC Yes	> A_IsAdmin=1
-Compiled	UAC No	> ExitApp
-Script		UAC Yes	> A_IsAdmin=1
-Script		UAC No	> ExitApp

Standard/Guest account UAC ON:
-Compiled	Input admin password prompt	> A_IsAdmin=1
-Compiled	Don't input admin password	> ExitApp
-Script		Input admin password prompt	> A_IsAdmin=1
-Script		Don't input admin password	> ExitApp

Standard/Guest account UAC OFF:
-Compiled	> runaway loop
-Script		> A_IsAdmin=0
Running a compiled script under a Standard user with UAC OFF will loop it like in the animated picture.
In my opinion the documentation script should never ExitApp but rather MsgBox A_IsAdmin=0 instead.
YOU'RE NOT ALEXANDER
lexikos
Posts: 9559
Joined: 30 Sep 2013, 04:07
Contact:

Re: Suggestions on documentation improvements

07 Nov 2016, 16:23

That's because of the (lack of) space after /restart.

Having ExitApp there makes the instructions below the example easier.
User avatar
WAZAAAAA
Posts: 88
Joined: 13 Jan 2015, 19:48

Re: Suggestions on documentation improvements

08 Nov 2016, 19:41

Admin rights R SRS BUSINESS so I tested the fixed Run-Script.ahk on multiple operating systems (XP/W7/W8.1/W10) under both administrator and standard user accounts, with UAC ON and OFF, compiled and non-compiled. It worked everywhere, great job.

I'm going to put this on top of some of my scripts from now on:
Spoiler
Last edited by WAZAAAAA on 19 Jun 2017, 20:15, edited 3 times in total.
YOU'RE NOT ALEXANDER
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: Suggestions on documentation improvements

08 Nov 2016, 20:40

i just got tired of users ignoring the admin message so i added the requirement in the manifest file and now my compiled exe auto prompts for admin privs

guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: Suggestions on documentation improvements

15 Nov 2016, 20:22

https://autohotkey.com/docs/commands/StringReplace.htm

OutputVarCount param is optional but the definition indicates otherwise

lexikos
Posts: 9559
Joined: 30 Sep 2013, 04:07
Contact:

Re: Suggestions on documentation improvements

15 Nov 2016, 22:23

What are you talking about? OutputVarCount is between the [] brackets.
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Suggestions on documentation improvements

15 Nov 2016, 22:28

I think it's because the descriptions on the other optional parameters include in their description "If omitted". But I also don't think the description needs to be changed. It would be redundant to say "If omitted, you will not have populated a variable with a count for how many replacements were made."
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Suggestions on documentation improvements

15 Nov 2016, 22:30

true, true but then again... you always have a choice. :trollface:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: Suggestions on documentation improvements

15 Nov 2016, 23:04

lexikos wrote:What are you talking about? OutputVarCount is between the [] brackets.
i'm an idiot

i saw the last "Limit := -1" and i thought it was only optional if the := was shown

TAC109
Posts: 1099
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Suggestions on documentation improvements

04 Dec 2016, 21:14

format() is missing from the list of built-in functions.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
User avatar
Almost_there
Posts: 404
Joined: 30 Sep 2014, 10:32

Re: Suggestions on documentation improvements

24 Jan 2017, 19:18

Haven't read through whole this thread, but I see several forum members do this, and the help file does not mention it.

It is clearly possible to combine assignment and comparison within same If statement, and same line.

Code: Select all

originalValue := 250
newValue := 2
If (originalValue := newValue)
	MsgBox, If statement was TRUE - The value of the `"originalValue`" is now %originalValue%
Else
	MsgBox, If statement was FALSE - The value of the `"originalValue`" is now %originalValue%
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Suggestions on documentation improvements

24 Jan 2017, 20:06

TAC109 wrote:format() is missing from the list of built-in functions.
You're this page should link to this page, right?
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
TAC109
Posts: 1099
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Suggestions on documentation improvements

24 Jan 2017, 20:47

joedf wrote:
TAC109 wrote:format() is missing from the list of built-in functions.
You're this page should link to this page, right?
Correct!
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe

Return to “Suggestions on Documentation Improvements”

Who is online

Users browsing this forum: No registered users and 9 guests