topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday November 2, 2024, 11:05 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: NANY 2019: Shorthand 3_2  (Read 37594 times)

Maestr0

  • Participant
  • Joined in 2010
  • *
  • Posts: 30
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #25 on: February 05, 2019, 03:25 PM »
Shades, you seem to be a Batch file guru, is there a failsafe way in a batch file to download files from within the batch file? Bitsadmin is deprecated, sadly :(

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,937
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #26 on: February 05, 2019, 09:11 PM »
You couldn't be more wrong.

If batch files are your thing, I found a lot of help and/or hints at the website of Rob van der Woude.

Downloading? From a website? Or a personal cloud drive?

Because of the inherited environment, a few batch scripts that are very important to the reeling and dealing of this company are in my care. And I have expanded their functionality significantly.

Spoiler
One element of that script is the transfer of software builds from a computer in Europe to South America where I reside.

Does such a scenario apply to your request? If so, I'll explain what I did. First, I made a server from old PC parts laying around, put Ubuntu Server LTS on it, installed WebMin and NextCloud on it and made that server face the Internet. On the other end I used several different protocols (FTP, FTPS, SFTP, SCP, WebDAV) to see what was the fastest method of transfer. In my case that was WebDAV (and with a really big margin), so the choice for NextCloud on my end was easily made. 

On the other end I had to maintain a batch script that makes checkouts from a CVS server, which was already old software in 1995, but it is still in use and the people working with it really do not want to change. On that end I really had no other option than continue with batch. Anyway, the checkout is done by batch, the building process is now also done using batch and then the my transfer batch script comes into play.

There is nice way to do transfers with command line tools. I did find a tool called CarotDAV, which is dead simple to use software for transferring files manually through the Windows GUI. It really is and you can use it also to connect it to Google, DropBox, OneDrive etc., as well. But the only software I could find with command line support was WinSCP. That is a pretty powerful piece of software for transferring files. But it sure isn't fast. It was faster to log into the server and use CarotDAV to make a manual transfer than to do it by batch script with WinSCP.

In my situation CarotDAV was always finished between 10 and 15 minutes, while with WinSCP (which supports the all the FTP, SCP and WebDAV protocols) it would always take between an hour and an hour and a half. But some 10 months ago a new build of CarotDAV came out, which has now also command line support (and a progress meter).

So now, when a build is started it is checked out, archived, put in a local repository, transferred to my environment, put in my local repository and specific other folder for automatic regression testing (done by another script that is not batch, because "dog fooding" and with that specific script language it is easy to generate reports from the huge battery of regression tests which also need to be sent by mail to several people). And when the transfer has been successful, the transfer script also generates a HTML mail message with build specific content to several people. All automagically without any further user interaction, besides a person initiating the build.

What I can tell you is that no-one should ever want to use batch scripts in this way. It is messy script code at best and has cost me way too much time troubleshooting to make it reliable. Development and troubleshooting all had to take place within a text editor and the command-line box that comes with Windows. No IDE of any kind :mad:

You'll learn to appreciate the Linux command line shells or PowerShell from MS so much more after an exercise like this. Be sure of that.


Well, you could generate in the main batch script another batch script for handling the download from either a specific or generic list of files then CALL it at the appropriate time in the main script and when done with the download you make the main batch script clean up that generated batch file. You will need the transfer tools you plan to use already in place on the necessary computer(s) to make that as "smooth" as possible.

But security-wise it is a flawed method. Not too big of a deal when you retrieve stuff from your own cloud drive or something like that, but in a security conscious environment, that method is best to be considered a 'no-no'.


Maestr0

  • Participant
  • Joined in 2010
  • *
  • Posts: 30
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #27 on: February 06, 2019, 04:39 AM »
Thanks for the info, Shades! I'll look into it.

My current idea is to have the batch file check for (and download as needed) the #include files the main script needs. That can't be done in the script itself because it throws an error when it doesn't find it.
If I can't reliably get the batch file to get the required included files, I'll use a script to check for the required files and then run the main script.

Oh, and yeah, the downloaded files are from my public dropbox folder.

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,937
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #28 on: February 06, 2019, 07:27 PM »
IF EXIST / IF NOT EXIST

That should help you find out if a file exist or not and apply conditions you like in the main batch script. If, for instance, you have a (short) static list of include files, you could could dedicate a section in your main batch script to generate a secondary batch script with the files that are there to copy. Then let the main batch script call this secondary script, which can now copy all existing files and when the secondary batch script is finished, you can let the main batch script delete the secondary script.

I do that to generate my HTML mail message, which is deleted after the command line mail client is done sending that generated message. And as long as you don't need passwords, it is pretty handy way of doing things.

And then you'll find out that you can achieve the same in PowerShell (or Linux shells) because these have much better support for pipes.   :D

chashnniel

  • Member
  • Joined in 2018
  • **
  • default avatar
  • Posts: 127
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #29 on: April 08, 2019, 08:56 AM »
2 Maestr0

here is another bug report

I'm running the latest version 3.2.0.46 (updated var the app)

When i first run this app, I started start.bat since I don't have ahk V2 installed. Then I get the error1(see pic below). But this actually have no matters, I can just close the error window and app can run normally.
Then I started my new search, everything is fine when I was searching English characters but there comes error2 when I searched Chinese characters.(I guess it doesn't suppirt Unicode.) I tried to open the file with Scrambled Code name and I got error3.
Regards. :)

Maestr0

  • Participant
  • Joined in 2010
  • *
  • Posts: 30
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #30 on: April 09, 2019, 12:42 AM »
2 Maestr0

here is another bug report

Thank you, much appreciated!

I'm running the latest version 3.2.0.46 (updated var the app)

When i first run this app, I started start.bat since I don't have ahk V2 installed. Then I get the error1(see pic below). But this actually have no matters, I can just close the error window and app can run normally.

Very strange. Can you reply to this message with the contents of your start.bat code in brackets?

Then I started my new search, everything is fine when I was searching English characters but there comes error2 when I searched Chinese characters.(I guess it doesn't suppirt Unicode.)

I'll see if I can change it to support Unicode. Watch this space!

I tried to open the file with Scrambled Code name and I got error3.
Regards. :)

Hmmmmm, possibly also due to Unicode. I'll look into it!

chashnniel

  • Member
  • Joined in 2018
  • **
  • default avatar
  • Posts: 127
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #31 on: April 09, 2019, 05:02 AM »
thx for your reply. :Thmbsup:

Can you reply to this message with the contents of your start.bat code in brackets?
One thing I need to make it clear is that I didn't modified any code in it. So here is the contents of my start.bat:
@echo OFF

start ./app/AHKv2_x32.exe shorthand3_ahk2.ahk



Here is the content of the error1 comes from:
In   .\app\shorthand3_ahk2_updater.ahk
<!DOCTYPE html><html xml:lang="en" class="maestro" xmlns="http://www.w4.org/1999/xhtml"><head><script nonce="Gwr7GMPeiqNeO2AkPHvU">
window._goch_ = {};
window.addEventListener('click', function(event) {
    'use strict';
    for (var elm = event.target; elm; elm = elm.parentElement) {
        if (elm.id &&
            window._goch_.hasOwnProperty(elm.id) &&
            window._goch_[elm.id].call(elm, event) === false) {
            event.preventDefault();
        }
    }
}, true);

...
...
...

I'll see if I can change it to support Unicode. Watch this space!
Take your time, I will wait :)

Maestr0

  • Participant
  • Joined in 2010
  • *
  • Posts: 30
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #32 on: April 09, 2019, 06:01 AM »
One thing I need to make it clear is that I didn't modified any code in it.

I didn't doubt that, I asked to make sure it was the latest version, as there is always a possibility that the updater didn't work right or something like that.

Replace the contents of your start.bat with this:

REM @echo OFF
SET ShortHandFolder=%~s1
START %ShortHandFolder%app\AHKv2_x32.exe %ShortHandFolder%shorthand3_start.ahk >>%ShortHandFolder%log\batch.log

if %ERRORLEVEL% neq 0 goto ProcessError

:ProcessError
REM error detected running shorthand3_start.ahk: running the script directly instead
START %ShortHandFolder%app\AHKv2_x32.exe %ShortHandFolder%shorthand3_ahk2.ahk

:answer0
SET ShortHandFolder=
REM finished

Here is the content of the error1 comes from:
In   .\app\shorthand3_ahk2_updater.ahk
<!DOCTYPE html><html xml:lang="en" class="maestro" xmlns="http://www.w4.org/1999/xhtml"><head><script nonce="Gwr7GMPeiqNeO2AkPHvU">
window._goch_ = {};
window.addEventListener('click', function(event) {
    'use strict';
    for (var elm = event.target; elm; elm = elm.parentElement) {
        if (elm.id &&
            window._goch_.hasOwnProperty(elm.id) &&
            window._goch_[elm.id].call(elm, event) === false) {
            event.preventDefault();
        }
    }
}, true);


Hmmmmm, that looks like there is an issue with the file the shorthand updater script is trying to download.
What do you get when you the following link in your browser?
https://www.dropbox....hk2_version.ini?dl=1

That's the file it should be trying to get, it gives version information and links for updated files.

I'm still working on the other issues.

chashnniel

  • Member
  • Joined in 2018
  • **
  • default avatar
  • Posts: 127
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #33 on: April 09, 2019, 06:21 AM »
thank you for such a quick repay!  :up:

What do you get when you the following link in your browser?
https://www.dropbox....hk2_version.ini?dl=1
I open the link above in chrome and it tried to download a file, please see pic below

Maestr0

  • Participant
  • Joined in 2010
  • *
  • Posts: 30
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #34 on: April 09, 2019, 06:21 AM »
I tried to open the file with Scrambled Code name and I got error3.
Regards. :)

Hm. It seems to be something in AHK v2...

this v1 code works in v1 without a problem:
file := "C:\test dir\你好.txt"
run, % file

but this v2 code throws an error:
file := "C:\test dir\你好.txt"
run file

I'll see if I can get around that, somehow :)

Maestr0

  • Participant
  • Joined in 2010
  • *
  • Posts: 30
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #35 on: April 09, 2019, 06:23 AM »
thank you for such a quick repay!  :up:

What do you get when you the following link in your browser?
https://www.dropbox....hk2_version.ini?dl=1
I open the link above in chrome and it tried to download a file, please see pic below

ah, yes. There's your problem # 2 ;)
It's a safe file, not sure how we can get around that... I'll see if I can have the text in a website url directly instead of in a file.

chashnniel

  • Member
  • Joined in 2018
  • **
  • default avatar
  • Posts: 127
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #36 on: April 09, 2019, 06:38 AM »
Hm. It seems to be something in AHK v2...

this v1 code works in v1 without a problem:

but this v2 code throws an error:
If so, then we can do nothing. so maybe just forget about this error.
Thanks for the infos

Maestr0

  • Participant
  • Joined in 2010
  • *
  • Posts: 30
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #37 on: April 09, 2019, 07:51 AM »
Hm. It seems to be something in AHK v2...

this v1 code works in v1 without a problem:

but this v2 code throws an error:
If so, then we can do nothing. so maybe just forget about this error.
Thanks for the infos

Nah, we have options, I'm poking other people about it now :)

We couldn't find a solution on Discord, now I've posted in autohotkey forums, let's see what shakes loose...
https://www.autohotk...php?f=76&t=63509
« Last Edit: April 09, 2019, 08:33 AM by Maestr0 »

Maestr0

  • Participant
  • Joined in 2010
  • *
  • Posts: 30
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #38 on: April 09, 2019, 12:02 PM »
Hm. It seems to be something in AHK v2...

this v1 code works in v1 without a problem:

but this v2 code throws an error:
If so, then we can do nothing. so maybe just forget about this error.
Thanks for the infos

Right, so, the issue was with the encoding of the script and not the txt file. Open the script in a file editor and encode it as UTF-8-BOM or something similar. I will update the script to 3.2.0.47 as soon as I have it working for the results of "Everything".

Update:
get the newest version of the script here: https://www.dropbox...._2_3.2.0.47.ahk?dl=1

Let me know if you have any more issues, or if any are not yet fixed.
« Last Edit: April 09, 2019, 12:17 PM by Maestr0 »

chashnniel

  • Member
  • Joined in 2018
  • **
  • default avatar
  • Posts: 127
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #39 on: April 09, 2019, 12:17 PM »
Right, so, the issue was with the encoding of the script and not the txt file. Open the script in a file editor and encode it as UTF-8-BOM or something similar. I will update the script to 3.2.0.47 as soon as I have it working for the results of "Everything".

Glad to hear that you found a solution :D
Just take your time.
Much thx

chashnniel

  • Member
  • Joined in 2018
  • **
  • default avatar
  • Posts: 127
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #40 on: April 09, 2019, 06:42 PM »
Update:
get the newest version of the script here: https://www.dropbox...._2_3.2.0.47.ahk?dl=1
Sorry for the late reply, I knew this update just now.
I replaced the new file and run the start.bat, at first it run with some errors then I just restarted it and it works like a charm now!!! :Thmbsup:
Thanks for this great work :-*

Maestr0

  • Participant
  • Joined in 2010
  • *
  • Posts: 30
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #41 on: April 10, 2019, 12:12 AM »
Update:
get the newest version of the script here: https://www.dropbox...._2_3.2.0.47.ahk?dl=1
Sorry for the late reply, I knew this update just now.
I replaced the new file and run the start.bat, at first it run with some errors then I just restarted it and it works like a charm now!!! :Thmbsup:
Thanks for this great work :-*

You're very welcome! Please, do not hesitate to let me know if you have any issues or suggestions.

chashnniel

  • Member
  • Joined in 2018
  • **
  • default avatar
  • Posts: 127
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #42 on: April 10, 2019, 01:07 AM »
another bug report

I run shorthand with admin, in adv search mode.
I don't quite understand what the containing field means, I guess its the result filter... or perhaps search for content in txt file(that's a great feature and I think maybe you have not finished it yet)

When I searched in the containing field(shorthand1.gif), I got an error(error4.png) each time I enter or delete a character.

I tried to follow the instruction in the error window, clear the % in line 2815, namely
%key% := this.value  --->   key := this.value

Then I got shorthand2.gif
In the final of shorthands.gif, when I clear the containing field and turn back to the main search input. I had to add or delete a character to get the search result. So it can't get the result instant even I clicked enter key.

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
Re: NANY 2019: Shorthand 3_2
« Reply #43 on: April 11, 2019, 07:23 AM »
Hi Maestr0, I'm learning to use Everything from within AutoHotkey so I peeked a little at your source code. I see you use ES on the command line rather than the Everything SDK/API. Was there some reason for that in this case? Speed? Stability? Other?

I have myself only very quickly tested the SDK/API so don't know what the advantages/disadvantages are in actual use.
There is sample AutoHotkey code here
https://www.autohotk...php?p=118613#p118613
and the Everything creator has well written SDK documentation here
https://www.voidtool...port/everything/sdk/