AHK-Scripts with different versions of Windows: Difference between revisions

From TotalcmdWiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
hello
Often a hotkey should only work in particular circumstances - i.e. when a special window is active. Otherwise the key should work as usual.
 
== Windows NT/2000/XP ==
The preferred method is ''#IfWin...'' (new since AHK-Version 1.0.41), because the code is more clearly the with the old syntax. Example:
 
#IfWinActive, ahk_class Notepad
^a::
MsgBox You have presed Ctrl-A while Notepad was active.
return
 
== Windows 95/98/ME ==
The new ''#IfWin...''-method is not completely supported in this Windows versions and unfortunately it is not planned this support to implement in future.
If Notepad is active the script work as expected. Otherwise Ctrl-A does not do anything, the keypress is 'highjacked'. Normally this is not desirable so it is recommended to use the following method:
 
 
$^a::    ; Using the $ prefix a hotkey can 'send itself'
IfWinActive, ahk_class Notepad
{
  MsgBox You have presed Ctrl-A while Notepad was active.
  return
}
Send ^a
return
 
This syntax works with all windows versions. Disadvantage is that you easy loose track in complex scripts. Additonal the conversion of Scripts with the new syntax to this one will be a lot of work.
 
 
 
== new proposal ==
 
The following method to re-write those scripts for '''Windows 95/98/ME''' is much easier - especially for extensive scripts. Though it has been described not long ago and there are not many experiences with this method.
 
Some additional lines at the begin of the script re-establish the normal key functions
 
#IfWinNotActive, ahk_class Notepad
$^a:: Send ^a
#IfWinActive, ahk_class Notepad
^a::
MsgBox Du hast Strg-A gedrückt während Notepad aktiv ist.
return
 
Those Scripts seem to run also with '''Windows NT/2000/XP'''!
 
Known problems while using this new syntax with AutoHotkey 1.0.44.04 or newer (please complete!):<br>
* Windows 95: not yet testet
* Windows 98: till now no problems known
* Windows ME: not yet testet
* Windows NT: not yet testet
* Windows 2K: not yet testet
* Windows XP: not yet extensively tested
 
 
'''Quellen'''<br>
[http://www.autohotkey.com/docs/FAQ.htm#HotContext Englische AutoHotkey-FAQ]<br>
[http://ghisler.ch/board/viewtopic.php?p=89055#89055 Deutsches Total Commander-Forum]
 
 
 
 
{{translated|AHK-Skripte_unter_verschiedenen_Windows-Versionen|AutoHotkey}}

Revision as of 22:11, 3 June 2006

Often a hotkey should only work in particular circumstances - i.e. when a special window is active. Otherwise the key should work as usual.

Windows NT/2000/XP

The preferred method is #IfWin... (new since AHK-Version 1.0.41), because the code is more clearly the with the old syntax. Example:

#IfWinActive, ahk_class Notepad
^a::
MsgBox You have presed Ctrl-A while Notepad was active.
return

Windows 95/98/ME

The new #IfWin...-method is not completely supported in this Windows versions and unfortunately it is not planned this support to implement in future. If Notepad is active the script work as expected. Otherwise Ctrl-A does not do anything, the keypress is 'highjacked'. Normally this is not desirable so it is recommended to use the following method:


$^a::     ; Using the $ prefix a hotkey can 'send itself'
IfWinActive, ahk_class Notepad
{
  MsgBox You have presed Ctrl-A while Notepad was active.
  return
}
Send ^a
return

This syntax works with all windows versions. Disadvantage is that you easy loose track in complex scripts. Additonal the conversion of Scripts with the new syntax to this one will be a lot of work.


new proposal

The following method to re-write those scripts for Windows 95/98/ME is much easier - especially for extensive scripts. Though it has been described not long ago and there are not many experiences with this method.

Some additional lines at the begin of the script re-establish the normal key functions

#IfWinNotActive, ahk_class Notepad
$^a:: Send ^a

#IfWinActive, ahk_class Notepad
^a::
MsgBox Du hast Strg-A gedrückt während Notepad aktiv ist.
return

Those Scripts seem to run also with Windows NT/2000/XP!

Known problems while using this new syntax with AutoHotkey 1.0.44.04 or newer (please complete!):

  • Windows 95: not yet testet
  • Windows 98: till now no problems known
  • Windows ME: not yet testet
  • Windows NT: not yet testet
  • Windows 2K: not yet testet
  • Windows XP: not yet extensively tested


Quellen
Englische AutoHotkey-FAQ
Deutsches Total Commander-Forum




Back to AutoHotkey