Sign in to follow this  
Followers 0
Chattah

CTRL and ALT Keys Stays "Pressed" After Script Finishes Executing

4 posts in this topic

Brief Description: I'm making a script that will alow me to have multiple "clipboards" for coping and pasting.

You press CTRL + 1 thru 5 on the numberpad to copy and CTRL + ALT + 1 thru 5 on the numberpad to paste.

My problem is that after pasting the contents of the "clipboard" I'll sometimes end up with either the Control key or the Alt key still in a pressed down state. I have tried adding a short delay and then having the script press CTRLUP and ALTUP but this doesn't have any effect on the issue.

I'm using the latest AutoIT Beta on WinXP.

Thanks for any help you can offer!!

CODE

HotKeySet("^{NumPad1}", "_Multi_Copy_Paste");Copy Highlighted Text to NumPad Key 1

HotKeySet("^!{NumPad1}", "_Multi_Copy_Paste");Paste Highlighted Text from NumPad Key 1

HotKeySet("^{NumPad2}", "_Multi_Copy_Paste");Copy Highlighted Text to NumPad Key 2

HotKeySet("^!{NumPad2}", "_Multi_Copy_Paste");Paste Highlighted Text from NumPad Key 2

HotKeySet("^{NumPad3}", "_Multi_Copy_Paste");Copy Highlighted Text to NumPad Key 3

HotKeySet("^!{NumPad3}", "_Multi_Copy_Paste");Paste Highlighted Text from NumPad Key 3

HotKeySet("^{NumPad4}", "_Multi_Copy_Paste");Copy Highlighted Text to NumPad Key 4

HotKeySet("^!{NumPad4}", "_Multi_Copy_Paste");Paste Highlighted Text from NumPad Key 4

HotKeySet("^{NumPad5}", "_Multi_Copy_Paste");Copy Highlighted Text to NumPad Key 5

HotKeySet("^!{NumPad5}", "_Multi_Copy_Paste");Paste Highlighted Text from NumPad Key 5

Func _Multi_Copy_Paste()

$Current_Window_Title = WinGetTitle("")

Switch @HotKeyPressed

Case "^{NumPad1}"

Send("^c")

$Multi_Copy_Paste_1 = ClipGet()

MsgBox(0, "", $Multi_Copy_Paste_1, 1)

Case "^!{NumPad1}"

ClipPut($Multi_Copy_Paste_1)

Send("^v")

Case "^{NumPad2}"

Send("^c")

$Multi_Copy_Paste_2 = ClipGet()

MsgBox(0, "", $Multi_Copy_Paste_2, 1)

Case "^!{NumPad2}"

ClipPut($Multi_Copy_Paste_2)

Send("^v")

Case "^{NumPad3}"

Send("^c")

$Multi_Copy_Paste_3 = ClipGet()

MsgBox(0, "", $Multi_Copy_Paste_3, 1)

Case "^!{NumPad3}"

ClipPut($Multi_Copy_Paste_3)

Send("^v")

Case "^{NumPad4}"

Send("^c")

$Multi_Copy_Paste_4 = ClipGet()

MsgBox(0, "", $Multi_Copy_Paste_4, 1)

Case "^!{NumPad4}"

ClipPut($Multi_Copy_Paste_4)

Send("^v")

Case "^{NumPad5}"

Send("^c")

$Multi_Copy_Paste_5 = ClipGet()

MsgBox(0, "", $Multi_Copy_Paste_5, 1)

Case "^!{NumPad5}"

ClipPut($Multi_Copy_Paste_5)

Send("^v")

EndSwitch

Sleep(500)

WinActivate ($Current_Window_Title)

Send("{CTRLUP}")

Send("{ALTUP}")

EndFunc

Share this post


Link to post
Share on other sites



Any ideas?

Share this post


Link to post
Share on other sites

I think it's because all your Hotkeys call the same function.

If the function is still busy while you press the next hotkey,

there will be trouble ...

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try this

CODE

Opt("OnExitFunc", "endscript")

HotKeySet("^{NumPad1}", "_Multi_Copy_Paste");Copy Highlighted Text to NumPad Key 1

HotKeySet("^!{NumPad1}", "_Multi_Copy_Paste");Paste Highlighted Text from NumPad Key 1

HotKeySet("^{NumPad2}", "_Multi_Copy_Paste");Copy Highlighted Text to NumPad Key 2

HotKeySet("^!{NumPad2}", "_Multi_Copy_Paste");Paste Highlighted Text from NumPad Key 2

HotKeySet("^{NumPad3}", "_Multi_Copy_Paste");Copy Highlighted Text to NumPad Key 3

HotKeySet("^!{NumPad3}", "_Multi_Copy_Paste");Paste Highlighted Text from NumPad Key 3

HotKeySet("^{NumPad4}", "_Multi_Copy_Paste");Copy Highlighted Text to NumPad Key 4

HotKeySet("^!{NumPad4}", "_Multi_Copy_Paste");Paste Highlighted Text from NumPad Key 4

HotKeySet("^{NumPad5}", "_Multi_Copy_Paste");Copy Highlighted Text to NumPad Key 5

HotKeySet("^!{NumPad5}", "_Multi_Copy_Paste");Paste Highlighted Text from NumPad Key 5

While 1 ;You need a loop or it wont work at all

Wend

Func _Multi_Copy_Paste()

$Current_Window_Title = WinGetTitle("")

Switch @HotKeyPressed

Case "^{NumPad1}"

Send("^c")

$Multi_Copy_Paste_1 = ClipGet()

MsgBox(0, "", $Multi_Copy_Paste_1, 1)

Case "^!{NumPad1}"

ClipPut($Multi_Copy_Paste_1)

Send("^v")

Case "^{NumPad2}"

Send("^c")

$Multi_Copy_Paste_2 = ClipGet()

MsgBox(0, "", $Multi_Copy_Paste_2, 1)

Case "^!{NumPad2}"

ClipPut($Multi_Copy_Paste_2)

Send("^v")

Case "^{NumPad3}"

Send("^c")

$Multi_Copy_Paste_3 = ClipGet()

MsgBox(0, "", $Multi_Copy_Paste_3, 1)

Case "^!{NumPad3}"

ClipPut($Multi_Copy_Paste_3)

Send("^v")

Case "^{NumPad4}"

Send("^c")

$Multi_Copy_Paste_4 = ClipGet()

MsgBox(0, "", $Multi_Copy_Paste_4, 1)

Case "^!{NumPad4}"

ClipPut($Multi_Copy_Paste_4)

Send("^v")

Case "^{NumPad5}"

Send("^c")

$Multi_Copy_Paste_5 = ClipGet()

MsgBox(0, "", $Multi_Copy_Paste_5, 1)

Case "^!{NumPad5}"

ClipPut($Multi_Copy_Paste_5)

Send("^v")

EndSwitch

Sleep(500)

WinActivate ($Current_Window_Title)

Send("{CTRLUP}")

Send("{ALTUP}")

EndFunc

Func endscript()

Send("{CTRLUP}")

Send("{ALTUP}")

EndFunc ;==>endscript

Edited by ReaImDown

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

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