Suspend Copy and Paste Script with Key-hold Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
delliott
Posts: 2
Joined: 21 Jan 2019, 16:34

Suspend Copy and Paste Script with Key-hold

21 Jan 2019, 17:31

Hi, AHK Community!

I'm fairly new to auto-hotkey, but have been using it for quite some time now to help me with repetitive tasks. I have been diving into the forum and tutorials, but have hit a dead end on resolving my currently dilemma. My right arm is disabled. I frequently use the copy and paste function within Windows, more so I use the mouse for a majority of my task. The mouse only consists of a left click (LButton), right click button (RButton), middle mouse click (MButton), and up (WheelUp) and down (WheelDown) scroll wheel capabilities.

Summary of Problem: I have grown partial to using a code for "Scroll Up" (WheelUp) for Copying Text/Numbers and "Scroll Down" (WheelDown) for Pasting them. This keeps me working, without having to remove my hand from the mouse to the keyboard to press Ctrl-C and Ctrl-V. The problem is, while this grants me additional productivity it also takes away from the scroll wheel's intended use (or in my case, quickly scrolling up and down rather lengthy reports). I've tried AHK 'Pause' Breaks, and KeyWait to no avail. Honestly, every time I try to tackle adding new code to try and get my desired effect it results in a dumpster fire. I've given up.

Goal: My first priority is to retain the hotkey I currently have setup within mouse's scroll wheel for WheelUp-Copy and WheelDown-Paste, but I would also like the ability to disable it briefly in order to quickly scroll up and down a report/web page/file. My goal would be a code that will temporary disable my hotkey, WheelUp-Copy and WheelDown-Paste, by simply holding down the Left Click (LButton); briefly allowing me to quickly scroll up and down a page. Preferably, the copy/paste feature I have written would reactivate by simply letting go of the left click (LButton).

Scroll Up/Down Copies and Paste, unless I have the left mouse button held down. If the left mouse button is held down, the mouse wheel scrolls up and down web pages.

What I have now:
SetControlDelay, -1
SetWinDelay, -1
SetMouseDelay, -1
SetKeyDelay, -1
SetBatchLines, -1
ListLines, Off
Process, Priority,, High
#KeyHistory 0
#NoEnv
#SingleInstance Force
WheelUp::^c
WheelDown::^v
Return

PS: I already use the middle mouse button for this:
Mbutton::
FormatTime, CurrentDateTime,, MM/dd/yyyy
SendInput %CurrentDateTime%{space}


I would appreciate any help you could provide!

Thank you,
Don | [email protected]
User avatar
SALZKARTOFFEEEL
Posts: 60
Joined: 10 May 2017, 11:14
GitHub: SALZKARTOFFEEEL
Location: Germany
Contact:

Re: Suspend Copy and Paste Script with Key-hold

21 Jan 2019, 17:53

Your goal isn't quite that simple to achieve in just the way you wrote it. Enabling you to scroll while the left mouse button is pressed is problematic to say the least. The left mouse button is used for way too much and having such a functionality would either disable it entirely (not good) or create a total mess while scrolling, because you essentially drag your mouse when you click and scroll (maybe a bit better).
Instead, how about using a short click of both mouse buttons (left and right) to toggle scrolling?
Here is the code for that:

Code: Select all

toggle := true

#if
~LButton::
~RButton::
If GetKeyState("LButton") && GetKeyState("RButton")
	toggle := !toggle
return

#if toggle
WheelUp::^c
WheelDown::^v
I really hope this helps.
If you have any questions, feedback, whatever, just ask/tell me! I can also walk you through a full explanation of the little script, if you want that.
mast4rwang
Posts: 141
Joined: 19 Jul 2017, 09:59

Re: Suspend Copy and Paste Script with Key-hold  Topic is solved

21 Jan 2019, 18:04

Code: Select all

#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
;#NoTrayIcon
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
CoordMode, Mouse, Screen

*WheelUp::
    if(GetKeyState("LButton", "P") = 0)
    {
        send,{LCtrl Down}
        send,{c Down}
        sleep,25
        send,{c Up}
        send,{LCtrl Up}
    }
    else
        send,{WheelUp}
return


*WheelDown::
    if(GetKeyState("LButton", "P") = 0)
    {
        send,{LCtrl Down}
        send,{v Down}
        sleep,25
        send,{v Up}
        send,{LCtrl Up}
    }
    else
        send,{WheelDown}
Return

delliott
Posts: 2
Joined: 21 Jan 2019, 16:34

Re: Suspend Copy and Paste Script with Key-hold

21 Jan 2019, 22:00

Thank you so much for your help! I appreciate this more than you will ever know.

You're both awesome,
Don

Return to “Ask For Help”

Who is online

Users browsing this forum: flyingDman, hot4harddrives, MannyKSoSo and 198 guests