<VB6.0 & android开发小工具> 桌面帮助程序 里面涉及到的代码

小项目桌面帮助程序 里面涉及到的代码



1.

'打开任务管理器

Shell "taskmgr.exe", vbNormalFocus
Dim s As String
s = Environ("windir")
s = s & "\system32\taskmgr.exe"
Open s For Random Lock Read As #1
Close #1

Shell s, 1


2.

'重启电脑

If MsgBox("最后一次确认你的重启指令,是否重启?", vbOKCancel, "提示") = vbOK Then
Shell "cmd /c" & "shutdown -r -t 10"


3.

‘打开某一exe文件

Shell "Explorer C:\Program Files\开发者帮助程序", vbNormalFocus


4.

'打开设别管理器

Shell "cmd /c devmgmt.msc", vbNormalFocus


5.

'打开服务
   
Shell "cmd /c services.msc", vbNormalFocus


6.

'重启资源管理器

On Error Resume Next
Dim s
s = "explorer.exe" '进程名称可以自己更改
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name='" & s & "'")
For Each objProcess In colProcessList
objProcess.Terminate '结束进程
Next
Set objProcess = Nothing
Set colProcessList = Nothing
Set objWMIService = Nothing
'重新启动


7.

'打开浏览器
 Shell "explorer.exe https://baidu.com/"


8.

读取电脑配置信息

Set wmi = GetObject("winmgmts:\\.\root\CIMV2")
Set w = wmi.ExecQuery("select * from win32_processor")
a = "CPU名称:"
For Each i In w
   a = a & vbCrLf & i.Name
Next
Set w = wmi.ExecQuery("select * from win32_ComputerSystem")
a = a & vbCrLf & vbCrLf & "内存大小:"
For Each i In w
    a = a & vbCrLf & Format(i.TotalPhysicalMemory / 1024 / 1024 / 1024, "0.0") + " GB"
    
Next
Set w = wmi.ExecQuery("select * from win32_DiskDrive")
a = a & vbCrLf & vbCrLf & "硬盘大小:"
For Each i In w
    a = a & vbCrLf & Format(i.Size / 1024 / 1024 / 1024, "0.0") + " GB"
Next


Set w = wmi.ExecQuery("select * from win32_VideoController")
a = a & vbCrLf & vbCrLf & "显卡型号——显存:"
For Each i In w
    a = a & vbCrLf & i.Name & " ——" & Format(i.AdapterRAM / 1024 / 1024 / 1024, "0.0") + " GB"
Next

Label1.Caption = a


9.

关闭本容器 加载另一容器

Unload Me
Form3.Show


10.

显示时间

Text1.Text = Time

Text1.Text = Data

Text1.Text = Now 


11.

QQ对话框重复发信息核心代码

On Error Resume Next
Dim wsh, ye
Set wsh = CreateObject("wscript.shell")
For i = 1 To Text2.Text
wscript.sleep 700
wsh.AppActivate (Text1.Text)
wsh.SendKeys "^v" + " --- From QQSendGad"
wsh.SendKeys i
wsh.SendKeys "%s"
Next
wscript.quit


12.

窗口抖动 时间控件放入以下代码

Dim i As Integer
For i = 0 To 6
Me.Top = Me.Top - 8 * 15: Sleep 20: DoEvents
Me.Left = Me.Left - 8 * 15: Sleep 40: DoEvents
Me.Top = Me.Top + 8 * 15: Sleep 40: DoEvents
Me.Left = Me.Left + 8 * 15: Sleep 40: DoEvents
Next i
Timer1.Interval = 100


13.

静音控制

Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const jingyin = 173

时间控件写

keybd_event jingyin, 0, 0, 0
Timer1.Interval = "200"


14.

你是猪吗小游戏

Option Explicit
Private Sub Command1_GotFocus()
Command2.SetFocus
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Randomize Timer
With Me
 Command1.Move Rnd * (.ScaleWidth - Command1.Width), Rnd * (.ScaleHeight - Command1.Height)
End With
End Sub
Private Sub Command2_Click()
MsgBox "就知道你是猪!"
End
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True

Command1.Caption = "不是"
Command2.Caption = "是"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
End Sub


15.

鼠标抖动

Private Declare Function SetCursorPos& Lib "user32" (ByVal x As Long, ByVal y As Long)
Private Declare Function GetCursorPos& Lib "user32" (XY As PointAPI)
Private Type PointAPI
x As Long: y As Long
End Type

Private Sub Label3_Click()
Unload Me
End
End Sub

Private Sub Timer1_Timer()
Dim XY As PointAPI, foot As Integer
Call GetCursorPos(XY)
Randomize
foot = 99 '抖动幅度
XY.x = XY.x + 5 * (-1) ^ Int(1 + 2 * Rnd) '-1的乘方,左右抖动
XY.y = XY.y + 5 * (-1) ^ Int(1 + 2 * Rnd) '-1的乘方,上下抖动
SetCursorPos XY.x, XY.y
End Sub

Private Sub Timer2_Timer()
Label2.Visible = True
Label1.Visible = False
Timer1.Enabled = True
Timer1.Interval = 10 '抖动频率
End Sub


16.

隐藏桌面

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_HIDE = 0
Private Const SW_RESTORE = 9

Private Sub Form_Load()
Dim Hwd As Long
Dim rtn As Long
Hwd = FindWindow("Progman", vbNullString)
rtn = ShowWindow(Hwd, SW_HIDE)

End Sub

Private Sub Label2_Click()
Dim Hwd As Long
Dim rtn As Long
Hwd = FindWindow("Progman", vbNullString)
rtn = ShowWindow(Hwd, SW_RESTORE)
Unload Me
End
End Sub


会及时跟帖,有问题大家留下评论即可。

猜你喜欢

转载自blog.csdn.net/csdn_lg_one/article/details/77784948