0

明らかな何かが欠けていることは知っていますが、なぜこれが機能しないのかわかりません。#Warn のコメントを外すと、変数が割り当てられていないことを知っている最初のメッセージボックスに hello が表示されないのはなぜですか? これは、ahk ファイル内の唯一のものです。

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance force

; Reload the script  
^!z::
WinActivate, ahk_class Notepad++
Send {ctrl down}s{ctrl up}
sleep 100
Reload
return


ADPass = hello

!5::
MsgBox, %ADPass%
Msgbox, test
return
4

2 に答える 2

0

他の答えはおそらくうまくいくと思います.リターンの前に変数を設定する必要があります. 戻り値は、マシンがそのコード行に到達していないことを意味します。これを試してください。

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance force
ADPass = hello; this doesn't have to stay here, just make sure it's before the return.
; Reload the script  
^!z::
WinActivate, ahk_class Notepad++
Send {ctrl down}s{ctrl up}
sleep 100
Reload
return




!5::
MsgBox, %ADPass%
Msgbox, test
return

また

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance force
; Reload the script  
^!z::
WinActivate, ahk_class Notepad++
Send {ctrl down}s{ctrl up}
sleep 100
Reload
return




!5::
goto set
point:
MsgBox, %ADPass%
Msgbox, test
return


set:
ADPass = hello
goto point
Return
于 2013-07-23T21:13:06.463 に答える