In a recent question, vbscript using InStr to find info that varies within a URL, I had asked about finding info in a URL. I later realized I didn't need to find the info in the URL, I just needed to be able to capture the URL from the location box in Internet Explorer and be able to use it to gather data from a web page. Here's what I have so far:
Option Explicit
Dim objIE, objShell, objShellWindows
Dim strIDNum, strURL, strWindow, strURLFound, WShell, i
'=============================================================
'=== Code for capturing URL of current page will go here ===
'=============================================================
strURL = 'URL that is captured by the above coding
strWindow = "Workflow Process"
Set objIE = CreateObject("InternetExplorer.Application")
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
Set WShell = CreateObject("WScript.Shell")
strURLFound = False
'To fix item not found error
For Each objIE in objShellWindows
Next
For i = 0 to objShellWindows.Count - 1
Set objIE = objShellWindows.Item(i)
On Error Resume Next
If InStr(Ucase(objShellWindows.Item(i).LocationURL), Ucase(strURL)) Then
If InStr(Ucase(objShellWindows.Item(i).FullName), "IEXPLORE.EXE") Then
If Err.Number = 0 Then
If InStr(objShellWindows.Item(i).document.title, (strWindow)) Then
strURLFound = True
Exit For
End If
End If
End If
End If
Next
Once I have the URL for the site my users will be on, I will be using the code below to gather the info:
WShell.AppActivate strWindow
WScript.Sleep 300
strIDNum = objIE.document.getElementByID("ID_PlaceHolder").value
How do I go about getting the URL from the page they are on?
Have you tried objIE.LocationURL? Also, thanks to Tomalak for providing objIE.document.location.href.
I was able to figure out how to get information from another web site with a URL that changes. First, I needed the base URL to at least get me there, once found, it really didn't matter what additional info was in the URL because each page is set up the same, just different data flowing through it. The end result is the code below.
Option Explicit
Dim objIE, objShell, objShellWindows
Dim strIDNum, strURL, strWindow, strURLFound, WShell, i
strURL = "http://www.myworkplace.com"
strWindow = "Workflow Process"
Set objIE = CreateObject("InternetExplorer.Application")
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
Set WShell = CreateObject("WScript.Shell")
strURLFound = False
'To fix item not found error
For Each objIE in objShellWindows
Next
For i = 0 to objShellWindows.Count - 1
Set objIE = objShellWindows.Item(i)
On Error Resume Next
If InStr(Ucase(objShellWindows.Item(i).LocationURL), Ucase(strURL)) Then
If InStr(Ucase(objShellWindows.Item(i).FullName), "IEXPLORE.EXE") Then
If Err.Number = 0 Then
If InStr(objShellWindows.Item(i).document.title, (strWindow)) Then
strURLFound = True
Exit For
End If
End If
End If
End If
Next
WShell.AppActivate strWindow
WScript.Sleep 300
strIDNum = objIE.document.getElementByID("ID_PlaceHolder").innertext
As you can see in the last line, I also used innertext rather than value to get the ID number.
Related
i have this scripts error below:
attempt to call a boolean value
attempt to call a number value
Here is the script :
--Game Info
local SystemName = "TestSystemname"
local WhitelistedServ = false
local OwnerId = game.CreatorId
local GameId = game.GameId
local MaxPlayers = game.Players.MaxPlayers
local GameUrl = "https://www.roblox.com/games/"..GameId
--Webhook sender and message creator in JS
local WebhookUrlServ = ""
local MessageDataServ = {["content"] = "New game started with the whitelist system !"..SystemName
"The Owner Id= "..OwnerId
"Is Game whitelisted ? "..WhitelistedServ
"How Many Players Max? "..MaxPlayers
"The Game Url= "..GameUrl}
MessageDataServ = HttpServ:JSONEncode(MessageDataServ)
Thanks,
I found the problem, i tryed to send a value i just need replace this
local WhitelistedServ = false
by this
local WhitelistedServ = "false"
and it will be work, value cant be in this script for some reason and make with embed is better.
Why does my script start two notepad instances without waiting for the user to close the first notepad? I would like that my script opens one text file, than waits for closing of notepad before it opens the next one.
set service = GetObject ("winmgmts:")
Dim ArchiveList
Dim ExportTool
Dim running
ExportTool = "notepad.exe "
ArchiveList = Array("A.txt","b.txt")
For Each element In ArchiveList
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run(ExportTool & element)
running = true
WScript.Sleep 3000
Do while running
running = false
for each Process in Service.InstancesOf ("Win32_Process")
If Process.Name = ExportTool then
running = true
End If
next
Loop
MsgBox "Hallo Erdling", VBOKOnly, "Muhaha"
' not running
Next
I do not understand why this is not working.
running is never set to True by your For Each Process loop as the ExportTool value will not be found in the Services List due to the extra space.
Remove the space and add it where you concatenate the ExportTool and element values:
set service = GetObject ("winmgmts:")
Dim ArchiveList
Dim ExportTool
Dim running
ExportTool = "notepad.exe" ' remove trailing space
ArchiveList = Array("A.txt","b.txt")
For Each element In ArchiveList
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run(ExportTool & " " & element) ' add space
running = true
WScript.Sleep 3000
Do while running
running = false
for each Process in Service.InstancesOf ("Win32_Process")
If Process.Name = ExportTool then
running = true
End If
next
Loop
MsgBox "Hallo Erdling", VBOKOnly, "Muhaha"
' not running
Next
Should work now.
Because
ArchiveList = Array("A.txt","b.txt")
creates an array with two elements, so that the loop starting with
For Each element In ArchiveList
will run for element = "A.txt" and element = "B.txt" and
objShell.Run(ExportTool & element)
will .Run Notepad.exe for each text file.
I have a vbscript to get some informations about the system printing of a remote computer. I can get all the drivers installed, the default network printer name and all my results are send in a outputfile.
I want to get informations about my default network printer by the prncnfg.vbs from the printer server (driver, location, etc.) and send these informations in my outputfile.
Maybe there is an other way to do that ?
Thanks for any suggestions
So, I start to understand the way to do that. But something doesn't work.
First I need to read a file and remove 10 caracters to create my variable, this process works very well:
'Read C:\Temp\DefaultPrinter
Dim shortDefaultPrinter
If objFSO.FileExists("\"& strComputer &"\c$\Temp\DefaultPrinter.txt") then
Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("\"& strComputer &"\c$\Temp\DefaultPrinter.txt",1)
DefaultPrinter = objFileToRead.ReadAll()
'remove text \vangogh\
shortDefaultPrinter = Right(DefaultPrinter, Len(DefaultPrinter) - 10)
'MsgBox(shortDefaultPrinter)
objFileToRead.Close
Set objFileToRead = Nothing
Second I want to use my variable shortDefaultPrinter for my query to find the location of my printer:
'Select DefaultPrinter and show location
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "Select printerName, serverName, Location from " _
& " 'LDAP://DC=huge,DC=ad,DC=hcuge,DC=ch' where objectClass='printQueue' and printerName='" & shortDefaultPrinter & "' "
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
PrinterLocation = objRecordSet.Fields("Location").Value
MsgBox(PrinterLocation)
objRecordSet.MoveNext
Loop
MsgBox doesn't open, but if I write the name of the printer in place of " & shortDefaultPrinter & ", ex dmed-i714, the process works.
Here I am. If anyone has a suggestion it would be appreciate.
I'm not a programmer so this is difficult for me. I want to make an extension to send the full path to the clipboard in the full format. Example:
D:\MyFolder\music\audio.mp3
I recently found and butchered this extension which sends the running time to the clipboard. Is it possible to modify it so it gets the full path instead of the running time?
I'm using VLC media player 2.0.5 Twoflower 32 bits.
Windows 7 professional 32bits SP1
Here's the content of the .lua file I'm using and want to modify:
-- Time2Clip.lua -- VLC extension --
--[[
INSTALLATION:
Put the file in the VLC subdir /lua/extensions, by default:
* Windows (all users): %ProgramFiles%\VideoLAN\VLC\lua\extensions\
Restart the VLC.
Then you simply use the extension by going to the "View" menu and selecting it.
--]]
function descriptor()
return {
title = "Time2Clip";
version = "1.0";
author = "valuex";
url = 'https://forum.videolan.org/viewtopic.php?f=29&t=101114';
shortdesc = "Time2Clip";
description = "<div style=\"background-color:lightgreen;\"><b>just a simple VLC extension </b></div>";
capabilities = {"input-listener"}
}
end
function activate()
create_dialog()
end
function close()
vlc.deactivate()
end
function create_dialog()
w = vlc.dialog("Time2Clip")
--w2 = w:add_button("Save_to_Clip", click_SAVE,2,1,1,1)
click_SAVE()
end
function click_SAVE()
local input = vlc.object.input()
if input then
local curtime=vlc.path()
-- local curtime=vlc.var.get(input, "time")
-- w2:set_text( curtime )
save_to_clipboard(curtime)
end
end
function save_to_clipboard(var)
strCmd = 'echo '..var..' |clip'
os.execute(strCmd)
vlc.deactivate()
end
I read LUA's README.TXT file and found this but I don't know how to use it. Please help me. Thanks in advance.
input.item(): Get the current input item. Input item methods are:
:uri(): Get item's URI.
:name(): Get item's name.
How about:
function descriptor()
return {
title = "URI2Clip";
version = "1.0";
author = "";
url = '';
shortdesc = "URI2Clip";
description = "<div><b>Copy the media URI to the Windows clipboard</b></div>";
}
end
function activate()
local item = vlc.input.item()
local uri = item:uri()
uri = string.gsub(uri, '^file:///', '')
uri = string.gsub(uri, '/', '\\')
strCmd = 'echo '..uri..' |clip'
os.execute(strCmd)
end
URI returns something like file:///c:/users/username/Documents/song.mp3 so I convert that to c:\users\username... format instead. NB. This is only going to work for saved files, it will mangle web addresses.
I'm trying to connect to an Oracle RDB database using LSXLC (ODBC Connector).
But when it comes to stored procedures I'm having a hard time getting it to work.
The code below always results in "Error: Parameter name not supplied: fnl_date, Connector 'odbc2', Method -Call-". The error is triggered on "count = connection.Call(input, 1, result)"
Can anyone tell me what I'm doing wrong?
Public Function testLsxlcProc()
On Error GoTo handleError
Dim connection As LCConnection("odbc2")
connection.Server = "source"
connection.Userid = "userid"
connection.Password = "password"
connection.procedure = "proc_name"
connection.Connect
If connection.IsConnected Then
Dim input As New LCFieldList()
Dim result As New LCFieldList()
Dim break As LCField
Set break = input.Append("fnl_date", LCTYPE_TEXT)
break.Text = "2014-07-01"
Dim agrNo As LCField
Set agrNo = input.Append("fnl_agreement_no", LCTYPE_TEXT)
agrNo.Text = "123456"
Dim curr As LCField
Set curr = input.Append("fnl_currency_code", LCTYPE_TEXT)
curr.Text = "SEK"
Dim stock As LCField
Set stock = input.Append("fnl_stock_id", LCTYPE_TEXT)
stock.Text = "01"
connection.Fieldnames = "status, value"
Dim count As Integer
count = connection.Call(input, 1, result)
Call logger.debug("Count: " & count)
Else
Error 2000, "Unable to connect to database."
End If
handleExit:
connection.Disconnect
Exit Function
handleError:
On Error Resume Next
Call logger.error(Nothing)
Resume handleExit
End Function
Thanks in advance!
I had made a stupid mistake and had a mismatch between the name of the input parameter in Domino and the name of the input parameter in the stored procedure.
Make sure all names match up and there shouldn't be a problem.
Stored-Procedure "mylib.MyStoredProc" wird aufgerufen ...
LcSession.Status = 12325: LC-Error: errCallStoredProc 12325 (Error: Parameter name not supplied: P_S651_AC, Connector 'odbc2', Method -Call-)
Solution: changed "mylib" into "MYLIB" and all was well.
Check not only Parameter-Names, but also the Search-Path.