2013-07-23 5 views
0

Я знаю, что мне не хватает чего-то очевидного, но я не могу понять, почему это не работает. Почему не приветствуется в первом msgbox, я знаю, он говорит, что переменная не назначена, если я раскомментирую #Warn? Это единственное в файле 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 

ответ

1

Ваше назначение ADPass никогда не будет выполнено, так как она находится между 2 горячими клавишами. Вы должны поместить его перед тем, как начать свои горячие клавиши (до ^!z) или поместить его в свою горячую клавишу (!5), чтобы убедиться, что она выполнена.

+0

Спасибо, я должен пропустить, что в руководстве! –

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 
Смежные вопросы