Sign in to follow this  
Followers 0

HotKey!

12 posts in this topic

Posted

hey guys, a friend of mine needs help with hotkeys.

this is his script:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("", 215, 235, 299, 218)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 112, 16, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 112, 40, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 112, 64, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 112, 88, 97, 17)
$Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 112, 112, 97, 17)
$Checkbox6 = GUICtrlCreateCheckbox("Checkbox6", 112, 136, 97, 17)
$Checkbox7 = GUICtrlCreateCheckbox("Checkbox7", 112, 160, 97, 17)
$Checkbox8 = GUICtrlCreateCheckbox("Checkbox8", 112, 184, 97, 17)
$Label1 = GUICtrlCreateLabel("Hot Key Ctrl+1", 8, 16, 72, 17)
$Label2 = GUICtrlCreateLabel("Hot Key Ctrl+2", 8, 40, 72, 17)
$Label3 = GUICtrlCreateLabel("Hot Key Ctrl+3", 8, 64, 72, 17)
$Label4 = GUICtrlCreateLabel("Hot Key Ctrl+4", 8, 88, 72, 17)
$Label5 = GUICtrlCreateLabel("Hot Key Ctrl+5", 8, 112, 72, 17)
$Label6 = GUICtrlCreateLabel("Hot Key Ctrl+6", 8, 136, 72, 17)
$Label7 = GUICtrlCreateLabel("Hot Key Ctrl+7", 8, 160, 72, 17)
$Label8 = GUICtrlCreateLabel("Hot Key Ctrl+8", 8, 184, 72, 17)
$Label9 = GUICtrlCreateLabel("Hot Key For Open and Close Alt+1", 8, 208, 165, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

he said that when he presses any hotkey it dsnt works...

Share this post


Link to post
Share on other sites



Posted

iTwIx,

Welcome to the Autoit forum. :)

And why does your friend think his HotKeys will work if he does not use HotKeySet at some point in the script? ;)

M23

Share this post


Link to post
Share on other sites

Posted

yh xD he only wrote hotkey in the label.... xD i was kinda ;) but he was keeping asking me to do it...

btw thnx for the welcome =)

Share this post


Link to post
Share on other sites

Posted

iTwIx,

And so what is the question that you have? ;)

M23

Share this post


Link to post
Share on other sites

Posted

for now its all... thnx=)

Share this post


Link to post
Share on other sites

Posted

how hes script is the following:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
HotKeySet("{Alt}"); That For Closs And Open the From
#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("", 215, 235, 299, 218)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 112, 16, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 112, 40, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 112, 64, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 112, 88, 97, 17)
$Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 112, 112, 97, 17)
$Checkbox6 = GUICtrlCreateCheckbox("Checkbox6", 112, 136, 97, 17)
$Checkbox7 = GUICtrlCreateCheckbox("Checkbox7", 112, 160, 97, 17)
$Checkbox8 = GUICtrlCreateCheckbox("Checkbox8", 112, 184, 97, 17)
$Label1 = GUICtrlCreateLabel("HotKeySet 1", 8, 16, 72, 17)
$Label2 = GUICtrlCreateLabel("HotKeySet 2", 8, 40, 72, 17)
$Label3 = GUICtrlCreateLabel("HotKeySet 3", 8, 64, 72, 17)
$Label4 = GUICtrlCreateLabel("HotKeySet 4", 8, 88, 72, 17)
$Label5 = GUICtrlCreateLabel("HotKeySet 5", 8, 112, 72, 17)
$Label6 = GUICtrlCreateLabel("HotKeySet 6", 8, 136, 72, 17)
$Label7 = GUICtrlCreateLabel("HotKeySet 7", 8, 160, 72, 17)
$Label8 = GUICtrlCreateLabel("HotKeySet 8", 8, 184, 72, 17)
$Label9 = GUICtrlCreateLabel("Hot Key For Open and Close Alt", 8, 208, 165, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Checkbox1
HotKeySet("{1}")("")
Case $Checkbox2
HotKeySet("{2}")("")
Case $Checkbox3
HotKeySet("{3}")("")
Case $Checkbox4
HotKeySet("{4}")("")
Case $Checkbox5
HotKeySet("{5}")("")
Case $Checkbox6
HotKeySet("{6}")("")
Case $Checkbox7
HotKeySet("{7}")("")
Case $Checkbox8
HotKeySet("{8}")("")

EndSwitch
WEnd

but it still dsnt work

Share this post


Link to post
Share on other sites

Posted (edited)

You have to assign a function to HotKeySet and it's incorrectly formatted too. Refer to the Help file about HotKeySet.

Edited by guinness

Share this post


Link to post
Share on other sites

Posted

iTwIx,

And why should it? Does your friend look at the Help file before coding or does he expect AutoIt to guess what he wants? ;)

The syntax for HotKeySet should be:

HotKeySet( HotKey, "Function_Name")

So where is the "Function_Name" (and the function itself? :)

M23

P.S. And you do not need the { } either. :D

Share this post


Link to post
Share on other sites

Posted (edited)

ok this is what my friend replayed me in another website:

See That i make it

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
HotKeySet("{z}", "Selectoncheckbox1")
#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("", 215, 235, 299, 218)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 112, 16, 97, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Checkbox1


EndSwitch
WEnd


Func Selectoncheckbox1()
    MsgBox(4096, "", "This is a message.")
EndFunc   ;==>ShowMessage

but i went change MsgBox(4096, "", "This is a message.") to Select on checkbox1 not MsgBox(4096, "", "Select on checkbox1")

went change to select on checkbox1 no went it MsgBox Posted Image

sorry bro i dont understand what have u said...

ok that it

[/size][/font][/color]


#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
HotKeySet("{z}", "Selectoncheckbox1")
#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("", 215, 235, 299, 218)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 112, 16, 97, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Checkbox1


EndSwitch
WEnd


Func Selectoncheckbox1()
    MsgBox(4096, "", "00000000000") ; i went change Msgbox to  i dont know what need to change MsgBox to ...... to make (HotKeySet) can Select On Checkbox1
EndFunc

(write it and GM will know what i mean

i went change Msgbox to i dont know what need to change MsgBox to ...... to make (HotKeySet) can Select On Checkbox1)

(I am very sorry for bothering you)

Edited by iTwIx

Share this post


Link to post
Share on other sites

Posted

iTwIx,

I have absolutely no idea what you are trying to do. ;)

The first script you have posted shows the HotKey being set (although you do not need the { } as I have already mentioned) but what on earth do you mean by?

to make (HotKeySet) can Select On Checkbox1

The HotKey runs the function that you tell it to run - in this case Selectoncheckbox1. If you want the function to run when you select the checkbox then you need to do something like this:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("", 215, 235, 299, 218)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 112, 16, 97, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Checkbox1
            Selectoncheckbox1()
    EndSwitch
WEnd

Func Selectoncheckbox1()
    MsgBox(4096, "", "00000000000") 
EndFunc   ;==>Selectoncheckbox1

Perhaps you need to get your friend to post here explaining what is going on rather than giving you snippets of script which only confuse us all. :)

M23

Share this post


Link to post
Share on other sites

Posted

yh im confused too lol my friend doesnt speaks well english so... ;)

Share this post


Link to post
Share on other sites

Posted

i Will Help me i am Really Surprised for

Melba23 cant help you !

see will add 2 func Only that it

Func Selectoncheckbox()
GUICtrlSetState($Checkbox1, $GUI_CHECKED)
EndFunc
Func Selectoncheckbox1()
GUICtrlSetState($Checkbox1, $GUI_unchecked)
EndFunc

will make 2 hotkeyset

if went all Script

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

HotKeySet("{z}", "Selectoncheckbox")
HotKeySet("{x}", "Selectoncheckbox1")
#Region ### START Koda GUI section ### Form=Form1.kxf
$Form1 = GUICreate("", 215, 235, 299, 218)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 112, 16, 97, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

Func Selectoncheckbox()
GUICtrlSetState($Checkbox1, $GUI_CHECKED)
EndFunc
Func Selectoncheckbox1()
GUICtrlSetState($Checkbox1, $GUI_unchecked)
EndFunc

if he went add more check box he will need add other to func but change name func and change name $Checkbox1 Depending on the name $Checkbox 1 and the name next func not any name HotKeySet("{x}", "Here name the next Func") so will add Func Here name The Next Func any name but Be necessary in HotKeySet i hope i help your Friend ;)

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

  • Recently Browsing   0 members

    No registered users viewing this page.