【问题标题】:Easiest way to call a Windows macro from Autohotkey (or VB)?从 Autohotkey(或 VB)调用 Windows 宏的最简单方法?
【发布时间】:2010-09-20 06:17:34
【问题描述】:

我想在 AutoHotkey 脚本中调用以下宏,以便将 MonthCal 对象中的某些日期设置为粗体。

http://msdn.microsoft.com/en-us/library/bb774722(VS.85).aspx

我会怎么做呢?

请注意,最简单的方法可能是编写一个使用宏并调用它的简单 VB 脚本。但我对 VB 脚本一无所知。有什么想法吗?

【问题讨论】:

    标签: windows vbscript macros autohotkey


    【解决方案1】:

    我通过他们伟大的 IRC channel 找到了以下脚本 on the AutoHotkey forums(感谢 _rhys 和 Titan)

    monthNb := 3   ; How many months are displayed. Can be fetched with MCM_GETMONTHRANGE
    MCM_FIRST := 0x1000
    MCM_SETDAYSTATE := MCM_FIRST + 8
    
    ; MCS_DAYSTATE = 1
    Gui, Add, MonthCal, +0x1 vMyCalendar
    Gui, Add, Button, gBoldify w100, B
    Gui Show
    
    Gui +LastFound
    guiID := WinExist()
    ControlGet mcID, Hwnd, , SysMonthCal321, ahk_id %guiID%
    
    Gosub SetDayState
    Return
    
    Boldify:
    VarSetCapacity(daysBuffer, 4 * monthNb, 0)
    if bOdd
    {
       days = 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31
    }
    else
    {
       days = 2,4,6,8,10,12,14,16,18,20,22,24,26,28,30
    }
    bOdd := not bOdd
    addr := &daysBuffer + 4
    Loop Parse, days, `,
    {
       o1 := (A_LoopField - 1) / 8
       o2 := Mod(A_LoopField - 1, 8)
       val := *(addr + o1) | (1 << o2)
       DllCall("RtlFillMemory", "UInt", addr + o1, "UInt", 1, "UChar", val)
    }
    Gosub SetDayState
    Return
    
    SetDayState:
       SendMessage MCM_SETDAYSTATE, monthNb, &daysBuffer, , ahk_id %mcID%
    Return
    
    GuiClose:
    GuiEscape:
    ExitApp
    

    【讨论】:

      猜你喜欢
      • 2018-04-12
      • 2010-11-10
      • 2017-10-19
      • 2010-11-03
      • 1970-01-01
      • 1970-01-01
      • 2020-11-09
      • 2010-09-11
      • 1970-01-01
      相关资源
      最近更新 更多