zxtnt09

[Solved] Hotkey For Button

9 posts in this topic

#1 ·  Posted (edited)

Hi guys,

Can i Use Hotkey Like That  ? 

=>

;button box
$button = GUICtrlCreateButton("Button",272, 45, 75 , 25 )
GUICtrlSetColor(-1, 0x6699FF)
GUISetState(@SW_SHOW)
GUICtrlSetBkColor($changebutton, 0x2929A3)

;while switch
While 1
Switch $test
Case $button
   test2()
Exit
EndSwitch
Sleep(10)
WEnd


;Button hotkey func 
Func test2() 
If $button = True Then 
"""" Press F1 """"" 
EndIf 
EndFunc

 

i don't know how can i use that, after click on "button" , "F1" do.

thanks

Edited by zxtnt09
solved

Share this post


Link to post
Share on other sites



Try explaining this in a little more detail as this isn't very clear what you are looking for.

 

Jos

​yes sry,

it's meant  :

1 ) Make button

2 ) Click on button 

3 ) after click on , for example "F1" on the keyboard to activate.

Ex Picture : 

sry for bad english

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

it is still not clear at all but well i am gonna to explain you two type of action possible, becose i guess you need one or the other:

 

A:)you can use a function for one keypress

B:)or click on a buttom to simulate a keypress

A:) If you bind a key to one function it s very simple to do

for exemple : i want to send a command after the F1 key pressed you can code somthing like that

HotKeySet("{F1}", "About")
   
   
   Function About ()
        "Do my about function"
   EndFunc

Dont forget to bind F1 at the beginning of your script

 

B:) if you push on the about button you want to emulate the F1

you have to setup a switch case code in your script

 

Switch GUIGetMsg()
               Case $About
                    Send ("{F1}")
EndSwitch

in this case i assume you made a GUI in your script with a button declared as the "$About" variable.

 

If you need something else plz say us.

 

Edited by caramen
1 person likes this

Share this post


Link to post
Share on other sites

Thanks dear , and sry for my bad english .

it's my code : 

$mainform = GUICreate("test", 500, 500, 500, 500)
GUISetFont(10, 100000, 0, "Segoe UI")
GUISetBkColor(0x00bbbb)
GUICtrlSetColor(-1, 0x00bbbb)
GUISetState(@SW_SHOW)

$about = GUICtrlCreateButton("About",110, 110, 110 , 110 )
GUICtrlSetColor(-1, 0x6699FF)
GUISetState(@SW_SHOW)
GUICtrlSetBkColor($about, 0x2929A3)
    
While 1
    $test = GUIGetMsg()
    Switch $test
            Case $about
            about()
            Exit
    EndSwitch
    Sleep(10)
WEnd

Func about()
If $about = True Then
Send ("{F1}")
EndIf
EndFunc

but "F1" wasn't work!

Share this post


Link to post
Share on other sites

Try this :

#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>

$mainform = GUICreate("test", 500, 500, 500, 500)
GUISetFont(10, 100000, 0, "Segoe UI")
GUISetBkColor(0x00bbbb)
GUICtrlSetColor(-1, 0x00bbbb)
GUISetState(@SW_SHOW)

$about = GUICtrlCreateButton("About",110, 110, 110 , 110 )
GUICtrlSetColor(-1, 0x6699FF)
GUISetState(@SW_SHOW)
GUICtrlSetBkColor($about, 0x2929A3)


While 1

    Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
               Exit
            Case $about
               about()
    EndSwitch

    Sleep(10)

WEnd

Func about()

    Send ("{F1}")
    MsgBox ( $MB_SYSTEMMODAL , "F1", "F1 Has been Pressed")

EndFunc

 

Be aware :

 

If you send F1 in your script you wont see when the key in pressed since ... F1 does not doing anysomething else in your windows.

 

You can add a condoition with other includes.. if i remember it's misc.au3

 

and use :

If _IsPressed ("{F1}") Then
    "Open this website"
EndIf

or any other action

If your question is answered dont forget to mark the topic solved ;)

1 person likes this

Share this post


Link to post
Share on other sites

You can make a condition where if the window you want to have F1 is active then the action is processed.

​yes , i think i need it,

cus when i use that it's just use for my program , and i don't want it.

i want for ex , if click on "f1" , f1 do in "my computer",

thanks if you helping me.

 

Share this post


Link to post
Share on other sites

Look for examples in the help file for WinExists and any functions that are named similar i.e. ProcessExists(), WinActive(), WinClose(), WinTitleMatchMode (Option), WinWait(), WinWaitActive(), WinWaitClose(), WinWaitNotActive()

1 person likes this

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

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