我在Windows Surface(平板电脑)上运行vb app 当应用程序最小化时,我需要切换到该应用程序,或者当用户单击应用程序图标时,我需要切换到焦点
已经尝试过AppFocus但没有工作 还有一些shell命令
我只需要在Windows 8磁贴或图标上点击我的应用的磁贴时,复制任务管理器切换到MyApp的行为
答案 0 :(得分:0)
我用过这个..
Shell FileName
其中FileName是完整路径和文件名加扩展名。
Shell "F:\ExeFiles\SomeProgram.exe"
如果您不想运行多个实例,请使用...
检入您的被叫应用Sub ActivatePrevInstance()
'if there is a previous instance of this app activate it and terminate
Dim OldTitle As String, PrevHndl As Long, Result As Long
'Save the title of the application.
OldTitle = App.Title
'Rename the title of this application
App.Title = "unwanted instance"
'Attempt to get window handle using VB6 class name
If PrevHndl = 0 Then PrevHndl = FindWindow("ThunderRT6Main", OldTitle)
If PrevHndl = 0 Then
'No previous instance found. Restore name
App.Title = OldTitle
Else
PrevHndl = GetWindow(PrevHndl, GW_HWNDPREV)
Result = OpenIcon(PrevHndl) 'Restore the program.
Result = SetForegroundWindow(PrevHndl) 'Activate
End 'close application
End If
End Sub