Jump to content

[Solved] Hotkey For Button


Recommended Posts

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
Link to comment
Share on other sites

  • Developers

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

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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

Link to comment
Share on other sites

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

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
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!

Link to comment
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 ;)

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
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.

 

Link to comment
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()

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...