Jump to content

Recommended Posts

Posted (edited)

In an Autoit script, I set Ctrl_S as a hotkey: HotKeySet("^s","SaveData"). Ctrl_S should only execute SaveData() when Form1 is active; a menuitem on this form is "Save Ctrsl_S".

I then open another application. When I press Ctrl_S, SaveData() is executed. This is not what I want!

How do I restrict execution of SaveData() to when the script is running and this form is active?

...chris

Edited by c.haslam
Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Posted (edited)

just use GUISetAccelerators :)

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted (edited)

just use GUISetAccelerators :)

Hi,

You can use _IsPressed with options

#Include <misc.au3>

While 1
If _Ispressed("11") and _IsPressed("53") and WinActive("yourapp","") Then
;if ctrl+s and the window of your app is active
_SaveData()
Endif
Wend
Edited by FireFox
Posted

You can also simply do :

HotKeySet("{LCTRL}{S}","_SaveData")

Func _SaveData()
If winActive("your app window","") Then
;your function
EndIf
EndFunc
Posted

Many thanks to all.

...chris

BTW Where do I find the codes for HotKey() and _IsPressed()? I have found a table of ASCII character codes in the Help, but not for keystrokes.

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Posted

Many thanks to all.

...chris

BTW Where do I find the codes for HotKey() and _IsPressed()? I have found a table of ASCII character codes in the Help, but not for keystrokes.

search in the help file for ''Send Key List''

Posted

Robjong,

Thanks. I have the GUISetAccelerators() approach working.

...chris

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Posted

search in the help file for ''Send Key List''

The Send Key List gives the constituent parts of the argument of SendKeys (and GUISetAccelerators) but _isPressed takes a numeric argument.

...chris

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...