Pausing the Windows Clipboard

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
GameNtt
Posts: 154
Joined: 19 Aug 2022, 03:36

Pausing the Windows Clipboard

Post by GameNtt » 27 Nov 2022, 00:36

A while back, I had asked how to stop/pause the Windows Clipboard service on Reddit. A user had given me a response
Via net or sc executables:

sc stop SERVICE
sc start SERVICE

net stop SERVICE
net start SERVICE
There are more methods tho, but this are the easiest.

searX: start/stop Windows services

That you'll need to invoke via Run(docs) command from AHK:

Run sc.exe stop SERVICE,, Hide
I had asked them to tell how to stop/pause it in the context of a hotkey as I did not exactly understand it but they never responded. So could anyone do it in the context of a hotkey?
An example hotkey could be this

Code: Select all

#^c::
;pause the service
Send, ^c
;unpause the service
https://www.reddit.com/r/AutoHotkey/comments/y5hkxc/comment/isya3cg/

User avatar
Smile_
Posts: 858
Joined: 03 May 2020, 00:51

Re: Pausing the Windows Clipboard

Post by Smile_ » 27 Nov 2022, 03:01

Press Windows + Ctrl + C to start or stop a non-disactivated service.

Code: Select all

#^c::(Toggle := !Toggle ) ? Run("net start SERVICE") : Run("net stop SERVICE")

Run(c) {
	Run, %ComSpec% /k %c%
}

GameNtt
Posts: 154
Joined: 19 Aug 2022, 03:36

Re: Pausing the Windows Clipboard

Post by GameNtt » 27 Nov 2022, 03:54

How would I implement it without a toggle? I want it in such a way that it gets paused and unpaused without manual input. Like in this hotkey, I'm copying text and storing in a variable which I don't want to clutter the clipboard so I want to pause it before I copy then after copying, the clipboard resumes. The way I do it right now is a little complicated that's why I want a solution that works in a simpler way.

Code: Select all

;below is the way I am doing it currently
#^c::
Send, ^c
ClipWait
text := Clipboard
clipboard = 
return

User avatar
Smile_
Posts: 858
Joined: 03 May 2020, 00:51

Re: Pausing the Windows Clipboard

Post by Smile_ » 27 Nov 2022, 04:25

Well then I believe you don't have to stop a service for that

Code: Select all

#^c::
	SavedClip := ClipboardAll	; Save the clipboard.

	Clipboard := ""
	Send, ^c
	ClipWait
	text := Clipboard

	Clipboard := SavedClip		; Restore the saved clipboard.
Return
See the first example here.

GameNtt
Posts: 154
Joined: 19 Aug 2022, 03:36

Re: Pausing the Windows Clipboard

Post by GameNtt » 27 Nov 2022, 04:43

Smile_ wrote: Well then I believe you don't have to stop a service for that

Code: Select all

#^c::
	SavedClip := ClipboardAll	; Save the clipboard.

	Clipboard := ""
	Send, ^c
	ClipWait
	text := Clipboard

	Clipboard := SavedClip		; Restore the saved clipboard.
Return
See the first example here.
I don't have to stop a service for that, but I am asking how would I go about stopping a service within a hotkey without manual input so that if I wish to I could implement it in a hotkey.

User avatar
Smile_
Posts: 858
Joined: 03 May 2020, 00:51

Re: Pausing the Windows Clipboard

Post by Smile_ » 27 Nov 2022, 04:51

Then you have it, last script should do the trick.
last script saves the current clipboard in the first line SavedClip := ClipboardAll, then make use like you want of the clipboard, then it restores back the saved clipboard just in the last line Clipboard := SavedClip.

Post Reply

Return to “Ask for Help (v1)”