我已经有链接了 http://cam.sheratonamsterdamairportview.com/view_live1.jpg . 此链接链接到史基浦机场的相机,每 20 秒拍摄一张照片。
我真的很想每 20 秒更新一次这张照片作为我的桌面背景。这可能吗?
我需要制作一个程序还是可以将它与技巧联系起来?顺便说一句,我运行的是 Windows 7。
最佳答案
如果您使用的是 Windows XP,您只需在桌面上添加 Activity 内容即可。
Right Mouse Button on Desktop -> Properties -> Desktop tab -> Customize Desktop -> Web tab -> New -> Location "www"
设置您的 URL 并激活内容。您将在桌面上看到一个小窗口,其中包含来自相机的图片。如果它不会自动刷新,则创建一个简单的页面,元刷新 20 秒,并为您的链接设置带有 src 属性的 img 标签。
我不确定以上是否适用于 Vista/7。
否则
这可能对您有用:
'Set the wallpaper
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_VideoController",,48)
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("Process")
Set objFSO = CreateObject("Scripting.FileSystemObject")
WinPath = WshSysEnv("SystemRoot") & "\YourWallpaper.bmp"
If Not objFSO.FileExists(winpath) then
'If the file does not exist then copy it
For Each objItem in colItems
sourcePath = "\\path\here\"
rightSize = "NameHere" & objItem.CurrentHorizontalResolution & "x" & objItem.CurrentVerticalResolution & ".bmp"
objFSO.CopyFile sourcePath & rightSize, WSHShell.ExpandEnvironmentStrings ("%SystemRoot%") & "\NameYourWallpaper.bmp", overwrite = True
Next
End If
'************************************************************************************************************************************************
'Set Wallpaper Bitmap to Default
Set WshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
sWinDir = objFSO.GetSpecialFolder(0)
sWallPaper = sWinDir & "\NameYourWallpaper.bmp"
' update in registry
WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", sWallPaper
WshShell.Regwrite "HKCU\Software\Microsoft\Internet Explorer\Desktop\General\Wallpaper", sWallPaper
WshShell.Regwrite "HKCU\Software\Microsoft\Internet Explorer\Desktop\General\BackupWallpaper", sWallPaper
' let the system know about the change
WshShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True
这是 VBscript,它将更改桌面背景并在之后重新加载您的配置文件以让您看到更改。
或者,如果您想要更多,这里有一段代码,您应该看看:
此示例演示了许多有用的技术,包括: 从随机列表中选择一个文件。 设置桌面墙纸。 设置桌面墙纸样式(居中、平铺或拉伸(stretch))。 编写注册表项。 将文件移入废纸篓。 使用系统默认的编辑器编辑文件。 当程序启动时(以及当您单击 Apply 按钮时),程序调用 ReadFiles。该例程读取指定目录中文件的名称,并保存以 BMP、GIF、JPG 和 JPEG 结尾的文件。加载所有文件名后,例程调用 RandomizeNames 来随机化列表。
Sub ReadFiles()
Dim file As String
Dim ext As String
' Create the new file name collection.
Set FileNames = New Collection
' Get the file names.
file = Dir(DirName & "\*.*")
Do While file <> ""
If LCase$(file) <> "temp.bmp" Then
ext = UCase$(Right$(file, 4))
If ext = ".BMP" Or ext = ".GIF" Or _
ext = ".JPG" Or ext = "JPEG" _
Then _
FileNames.Add file
End If
file = Dir()
Loop
NumNames = FileNames.Count
RandomizeNames
End Sub
子例程 RandomizeNames 创建一个索引数组,其中一个条目对应 FileNames 集合中的每个名称。对于 i = 1 到 NumNames - 1,例程选择一个随机索引并将其交换到位置 i。
Private Sub RandomizeNames()
Dim idx As Integer
Dim tmp As Integer
Dim i As Integer
ReDim Indexes(1 To NumNames)
For i = 1 To NumNames
Indexes(i) = i
Next i
' Randomize them.
For i = 1 To NumNames - 1
idx = Int((NumNames - i + 1) * Rnd + i)
tmp = Indexes(i)
Indexes(i) = Indexes(idx)
Indexes(idx) = tmp
Next i
' Point to the index to display.
NextIndex = 1
End Sub
当定时器触发时,程序调用 ShowFile 以显示随机列表中的下一个文件。
Private Sub SwitchTimer_Timer()
Dim secs As Long
Dim pic As Integer
' See if it's time yet.
secs = DateDiff("s", Now, NextTime)
If secs <= 1 Then
If FileNames.Count > 1 Then
pic = Indexes(NextIndex)
NextIndex = NextIndex + 1
If NextIndex > NumNames Then RandomizeNames
ShowFile FileNames(pic)
End If
NextTime = DateAdd("s", Pause, Now)
secs = Pause
End If
If secs <= 60 Then
SwitchTimer.Interval = secs * 1000
Else
SwitchTimer.Interval = 60000
End If
SwitchTimer.Enabled = True
End Sub
子例程 ShowFile 检查样式组合框并设置注册表项以使桌面图像居中、平铺或拉伸(stretch)。 接下来,如果文件是位图文件,程序只需调用 SystemParametersInfo API 函数来设置桌面背景图像。
如果文件不是位图文件,程序会将其加载到隐藏的 PictureBox 中,然后将图像保存为位图文件。然后调用 SystemParametersInfo。
Private Sub ShowFile(ByVal file_name As String)
Const STYLE_CENTERED As String = "0"
Const STYLE_TILED As String = "1"
Const STYLE_STRETCHED As String = "2"
Const TILE_NO As String = "0"
Const TILE_YES As String = "1"
Dim had_error As Boolean
' Set the display style.
had_error = False
Select Case cboStyle.Text
Case "Centered"
If SetRegistryValue(HKEY_CURRENT_USER, _
"Control Panel\Desktop", "TileWallpaper", _
TILE_NO) _
Then had_error = True
If SetRegistryValue(HKEY_CURRENT_USER, _
"Control Panel\Desktop", "WallpaperStyle", _
STYLE_CENTERED) _
Then had_error = True
Case "Tiled"
If SetRegistryValue(HKEY_CURRENT_USER, _
"Control Panel\Desktop", "TileWallpaper", _
TILE_YES) _
Then had_error = True
If SetRegistryValue(HKEY_CURRENT_USER, _
"Control Panel\Desktop", "WallpaperStyle", _
STYLE_TILED) _
Then had_error = True
Case "Stretched"
If SetRegistryValue(HKEY_CURRENT_USER, _
"Control Panel\Desktop", "TileWallpaper", _
TILE_NO) _
Then had_error = True
If SetRegistryValue(HKEY_CURRENT_USER, _
"Control Panel\Desktop", "WallpaperStyle", _
STYLE_STRETCHED) _
Then had_error = True
End Select
If had_error Then
MsgBox "Error saving desktop style to registry.", _
vbOKOnly, "Registry Error"
End If
' Display the file.
FileLabel.Caption = file_name
m_CurrentFile = DirName & "\" & file_name
If UCase$(Right$(file_name, 4)) = ".BMP" Then
SystemParametersInfo SPI_SETDESKWALLPAPER, _
0, m_CurrentFile, SPIF_UPDATEINIFILE
Else
HiddenPict.Picture = LoadPicture(m_CurrentFile)
SavePicture HiddenPict.Picture, DirName & _
"\temp.bmp"
SystemParametersInfo SPI_SETDESKWALLPAPER, _
0, DirName & "\temp.bmp", _
SPIF_UPDATEINIFILE
End If
End Sub
当您点击编辑按钮时,程序使用ShellExecute API函数来编辑当前图片文件。
Private Sub cmdEdit_Click()
ShellExecute ByVal 0&, "edit", m_CurrentFile, _
vbNullString, vbNullString, SW_SHOWMAXIMIZED
End Sub
当您单击“删除”按钮时,程序会调用子例程 DeleteFile 将文件移入废纸篓。然后它会显示下一张图片。
Private Sub cmdDelete_Click()
' Delete the file.
DeleteFile m_CurrentFile, False
' Display the next file.
cmdNext_Click
End Sub
子例程 DeleteFile 使用 SHFileOperation API 函数将文件移动到废纸篓,可选择要求用户确认。
Public Sub DeleteFile(ByVal file_name As String, ByVal _
user_confirm As Boolean)
Dim op As SHFILEOPSTRUCT
With op
.wFunc = FO_DELETE
.pFrom = file_name
If user_confirm Then
' Make the user confirm.
.fFlags = FOF_ALLOWUNDO
Else
' Do not make the user confirm.
.fFlags = FOF_ALLOWUNDO Or FOF_NOCONFIRMATION
End If
End With
SHFileOperation op
End Sub
取自here
关于java - 通过链接更新桌面背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11719160/
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
尝试通过RVM将RubyGems升级到版本1.8.10并出现此错误:$rvmrubygemslatestRemovingoldRubygemsfiles...Installingrubygems-1.8.10forruby-1.9.2-p180...ERROR:Errorrunning'GEM_PATH="/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/ruby-1.9.2-p180@global:/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/rub
我正在使用puppet为ruby程序提供一组常量。我需要提供一组主机名,我的程序将对其进行迭代。在我之前使用的bash脚本中,我只是将它作为一个puppet变量hosts=>"host1,host2"我将其提供给bash脚本作为HOSTS=显然这对ruby不太适用——我需要它的格式hosts=["host1","host2"]自从phosts和putsmy_array.inspect提供输出["host1","host2"]我希望使用其中之一。不幸的是,我终其一生都无法弄清楚如何让它发挥作用。我尝试了以下各项:我发现某处他们指出我需要在函数调用前放置“function_”……这
我正在编写一个gem,我必须在其中fork两个启动两个webrick服务器的进程。我想通过基类的类方法启动这个服务器,因为应该只有这两个服务器在运行,而不是多个。在运行时,我想调用这两个服务器上的一些方法来更改变量。我的问题是,我无法通过基类的类方法访问fork的实例变量。此外,我不能在我的基类中使用线程,因为在幕后我正在使用另一个不是线程安全的库。所以我必须将每个服务器派生到它自己的进程。我用类变量试过了,比如@@server。但是当我试图通过基类访问这个变量时,它是nil。我读到在Ruby中不可能在分支之间共享类变量,对吗?那么,还有其他解决办法吗?我考虑过使用单例,但我不确定这是
我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search
我将应用程序升级到Rails4,一切正常。我可以登录并转到我的编辑页面。也更新了观点。使用标准View时,用户会更新。但是当我添加例如字段:name时,它不会在表单中更新。使用devise3.1.1和gem'protected_attributes'我需要在设备或数据库上运行某种更新命令吗?我也搜索过这个地方,找到了许多不同的解决方案,但没有一个会更新我的用户字段。我没有添加任何自定义字段。 最佳答案 如果您想允许额外的参数,您可以在ApplicationController中使用beforefilter,因为Rails4将参数
所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
我在理解Enumerator.new方法的工作原理时遇到了一些困难。假设文档中的示例:fib=Enumerator.newdo|y|a=b=1loopdoy[1,1,2,3,5,8,13,21,34,55]循环中断条件在哪里,它如何知道循环应该迭代多少次(因为它没有任何明确的中断条件并且看起来像无限循环)? 最佳答案 Enumerator使用Fibers在内部。您的示例等效于:require'fiber'fiber=Fiber.newdoa=b=1loopdoFiber.yieldaa,b=b,a+bendend10.times.m
我有一张背景图片,我想在其中添加一个文本框。我想弄清楚如何将标题放置在其顶部的正确位置。(我使用标题是因为我需要自动换行功能)。现在,我只能让文本显示在左上角,但我需要能够手动定位它的开始位置。require'RMagick'require'Pry'includeMagicktext="Loremipsumdolorsitamet"img=ImageList.new('template001.jpg')img 最佳答案 这是使用convert的ImageMagick命令行的答案。如果你想在Rmagick中使用这个方法,你必须自己移植