what does ByRef do? - AutoHotkey Community
文章推薦指數: 80 %
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
延伸文章資訊
- 1函數- AutoHotKey.tw - Google Sites
同樣地, 使用ByRef 送回長字串給呼叫者通常比類似 Return HugeString 的方式執行的更好. [AHK_L 60+]: 如果傳遞給ByRef 參數的不是可修改的變數, 那麼函數...
- 2AutoHotkey-Scripts/Functions.ahk at master - GitHub
A collection of my AutoHotkey scripts and libraries - AutoHotkey-Scripts/Functions.ahk at master ...
- 3returning values from an AutoHotkey function with byref
- 4Get String Value of passed ByRef Variable - Stack Overflow
ahk 002: myvar := "george" 003: passit(myvar) 007: MsgBox,GetOriginalVariableNameForSingleArgumen...
- 5函数| AutoHotkey
然而, 当函数传递给它自己全局变量, 静态变量或ByRef 参数时不会产生这样的问题. 如果一个参数在函数调用中被解析为一个变量(例如 Var 或 ++Var 或 Var*=2 ) ...