2016-04-04 11 views
0

私のif行8の文が機能しません。 %Width%のMsgboxが3200を示しても、私は常に「幅は3200ではありません」というメッセージボックスを表示します。 ifを==に変更し、3200ではなく「3200」をチェックすることは効果がありません。Autohotkey if文が機能していない

また、ifの文をactiveMonitorInfoメソッドの中に入れました。これは同じ動作を示しています。

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

activeMonitorInfo(X, Y, Width, Height) 
Msgbox %Width% 

if (%Width% = 3200) { 
    msgbox "Width is 3200" 
    return 
} else { 
    msgbox "Width is not 3200" 
    return 
} 

activeMonitorInfo(ByRef X, ByRef Y, ByRef Width, ByRef Height) 
{ 
    CoordMode, Mouse, Screen 
    MouseGetPos, mouseX , mouseY 
    SysGet, monCount, MonitorCount 
    Loop %monCount% 
    { 
     SysGet, curMon, Monitor, %a_index% 
     if (mouseX >= curMonLeft and mouseX <= curMonRight and mouseY >= curMonTop and mouseY <= curMonBottom) { 
       X  := curMonTop 
       y  := curMonLeft 
       Height := curMonBottom - curMonTop 
       Width := curMonRight - curMonLeft 
       return 
     } 
    } 
} 

答えて

1

省略パーセント記号:

if width = 3200 
{ 

if(width=="3200") { 

と同じよう

if (Width = 3200) { 

同じですが、いくつかの理由のため、if width == 3200またはif width = "3200"は動作しません。私は上記の最初の方法を使用するだけで、何も間違ってしまうことはありません。

ドキュメントでvalue(または名前、テキスト、番号など)が明示的に求められる場合は、%が必要です。

また、リテラルアサイメントのパーセント記号:a = %width%を使用します。ただし、式の割り当てがa := widthの場合は使用できません。

+0

ありがとうございます、私はピエロです:) – RichardB

関連する問題