Sign in to follow this  
Followers 0
hlstriker

HotKeySet Help

11 posts in this topic

I am trying to make a HotKeySet read from a combo box (drop down menu). I can't get it to read the key in the combo box though.

Here is the code I am trying...

$keyselect1 = GuiCtrlCreateCombo("Select Key", 60, 50, 100, 22)
GUICtrlSetData(-1,"{HOME}|{END}")

$key = GUICtrlRead($keyselect1)

HotKeySet($key,"start")

Thanks.

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Anyone have any ideas?

*B.umping*

*U.p*

*M.y*

*P.ost*

<{POST_SNAPBACK}>

ahh .. yes 30 minutes is slow isn't it.... :(

Maybe your posted example isn't very clear...

You want to use a hotkey which will start func Start() but no code is shown.

It helps in general if you post a small but working script that shows your issue...

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Sorry for bumping so soon :(

Anyhow, the code I have works fine if I just have the HotKeySet name as {HOME} and not as $key...

Example:

HotKeySet("{HOME}","start")

When I try and add the variable... $key ...nothing happens. I want it to read from my combo box and have the key from the combo box be in place of where "{HOME}" is on the HotKeySet.

Here is the code I used again...

$keyselect1 = GuiCtrlCreateCombo("Select Key", 60, 50, 100, 22)
GUICtrlSetData(-1,"{HOME}|{END}")

$key = GUICtrlRead($keyselect1)

HotKeySet($key,"start")

Share this post


Link to post
Share on other sites

Sorry for bumping so soon  :(

Anyhow, the code I have works fine if I just have the HotKeySet name as {HOME} and not as $key...

Example:

HotKeySet("{HOME}","start")

When I try and add the variable... $key ...nothing happens. I want it to read from my combo box and have the key from the combo box be in place of where "{HOME}" is on the HotKeySet.

Here is the code I used again...

$keyselect1 = GuiCtrlCreateCombo("Select Key", 60, 50, 100, 22)
GUICtrlSetData(-1,"{HOME}|{END}")

$key = GUICtrlRead($keyselect1)

HotKeySet($key,"start")

<{POST_SNAPBACK}>

Maybe you need to use :

GUICtrlSetData(-1,"{HOME}|{END}","{HOME}")

To set the default selection to {Home} ?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Ok, that worked for {HOME} key, but now when I choose {END} from the combo box, it is still set on {HOME} for the HotKeyset. I don't know why it won't change to {END} when it is set on it?

Edited by hlstriker

Share this post


Link to post
Share on other sites

Ok, that worked for {HOME} key, but now when I choose {END} from the combo box, it is still set on {HOME} for the HotKeyset. I don't know why it won't change to {END} when it is set on it?

<{POST_SNAPBACK}>

well, that works like any other gui...

something like:

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

$keyselect1 = GuiCtrlCreateCombo("Select Key", 60, 50, 100, 22)
GUICtrlSetData(-1,"{HOME}|{END}")

$key = GUICtrlRead($keyselect1)

HotKeySet($key,"start")

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $keyselect1 Then 
        $key = GUICtrlRead($keyselect1)
        HotKeySet($key,"start")
    EndIf
    
Wend

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

That sort of works. Now what happens is...

Say you select the {HOME} key. It will work.

Then you will select the {END} key, and that will work... Along with the {HOME} key!!!

I want it so when either one or the other key is selected, only the one will make the function work. Any ideas? Thanks for all the help so far JdeB :(

Share this post


Link to post
Share on other sites

This removes the hotkey for home :

HotKeySet("{HOME}")

I think you'll get it from there..

Share this post


Link to post
Share on other sites

You have to unregister the function from the hotkey

#include <GUIConstants.au3>

Func start()
    MsgBox(0, "test", "success!")
EndFunc


GUICreate("My GUI"); will create a dialog box that when displayed is centered

$keyselect1 = GuiCtrlCreateCombo("Select Key", 60, 50, 100, 22)
GUICtrlSetData(-1,"HOME|END")

$key = GUICtrlRead($keyselect1)

HotKeySet($key,"start")

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $keyselect1 Then
        $key = GUICtrlRead($keyselect1)
        HotKeySet("{HOME}")
        HotKeySet("{END}")
        HotKeySet("{" & $key & "}","start")
    EndIf
    
Wend

Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
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
Sign in to follow this  
Followers 0