AutoHotkey Community

It is currently May 26th, 2012, 3:32 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: March 13th, 2009, 7:59 pm 
Offline

Joined: December 23rd, 2007, 7:47 pm
Posts: 62
Location: Austin
Hi,

I'm using a function such as:

Code:
   Clipboard_temp := Clipboard
   Clipboard = %command%
   send, ^v
   send, {left %cursor_move_left%}
   Clipboard := Clipboard_temp


To paste a command when I press a hotkey.

Suppose the command was "\( \)".

Sometimes it works, but other times "\( ahk_id 0x932 \)" is pasted instead of "\( \)".

Let me know if you have a solution.

Thanks,

Joon


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2009, 8:13 pm 
Code:
Clipboard_temp := Clipboard
Clipboard = %command%
Send, ^v
Send, {left %cursor_move_left%}
Sleep, 300
Clipboard := Clipboard_temp


AHK sends ^v just fine, but it can't control how long it takes the receiving program to process that request. Sounds to me like you're getting to the "Clipboard := Clipboard_temp" portion if your code before the receiving program has finished processing the request to receive the clipboard, so the clipboard's contents change first then they're pasted.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2009, 8:25 pm 
Offline

Joined: December 23rd, 2007, 7:47 pm
Posts: 62
Location: Austin
sinkfaze n-l-i wrote:
Code:
Clipboard_temp := Clipboard
Clipboard = %command%
Send, ^v
Send, {left %cursor_move_left%}
Sleep, 300
Clipboard := Clipboard_temp


AHK sends ^v just fine, but it can't control how long it takes the receiving program to process that request. Sounds to me like you're getting to the "Clipboard := Clipboard_temp" portion if your code before the receiving program has finished processing the request to receive the clipboard, so the clipboard's contents change first then they're pasted.


Thanks for the reply.

Actually, I just found out that Send, {left %cursor_move_left%} part was the problem. After take that part out, no single incidence.

Now I have to figure out how to do the cursor thing without the problem.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2009, 8:43 pm 
Change the order of the commands:

Code:
Clipboard_temp := Clipboard
Clipboard := command
ClipWait, 1
Send, ^v
Sleep, 300
Clipboard := Clipboard_temp
ClipWait, 1
Send, {left %cursor_move_left%}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2009, 8:47 pm 
Offline

Joined: December 23rd, 2007, 7:47 pm
Posts: 62
Location: Austin
I used sendplay instead of send, and it is much better. Now it is mostly reliable. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2009, 10:32 pm 
rogal wrote:
I used sendplay instead of send, and it is much better. Now it is mostly reliable. :)


Mostly reliable should be a last resort. :wink:

Were you specifying SendMode Input or SendMode Play in your script before? I still think tweaking the sequencing in the script will ultimately be helpful in optimizing the function.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2009, 10:38 pm 
Offline

Joined: December 23rd, 2007, 7:47 pm
Posts: 62
Location: Austin
sinkfaze n-l-i wrote:
Mostly reliable should be a last resort. :wink:

Were you specifying SendMode Input or SendMode Play in your script before? I still think tweaking the sequencing in the script will ultimately be helpful in optimizing the function.


Thanks. At least AhK_whatever message has never showed up since I started using sendplay.

I will try other stuff to optimize the function later. (stuch at an assignment at the moment)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2009, 7:02 am 
Offline

Joined: December 23rd, 2007, 7:47 pm
Posts: 62
Location: Austin
Wow. I just installed the new version of AutoHotKey and the problem went away. It is much more reliable even without sleep commands.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group