what does ByRef do? - AutoHotkey Community

文章推薦指數: 80 %
投票人數:10人

You can compare a byrefparameter to the 'outpuvar...' paramater of MouseGetPos command, for exemple: Code: Select all - Download - Toggle ... AutoHotkeyCommunity Let'shelpeachotherout Skiptocontent Home Quicklinks Unansweredtopics Activetopics Search WebSearch Forums Members Theteam IRC Commands Tutorial Download - 1.1.34.04 FAQ Login Register Search Login Register WebSearch Search Advancedsearch Home Boardindex AutoHotkey AskForHelp Search Itiscurrently25Aug2022,14:00 AlltimesareUTC-05:00 whatdoesByRefdo? Topicissolved GethelpwithusingAutoHotkeyanditscommandsandhotkeys Forumrules PostReply Emailtopic Printview Search Advancedsearch 4posts •Page1of1 bigdeal Posts:66 Joined:13Feb2017,06:31 whatdoesByRefdo? Reportthispost @ Quote 09Apr2017,13:48 heyimnewbieandimalittlestartingtolearnahk,soIreaditandstilldon'tunderstandwhatitdoes,cansomeoneexplainmequick,thanksinadvancebtw Top A_AhkUser Posts:1147 Joined:06Mar2017,16:18 GitHub:AAhkUser Location:France Re:whatdoesByRefdo? Reportthispost @ Quote 09Apr2017,14:31 Code:SelectallMyFunc(__param){ ;... } MyFunc(test) MsgBox%test;returnblanknotdefinedoutsidethescopeofthefunction ;---------------------------------------- MyFunc(ByRef__param){ __param:="blabla" } MyFunc(test) MsgBox%test;returnblablasincetheuseofByRefcauseseachparametertobecomeanaliasforthevariablepassedinfromthecaller EDIT*: Youcancompareabyrefparametertothe'outpuvar...'paramaterofMouseGetPoscommand,forexemple: Code:SelectallMouseGetPos,OutputVarX,OutputVarY,OutputVarWin,OutputVarControl MsgBox%"theIDofthewindowunderthemousis".OutputVarWin and: Code:SelectallMouseGetPos(OutputVarX,OutputVarY,OutputVarWin,OutputVarControl) MsgBox%"theIDofthewindowunderthemousis".OutputVarWin MouseGetPos(ByRefOutputVarX:"",ByRefOutputVarY:="",ByRefOutputVarWin:="",ByRefOutputVarControl:="",Mode:=""){ MouseGetPos,OutputVarX,OutputVarY,OutputVarWin,OutputVarControl,%Mode } dobasicallythesame. Hopethishelps. LasteditedbyA_AhkUseron09Apr2017,14:41,edited1timeintotal. ■myscripts■ Top bigdeal Posts:66 Joined:13Feb2017,06:31 Re:whatdoesByRefdo? Reportthispost @ Quote 09Apr2017,14:41 OOOOOOOOOOOOsoitallowsyoutousethatvariableinthefunction,gotitthanksalotman Top A_AhkUser Posts:1147 Joined:06Mar2017,16:18 GitHub:AAhkUser Location:France Re:whatdoesByRefdo?  Topicissolved Reportthispost @ Quote 09Apr2017,15:13 bigdealwrote:OOOOOOOOOOOOsoitallowsyoutousethatvariableinthefunction Yesbutnoteitisalsothedefnitionoftheglobalkeywords: Code:Selectalltest:="" MyFunc(){ globaltest;maketest--createoutsidethefunction--accessiblewithinthescopeofthefunction--wherevariableareallimpicitlylocals--declaringitasglobal(see:https://autohotkey.com/docs/Functions.htm#Locals) test:="bonjour" } MyFunc() MsgBox%test;returnsbonjour Infact,oneofthemainadvantageofusingByRefisthatitallowssendbackextraresultssincereturncansendbackonlyonevalue. Code:Selectalltest:="" MyFunc(ByRef__param){ globaltest:="bonjour" __param:=100*3 return7 } MsgBox%MyFunc(var).",".test.",".var;returns7,bonjour,300 SeealsodocumentationnowyougotitforothercasewhereitisadvantageoustouseByRefparameters. ■myscripts■ Top Displaypostsfromprevious:Allposts1day7days2weeks1month3months6months1year SortbyAuthorPosttimeSubjectAscendingDescending PostReply Emailtopic Printview 4posts •Page1of1 Returnto“AskForHelp” Jumpto AutoHotkeyFoundation   AboutThisCommunity   ForumIssues AutoHotkey   AskForHelp     Gaming     AutoHotkeyv2Help   ScriptsandFunctions     Gaming     AutoHotkeyv2ScriptsandFunctions   Tutorials     TipsandTricks     TipsandTricksforv2   WishList     Suggestionsondocumentationimprovements   BugReports   AutoHotkeyv2Development   AutoHotkey_H     AskForHelp     Development   Announcements   Editors     AdventureIDE       OldTopics     AHKStudio     Notepad++     PuloversMacroCreator     SciTE4AutoHotkey     VisualStudioCode   GeneralDiscussion General   OtherUtilities&Resources   OtherProgrammingLanguages     C/C++     ASM     C#   Offtopic   RPA Otherlanguages   LookingforVolunteersinotherlanguages   Deutsch(German)     IchbraucheHilfe       Spiele     SkripteundFunktionen     Tutorials     Tooltime     Allgemeines   中文(Chinese)     请求帮助     脚本函数     教程资料     相关工具     其他   Español(Spanish)     PedirAyuda       AutomatizacióndeJuegos     ScriptsyFunciones     Tutoriales     OtrasUtilidadesyRecursos     General   Русский(Russian)     Помощь       СкриптыдляИгр     Скриптыибиблиотеки     Статьиируководства     ПрочиересурсыиПО.     Свободноеобщение   Français(French)     J'aibesoind'aide     ScriptsetFonctions     Tutoriels     AutresUtilitairesetRessources     HorsSujet   Português(Portuguese)     AjudaeSuporteGeral     ScriptseFunções     Tutoriais     OutrasFerramentaseRecursos     OutrosAssuntos   한국어(Korean) Whoisonline Usersbrowsingthisforum:Avtem,Bill,Bing[Bot],dellarocco88,dieissonc,Google[Bot],hunger2k,miracle,Smile_,swub,teadrinker,wddoggerand70guests Home Boardindex AlltimesareUTC-05:00 Deletecookies Theteam Contactus PoweredbyphpBB®ForumSoftware©phpBBLimited StylebyArty    



請為這篇文章評分?