Page 1 of 1

Please Help woth Simple Copy and Paste Script

Posted: 31 May 2019, 10:38
by robertdangerbyrd
I've spent the last two hours trying to figure this out and I just can't get it.

I need a simple script that presses CTRL C to copy an image that im currently viewing, then Alt Tab to switch the the previous window and CTRL V to paste a copy of that image then Atl Tab to switch back to the image.

Below is what I have and I cant seem to get it.

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

^z::
Send {^c}
Send {AltTab}
Send {^v}
Send {AltTab}
Return

Re: Please Help woth Simple Copy and Paste Script

Posted: 31 May 2019, 11:11
by Hellbent
I have tried a number of times over the years to get alt+Tab to work, but it never works, no matter how I write it.
As for the point about how something is written, I don't use send very often, but I'm not sure Send,{AltTab} is a thing.
Try,

Code: Select all

Send, {Alt Down}{Tab}{Alt Up}
I have seen others say that it works for them, so maybe it will work for you. It has never worked for me though.

If sending Alt+Tab is not a route you end up being able to take, there are a few other ways that you can get the outcome you want. A simple one is to hard code swapping between two known windows. If it's basically always the same two windows, this is a simple enough process to script.

Re: Please Help woth Simple Copy and Paste Script

Posted: 31 May 2019, 11:45
by Hellbent
After some playing around I got it to work using this.

Code: Select all

*Numpad3::
	Send,^c
	ClipWait
	run C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Window Switcher.lnk
	sleep,100
	send,{enter}
	sleep,100
	Send,^v
	run C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Window Switcher.lnk
	sleep,100
	send,{enter}
	return
hope that helps.

Re: Please Help woth Simple Copy and Paste Script

Posted: 31 May 2019, 11:48
by thienphuongx
Send {AltTab} not work
Why not use Send, !{Tab}

Re: Please Help woth Simple Copy and Paste Script

Posted: 31 May 2019, 11:54
by Hellbent
thienphuongx wrote:
31 May 2019, 11:48
Send {AltTab} not work
Why not use Send, !{Tab}
Does that switch windows for you? Doesn't for me.

Re: Please Help woth Simple Copy and Paste Script

Posted: 31 May 2019, 11:58
by thienphuongx
Hellbent wrote:
31 May 2019, 11:54
thienphuongx wrote:
31 May 2019, 11:48
Send {AltTab} not work
Why not use Send, !{Tab}
Does that switch windows for you? Doesn't for me.
I used to win 7 64 bit, And you?

Re: Please Help woth Simple Copy and Paste Script

Posted: 31 May 2019, 12:09
by Hellbent
thienphuongx wrote:
31 May 2019, 11:58
I used to win 7 64 bit, And you?
Win 8.1 64 bit

Re: Please Help woth Simple Copy and Paste Script

Posted: 31 May 2019, 12:26
by Vaklev
Try this:

Code: Select all

^z::
Send {lcontrol down}c{lcontrol up}
Send {lalt down}{tab}{lalt up}
Send {lcontrol down}v{lcontrol up}
Send {lalt down}{tab}{lalt up}
Return

*Numpad3::
	Send {lcontrol down}c{lcontrol up}
	ClipWait
	run C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Window Switcher.lnk
	sleep,100
	send,{enter}
	sleep,100
	Send,{lcontrol down}v{lcontrol up}
	run C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Window Switcher.lnk
	sleep,100
	send,{enter}
	return
	
It will ensure your control and alt keys are firmly pressed while hitting the c and v for copy paste

Note: In case your wondering what the hell that L means, its basically the left control/alt key, you can use R for right but I think L is more practical

Re: Please Help woth Simple Copy and Paste Script

Posted: 01 Jun 2019, 17:36
by robertdangerbyrd
I tried both of the suggested scripts with no success.

I tried with my environment variables and withourt and still no good.

What should the entire txt file look like? I must be missing something.

Re: Please Help woth Simple Copy and Paste Script

Posted: 02 Jun 2019, 12:04
by robertdangerbyrd
OK, I copied this into my file exactly as shown below and it works when I hit Ctrl Z. But maybe 30% of the time it does not swap back to the image.


^z::
Send {lcontrol down}c{lcontrol up}
Send {lalt down}{tab}{lalt up}
Send {lcontrol down}v{lcontrol up}
Send {lalt down}{tab}{lalt up}
Return

*Numpad3::
Send {lcontrol down}c{lcontrol up}
ClipWait
run C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Window Switcher.lnk
sleep,100
send,{enter}
sleep,100
Send,{lcontrol down}v{lcontrol up}
run C:\Users\Default\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Window Switcher.lnk
sleep,100
send,{enter}
return

Re: Please Help woth Simple Copy and Paste Script

Posted: 02 Jun 2019, 12:30
by vsub
From what to what program are you trying to switch(exe name will probably be enough...and if it's not QT window,WinMenuSelectItem will probably also work)

This for example checks every time you copy something if it is image and if it is,send it to xnview without switching windows

Code: Select all

#SingleInstance,Force
#NoEnv
#Persistent
OnClipboardChange("ClipChanged")
Return


ClipChanged() {
if DllCall("IsClipboardFormatAvailable", "Uint", 2)
WinMenuSelectItem,ahk_exe xnview.exe,,Edit,Import Clipboard
}
There are manu ways to change the script to not constantly keep alt+tabing

Re: Please Help woth Simple Copy and Paste Script

Posted: 03 Jun 2019, 12:26
by robertdangerbyrd
I would be looking at an image using the windows photo viewer when I execute the script. I simply want the image im looking at to be copied to the last folder I have had open.

Re: Please Help woth Simple Copy and Paste Script

Posted: 03 Jun 2019, 12:28
by robertdangerbyrd
So what would the entire script be?

Re: Please Help woth Simple Copy and Paste Script

Posted: 03 Jun 2019, 14:27
by vsub
Well if it is that simple,why don't you just use Ctrl+S without the need of a script.
You are pressing Ctrl+Z as a hotkey,the "S" is just a tinny bit higher.

When you choose a folder once,it will always save there

~^s::
keywait,s
WinWaitActive,Save As
Send,{Enter}
Return

You can also choose where to save by using ConrolSetText but as I said,if you save manually once and choose the folder,then after that everything will be saved there

Re: Please Help woth Simple Copy and Paste Script

Posted: 03 Jun 2019, 15:16
by jeeswg
You can get the file path by using the clipboard, as in this script:
How can you extract the full path of the photo visible in photo gallery? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=48993&p=218126#p218126

And then use AHK's FileCopy to copy the file.

Re: Please Help woth Simple Copy and Paste Script

Posted: 18 Jun 2019, 12:21
by robertdangerbyrd
I'm sorry, but I don't really understand enough about this to make use of that information. If you could provide the script that I can copy that would be much appreciated.

Re: Please Help woth Simple Copy and Paste Script

Posted: 22 Jul 2019, 14:59
by robertdangerbyrd
Anybody who can offer some help here? The script works sporadically. Probably 50% of the time it copies the file, and 25% of the time it doesn't switch back to the photo.

Re: Please Help woth Simple Copy and Paste Script

Posted: 22 Jul 2019, 15:02
by robertdangerbyrd
I like the idea of using control S to designate the save to folder, but dont know enough to complete the script.

Re: Please Help woth Simple Copy and Paste Script

Posted: 30 Jul 2019, 14:52
by robertdangerbyrd
anybody willing to assist?

Re: Please Help woth Simple Copy and Paste Script

Posted: 31 Jul 2019, 09:13
by vsub
Do you want the image to always be saved to a specific folder
Do you still want to use Ctrl+Z or it can be another hotkey