Clipboard help

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Trigg
Posts: 97
Joined: 07 Apr 2017, 19:43

Clipboard help

08 May 2017, 14:28

Okay. I'm having clipboard trouble guys. It's a little hard to explain what I'm asking for, but here goes.

Whenever I have any of these letters/numbers copied, I want them to go to certain lines to copy a name. In the end, I want the letters to all eventually go to Contractor, and all the numbers to go to Supplier. If the clipboard is 2, I want it to do something entirely different, but still end up going to Supplier.

Unfortunately, my script is only going to the first line and not going through all the whole script until it finds the copied text/number.

Code: Select all

\::

If Clipboard = A
Goto, A
If Clipboard = B
Goto, Contractor
If Clipboard = C
Goto, C
If Clipboard = CC
Goto, C
If Clipboard = CCC
Goto, C
If Clipboard = CCCC
Goto, C
If Clipboard = D
Goto, Contractor
If Clipboard = E
Goto, E
If Clipboard = EE
Goto, E
If Clipboard = F
Goto, F
If Clipboard = FF
Goto, F
If Clipboard = FFF
Goto, F


;Suppliers

If Clipboard = 1
Goto, Supplier
If Clipboard = 2
Goto, 2
If Clipboard = 22
Goto, 2
If Clipboard = 3
Goto, 3
If Clipboard = 33
Goto, 3
If Clipboard = 4
Goto, Supplier
If Clipboard = 44
Goto, Supplier
If Clipboard = 444
Goto, Supplier
If Clipboard = 5
Goto, Supplier
If Clipboard = 55
Goto, Supplier
If Clipboard = 6
Goto, Supplier
If Clipboard = 66
Goto, Supplier
If Clipboard = 7
Goto, Supplier



;                   Contractors 2

A:
Clipboard = Aaron
ClipWait
MsgBox A
Goto, Contractor

C:
Clipboard = Charlie
ClipWait
Goto, Contractor

D:
Clipboard = Dailey
ClipWait
Goto, Contractor

E:
Clipboard = Elmer
ClipWait
Goto, Contractor

F:
Clipboard = Frederick
ClipWait
Goto, Contractor


;               Suppliers 2


2:
Clipboard = 20000000
ClipWait
Goto, Supplier
Exit
222:
Send, ^v
Exit


22:
Clipboard = 22
ClipWait
Goto, Adjuster

3:
Clipboard = James
ClipWait
Goto, Supplier


Contractor:
MsgBox Contractor
Sleep, 200
Send, ^v


Supplier:
MsgBox Supplier
Sleep, 200
Send, ^v
If Clipboard = 20000000
Goto, 22


Adjuster:
MsgBox Adjuster
Clipboard = 2222222222
Goto, 222
User avatar
Spawnova
Posts: 554
Joined: 08 Jul 2015, 00:12
Contact:

Re: Clipboard help

08 May 2017, 20:55

I'm not sure exactly where your problem lies =[

However I've written a script which you may find useful.

Code: Select all

;contractors[key=letter] := value=name
;if clipboard == E or clipboard == EEE (etc) then it will send Elmer
contractors := []
contractors["A"] := "Aaron"
contractors["B"] := "Bravo"
contractors["C"] := "Charlie"
contractors["D"] := "Dailey"
contractors["E"] := "Elmer"
contractors["F"] := "Frederick"

;suppliers[key=number] := value=number/text
;if clipboard == 3 then it will send james
suppliers := []
suppliers[2] := 20000000
suppliers[3] := "james"
suppliers[22] := 22222222


\::
if clipboard = F
msgbox Frederick
if RegExMatch(clipboard,"^([a-zA-Z])",match) { ;if the clipboard starts with letters save the first letter to match variable
	if contractors.HasKey(match)
		clipboard := contractors[match] ;if the letter is in our array clipboard will equal the array value
	sleep 200
	;if contractors.HasKey(match) ;uncomment if you want to send ^v only when a match is found
	send ^v
} else if RegExMatch(clipboard,"^(\d+)",match) { ;if the clipboard starts with numbers, save them to match variable
	if suppliers.HasKey(match) ;is number is in array, send array value, otherwise just send the number in the clipboard
		clipboard := suppliers[match]
	sleep 200
	send ^v
	if (match == 2 or match == 22) { ;example for extra specific conditions
		msgbox entered 2 or 22`, closing program
		exitapp
	}
}
return
iseahound
Posts: 1444
Joined: 13 Aug 2016, 21:04
Contact:

Re: Clipboard help

08 May 2017, 21:03

use gosub instead of goto.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Joey5 and 335 guests