Jump to content

Assign word to 'f9' key


am632
 Share

Recommended Posts

Hi,

I'm bored of constantly typing out common things everyday like various usernames/passwords/email addys etc so I put this script together.

Basically once you run the script, press 'Alt+Shift+9' brings up a menu, tick the box for the word you want to assign to the f9 key, and click set, then every time you press the f9 key in a text box/document it will type out the word you selected.

#cs ----------------------------------------------------------------------------

 Author:         Aaron Marsh

 Script:        Sets the F9 Key to a word

#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon

Local $getword

;Function
HotKeySet("{f9}", "capturef9")
Func capturef9()
    HotKeySet("{f9}")
    Send($getword)
    HotKeySet("{f9}", "capturef9")
EndFunc

HotKeySet("+!9", "menuf9")
Func menuf9()
    HotKeySet("+!9")
$form = GuiSetState(@SW_SHOW)
    HotKeySet("+!9", "menuf9")
EndFunc

;Gui
$form = GUICreate("Main Menu", 430, 300, 677, 324)

$title = GUICtrlCreateLabel("Choose a word to assign to the 'F9' Key", 16, 24, 394, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")

$checkbox1 = GUICtrlCreateCheckbox("Default Word", 48, 72, 153, 17)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")

$checkbox2 = GUICtrlCreateCheckbox("Default Word 2", 48, 104, 169, 17)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")

$checkbox3 = GUICtrlCreateCheckbox("Default Word 3", 48, 136, 193, 17)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")

$checkbox4 = GUICtrlCreateCheckbox("Default Word 4", 48, 168, 193, 17)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")

$setbutton = GUICtrlCreateButton("Set", 76, 230, 81, 33, $WS_GROUP)
$closebutton = GUICtrlCreateButton("Close", 172, 230, 81, 33, $WS_GROUP)
$quitbutton = GUICtrlCreateButton("Quit", 268, 230, 81, 33, $WS_GROUP)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
$form = GuiSetState(@SW_HIDE)
EndSwitch
Select
    Case $nMsg = $setbutton
            If GUICtrlRead($checkbox1) = $GUI_CHECKED Then
            $getword = "Default Word"
TrayTip("", "F9 has been set to " & $getword, 5)
EndIf

If GUICtrlRead($checkbox2) = $GUI_CHECKED Then
            $getword = "Default Word 2"
TrayTip("", "F9 has been set to " & $getword, 5)
EndIf

If GUICtrlRead($checkbox3) = $GUI_CHECKED Then
            $getword = "Default Word 3"
TrayTip("", "F9 has been set to " & $getword, 5)
EndIf

If GUICtrlRead($checkbox4) = $GUI_CHECKED Then
            $getword = "Default Word 4"
TrayTip("", "F9 has been set to " & $getword, 5)
EndIf

    Case $nMsg = $closebutton
        $form = GuiSetState(@SW_HIDE)

    Case $nMsg = $quitbutton
            Exit
EndSelect

WEnd

The only thing you got 2 do is make sure only 1 box is ticked at a time otherwise the word that is assigned will be the last in the list.

if anyone knows how to make it auto de-select a checkbox when another is selected then that would be gr8.

thanks

Link to comment
Share on other sites

#cs ----------------------------------------------------------------------------

    Author:         Aaron Marsh

    Script:        Sets the F9 Key to a word

#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon

Local $getword
Local $form

;Function
HotKeySet("{f9}", "capturef9")
Func capturef9()
    HotKeySet("{f9}")
    Send($getword)
    HotKeySet("{f9}", "capturef9")
EndFunc   ;==>capturef9

HotKeySet("+!9", "menuf9")
Func menuf9()
    HotKeySet("+!9")
    GUISetState(@SW_SHOW, $form)
    HotKeySet("+!9", "menuf9")
EndFunc   ;==>menuf9

;Gui
$form = GUICreate("Main Menu", 430, 300, 677, 324)
GUISetFont(12, 400, 0, "Courier New")

$Group1 = GUICtrlCreateGroup("Choose a word to assign to the 'F9' Key", 5, 5, 415, 200)
$checkbox1 = GUICtrlCreateRadio("Default Word", 48, 72, 153, 17)
$checkbox2 = GUICtrlCreateRadio("Default Word 2", 48, 104, 169, 17)
$checkbox3 = GUICtrlCreateRadio("Default Word 3", 48, 136, 193, 17)
$checkbox4 = GUICtrlCreateRadio("Default Word 4", 48, 168, 193, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$setbutton = GUICtrlCreateButton("Set", 76, 230, 81, 33, $WS_GROUP)
$quitbutton = GUICtrlCreateButton("Quit", 268, 230, 81, 33, $WS_GROUP)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE, $form)
    EndSwitch
    Select
        Case $nMsg = $setbutton
            If GUICtrlRead($checkbox1) = $GUI_CHECKED Then
                $getword = "Default Word"
                TrayTip("", "F9 has been set to " & $getword, 5)
                GUISetState(@SW_HIDE, $form)
            EndIf

            If GUICtrlRead($checkbox2) = $GUI_CHECKED Then
                $getword = "Default Word 2"
                TrayTip("", "F9 has been set to " & $getword, 5)
                GUISetState(@SW_HIDE, $form)
            EndIf

            If GUICtrlRead($checkbox3) = $GUI_CHECKED Then
                $getword = "Default Word 3"
                TrayTip("", "F9 has been set to " & $getword, 5)
                GUISetState(@SW_HIDE, $form)
            EndIf

            If GUICtrlRead($checkbox4) = $GUI_CHECKED Then
                $getword = "Default Word 4"
                TrayTip("", "F9 has been set to " & $getword, 5)
                GUISetState(@SW_HIDE, $form)
            EndIf

        Case $nMsg = $quitbutton
            Exit
    EndSelect

WEnd

nice little script i played around with it a lil and changed the check box's to radio's to fix the multiple selection issue. works nice

Link to comment
Share on other sites

Hey

Looking at this script

Instead of having radio box's

If there a way to keep the check boxes, and if 2 things are checked to send both those things

so if 1 and 3 were checked

it would send

Default Word

and

Default Word 3

Link to comment
Share on other sites

Hi BoD.

I cleaned up the code from post 1 and made it to a basic example for what you are asking, you can probably work from here.

#cs ----------------------------------------------------------------------------

    Author:         Aaron Marsh
    Edited by:      Alexander Samuelsson (AdmiralAlkex)

    Script:        Sets the F9 Key to a word

#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon

Local $getword

;Function
HotKeySet("{f9}", "capturef9")
Func capturef9()
    HotKeySet("{f9}")
    Send($getword)
    HotKeySet("{f9}", "capturef9")
EndFunc   ;==>capturef9

HotKeySet("+!9", "menuf9")
Func menuf9()
    HotKeySet("+!9")
    $form = GUISetState(@SW_SHOW)
    HotKeySet("+!9", "menuf9")
EndFunc   ;==>menuf9

;Gui
$form = GUICreate("Main Menu", 430, 300, 677, 324)

$title = GUICtrlCreateLabel("Choose a word to assign to the 'F9' Key", 16, 24, 394, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")

$checkbox1 = GUICtrlCreateCheckbox("Default Word", 48, 72, 153, 17)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")

$checkbox2 = GUICtrlCreateCheckbox("Default Word 2", 48, 104, 169, 17)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")

$checkbox3 = GUICtrlCreateCheckbox("Default Word 3", 48, 136, 193, 17)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")

$checkbox4 = GUICtrlCreateCheckbox("Default Word 4", 48, 168, 193, 17)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")

$setbutton = GUICtrlCreateButton("Set", 76, 230, 81, 33, $WS_GROUP)
$closebutton = GUICtrlCreateButton("Close", 172, 230, 81, 33, $WS_GROUP)
$quitbutton = GUICtrlCreateButton("Quit", 268, 230, 81, 33, $WS_GROUP)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            $form = GUISetState(@SW_HIDE)

        Case $setbutton
            $getword = ""

            If BitAnd(GUICtrlRead($checkbox1),$GUI_CHECKED) Then
                $getword &= "Default Word"
            EndIf

            If BitAnd(GUICtrlRead($checkbox2),$GUI_CHECKED) Then
                $getword &= "Default Word 2"
            EndIf

            If BitAnd(GUICtrlRead($checkbox3),$GUI_CHECKED) Then
                $getword &= "Default Word 3"
            EndIf

            If BitAnd(GUICtrlRead($checkbox4),$GUI_CHECKED) Then
                $getword &= "Default Word 4"
            EndIf

            If $getword <> "" Then TrayTip("", "F9 has been set to " & $getword, 5)

        Case $closebutton
            $form = GUISetState(@SW_HIDE)

        Case $quitbutton
            Exit
    EndSwitch

WEnd
Link to comment
Share on other sites

Hi guys,

I was thinking how to make the script better and thought it would probably be best to just have an input box so you can just type a word you want, then set it, so heres the code

#cs ----------------------------------------------------------------------------

 Author:         Aaron Marsh

 Script:        Sets the F9 Key to a word

#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon

Local $getword

;Function
HotKeySet("{f9}", "capturef9")
Func capturef9()
    HotKeySet("{f9}")
    Send($getword)
    HotKeySet("{f9}", "capturef9")
EndFunc

HotKeySet("+!9", "menuf9")
Func menuf9()
    HotKeySet("+!9")
$form = GuiSetState(@SW_SHOW)
    HotKeySet("+!9", "menuf9")
EndFunc

;Gui
$form = GUICreate("Main Menu", 430, 170, 677, 324)

$title = GUICtrlCreateLabel("Choose a word to assign to the 'F9' Key", 16, 24, 394, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")

;InputBox
$INPUTBOX = GUICtrlCreateInput("", 25, 70, 355, 23)
GUICtrlSetFont(-1, 14, 400, 0, "Courier New")

$setbutton = GUICtrlCreateButton("Set", 76, 120, 81, 33, $WS_GROUP)
$closebutton = GUICtrlCreateButton("Close", 172, 120, 81, 33, $WS_GROUP)
$quitbutton = GUICtrlCreateButton("Quit", 268, 120, 81, 33, $WS_GROUP)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
$form = GuiSetState(@SW_HIDE)
EndSwitch

Select
    Case $nMsg = $setbutton
        $readword = GUICtrlRead($INPUTBOX)
        GUICtrlSetData($INPUTBOX, $readword)
        $getword = $readword
        $form = GuiSetState(@SW_HIDE)
EndSelect

Select
    Case $nMsg = $closebutton
        $form = GuiSetState(@SW_HIDE)

    Case $nMsg = $quitbutton
            Exit
EndSelect

WEnd

works ok if u put spaces in the input aswell. Hope you like it

Edited by am632
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...