Sign in to follow this  
Followers 0
GeekyBunny

Hotkeyset

15 posts in this topic

How do i set a hotkey to a button i made in the Graphical user interface in koda? Well, yet again, i'm a newbie to this. Your help will be appreciated.

Share this post


Link to post
Share on other sites



How do i set a hotkey to a button i made in the Graphical user interface in koda? Well, yet again, i'm a newbie to this. Your help will be appreciated.

Any code or something to help explain a bit more of what you need? :)

Share this post


Link to post
Share on other sites

How do i set a hotkey to a button i made in the Graphical user interface in koda? Well, yet again, i'm a newbie to this. Your help will be appreciated.

 

Have a look at HotKeySet,

Whatever function that button is calling get the hotkey to call the same function.


[font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font]

Share this post


Link to post
Share on other sites

As olo pointed out, how about posting the code for the GUI you created? Help us help you :)

1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

As i said, "I'm new your help would be greatly appreciated :)
Well, This is a program i am making for paint. I want it to click around 7 times whenever i press a special key. Plus, I want a hotkey set to $Button1. So that i don't have to press start everytime.
Well, here is the code : 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 251, 245, 927, 209)
$Button1 = GUICtrlCreateButton("Start", 24, 16, 75, 25)
$Button2 = GUICtrlCreateButton("Instructions", 24, 64, 75, 25)
$Button3 = GUICtrlCreateButton("Quit", 24, 104, 75, 25)
$Label1 = GUICtrlCreateLabel("Made by GeekyBunny", 128, 96, 84, 81)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            If  $Button1 <> 0 then
                MouseClick("Left")
                MouseWheel("Down")
                MouseClick("Left")
                MouseWheel("Down")
                MouseClick("Left")
                MouseWheel("Down")
                EndIf
        Case $Button2
            MsgBox(0,"Instructions","Try")
        Case $Button3
            Exit
    EndSwitch
WEnd
Edited by GeekyBunny

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I guess I am confused. You say you want to take some action on $Button1, but you don't want to click it all the time. How is your program to know you want to take said action if you don't click the button? And if you set a hotkey to perform the same steps as clicking the button, aren't you doubling your effort for the same number of clicks/button presses?

 

Edit: To answer your question, despite the confusion your approach brings me - you would look at HotKeySet in the help file sd mrflibblehat suggested.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

I guess I am confused. You say you want to take some action on $Button1, but you don't want to click it all the time. How is your program to know you want to take said action if you don't click the button? And if you set a hotkey to perform the same steps as clicking the button, aren't you doubling your effort for the same number of clicks/button presses?

 

Edit: To answer your question, despite the confusion your approach brings me - you would look at HotKeySet in the help file sd mrflibblehat suggested.

(I can make only 4 more posts)

Erm, sorry for troubling you what i meant to say is that the i want a hotkeyset as an alternative for the button i press so that i keep hitting the hotkey instead of going back to the form1 and click the button. Like isn't there a way to give the button a hotkey so that whenever i press a certain key, say, "F5", it completes a certain function which i had written in the button.

Share this post


Link to post
Share on other sites

Sure you can. Something like this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{F5}", "_myFunc")

Local $msg

GUICreate("Test", 300, 300)
$Button1 = GUICtrlCreateButton("Button 1", 10, 10, 100,30)

GUISetState(@SW_SHOW)

    While 1
        $msg = GUIGetMsg()
            Select
                Case $msg = $GUI_EVENT_CLOSE
                    ExitLoop
                Case $msg = $Button1
                    _myFunc()
            EndSelect
    WEnd

GUIDelete()

Func _myFunc()
    If $msg = $Button1 Then
        MsgBox(0, "", "I got here from the button")
    Else
        MsgBox(0, "", "I got here from a hotkey")
    EndIf
EndFunc

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Just have HotKeySet and $Button1 call the same function. And you would need to move the $Button1 actions (which are currently in the Switch) to a separate function.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Thank you guys very much! :)
It might be a bother but you guys would be getting way more questions from me >_>
But i am very thankful to you guys! And the helpful community :)

Share this post


Link to post
Share on other sites

(2nd last post >_<)

I can define my function anywhere? Right? Even at the end of the script, right? o-o

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Correct. Typically they are put at the end, after the "Main" portion of the script, but they can go anywhere.

 

Edit: Fixed horrible spelling.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

GeekyBunny,

I have lifted the "New Members" post restriction for you. :)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

GeekyBunny,

I have lifted the "New Members" post restriction for you. :)

M23

Thank you very much! :D 

You guys are the best! :3

Now, i can post when i want without waiting till the morning but for now, All my problems are solved due to JLogan3o13's answer! :) 

But still thank you very much :)

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