Jump to content

Removing HotKeySet


Recommended Posts

Hi guys,

I've written a program (be it crude) that will change my e-mail address in outlook.

The problem I've encountered is that after I've used HotKeySet for a single character, if i try & Send("") that character to a field, the character doesn't appear, rather it waits until the loop has finished, then runs it again with the new character loop..

for eg, if the e-mail address contained a "g", an "s", etc, it wouldn't write these letters into the e-mail address field, but would call the hot key.

I really don't want to use an ALT, CTRL or SHIFT combo.

I'm sure there is a much better way of doing this, if there is, feel free to post it :)

(I also couldn't figure out how to pass a variable to a function from within HotKeySet, but that's another matter - would just tidy up the code).

Cheers.

_____________________________________

AutoItSetOption("WinTitleMatchMode", 2)

HotKeySet("{ESC}", "TermApp")

HotKeySet("g", "ChangeEmailG")

HotKeySet("s", "ChangeEmailS")

HotKeySet("c", "ChangeEmailC")

HotKeySet("y", "ChangeEmailY")

HotKeySet("t", "ChangeEmailT")

GUICreate("Select an e-mail address", 300, 300)

GUICtrlCreateLabel("@mydomain.com", 5, 0)

Dim $r1

Dim $r2

Dim $r3

Dim $r4

Dim $r5

$r1 = GUICtrlCreateLabel("&ggg", 5, 20)

$r2 = GUICtrlCreateLabel("&sss", 5, 40)

$r3 = GUICtrlCreateLabel("&ccc", 5, 60)

$r4 = GUICtrlCreateLabel("&yyy", 5, 80)

$r5 = GUICtrlCreateLabel("&ttt", 5, 100)

GUISetState()

Func TermApp()

Exit

EndFunc

; Assign the e-mail address

Dim $emailaddress

Func ChangeEmailG()

$emailaddress = "ggg@mydomain.com"

EmailChange()

EndFunc

Func ChangeEmailS()

$emailaddress = "sss@mydomain.com"

EmailChange()

EndFunc

Func ChangeEmailC()

$emailaddress = "ccc@mydomain.com"

EmailChange()

EndFunc

Func ChangeEmailY()

$emailaddress = "yyy@mydomain.com"

EmailChange()

EndFunc

Func ChangeEmailT()

$emailaddress = "ttt@mydomain.com"

EmailChange()

EndFunc

While 1

Sleep(1000); not sure why we need to sleep here, but anyway..

WEnd

; Change the e-mail

Func EmailChange()

;Check to see if Outlook is running

IF ProcessExists("outlook.exe") = 0 THEN ;if not running

Dim $StartApp

$StartApp = MsgBox(4, "Start Outlook", "Outlook is not running, do you want to start it?")

IF $StartApp = 6 THEN ;yes

Run("");Open Outlook.. will add later

ELSE

Exit

ENDIF

ENDIF

WinActivate(" - Microsoft Outlook")

WinWaitActive(" - Microsoft Outlook")

Send("!ta")

WinWaitActive("E-mail Accounts", "This wizard will allow you to change the e-mail accounts and directories that Outlook uses.")

Send("!v!n")

WinWaitActive("E-mail Accounts", "Outlook processes e-mail for these accounts in the following order")

Send("!c")

WinWaitActive("E-mail Accounts", "User Information")

Send("!e" & $emailaddress & "!n")

WinWaitActive("E-mail Accounts", "Outlook processes e-mail for these accounts in the following order")

Send("{ENTER}")

Exit

EndFunc

Link to comment
Share on other sites

Make 2 new functions. In the first, put all of your HotKeySet functions. In the other, un-define all of the hot keys. At the top of function Change(), call the function that disable all hot keys. At the end of function Change(), call the function to creates all hot keys.

However, if you really want an EXIT at the end of function Change(), then simply disable the hot keys at the start of the function as the hot keys are no longer needed.

Phillip

Link to comment
Share on other sites

How do I disable the Hot Keys?

I'd prefer to use the 1st letter (or the most obvious letter) associated with the e-mail address, less think time = faster change..

<{POST_SNAPBACK}>

Actually, disabling is the same as undefining, or as the help file says it, "unset".

From the help file for HotKeySet, the function parameter:

Leave blank to unset a previous hotkey.

Phillip

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