我用 AppleScript 制作了一个名为 FRIDAY 的应用程序。当我告诉它“打开 chrome”时,它会打开谷歌浏览器,这是在脚本编辑器和脚本编辑器的外部工作。我还可以告诉它“打开一个新标签”并使用按键打开一个新标签:
-- this boolean is the reason this script keeps runing
set condition to false
say "Welcome sir"
set commands to {"what is todays date", "what time is it", "what is the time", "what day is it", "what month is it", "which month is it", "friday you up", "friday", "friday you tere", "you there", "empty the trash", "take out the trash", "clean up", "new tab", "next tab", "back", "take a nap", "go to sleep", "take …Run Code Online (Sandbox Code Playgroud) applescript keystroke systemevent applescript-objc system-error
我有一个WinForms应用程序,可以在系统进入暂停状态(睡眠)和恢复时跟踪.App将SystemEvents此类用于此目的.它在我的机器上工作正常.但是,对于某些用户来说,似乎PowerModes.Resume并不总是提出事件.应用程序接收多个,其间PowerModes.Suspend没有任何PowerModes.Resume奇怪的.
我的主要问题是如何可能发生这种情况以及如何避免它并使恢复检测可靠?
代码非常简单,基本上遵循(非常简短):
Imports Microsoft.Win32
Friend Class TehClass
Implements IDisposable
Private Sub New()
AddHandler SystemEvents.PowerModeChanged, AddressOf Me.System_PowerModeChanged
End Sub
Private Sub System_PowerModeChanged(sender As Object, args As PowerModeChangedEventArgs)
Log.Info("Power mode changed: {0}.", args.Mode)
End Sub
#Region "IDisposable Support"
' just dropping handler there
#End Region
End Class
Run Code Online (Sandbox Code Playgroud)
应用程序中始终存在一个现有表单.但是,它可以在通知区域中最小化或隐藏.还有一些参考实际的实例TehClass.
这是示例日志:
[2015-09-15 22:38:38,501] Power mode changed: Suspend.
[2015-09-16 07:10:31,106] Power mode changed: Resume.
[2015-09-16 08:54:21,112] Power mode changed: Suspend.
[2015-09-16 09:14:36,252] Power mode …Run Code Online (Sandbox Code Playgroud) 最近我试图制作一个日历应用程序,它将向用户显示当前的年月日期.问题是,如果用户要在第二天保持我的应用程序运行,我该如何得到通知?我该如何更改显示的日期?我不想轮询当前日期来更新它.这在c#中是否可行.
注意:我尝试了SystemEvent.TimeChanged事件,但只有当用户从控制面板手动更改时间/日期时,它才有效.
JSF注释@ListenerFor不适用于GlassFish或Tomcat.没有错误或警告.它只是不调用方法processEvent().
@ListenersFor({@ListenerFor(systemEventClass=PostConstructApplicationEvent.class),
public class MySystemEventListener implements SystemEventListener {
@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {
if(event instanceof PostConstructApplicationEvent){
System.out.println("*********************************************");
System.out.println("processEvent Method is Called: PostConstructApplicationEvent");
System.out.println("*********************************************");
}
if(event instanceof PreDestroyApplicationEvent){
System.out.println("*********************************************");
System.out.println("processEvent Method is Called: PreDestroyApplicationEvent");
System.out.println("*********************************************");
}
}
@Override
public boolean isListenerForSource(Object o) {
return (o instanceof Application);
}
}
Run Code Online (Sandbox Code Playgroud)
有了这个想法?
systemevent ×4
.net ×1
annotations ×1
applescript ×1
c# ×1
datetime ×1
events ×1
jsf-2 ×1
keystroke ×1
listener ×1
resume ×1
system-error ×1
vb.net ×1