Jump to content

Recommended Posts

Posted (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 by AlienStar
Posted

You can set it up using GUISetAccelerators instead of Hotkeys.

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 Gude
How 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

Posted
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 !!!!

Posted

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 Gude
How 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

Posted

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

 

Posted

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

 

 

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 Gude
How 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

Posted
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 Gude
How 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

Posted

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]]

 

Posted

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...