cliclick(shortfor“CommandLineInterfaceClick”)isatoolforexecutingmouse-andkeyboard-relatedactionsfromtheshell/Terminal.ItiswritteninObjective-CandrunsonOSX10.15orlater.
Formoreinformationorfordownloadingacompiledbinary,pleasetakealookatcliclick’shomepage
Author:CarstenBlüm,Website:www.bluem.net
UsageTogetaquickfirstimpression,thisiswhatyouwillgetwhenyouinvokecliclick-h:
USAGEcliclick[-r][-m<mode>][-d<target>][-e<num>][-f<file>][-w<num>]command1[command2]OPTIONS-rRestoreinitialmouselocationwhenfinished-m<mode>Themodecanbeeither“verbose”(cliclickwillprintadescriptionofeachactiontostdoutjustbeforeitisperformed)or“test”(cliclickwillonlyprintthedescription,butnotperformtheaction)-d<target>Specifythetargetwhenusingthe“p”(“print”)command.Possiblevaluesare:stdout,stderr,clipboardorthepathtoafile(whichwillbeoverwrittenifitexists).Bydefault(ifoptionnotgiven),stdoutisusedforprinting-e<easing>Setaneasingfactorformousemovements.Thehigherthisvalueis(default:0),themorewillmousemovementsseem“natural”or“human-like”,whichalsoimplies:willbeslower.Ifthisoptionisused,theactualspeedwillalsodependonthedistancebetweenthestartandtheendposition,i.e.thetimeneededformovingwillbehigherifthedistanceislarger.-f<file>Insteadofpassingcommandsasarguments,youmayinsteadspecifyafilefromwhichcliclickwillreadthecommands(orstdin,when-isgivenasfilename).Eachlineinthefileisexpectedtocontainacommandinthesameformat/syntaxascommandsgivenasargumentsattheshell.Additionally,linesstartingwiththehashcharacter#areregardedascomments,i.e.:ignored.Leadingandtrailingwhitespaceisignored,too.-w<num>Waitthegivennumberofmillisecondsaftereachevent.Ifyoufindthatyouusethe“wait”commandtoooften,using-wcouldmakethingseasier.Pleasenotethat“wait”isnotaffectedby-w.Thismeansthatinvoking“cliclick-w200wait:500”willwaitfor700milliseconds.Thedefault(andminimum)valuefor-wis20.-VShowcliclickversionnumberandreleasedate-oOpenversionhistoryinabrowser-nSendadonationCOMMANDSTousecliclick,youpassanarbitrarynumberofcommandsasarguments.Acommandconsistsofacommandidentifier(astringthattellscliclickwhatkindofactiontoperform)andusuallyoneormoreargumentstothecommand,whichareseparatedfromthecommandidentifierwithacolon.Example:“c:123,456”isthecommandforclicking(the“c”isthecommandidentifierforclicking)atthepositionwithxcoordinate123andycoordinate456.Seebelowforalistofallcommandsandtheargumentstheyexpect.Wheneveracommandexpectsapairofcoordinates,youmayproviderelativevaluesbyprefixingthenumberwith“+”or“-”.Forexample,“m:+50,+0”willmovethemouse50pixelstotheright.Ofcourse,relativeandabsolutevaluescanbemixed,andnegativevaluesarepossible,so“c:100,-20”wouldbeperfectlyvalid.(Ifyouneedtospecifyabsolutenegativevaluesincaseyouhaveasetupwithaseconddisplayarrangedtotheleftofyourmaindisplay,prefixthenumberwith“=”,forinstance“c:100,=-200”.)LISTOFCOMMANDSrc:x,yWillRIGHT-CLICKatthepointwiththegivencoordinates.Example:“rc:12,34”willright-clickatthepointwithxcoordinate12andycoordinate34.Insteadofxandyvalues,youmayalsouse“.”,whichmeans:thecurrentposition.Using“.”isequivalenttousingrelativezerovalues“c:+0,+0”.m:x,yWillMOVEthemousetothepointwiththegivencoordinates.Example:“m:12,34”willmovethemousetothepointwithxcoordinate12andycoordinate34.kd:keysWilltriggeraKEYDOWNeventforacomma-separatedlistofmodifierkeys.Possiblekeysare:-alt-cmd-ctrl-fn-shiftExample:“kd:cmd,alt”willpressthecommandkeyandtheoptionkey(andwillkeepthemdownuntilyoureleasethemwithanothercommand)kp:keyWillemulatePRESSINGAKEY(keydown+keyup).Possiblekeysare:-arrow-down-arrow-left-arrow-right-arrow-up-brightness-down-brightness-up-delete-end-enter-esc-f1-f2-f3-f4-f5-f6-f7-f8-f9-f10-f11-f12-f13-f14-f15-f16-fwd-delete-home-keys-light-down-keys-light-toggle-keys-light-up-mute-num-0-num-1-num-2-num-3-num-4-num-5-num-6-num-7-num-8-num-9-num-clear-num-divide-num-enter-num-equals-num-minus-num-multiply-num-plus-page-down-page-up-play-next-play-pause-play-previous-return-space-tab-volume-down-volume-upExample:“kp:return”willhitthereturnkey.tc:x,yWillTRIPLE-CLICKatthepointwiththegivencoordinates.Example:“tc:12,34”willtriple-clickatthepointwithxcoordinate12andycoordinate34.Insteadofxandyvalues,youmayalsouse“.”,whichmeans:thecurrentposition.Note:Ifyoufindthatthisdoesnotworkinatargetapplication,pleasetryifdouble-clickingplussingle-clickingdoes.ku:keysWilltriggeraKEYUPeventforacomma-separatedlistofmodifierkeys.Possiblekeysare:-alt-cmd-ctrl-fn-shiftExample:“ku:cmd,ctrl”willreleasethecommandkeyandthecontrolkey(whichwillonlyhaveaneffectifyouperformeda“keydown”before)dm:x,yWillcontinuetheDRAGeventtothegivencoordinates.Example:“dm:112,134”willdragandcontinuetothepointwithxcoordinate112andycoordinate134.c:x,yWillCLICKatthepointwiththegivencoordinates.Example:“c:12,34”willclickatthepointwithxcoordinate12andycoordinate34.Insteadofxandyvalues,youmayalsouse“.”,whichmeans:thecurrentposition.Using“.”isequivalenttousingrelativezerovalues“c:+0,+0”.dd:x,yWillpressdowntoSTARTADRAGatthegivencoordinates.Example:“dd:12,34”willpressdownatthepointwithxcoordinate12andycoordinate34.Insteadofxandyvalues,youmayalsouse“.”,whichmeans:thecurrentposition.w:msWillWAIT/PAUSEforthegivennumberofmilliseconds.Example:“w:500”willpausecommandexecutionforhalfasecondp[:str]WillPRINTthegivenstring.Ifthestringis“.”,thecurrentMOUSEPOSITIONisprinted.Asaconvenience,youcanskipthestringcompletelyandjustwrite“p”togetthecurrentposition.Example:“p:.”or“p”willprintthecurrentmousepositionExample:“p:'Helloworld'”willprint“Helloworld”du:x,yWillreleasetoENDADRAGatthegivencoordinates.Example:“du:112,134”willreleaseatthepointwithxcoordinate112andycoordinate134.cp:strWillPRINTTHECOLORvalueatthegivenscreenlocation.Thecolorvalueisprintedasthreedecimal8-bitvalues,representing,inorder,red,green,andblue.Example:“cp:123,456”mightprint“127630”dc:x,yWillDOUBLE-CLICKatthepointwiththegivencoordinates.Example:“dc:12,34”willdouble-clickatthepointwithxcoordinate12andycoordinate34.Insteadofxandyvalues,youmayalsouse“.”,whichmeans:thecurrentposition.t:textWillTYPEthegivenTEXTintothefrontmostapplication.Ifthetextincludesspace(s),itmustbeenclosedinquotes.Example:“type:Test”willtype“Test”Example:“type:'VieleGrüße'”willtype“VieleGrüße”LimitationsItisnotpossibletousecliclickbeforeauserlogsin,i.e.:tocontroltheloginwindow.
BuildingcliclickEitherbuildinXcode,asusual,orbuildfromtheshellbycdingintotheprojectdirectoryandtheninvokingeitherxcodebuildormake(whateveryouprefer).Ineithercase,cliclickwillnotbeinstalled,butyouwillsimplygetanexecutablecalled“cliclick”intheprojectdirectorywhichyoucanthenmovewhereveryouwanttohaveit.(Youcanputitanywhereyoulike.)Toinstallitto/usr/local/bin,youcanalsosimplyinvokesudomakeinstall,whichwilldothisforyou.
PleasenotethatwhilethecodewillrunonOSX10.9andlater,BaseSDKandarchitecturesselectedintheXcodeprojectaresettothecurrentSDK.Therefore,ifyouwanttobuildforanoldersystem,besuretochangethesesettingsaccordingly.Ifyouhaveproblemswhenbuildingandgetamessagecomplainingaboutundefinedsymbols,chancesarethatthiscanbefixedbydisabling“ImplicitlylinkObjective-CRuntimeSupport”inthebuildsettings.
ContributingIfyouwouldliketocontributeanewfeature,abugfixorotherimprovement,pleasedosousingapullrequest.However,pleasetakecarethat:
Thereisonepullrequestpertopic.I.e.:ifyouwouldliketocontributeanewfeatureandtwobugfixes,openthreepullrequests.AllcommitmessagesareinEnglish.Ideally,allnon-obviousfeaturesorchangesshouldbeshortlyexplained.Thismightnotonlyincludewhatyoucommitted,butalsowhyyoudidit(motivation,usagescenario,…).
评论