Jump to content

Paste using (^v), Hotkey


Recommended Posts

Hi every one,

I have a script that calls a gui creating function by hotkey:

Global  $hkey

$hkey="!x"

HotKeySet($hkey) ;unregestring the hotkey

HotKeySet($hkey, "creatgui")

then a calls paste command

......

ClipPut("____________________________")

Send("^v")

then

GUIDelete()

HotKeySet($hkey) ;unregestring the hotkey

 

Everything runs smoothly but,

1- The paste command works several times then it sends ONLY  "v".

2- The hotkey works several times then it stop working.

I tried removing the unregestring changing hotkeys and modifiers , Different version of  "^v" like "^V", "{CTRLDOWN}" "V" "{CTRLUP}" ,"{Ctrl}v"

also I tried using AutoItSetOption ( "SendKeyDelay" , 0 ),

I got the same broplem, is there a better way for hotkeys and pasting. (pasting to different programms)

ThanX in Advance

 

 

Link to comment
Share on other sites

Your code is incomplete, so we can't tell if maybe you're doing something wrong with unregistering the hotkey before re-registering it again, or trying to invoke the hotkey when the hotkey is temporarily disabled by another instance of the invocation, stuff like that.

Be sure to put your code in code tags for readability's sake and if possible to write a complete, runnable reproducer script so it can be tried out by others. Also, writing a reproducer script often already helps find the problem in the original script :) 

In general: if possible, avoid the use of hotkeys (they come with all sorts of risks like race conditions with actual keyboard usage and I/O asynchronicity) and instead try to identify the control you're pasting to (AU3Info is very useful for that), then use GuiCtrlSetData to insert the data straight into the control.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Thanx for the reply,

I use it to paste in to diff programs including word, firefox, chrome.

and ofcoarse I used a reproducer in my tries and it works good for a while then it suddenly fails after using the hotkey many times, and sometimes it only paste v not what in clipboard.

So my question "Is there a better ways for setting hotkeys and pasting." (Like UDFs).

ThanX .

Link to comment
Share on other sites

Well, not to be a PITA, but: maybe there is a better way, and then, maybe there isn't. Quite hard to tell if there's a better way of doing what you're trying to do if it is unclear what you're trying to do and how you're trying to do it :) 

In short, you probably shouldn't be having the problems you're having unless either you run into some strange race condition or you have some sort of mistake in your script, both of which people could probably answer to if there was a better explanation or an example script that reproduces the problem. So posting a working reproducer would help.

For Word, there's a large UDF (Word.au3) that allows all sorts of interactions with Word that may enable you to do things better. For browser interactions, the same things go. For hotkey setting you shouldn't need much more than HotKeySet.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

if using ClipPut, then why not use ClipGet to finish...

ClipPut("____________________________")
Send(ClipGet())

 

If @error Then
    MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!")
EndIf

"Yeah yeah yeah patience, how long will that take?"  -Ed Gruberman

REAL search results  |  SciTE4AutoIt3 Editor Full Version

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