How could I, in Windows, designate a file of a type like GIF to be opened in MSIE via a specific HTML doc? - gif

Windows "viewers" (like Windows Live Photo Gallery or Windows Photo Viewer) have not supported GIF animation since the days of Windows XP. The handiest way I know now to view animation of a GIF is to open it with MSIE -- but THAT, unlike Windows Photo Viewer, does not let me "scroll" through a directory to view other image files. It occurred to me that I could create a scripted HTML document that would perform that "scrolling" through the directory, but I don't know of a way to set it up so that by right-clicking an animated GIF file in my "Recent Items" (or elsewhere), and selecting "Open with...", that one of the options in that group would be the HTML doc I had created, to be opened in MSIE and given the name of the file I had right-clicked on (in the location.search property, for example), so that it would display THAT animated GIF initially, but then, by my script in the HMTL document, would let me scroll through the directory to view other image files as well. Also, I would want this option to be available for any type of image file, so that I could initially view, say, a JPEG file, but then subsequent "directory scrolling" could include GIFs or BMPs, etc. IS there a way to do that?

As the saying goes, "Don't get me started!" :)
I hadn't actually planned on having the batch write to the HTML file, but given that approach, I decided to put my javascript into a JS file, and have the batch write code that would reference it, thus:
#echo ^<html^>^<body onkeydown='kdn(event.keyCode)'^>^<span id='im'^>^<img style='display:none' src=%1^>^</span^>^<script src='c:/wind/misc/peruse.js'^>^</script^> > c:\wind\misc\peruse.htm
#start c:\wind\misc\peruse.htm
I found that the only way to handle the backslashes in %1 was to store it directly to an img src, as you did; however, I wanted more detailed code for the img than I wanted to write at this stage, so I set it to be invisible and placed it inside an id'd span for later elaboration by my script. It's nice to know about %~p1 but I don't really need it here.
And here is a rudimentary script (in peruse.js) for folder navigation that it calls up:
document.bgColor = 'black';
f = ('' + document.images[0].src).substr(8);
document.getElementById('im').innerHTML = '<table height=100% width=100% cellspacing=0 cellpadding=0><tr><td align="center" valign="middle"><img src="' + f + '" onMouseDown="self.focus()"></td></tr></table>';
fso = new ActiveXObject("Scripting.FileSystemObject");
d = fso.GetFolder(r = f.substr(0, (b = f.lastIndexOf('/')) + (b < 3)));
if(b > 2) r += '/';
b = (document.title = f.substr(++b)).toLowerCase();
for(n = new Enumerator(d.files) , s = [] , k = -1 , x = '..jpg.jpeg.gif.bmp.png.art.wmf.'; !n.atEnd(); n.moveNext()) {
if(x.indexOf((p = n.item().name).substr(p.lastIndexOf('.') + 512 & 511).toLowerCase() + '.') > 0) {
s[++k] = p.toLowerCase() + '*' + p
}
}
for(s.sort() , i = 0 , j = k++ , status = k + ' file' + (k > 1 ? 's' : '') , z = 100; (x = s[n = (i + j) >> 1].substr(0, s[n].indexOf('*'))) != b; ) {
x < b ? i = (i == n) + n : j = n
}
document.title = (n + 1) + ': ' + document.title;
function kdn(e, x) {
if(k > 1 && ((x = e % 63) == 37 || x == 39)) {
document.images[0].src = r + (x = s[n = (n + x - 38 + k) % k].substr(s[n].indexOf("*") + 1));
e = 12;
document.title = (n + 1) + ': ' + x;
setTimeout("status+=''", 150)
};
if(e == 12 || e == 101 || e == 107 || e == 109) {
document.images[0].style.zoom = (z = e < 107 ? 100 : e == 107 ? z * 1.2 : z / 1.2) + '%'
}
}
self.focus()
It sets the page background to black,
recovers the path-and-filename into f (with the problematical backslashes converted to forward slashes),
sets up table code so the image appears in the center of the window,
accesses the filesystemobject, and, with the path portion extracted from f into r,
sets the page title to just the filename (with the lowercase name stored to b),
and iterates the folder, checking for any image file,
creates an array s of all those files, with names in lowercase followed by their original case-format,
sorts the array case-blind, and binary-searches the array for the original file (as b) so it knows where to proceed from,
and prefixes the number-within-folder to the page title;
then the keydown function uses the left and right arrows to move backward and forward in the folder, with wraparound,
and uses the numpad+ and - to enlarge or shrink the image, and numpad-5 to reset the size (which also occurs for every new image).
It still remains, though, that I'd like to know of a way to simply pass the original %1 info to an HTML file, without writing a file in the process. I might expect it to be a way to have it "appended to the web address", as is done with info following a ? which gets placed in location.search. I don't know if the command line for iexplore.exe could have a parameter for passing info to location.search.

Related

Godot: How to override function from inherited script?

How does one override a function that was defined in a parent script?
Here's my parent script:
# Object.gd
extends Area2D
var id = 0
var coords
func _ready():
assign_values()
func assign_values():
var a = global_position.x
var b = global_position.y
#cantor pairing function
id = (a + b) * ( a + b + 1) / 2 + b
coords = global_position
Here's the script that extends the parent script. I am trying to overwrite the assign_values() function in the new script to calculate the id differently. When I call assign_values in the extended script the weirdest thing happens. I can't print the individual components of the coords vector anymore, even though the type checks out and printing the vector works fine, too.
# Road.gd
extends "res://Object.gd"
func assign_values():
coords = Vector2(128, 96)
var a = coords.x # <- Here be Dragons
var b = coords.y
#cantor pairing function
id = (a + b) * ( a + b + 1) / 2 + b
print(typeof(coords)) # prints 5 -> Vector2 type
print(coords) # prints (128, 96), looks alright
print(coords.x) # Boom! crashes with error Invalid get index 'x' (on base: 'Nil').
I'm at a loss why I get this weird vector error. Notably, the whole thing works if I just write a new function in the extended script, func assign_new_values(), but I am not sure this is the right way to do this. I expected Godot to override functions from parent scripts if they are just declared again, but that does not seem to work. What is the proper way to do this? Could not find anything in the documentation..

How to program a URL? (For search query)

A co-worker of mine shared an autohotkey script (it's actually an exe file that runs on the background). Anyways, when I click the hotkeys it opens up a company webiste and creates a shared query for whatever's on the clipboard. I was wondering how this is done and how I can make my own.
I'm specially curious about the "URL" modification that includes all these search options:
https://<COMPANYWEBSITE>/GotoDocumentSearch.do
That's the URL where I can search (sorry it's restricted and even if I link it you cant access it).
Anyways, after I set up all my options and stuff and click the search button I get the following URL:
https://<COMPANYWEBSITE>/DocumentSearch.do
I inspected the website source and this is the function that's called when I press the search button:
function preSubmitSearch(docPress) {
document.pressed = docPress;
// setup local doc types for submit by lopping over multi selects and building json data string
var localDocTypesJson = "{";
var sep = "";
jQuery(".localTypeSel").each(function (i) {
var selLocalTypes = jQuery(this).multiselect("getChecked");
// get doc type code from id ex. 'localTypeSel_PD'
//window.console.log("this.id=" + this.id);
var tmpArr = this.id.split("_");
var docTypeCode = tmpArr[1];
var selLocalTypesCnt = selLocalTypes.length;
if (selLocalTypesCnt > 0) {
var localTypes = "";
var sep2 = "";
for (var i2 = 0; i2 < selLocalTypesCnt; i2++) {
localTypes += sep2 + "\"" + selLocalTypes[i2].value + "\"";
sep2 = ",";
}
localDocTypesJson += sep + "\"" + docTypeCode + "\": [" + localTypes + "]";
sep = ",";
}
});
localDocTypesJson += "}";
jQuery("#localDocTypesJson").val(localDocTypesJson);
}
HOWEVER, the working code that was shared with me (that was written ages ago by some employee who's not here anymore). Has the following URL when I use the autohotkey:
https://<COMPANYWEBSITE>/DocumentSearch.do?searchType=all&localDocTypesJson=7D&formAction=search&formInitialized=true&searchResultsView=default&btn_search=Search&docName=*<CLIPBOARD>*&wildcards=on&docRevision=&latestRevOnly=true&docProjectNumber=&docEngChangeOrder=&docLocation=&findLimit=500&docTypes=Customer+Drawing&docTypes=Production+Drawing&docTypes=Manufacturing+Process+Document&docTypes=Specification+Or+Standard
Note: replaced text with "CLIPBOARD" for clarification.
I was wondering if that's a type of "URL-programming" or how can I make a direct URL that prompts for the search results from the website? is that Javascript? or how is that programmed? (I know Swift and some Java, but have never really used Javascript).
It doesn't seem like you are asking an AutoHotKey (AHK) question, but to give you an AHK example you can copy, here is how I would use AHK to use Google.com to search for whatever is in my clipboard:
wb := ComObjCreate("InternetExplorer.Application")
wb.Visible := true
wb.Navigate("https://www.google.com/search?q=" . StrReplace(Clipboard, " ", "+") . "", "")
Note, the URL format includes the query ("?q=whatever+you+had+in+Clipboard") in it with spaces replaced by "+"s.
Hth,

lotusscript and dir function

I have one problem, and it drives me crazy,
Here is a line of code
qdName$ = Dir(fDir, ATTR_DIRECTORY)
fDir is a directory path.
Aim: I want to retrieve only Directory list under fDir path
Reality: I get all objects, directories, files, etc, what I doing wrong?
Here is a piece of code
qdName$ = Dir(fDir, 16)
While qdName$ <> ""
If qdName <> "." And qdName <> ".." And InStr(1, qdName$, ".JPG", NoCaseNoPitch) = "0" Then
folders = folders + 1
If InStr(1, qdName, "tmp") = 0 Then
Name fDir + qdName As fDir + "tmp" + SetDoc.counter(0)
qdName$ = "tmp" + SetDoc.counter(0)
Set item = SetDoc.replaceItemValue("counter", CStr(CInt(SetDoc.counter(0)) + 1))
Call SetDoc.save(True, True)
End If
dList(dNo%) = qdName$
dNo% = dNo% + 1
qdName$ = Dir$()
Else
qdName$ = Dir$()
End If
Wend
Although the code is not complete, I think it is clear from comments what happens:
There is no Option declare in the options- section of the code.
That means: The variables do not have to be declared. Any used variable will automatically be an empty variant.
ATTR_DIRECTORY is a constant in lsconst.lss (found in program- directory of Notes- Client) and has the value 16 as can be read in the designer help:
0 Normal file ATTR_NORMAL
2 Hidden file ATTR_HIDDEN
4 System file ATTR_SYSTEM
8 Volume label ATTR_VOLUME
16 Directory ATTR_DIRECTORY
In case of not including lsconst using the statement %include "lsconst.lss", ATTR_DIRECTORY will be empty. As this is an optional parameter for dir, it will be handled as if it was not there - default handling is ATTR_NORMAL.
As a solution you should ALWAYS add Option Declare to your code and declare any used variable as this is a best practice to avoid such strange errors.
To get the constants defined by notes in addition use the %include statement.
Another possibility would be to use the number value instead of the constant:
qdName$ = Dir(fDir, 16)
should give the right result.

uiresume (gcbf) worked in the function, but failed when the function being called

I want to let the user select multiple ROI's on a picture. I used a while loop. I paused and let the user select an ROI. After that the while loop would continue unless the user clicked another button on the toolbar to terminate the while loop. The code worked on single pictures. I made the code a function. When I looped and called the function in another script, it failed to proceed. I pressed Ctrl + C and it showed that "Operation terminated by user during uiwait". Apparently the uiresume didn't work.
Please let me know where the problems are. Thanks! My code:
% Below was basically a copy of the example given in R2014a.
% It created an interactive toolbar with 2 pushbuttons.
fh = figure('ToolBar', 'none'); hold on;
h_im = imshow(rgb2gray (I));
tbh = uitoolbar(fh);
[X_OK, map_OK] = imread(fullfile(matlabroot,...
'toolbox','matlab','icons','greenarrowicon.gif'));
[X_rect, map_rect] = imread(fullfile(matlabroot,...
'toolbox','matlab','icons','tool_rectangle.gif'));
% Convert indexed image and colormap to truecolor
icon_OK = ind2rgb(X_OK, map_OK);
icon_rect = ind2rgb(X_rect, map_rect);
% Create 2 uipushtools in the toolbar
% I introduced 2 variables, leave and draw, to facilitate the control of the
% later while-loop.
pth_OK = uipushtool(tbh, 'CData',icon_OK,...
'TooltipString','Toolbar push button',...
'ClickedCallback',...
'leave = 1; uiresume (gcbf)');
pth_rect = uipushtool(tbh, 'CData',icon_rect, 'Separator','on',...
'TooltipString','Toolbar push button',...
'ClickedCallback',...
'draw = 1; uiresume (gcbf)');
% The loop for ROI selection.
ii = 1;
% Maximum the use can select 30 ROI's.
while ii < 31;
draw = 0;
uiwait;
if leave == 1;
% If the user pressed "OK" button, leave will be 1.
break;
end;
if draw == 1;
% If the user pressed the "rect" button, draw will be 1.
h = imrect;
wait (h);
gui_Mask = createMask(h, h_im);
greyImg (~gui_Mask) = 255;
ii = ii + 1;
continue;
end;
end;
I saw someone used set/waitfor instead.
I tried to change to set/waitfor. Now it works both in the function and when the function being called.
But I still want to know why uiresume didn't work.

How to deal with information received in two packets

This is the case. I want to make a game, client being made in flash and server on java. From server side, the first byte i write on the stream is the protocol id, like this:
try
{
Output.writeByte(LOGIN);
Output.writeByte((byte)ID);
Output.writeByte(new_position.x);
Output.writeByte(new_position.y);
Output.flush();
}
After the 'onResponse' event is triggered, the socket is read like this:
type:int = socket_client.readByte();
if (type == 0x1)
FP.console.log("You are logged as " + socket_client.readByte() + " in x:" + socket_client.readByte() + " y:" + socket_client.readByte() );
else if (type == 0x2)
FP.console.log("You are now in x:" + socket_client.readByte() + " y:" + socket_client.readByte());
As you probably have guessed by now, this gives me some problems. Sometimes, server sends the information split in two, so the above code throws an EOF exception. Tracing the following code gives me sometimes this result:
trace("SIZE: " + socket_client.bytesAvailable);
//var type:int = socket_client.readByte();
var values:String = "";
while (socket_client.bytesAvailable > 0)
values += socket_client.readByte() + " ";
trace(values);`
Values:
SIZE: 1
2
SIZE: 2
2 6
The first '2' is the protocol id, the second and the third stands for x and y values.
Now, the question is, how can i prevent this to happen? How could i 'wait' until i have all the information needed?
Btw, on java this never happens, but i have no more control than on as3.
Add BufferedOutputStream in output initialization like this:
Output = new DataOutputStream(new BufferedOutputStream(connection.getOutputStream()));
Basically you need to switch your message format from [type, data] to [type, length, data]. Then, wait to process the data until bytesAvailable >= length, otherwise put it into a buffer.
Here is an example SOCKET_DATA handler that uses this logic:
https://github.com/magicalhobo/Flash-CS5-mobile-proxy/blob/master/com/magicalhobo/mobile/proxy/MobileClient.as#L110