Posts

c# - How to get the window handle for a VBA MsgBox? -

i'm running c# script on large number of excel workbooks involves calling macro in each workbook; macro produces msgbox because of error handler, , pauses execution of script until click "ok" in msgbox. the title text of msgbox "error in processsub", , main text "error (type mismatch)". i thought maybe have concurrent thread finds open windows, , if finds msgbox, clicks "ok". i'm trying find window using this: using system.diagnostics; public process geterrorwindow() { process[] processlist = process.getprocesses(); foreach (process process in processlist) { if (process.mainwindowtitle=="error in processsub") { return process; } } } but doesn't find anything. when through processlist[] , seems find main excel window, , not of child windows vba code produces. there way find msgbox , click ok button? you can us...

html - Avoid the margin inside pre tag -

Image
this question has answer here: removing leading whitespace indented html source in pre/code tags 5 answers how avoid margin inside pre tag: <p>some text</p> <pre> <code> code </code> </pre> <p>some text</p> <style> pre { background-color: rgb(255,247,229); border: 1px solid red; } </style> the current output: the desired output: the current solution manually remove indentation in markup, shown below. however, understand, not optimal way. <pre> <code> code </code> </pre> you can try changing default value of white-space <pre> tag pre pre-line . pre-line sequences of whitespace collapsed. lines broken @ newline characters, @ <br> , , necessary fill line boxes. read more white-space on mdn . ...

c# - ASP.NET How to access multiple form labels text property with foreach loop -

i have form runat= "server" id = "myform" . profile page lots of labels. getting input text sql database. if sql data base have null value, wish text changed "not specified". such reason using following code, not working. foreach (control item in myform.controls) { label lbl = null; bool labelisempty = false; try { lbl = (label)item; labelisempty = (lbl.text == string.empty && lbl != null); } catch { } if (labelisempty) { lbl.text = "not specified"; } } myform.controls gives collection contains controls withing container( not labels). have check type control while iterating collection in order avoid throwing exception. in additional comment ware specify label has default text "label" need include in condition. whole scenario can implemented following: foreach (control item in myform.controls) { if (item label) ...

Class for reusable layout android -

i have reusable layout called title <?xml version="1.0" encoding="utf-8"?> <textview android:id="@+id/title_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparentright="true" android:layout_centervertical="true" android:gravity="center" android:text="@string/lesson_title" android:textsize="@dimen/title" /> <button android:id="@+id/title_book" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentright="true" android:layout_alignparenttop="true" android:onclick="onclick" android:text="@string/book" /> <button android:id="...

ecmascript 6 - ES6 javascript tests using Tape and Nightmare.js -

i've been trying test es6 code using tape assertions , nightmare.js load test page. keep trying different es6 methods: async/await, yield, generators, , think i'm bit on head. i'm not sure when , when not use babel-tape . can following test pass, minute create evaluate block errors out. documentation scarce (or uses mocha). what's best practice here? import {test} "tape"; import {default nightmare} "nightmare"; const page = nightmare().goto("http://localhost:4000/index.html"); page.evaluate(() => document.getelementsbytagname("body").length).end() .then((result) => { test("detect page body", (assert) => { assert.equal(1, result); assert.end(); }); }); ps. i'm using babel-tape-runner run tests. i can following test pass, minute create evaluate block errors out. hm, you're calling .end() on nightmare instance. shouldn't interacting instance once e...

.htaccess - Get link and Redirect with Htaccess -

i have website domain example.com , have file example.com/example.php how redirect file other website there have same domain name different in extension redirect example.com/example.php example.net/example.php htaccess? much! try this: rewriteengine on rewritebase / rewritecond %{http_host} !newdomain.com$ [nc] rewriterule ^(.*)$ http://newdomain.com/$1 [l,r=301]

c# - retrieve files created within a time range in a local folder -

need retrieve files created within time range (in granular of minute level) in local folder (files flat in folder, no sub-directories). using windows os , want find if c# code refer to? current solution native, scan folder files , filter timestamp. works if there more neat windows api filter file timestamp, should more reliable code. you can use filesystemwatcher have event raises when file created: filesystemwatcher watcher = new filesystemwatcher() { path = "c:\\", includesubdirectories = true, notifyfilter = notifyfilters.lastwrite | notifyfilters.directoryname | notifyfilters.filename, filter = "*.*" }; watcher.created += (s, e) => { messagebox.show(e.fullpath); }; filesystemwatcher