c.haslam Posted November 27, 2008 Share Posted November 27, 2008 (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 November 27, 2008 by c.haslam Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard Link to comment Share on other sites More sharing options...
ProgAndy Posted November 27, 2008 Share Posted November 27, 2008 (edited) just use GUISetAccelerators Edited November 27, 2008 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 Link to comment Share on other sites More sharing options...
FireFox Posted November 27, 2008 Share Posted November 27, 2008 (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 November 27, 2008 by FireFox Link to comment Share on other sites More sharing options...
FireFox Posted November 27, 2008 Share Posted November 27, 2008 You can also simply do : HotKeySet("{LCTRL}{S}","_SaveData") Func _SaveData() If winActive("your app window","") Then ;your function EndIf EndFunc Link to comment Share on other sites More sharing options...
c.haslam Posted November 27, 2008 Author Share Posted November 27, 2008 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 Link to comment Share on other sites More sharing options...
oMBRa Posted November 27, 2008 Share Posted November 27, 2008 Many thanks to all....chrisBTW 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'' Link to comment Share on other sites More sharing options...
Robjong Posted November 27, 2008 Share Posted November 27, 2008 hey,you might want to take a look at thishttp://www.autoitscript.com/forum/index.ph...mp;#entry610163 Link to comment Share on other sites More sharing options...
c.haslam Posted November 28, 2008 Author Share Posted November 28, 2008 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 Link to comment Share on other sites More sharing options...
c.haslam Posted November 28, 2008 Author Share Posted November 28, 2008 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now