Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

v1.0.43 released: Send keystrokes faster & more reliably


  • Please log in to reply
25 replies to this topic
corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004
Nice. Thanks :)

Added "WinGet ControlListHwnd", which retrieves a list of control HWNDs; 3) Added "ControlGet Hwnd", which retrieves the HWND that corresponds to a control's ClassNN.

Out of curiosity, do these use FindWindowEx internally?

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Aaah, very nice one, with long waited features!
At least we can get rid of this GetChildHWND we pasted in so many scripts!
I will download it right now!
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

Out of curiosity, do these use FindWindowEx internally?

"WinGet ControlListHwnd" uses EnumChildWindows() to write each child's HWND to the list.

"ControlGet Hwnd" calls the standard ControlExist(ParentWindow, ClassNameAndNum), which is used by almost all of the ClassNN-accepting commands. It calls EnumChildWindows() to locate the specified instance number (NN of the ClassNN) or the specified text (such as the string "OK" on an OK button).

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Here are the changes for v1.0.43.07:

Fixed inability of "Menu, Tray, Icon" to load icon #1 from file types cpl/scr/drv/ocx/vbx/acm/bpl (broken by 1.0.43.03). Similarly, all icon-capable features have been improved to support these file types. [thanks Winkie & PhiLho]

Fixed the following legacy commands to accept function-calls containing commas: EnvAdd/Sub, LeftClick(Drag), RightClick(Drag). [thanks Titan]

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Here are the changes for v1.0.43.08:

Changed SendInput to use "SetKeyDelay -1, 0" when it reverts to SendEvent mode (unless SendEvent's KeyDelay "-1,-1", in which case "-1,-1" is used).

Added directive #NoEnv, which is recommended for all new scripts because:

1) It significantly improves performance whenever empty variables are used in an expression or command. It also improves DllCall's performance when unquoted parameter types are used (e.g. int vs. "int").

2) It prevents script bugs caused by environment variables whose names unexpectedly match variables used by the script.

3) A future version of AutoHotkey such as 1.1 might force this behavior into effect for all scripts (though such a change is not expected for at least a year).

Added built-in variables ComSpec and ProgramFiles to ease the transition to #NoEnv.

Added command EnvGet, which retrieves an environment variable.

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
With #NoEnv the speed relations are changed between the dll calls with quoted parameter types, and unquoted ones.
#NoEnv

T0 = %A_TickCount%
Loop 1000000
   DllCall("SystemParametersInfo",  UInt ,0x68,  UInt ,0,  UIntP ,X,  UInt ,0)
  ;DllCall("SystemParametersInfo", "UInt",0x68, "UInt",0, "UIntP",X, "UInt",0)
MsgBox % A_TickCount - T0
Quoted -> 44344, 37653, 44015 42813, 43781 ("UInt*" works, too)
Unquoted -> 41735, 32656, 41844, 40375, 34171 (UInt* is not OK, use UIntP)

It looks like, referencing a special variable (UInt) is faster, than parsing a literal string. Taking the idea one step further, the fastest version is
#NoEnv

func = SystemParametersInfo
T0 = %A_TickCount%
Loop 1000000
   DllCall(func, UInt,0x68, UInt,0, UIntP,X, UInt,0)
MsgBox % A_TickCount - T0
Func -> 38031, 39328, 33469, 30812, 33594

It is interesting how much the execution time fluctuates. The loop runs a million times, still there is more than 20% variation in the measured time.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Interesting results; thanks for posting them. I tested a variant of the above but didn't get such a big deviation. Here are the changes I made:
- Half as many iterations.
- SetBatchLines -1
- Only three trials

My results for the script below (trial1/trial2/trial3):
4115/4106/4096 quoted param types
4166/4126/4156 unquoted param types (slightly slower than above for some reason)
3866/3856/3855 unquoted param types & function name (~8% faster for some reason)

With #NoEnv omitted, the last two rows above took over 4 times as long.
#NoEnv
SetBatchLines -1

T0 = %A_TickCount%
Loop 500000
	DllCall("SystemParametersInfo", "UInt",0x68, "UInt",0, "UIntP",X, "UInt",0)
Elapsed1 := A_TickCount - t0

T0 = %A_TickCount%
Loop 500000
	DllCall("SystemParametersInfo",  UInt ,0x68,  UInt ,0,  UIntP ,X,  UInt ,0)
Elapsed2 := A_TickCount - t0

func = SystemParametersInfo 
T0 = %A_TickCount%
Loop 500000
	DllCall(func, UInt,0x68, UInt,0, UIntP,X, UInt,0)
Elapsed3 := A_TickCount - t0

MsgBox %Elapsed1%`n%Elapsed2%`n%Elapsed3%


Lemming
  • Members
  • 184 posts
  • Last active: Feb 03 2014 11:03 AM
  • Joined: 20 Dec 2005
Great idea, #NoEnv.

This will help prevent mysterious results for users who like to use variable names like TEMP, TMP, USERNAME, and PATH.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Here are the changes for v1.0.43.09:

Fixed SendInput not to revert to SendEvent merely because another script has a mouse hook. Only another keyboard hook should do that. [thanks baby-luck]

Fixed LV_GetCount() to work even if the "C" in its name is lowercase.

Changed FileSelectFile to follow/navigate shortcuts (.lnk files) rather than selecting them. There is also a new option to override this. [thanks Veovis & PhiLho]

Added "Gui +LastFoundExist" to detect the existence of a GUI window. [thanks Tekl & Evl]

Added built-in variables A_AppData, A_AppDataCommon, and A_Temp (A_Temp is the path to the folder designated to hold temporary files).

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Here are the changes for v1.0.43.10:

Improved PixelGetColor with two alternate modes that work in a broader variety of windows and full-screen apps. [thanks TDMedia]

Improved StringMid to allow "Count" to be omitted to retrieve all characters. [thanks kapege.de]

Improved FileSelectFile to support special folders such as My Computer via CLSID strings (FileSelectFolder and Run already support them).

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Here are the changes for v1.0.43.11:

Fixed %A_WorkingDir% on Windows 9x, which was sometimes blank. [thanks Points]

Improved BlockInput with a new mode that blocks only physical movement of the mouse, not keystrokes or mouse clicks.