GUI for copying and pasting

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tnmc77
Posts: 18
Joined: 27 Aug 2017, 16:53

GUI for copying and pasting

13 Sep 2017, 18:11

Hi,
I am a newbie but have put together a following script by reading and asking. The following script works for me most of the time but sometmes (randomly) it does not. Here is more detail.

SCRIPT:

Code: Select all

#Singleinstance, Force
Gui, Destroy
Gui,+AlwaysOnTop
Gui,+ToolWindow
Gui,+Border
Gui, Add, Button, y5 w60, &Copy
Gui, Show, y0
Return

#Singleinstance, Force

ButtonCopy:
#Singleinstance, Force
Send, !{Esc} ; Changed from Alt+Tab
Sleep, 20
Send ^a^c!{f4}
Winactivate, Powerscribe
Send ^{End}
^v
Return

End:
Reload
Return
edit: please use code tags!
WHAT IT IS USED FOR:

1) I activate the script and get a small GUI button "Copy" at the top of the desktop.
2) I also have programs Agfa and Poerscribe open.
3) I look at the study on Agfa which has a "notes" box.
4) I open the notes box and click on it.
5) I then click on the GUI "Copy" button.
6) That automatically copies all contents in the notes, closes the notes box, activates porscribe window, puts the cursor at the end of the window's contents and pastes the contents from the notes box in the powerscribe.
7) The "COPY" GUI button remains open at the top of the desktop and I repeat steps #4,5 and 6 for another study, which has different txt in the notes box.

PROBLEM:

90% of the time it works really well. However, 10% of the time it pastes in the powerscribe window something which was copied from the previous study. Most often, when I click on the "Copy" button, it pastes the correct content.

SOLUTION:

DON't have any and seeking from you.

? Role fro clipboard =

Many thanks in advance.
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: GUI for copying and pasting

15 Sep 2017, 14:58

Hi tnmc77,

Here's your code barely altered with minor details, hoping it could solve your problem:

Code: Select all

#Singleinstance, Force
SendMode, Input ; makes Send synonymous with "SendInput" which is faster than Send, so that the code is generally more reliable.

Gui, +AlwaysOnTop +ToolWindow
Gui, Add, Button, y5 w60, &Copy
Gui, Show, y0
return


ButtonCopy:
Send, !{Esc}
Sleep, 20
Send, ^a^c ; alternatively: ControlGetText
sleep, 70
send, !{f4}
Winactivate, Powerscribe
WinWaitActive, Powerscribe
Send, ^{End}
Send, ^v ; alternatively ControlSetText or Control, EditPaste
return

End:
Reload
Alternatively and instead of using the Send command, I only can suggest you to take advantage of some of the built-in commands like ControlGetText (vs send, ^a^c) or ControlSetText or Control, EditPaste, (vs send, ^{End}^v).

Here's a simple example of getting and setting control text with notepad:

Code: Select all

run, notepad
WinActivate, ahk_class Notepad
WinWaitActive, ahk_class Notepad
ControlSetText, Edit1, some text
sleep, 100
ControlSend, Edit1, !{End}, ahk_class Notepad
sleep, 100
Control, EditPaste, %A_Space%some other text, Edit1, ahk_class Notepad
sleep, 100
ControlGetText, OutputVar, Edit1, ahk_class Notepad
MsgBox % OutputVar
my scripts
tnmc77
Posts: 18
Joined: 27 Aug 2017, 16:53

Re: GUI for copying and pasting

23 Sep 2017, 06:31

A_AhkUser,
Thank you so much your suggestions. I will try to learn and implement. I had added Clipboard = at the start of the script and that seemed to have worked. I will still implement your suggestions to make the script faster.

Meanwhile, are you able to review the following script which was given to me by very helpful "FanaticGuru" in this forum. I have posed him the same question.
Many thanks.

Most of the time, the script correctly does its job, which is to identify the word "Conclusion:" and add numbering bullets to lines which follow the word "Conclusion:".

So Most of the time, it correctly converts the following...

CONCLUSION:
abc
def
ghi

to

CONCLUSION:
1. abc
2. def
3. ghi

However, it sometimes, and as best as I can tell randomly, converts it as follows...

CONCLUSION:1.
2. abc
3. def
4. ghi

or

CONCLUSION:
2. abc
3. def
4. ghi

The script:

F12::
Send ^a^c
ClipWait
S := "", Bullets := 0
Loop, Parse, Clipboard, `n, `r
{
if Bullet
if A_LoopField
{
S .= Bullet ". " A_LoopField "`r`n"
Bullet ++
continue
}
else
Bullet := 0
S .= A_LoopField "`r`n"
if (A_LoopField = "Conclusion:")
Bullet := 1
}
Clipboard := S
Send ^v
return
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: GUI for copying and pasting

23 Sep 2017, 07:17

@tnmc77
Please use :arrow: -tags ! :thumbup:
tnmc77
Posts: 18
Joined: 27 Aug 2017, 16:53

Re: GUI for copying and pasting

23 Sep 2017, 07:20

Code: Select all

F12::
Send ^a^c
ClipWait
S := "", Bullets := 0
Loop, Parse, Clipboard, `n, `r
{
if Bullet
if A_LoopField
{
S .= Bullet ". " A_LoopField "`r`n"
Bullet ++
continue
}
else
Bullet := 0
S .= A_LoopField "`r`n"
if (A_LoopField = "Conclusion:")
Bullet := 1
}
Clipboard := S
Send ^v
return
tnmc77
Posts: 18
Joined: 27 Aug 2017, 16:53

Re: GUI for copying and pasting

23 Sep 2017, 09:35

A_AhkUser,
Thank you so much your suggestions. I will try to learn and implement. I had added Clipboard = at the start of the script and that seemed to have worked. I will still implement your suggestions to make the script faster.

Meanwhile, are you able to review the following script which was given to me by very helpful "FanaticGuru" in this forum. I have posed him the same question.
Many thanks.

Most of the time, the script correctly does its job, which is to identify the word "Conclusion:" and add numbering bullets to lines which follow the word "Conclusion:".

So Most of the time, it correctly converts the following...

CONCLUSION:
abc
def
ghi

to

CONCLUSION:
1. abc
2. def
3. ghi

However, it sometimes, and as best as I can tell randomly, converts it as follows...

CONCLUSION:1.
2. abc
3. def
4. ghi

or

CONCLUSION:
2. abc
3. def
4. ghi

The script:

Code: Select all

F12::
Send ^a^c
ClipWait
S := "", Bullets := 0
Loop, Parse, Clipboard, `n, `r
{
if Bullet
if A_LoopField
{
S .= Bullet ". " A_LoopField "`r`n"
Bullet ++
continue
}
else
Bullet := 0
S .= A_LoopField "`r`n"
if (A_LoopField = "Conclusion:")
Bullet := 1
}
Clipboard := S
Send ^v
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 217 guests