Jump to content

Recommended Posts

Posted
  On 5/23/2013 at 10:54 AM, GeekyBunny said:

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? :)

Posted
  On 5/23/2013 at 10:54 AM, GeekyBunny said:

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]

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
  • Moderators
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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted
  On 5/23/2013 at 8:12 PM, JLogan3o13 said:

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.

  • Moderators
  • Solution
Posted

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

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 :)

  • Moderators
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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

  • Moderators
Posted

GeekyBunny,

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

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

  On 5/23/2013 at 9:09 PM, Melba23 said:

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 :)

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