从“右键单击”菜单中的字符串项创建变量

时间:2013-09-08 20:25:33

标签: autohotkey

我一直在使用优秀的Autohotkey一段时间,尽管以前没有编程经验,但已经能够为各种应用程序创建许多有用的快捷方式。

但是我正在努力创建一个简单的脚本来执行以下操作;

  • 在应用程序Ninjatrader 7(标题为“市场分析器”)
  • 中打开一个窗口
  • 打开“右键单击”菜单(此窗口中没有菜单栏),
  • 在此菜单中选择项目,打开“子菜单”
  • 现在我可以选择项目(大约30个)。名字&数量会每天不同。

我可以使用'ENTER'选择一个项目,这会将信息加载到窗口中(它是行和列格式),

所有这一切我都能做到。问题是,此刻它加载列表中的每个项目!

我希望能够指定一些项目来从列表中“排除”加载。我不明白的是AHK在突出显示项目/领域时是如何看待的?是看到'文字','屏幕位置',ascii还是什么?一旦我知道如何引用这些信息,我就可以创建一个“变量”来与之进行比较。

我担心我的知识非常有限,尽管我正在尽可能多地阅读以找到答案,但这非常令人沮丧。

我不是在寻找有人为我做这一切,只是一个帮助我前进的解释。我相信这将是一个简单的练习,但现在似乎超出了我的能力,我迫不及待地想为自己做这件事。

这是我到目前为止的代码。

; This is rough example of what I'm trying to achieve.
; I am aware this doesn't work at the moment but it shows the process as I see it!
; I don't know how to loop and select the next line down in the menu each time round?
; The list changes on a daily basis which is why I need to recognise the text as opposed  
; to just having a preset number of down arrow commands which would have solved my problem.
; I know it's a bit crude but it should show you what I mean! 

^+I::
WinActivate Market Analyzer
var1 = "Default""Forex""RSS" ; example of items that I want to omit from being selected

    Loop 6 ; example number of loops

    SEND +{F10}{DOWN 2}{Right}
IfInString, var1, "Default""Forex""RSS"
    {
    ; Do nothing
    }
else
    {
    Send {Enter}
    }
    SEND +{F10}{DOWN 2}{Right}{Down 1}
IfInString, var1, "Default""Forex""RSS"
    {
    ; Do nothing
    }
else
    {
    Send {Enter}
    }
    SEND +{F10}{DOWN 2}{Right}{Down 2}
IfInString, var1, "Default""Forex""RSS"
    {
    ; Do nothing 
    }
else
    {
    Send {Enter}
    }
    SEND +{F10}{DOWN 2}{Right}{Down 3}
IfInString, var1, "Default""Forex""RSS"
    {
    ; Do nothing
    }
else
    {
    Send {Enter}
    }
    SEND +{F10}{DOWN 2}{Right}{Down 4}
IfInString, var1, "Default""Forex""RSS"
    {
    ; Do nothing
    }
else
    {
    Send {Enter}
    }
    SEND +{F10}{DOWN 2}{Right}{Down 5}
IfInString, var1, "Default""Forex""RSS"
    {
    ; Do nothing 
    }
else
    {
    Send {Enter}
    }
return  

^+I::
WinActivate Market Analyzer
SEND +{F10}{DOWN 2}{RIGHT}{ENTER}          ;INSTRUMENT 1
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 1}{ENTER}  ;INSTRUMENT 2
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 2}{ENTER}  ;INSTRUMENT 3
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 3}{ENTER}  ;INSTRUMENT 4
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 4}{ENTER}  ;INSTRUMENT 5
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 5}{ENTER}  ;INSTRUMENT 6   
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 6}{ENTER}  ;INSTRUMENT 7
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 7}{ENTER}  ;INSTRUMENT 8
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 8}{ENTER}  ;INSTRUMENT 9
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 9}{ENTER}  ;INSTRUMENT 10
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 10}{ENTER} ;INSTRUMENT 11
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 11}{ENTER} ;INSTRUMENT 12
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 12}{ENTER} ;INSTRUMENT 13
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 13}{ENTER} ;INSTRUMENT 14
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 14}{ENTER} ;INSTRUMENT 15
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 15}{ENTER} ;INSTRUMENT 16
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 16}{ENTER} ;INSTRUMENT 17
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 17}{ENTER} ;INSTRUMENT 18
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 18}{ENTER} ;INSTRUMENT 19
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 19}{ENTER} ;INSTRUMENT 20
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 20}{ENTER} ;INSTRUMENT 21
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 21}{ENTER} ;INSTRUMENT 22
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 22}{ENTER} ;INSTRUMENT 23
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 23}{ENTER} ;INSTRUMENT 24
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 24}{ENTER} ;INSTRUMENT 25
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 25}{ENTER} ;INSTRUMENT 26
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 26}{ENTER} ;INSTRUMENT 27
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 27}{ENTER} ;INSTRUMENT 28
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 28}{ENTER} ;INSTRUMENT 29
SEND +{F10}{DOWN 2}{RIGHT}{DOWN 29}{ENTER} ;INSTRUMENT 30
RETURN      

非常感谢您提供的任何帮助!

0 个答案:

没有答案