Jump to content

[SOLVED] GuiSetAccelerators Help


Recommended Posts

Now, I know that you have to use beta, which I am :)

What I want to accomplish: Alt+Shift+N, Alt+Shift+C, Alt+Shift+Q and Up and Down need to be hotkeys only available WITHIN my app. I figured since i'm writing this entire program in beta, i'd give it a go. Was looking at the forum for Accelerator, and it says like:

include <GUIConstantsEx.au3>
GUICreate("Custom Msgbox", 210, 80)
GUICtrlCreateLabel("Please click a button!", 10, 10)
$YesID = GUICtrlCreateButton("Yes", 10, 50, 50, 20)
$NoID = GUICtrlCreateButton("No", 80, 50, 50, 20)
$ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)
; Set accelerators for Ctrl+y and Ctrl+n
Dim $AccelKeys[2][2]=[["^y", $YesID], ["^n", $NoID]]
GUISetAccelerators($AccelKeys)
GUISetState(); display the GUI

So, to me, in order for accelerators to work, it has to have an associated control id in the array, ok so no problem.

I figured then, i'd write:

Local Enum $SQueue = "3922", $Snew, $SClose, $SUP, $SDown
Dim $AccelKeys[5][2] = [["!+q", $SQueue],["!+n", $Snew],["!+c", $SClose],["{UP}", $SUP],["{DOWN}", $SDown]]
GUISetAccelerators($AccelKeys)

To give it mock ID's. But turns out when you press those keys nothing happens. Must i actually define a control? I mean, i'm not opposed to creating 5 invisible buttons lol, but still. I figured the enum trick would work. Any thoughts?

Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

1) Post WHOLE reproducing script

2) Look here

1) In effect, it was the whole script; the rest were just case handlers.

2) That's where i got the idea for accelerators from :)

#include<GUIConstantsEx.au3>
$form = GUICreate("test", 500, 500)
Local Enum $SQueue = "3922", $Snew, $SClose, $SUP, $SDown
Dim $AccelKeys[5][2] = [["!+q", $SQueue],["!+n", $Snew],["!+c", $SClose],["{UP}", $SUP],["{DOWN}", $SDown]]
GUISetAccelerators($AccelKeys)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $SQueue
            ConsoleWrite("queue" & @CRLF)
        Case $Snew
            ConsoleWrite("new" & @CRLF)
        Case $SClose
            ConsoleWrite("close" & @CRLF)
        Case $SUP
            ConsoleWrite("up" & @CRLF)
        Case $SDown
            ConsoleWrite("down" & @CRLF)
    EndSwitch
WEnd

Note, when you press any of those keys, nothing happens :(. So setting your own Identifiers for them doesn't seem to work. Which, of course, and i'm not being rude here, my apologizes if it sounds like it, brings me back to my question: Do i really need to create 5 hidden buttons here? lol

Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

GUICtrlCreateDummy would work

Sure enough does, thanks much bud :)

#include<GUIConstantsEx.au3>
$form = GUICreate("test", 500, 500)

$SQueue = GUICtrlCreateDummy()
$Snew = GUICtrlCreateDummy()
$SClose = GUICtrlCreateDummy()
$SUP = GUICtrlCreateDummy()
$SDown = GUICtrlCreateDummy()
Dim $AccelKeys[5][2] = [["!+q", $SQueue],["!+n", $Snew],["!+c", $SClose],["{UP}", $SUP],["{DOWN}", $SDown]]
GUISetAccelerators($AccelKeys)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $SQueue
            ConsoleWrite("queue" & @CRLF)
        Case $Snew
            ConsoleWrite("new" & @CRLF)
        Case $SClose
            ConsoleWrite("close" & @CRLF)
        Case $SUP
            ConsoleWrite("up" & @CRLF)
        Case $SDown
            ConsoleWrite("down" & @CRLF)
    EndSwitch
WEnd

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

  • 4 years later...

Is there a reason why you're necroposting so often, this thread is over 4 years old so there's really no need to resurrect it just to post a thank you.

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

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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