AlienStar Posted November 7, 2018 Share Posted November 7, 2018 (edited) hello everybody I'm using HotKeySet for ENTER but then I'm not able to use ENTER in other programs to solve I set it only when the windows is active but it failed $title = "hello" $hGUI = GUICreate($title, 500, 500) While 1 $GUIMsg = GUIGetMsg() Select Case $GUIMsg = $GUI_EVENT_CLOSE Exit Case WinActive($GUI_ttl)= False HotKeySet("{ENTER}", "ENTER_KEY") EndSelect WEnd Func ENTER_KEY() Msgbox(0,"OK","Entered") EndFunc where is the wrong in my code ? please help Edited November 10, 2018 by AlienStar Link to comment Share on other sites More sharing options...
BrewManNH Posted November 7, 2018 Share Posted November 7, 2018 You can set it up using GUISetAccelerators instead of Hotkeys. AlienStar 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
AlienStar Posted November 7, 2018 Author Share Posted November 7, 2018 24 minutes ago, BrewManNH said: You can set it up using GUISetAccelerators instead of Hotkeys. here is the code I edit $title = "hello" $hGUI = GUICreate($title, 500, 500) Local $aAccelKeys[1][1] = [["{ENTER}", ENTER_KEY()]] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) While 1 $GUIMsg = GUIGetMsg() Select Case $GUIMsg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func ENTER_KEY() Msgbox(0,"OK","Entered") EndFunc where is the wrong ? the function ENTER_KEY() is executed without press ENTER !!!! Link to comment Share on other sites More sharing options...
BrewManNH Posted November 7, 2018 Share Posted November 7, 2018 Something like this (untested) $title = "hello" $hGUI = GUICreate($title, 500, 500) $cDummy = GUICtrlCreateDummy() Local $aAccelKeys[1][1] = [["{ENTER}", $cDummy]] GUISetAccelerators($aAccelKeys, $hGUI) GUISetState(@SW_SHOW) While 1 $GUIMsg = GUIGetMsg() Select Case $GUIMsg = $GUI_EVENT_CLOSE Exit Case $cDummy ENTER_KEY() EndSelect WEnd Func ENTER_KEY() MsgBox(0, "OK", "Entered") EndFunc ;==>ENTER_KEY If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
AlienStar Posted November 7, 2018 Author Share Posted November 7, 2018 it sent me this error "C:\Users\Master\Desktop\New AutoIt v3 Script (14).au3" (12) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: Local $aAccelKeys[1][1] = [["{ENTER}", $cDummy]] Local $aAccelKeys[1][1] = [["{ENTER}", ^ ERROR Link to comment Share on other sites More sharing options...
BrewManNH Posted November 8, 2018 Share Posted November 8, 2018 I told you it was untested, how are you going to fix it? Think of it as a learning experience. I have included the corrected version that works right, but you should try to fix it for yourself first, minor problem in the code. Spoiler #include <GUIConstantsEx.au3> $title = "hello" $hGUI = GUICreate($title, 500, 500) $cDummy = GUICtrlCreateDummy() Local $aAccelKeys[1][2] = [["{ENTER}", $cDummy]] GUISetAccelerators($aAccelKeys, $hGUI) GUISetState(@SW_SHOW) While 1 $GUIMsg = GUIGetMsg() Select Case $GUIMsg = $GUI_EVENT_CLOSE Exit Case $GUIMsg = $cDummy ENTER_KEY() EndSelect WEnd Func ENTER_KEY() MsgBox(0, "OK", "Entered") EndFunc ;==>ENTER_KEY AlienStar 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Nine Posted November 8, 2018 Share Posted November 8, 2018 you can do it like : HotKeySet("{ENTER}", "ENTER_KEY") You GUI code here Func Enter_Key () if not WinActive($GUI_ttl) then HotKeySet("{ENTER}") Send ("{ENTER}") HotKeySet("{ENTER}", "ENTER_KEY") endif EndFunc AlienStar 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
BrewManNH Posted November 8, 2018 Share Posted November 8, 2018 1 minute ago, Nine said: you can do it like If you use accelerators, you don't have to. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Nine Posted November 8, 2018 Share Posted November 8, 2018 1 minute ago, BrewManNH said: If you use accelerators, you don't have to. agree, that is 2 different ways to go... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Bert Posted November 8, 2018 Share Posted November 8, 2018 I remember having to deal with this problem in an app of mine. I've used both solutions above and either one works well. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
AlienStar Posted November 10, 2018 Author Share Posted November 10, 2018 finally it succeeded $cDummy = GUICtrlCreateDummy() Local $aAccelKeys[2][2] = [["{ENTER}", $cDummy],["{ENTER}", $cDummy]] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) While 1 $GUIMsg = GUIGetMsg() Select Case $GUIMsg = $GUI_EVENT_CLOSE Exit Case $GUIMsg = $cDummy ENTER_KEY() EndSelect WEnd Func ENTER_KEY() MsgBox(0, "OK", "Entered") EndFunc ;==>ENTER_KEY but I don't know why it failed whit the array below !! Local $aAccelKeys[1][1] = [["{ENTER}", $cDummy]] Link to comment Share on other sites More sharing options...
Nine Posted November 10, 2018 Share Posted November 10, 2018 4 minutes ago, AlienStar said: but I don't know why it failed whit the array below !! Local $aAccelKeys[1][1] = [["{ENTER}", $cDummy]] because it only defines one cell and you declare 2 cells $aAccelKeys[1][2] = ... should work AlienStar 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
AlienStar Posted November 11, 2018 Author Share Posted November 11, 2018 4 hours ago, Nine said: because it only defines one cell and you declare 2 cells $aAccelKeys[1][2] = ... should work thanks so much it works 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