Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
What I want is to be able to have a webpage (locally) with a form and when the user hits submit, that value is passed to the winbatch exe.
; here's a quick example to explain the basics of using DHTML. ; just run the script (it requires NO EXTERNAL FILES) and it'll ; walk you through it as it goes. ; you can then examine the coding. this doesn't cover everything ; but should get you going. there might be different ways to effect ; the same things. ; by Jay Alverson using Winbatch 2003J and MSIE 6 ;REVISIONS ;Dec 2 2004 ;Uses browserDoc.all.ButtonChoice instead of all.ButtonChoice. MSFT has changed the behavior of ;the objects exposed by Internet Explorer related COM servers again. Apparently access to the "All" object is restricted ;everytime the content of the HTML document change so you need to get a new object after every document object change. ;Code now requires 2004A or newer #definesubroutine startMSIE() Browser = ObjectOpen("InternetExplorer.Application") Browser.addressbar = @false Browser.statusbar = @false Browser.menubar = @false Browser.toolbar = @false ; Browser.fullscreen = @true browser.visible = @true url = "about:blank" ;<--- bad URL doesn't matter... browser.navigate(url) ;WaitForPageLoad() ; setup the document object... browserDoc = Browser.Document all = browserdoc.all return(browser) #endsubroutine #DefineSubroutine WaitForPageLoad() ; assume Browser While browser.busy || browser.readystate == 1 TimeDelay(0.5) EndWhile While browser.Document.ReadyState != "complete" TimeDelay(0.5) EndWhile return #EndSubroutine gosub Example1 gosub Example2 gosub Example3 return exit :Example1 br = startMSIE() ; write the needed spans, inputs for the user... browserdoc.writeln(`<h2 align="center">Click button when ready</h2>`) browserdoc.writeln(`<h3 align="center">Inspect the ONCLICK property for the INPUT when you look at the script</h3>`) browserdoc.writeln(`<center><span id="ButtonSpan"><input class="bigblue" type="submit" name="DoneButton" value="Done" onclick="ButtonChoice.innerText='Button Clicked'"></span></center>`) browserdoc.writeln(`These braces hold the ButtonChoice contents -->[<span class="hidden" id="ButtonChoice"></span>]`) ButtonChoice = browserDoc.all.ButtonChoice ;<--- reference the SPAN with the ID of ButtonChoice... while @true yields(2000) if ButtonChoice.innerText <> "" ;<--- stop looping when something appears in the SPAN... timedelay(3) ;<--- give user a few seconds to see the string "Button Clicked" appear within SPAN... break endif endwhile objectclose(ButtonChoice) br.quit message("Debug", "You clicked the button, so I closed the browser") return :Example2 br = startMSIE() ; write the needed spans, inputs for the user... browserdoc.writeln(`<style>.hidden {font-size: 1; color: white}</style>`) browserdoc.writeln(`<h2 align="center">That was nice, but lets hide the span so the user can't see it...</h2>`) timedelay(3) browserdoc.writeln(`<h2 align="center">Click button when ready</h2>`) browserdoc.writeln(`<center><span id="ButtonSpan"><input class="bigblue" type="submit" name="DoneButton" value="Done" onclick="ButtonChoice.innerText='Button Clicked'"></span></center>`) browserdoc.writeln(`<span class="hidden" id="ButtonChoice"></span>`) ButtonChoice = browserDoc.all.ButtonChoice ;<--- reference the SPAN with the ID of ButtonChoice... while @true yields(2000) if ButtonChoice.innerText <> "" ;<--- stop looping when something appears in the SPAN... break endif endwhile objectclose(ButtonChoice) br.quit message("Debug", "You clicked the button, so I closed the browser") return :Example3 br = startMSIE() ; write the needed spans, inputs for the user... browserdoc.writeln(`<style>.hidden {font-size: 1; color: white}</style>`) browserdoc.writeln(`<h2 align="center">This time you'll need to inspect the while loop in Example 3</h2>`) browserdoc.writeln(`<h2 align="center">Also look at the ONFOCUS property of TextBox1</h2>`) browserdoc.writeln(`<h2 align="center">We added another SPAN to detect when the ONFOCUS was triggered</h2>`) browserdoc.writeln(`<h2 align="center">When the INPUT box shows up make it the focus but don't type anything inside it</h2>`) timedelay(7) browserdoc.writeln(`<h2 align="center">Click button when ready</h2>`) browserdoc.writeln(`<center><input class="bigblue" type="text" name="TextBox1" size=10 value="" onfocus="FocusSpan.innerText='Focus'"></center>`) browserdoc.writeln(`<center><span id="ButtonSpan"><input class="bigblue" type="submit" name="DoneButton" value="Done" onclick="ButtonChoice.innerText='Button Clicked'"></span></center>`) browserdoc.writeln(`<span class="hidden" id="ButtonChoice"></span>`) browserdoc.writeln(`<span class="hidden" id="FocusSpan"></span>`) ButtonChoice = browserDoc.all.ButtonChoice ;<--- reference the SPAN with the ID of ButtonChoice... FocusSpan = all.FocusSpan ;<--- reference the SPAN that will hold the FOCUS flag... while @true ; this time we look at both the button and the focus spans before issuing commands... yields(2000) if ButtonChoice.innerText <> "" ;<--- stop looping when something appears in the SPAN... break endif if FocusSpan.innerText <> "" FocusSpan.innerText = "" ;<--- empty the span for next loop message("Debug", "TextBox1 has focus") endif endwhile objectclose(ButtonChoice) objectclose(FocusSpan) br.quit message("Debug", "You clicked the button, so I closed the browser") return dll = StrCat(DirWindows(1), "user32.dll") DllCall(dll, void:"keybd_event", long:16, long:0, long:0, long:0); shift key down Delay(5) DllCall(dll, void:"keybd_event", long:16, long:0, long:2, long:0); shift key up exit
Article ID: W16472
File Created: 2005:02:18:12:20:52
Last Updated: 2005:02:18:12:20:52