#Include Com.ahk ; COM
RunMSWordMacro(correct)
{
COM_Init()
Word := COM_GetActiveObject("Word.Application")
COM_Invoke(Word, "Run", "!"correct)
COM_Release(Word)
COM_Term()
}
; the hotkey is 1
1::RunMSWordMacro("correct")
为什么这段代码不起作用?看看图片“留言”,并帮助我 拜托,我是autohotkey的新用户。
当我按下热键时,它给了我这样的信息:
这是我的vba代码:
感谢David Metcalfe,这是我的vba代码:
Sub correct()
'
' correct Macro
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "p "
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.TypeText Text:="o "
End Sub
答案 0 :(得分:0)
如果您解释了代码的最终目标,那将会有所帮助。根据您提供的VBA,您似乎只是尝试运行Microsoft Word,在这种情况下,您可以完全使用AutoHotkey。
使用Run语法非常简单。
Run, C:\Path\to\Microsoft Word.exe
答案 1 :(得分:0)
来自这里的帮助: [https://autohotkey.com/boards/viewtopic.php?f=5&t=37197&e=1&view=unread#unread][1]
public async Task<AuthenticationResult> GetTokenByAuthorizationCodeAsync(string userId, string code, IMemoryCache memoryCache)
{
TokenCache userTokenCache = new SessionTokenCache(userId, memoryCache).GetCacheInstance();
try
{
AuthenticationContext authContext = new AuthenticationContext("https://login.microsoftonline.com/common/oauth2/v2.0/token/", userTokenCache);
ClientCredential credential = new ClientCredential(Configuration["MicrosoftAuth:ClientId"], Configuration["MicrosoftAuth:ClientSecret"]);
string[] scope = new List<String>().Append("https://graph.windows.net").ToArray();
AuthenticationResult result = await authContext.AcquireTokenByAuthorizationCodeAsync(code,new Uri(Configuration["MicrosoftAuth:RedirectUri"]), credential, Configuration["MicrosoftAuth:ResourceId"]);
return result;
}
catch (Exception)
{
return null;
}
}