[Script] Quick Picto Viewer and Fast Slideshow creator

Post your working scripts, libraries and tools
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

17 Oct 2019, 15:42

yes, on a specific key press or when returning to the image with the sound file.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
burque505
Posts: 1396
Joined: 22 Jan 2017, 19:37

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

17 Oct 2019, 15:52

This link for MCI looks promising. Perhaps you could use SendMessage or PostMessage to send one of the MCI commands to your process. I'll keep investigating but I I thought I should pass it on.

Edit: Here are the messages I found for that.
Attachments
mci messages.PNG
mci messages.PNG (66.76 KiB) Viewed 3950 times
User avatar
SpeedMaster
Posts: 397
Joined: 12 Nov 2016, 16:09

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

17 Oct 2019, 16:58

robodesign wrote:
17 Oct 2019, 14:56
However, imagine the following scenarios A and B:
A. The user navigates between images with wheel up/down or the arrow keys. Some images have sounds associated, some not. If I do not use wait, the sound needs to be cut-off when switching the image. Just use SoundPlay, [inexistent-file] for this ?
That's exactly what the script already does. If the file is not found it is like playing a non-existent file so the current playing sound will stop. There is no need to play a non-existent sound since soundpath already points to a non-existent file. ;)
robodesign wrote:
17 Oct 2019, 14:56
B. A slideshow is running, the sound is a minute long explaining the image. If I use wait for soundplay, the user will be forced to listen to it and not be able to stop it.
that's why there's the ok_to_wait variable, if you enable it it's precisely because you want to listen to the whole comment. If you don't want the script to wait until the sound is finished, just disable this variable ok_to_wait:=0
robodesign wrote:
17 Oct 2019, 14:56
How do I cut it off?
This is unfortunately the real problem with the wait option of the soundPlay command. It seems that there is no way to interrupt the waiting process in progress with the keyboard. :cry:
the possibility to play the corresponding audio file is of course not suitable for listening to music (it's not a jukebox feature) but it's very useful for small audio comments (e. g. the gentleman on the right is my uncle Jef...)
robodesign wrote:
17 Oct 2019, 15:16
And , during a slideshow... if I do not use Wait, how long do I know to wait for the audio to end?
It may be possible to extract the duration of the sound file and dynamically adapt the slide show duration accordingly but this seems complicated to implement.
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

17 Oct 2019, 17:34

@burque505 .yes. I know about MCI. that's the proper way to do it.... I even have an ahk wrapper I found months ago, but it doesn't work.. It's old. I will try to fix it, to get it working....but it's so much easier with AHK-H ^_^

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
burque505
Posts: 1396
Joined: 22 Jan 2017, 19:37

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

18 Oct 2019, 17:53

It will be possible, I think. See this Rosetta Code link that works.
Here is a baby step in the right direction:

Code: Select all

Escape::ExitApp

FileSelectFile, name, , ,Select a WAV file , WAV (*.wav)

Tooltip Playing %name%
MCI_SendString("close all wait")
MCI_SendString("open type waveaudio" . name)
MCI_SendString("play " . name . " wait")
MCI_SendString("close " . name . " wait")
Tooltip
Return
 
MCI_SendString(p_lpszCommand,ByRef r_lpszReturnString="",p_hwndCallback=0) {
	VarSetCapacity(r_lpszReturnString,512,0)
	Return DllCall("winmm.dll\mciSendString" . (A_IsUnicode ? "W":"A")
		,"Str",p_lpszCommand						;-- lpszCommand
		,"Str",r_lpszReturnString					;-- lpszReturnString
		,"UInt",512									;-- cchReturn
		,A_PtrSize ? "Ptr":"UInt",p_hwndCallback	;-- hwndCallback
		,"Cdecl Int")								;-- Return type
}
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

19 Oct 2019, 07:47

Thank you very much for this, burque505!

I'll look into it, as soon as I can.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
burque505
Posts: 1396
Joined: 22 Jan 2017, 19:37

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

20 Oct 2019, 16:03

Here's a little stripped-down player based on the demo for the old script. A link to a site I found useful is in the code. I'm still trying to get a handle on this, but I'm making progress.
This opens a WAV or MP3 file, and then you can start, pause, resume, or stop. All MCI functions for playing.
lil player.PNG
lil player.PNG (10.74 KiB) Viewed 3756 times
There are a couple of hotkeys in there I used for troubleshooting. If you don't need 'seek' capability, i.e. rewind, fast forward, reverse, etc., which you might not for an animated GIF, maybe this will be almost enough.

Code: Select all

#Persistent
#SingleInstance, Force

; ┌─────────────────────────────────────────────────────────┐
; │  These helped:                                          │
; │  https://www.vb-helper.com/tutorial_mci.html            │
; │  https://rosettacode.org/wiki/Record_sound#AutoHotkey   │
; └─────────────────────────────────────────────────────────┘
global name

gui Margin,0,0
gui Add,Button,w70 h35,Open
gui Add,Button,x+0 wp hp,Play
gui Add,Button,x+0 wp hp,Pause
gui Add,Button,x+0 wp hp,Resume
gui Add,Button,x+0 wp hp,Stop
gui Show

return

ButtonOpen:
FileSelectFile, name, , ,Select an audio file , Audio (*.wav;*.mp3)
return

ButtonPlay:
MCI_SendString("play " . name)
return

ButtonPause:
MCI_SendString("pause " . name)
return

ButtonResume:
MCI_SendString("resume " . name)
return

ButtonStop:
MCI_SendString("close " . name . " wait")

!y::
Msgbox The thread is not interrupted by a MsgBox
return

GuiClose:
Escape::ExitApp

!x::MCI_SendString("stop " . name)

; ┌──────────────────────────────────────────────────────────────┐
; │  Not clear on the difference between 'close' and 'stop' yet  │
; └──────────────────────────────────────────────────────────────┘

return

 
MCI_SendString(p_lpszCommand,ByRef r_lpszReturnString="",p_hwndCallback=0) {
	VarSetCapacity(r_lpszReturnString,512,0)
	Return DllCall("winmm.dll\mciSendString" . (A_IsUnicode ? "W":"A")
		,"Str",p_lpszCommand						;-- lpszCommand
		,"Str",r_lpszReturnString					;-- lpszReturnString
		,"UInt",512									;-- cchReturn
		,A_PtrSize ? "Ptr":"UInt",p_hwndCallback	;-- hwndCallback
		,"Cdecl Int")								;-- Return type
}


User avatar
SpeedMaster
Posts: 397
Joined: 12 Nov 2016, 16:09

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

20 Oct 2019, 17:24

burque505 wrote:
20 Oct 2019, 16:03
Here's a little stripped-down player based on the demo for the old script. A link to a site I found useful is in the code. I'm still trying to get a handle on this, but I'm making progress.
This opens a WAV or MP3 file, and then you can start, pause, resume, or stop. All MCI functions for playing.
All the links in the archived forum are dead. :cry:
https://autohotkey.com/board/topic/32291-library-mci-v11-playcontrol-media-files/
Here is a B64 script to create MCi.ahk file (v1.1) in the working directory ;)
Spoiler
here is a working example based on your example 8-)

Code: Select all

#include mci.ahk
#Persistent
#SingleInstance, Force

; +---------------------------------------------------------+
; ¦  These helped:                                          ¦
; ¦  https://www.vb-helper.com/tutorial_mci.html            ¦
; ¦  https://rosettacode.org/wiki/Record_sound#AutoHotkey   ¦
; +---------------------------------------------------------+
global name

gui Margin,0,0
gui Add,Button,w70 h35,Open
gui Add,Button,x+0 wp hp,Play
gui Add,Button,x+0 wp hp,Pause
gui Add,Button,x+0 wp hp,Resume
gui Add,Button,x+0 wp hp,Stop
gui Show

return

ButtonOpen:
FileSelectFile, name, , ,Select a WAV file , Audio (*.wav; *.mp3)
hMedia:=MCI_Open( name )
return

ButtonPlay:
MCI_Play(hMedia)
return

ButtonPause:
MCI_Pause(hMedia)
return

ButtonResume:
MCI_Resume(hMedia)
return

ButtonStop:
MCI_Stop(hMedia)
return

!y::
Msgbox The thread is not interrupted by a MsgBox
return

GuiClose:
Escape::ExitApp

!x::MCI_Stop(hMedia)

; +--------------------------------------------------------------+
; ¦  Not clear on the difference between 'close' and 'stop' yet  ¦
; +--------------------------------------------------------------+
return
Cheers
burque505
Posts: 1396
Joined: 22 Jan 2017, 19:37

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

20 Oct 2019, 18:18

@SpeedMaster, it works like a charm. That B64 script is black magic to me (very curious as to what original file you decode there), but it certainly does the trick. Thank you!
It was also very useful for me to compare the old lib with your updated version. @robodesign, maybe this is the final piece of the puzzle.
Regards,
burque505
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

21 Oct 2019, 04:02

@burque505 . The provided example... does not work here, unfortunately. I use Windows 10 , x64.

@SpeedMaster . Please tell me how to use the two code snippets you provided. I was unable to make it run.. I got it running. It works well, as expected. My questions are now.... does it work compiled? For any system? If I compile the generated mci.ahk file and qpv.ahk. Does this ahk differ on every system? Why did it have to be generated in the first place?

Thank you very much to both of you. I only need play/pause/stop, no seeking.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
SpeedMaster
Posts: 397
Joined: 12 Nov 2016, 16:09

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

21 Oct 2019, 11:12

robodesign wrote:
21 Oct 2019, 04:02
Why did it have to be generated in the first place?
The B64 script that generates the mci.ahk file is only a common way to share a file on a forum.
you no longer need the b64 script once the MCI.ahk file is created.
robodesign wrote:
21 Oct 2019, 04:02
...does it work compiled? For any system? If I compile the generated mci.ahk file and qpv.ahk. Does this ahk differ on every system?
MCI is an API that is normally present on all recent versions of Windows so it should work (I think from XP to Win 10).
more info here: https://docs.microsoft.com/en-us/windows/win32/multimedia/mci
But I can't certify that the AHK library (mci.ahk) that drives the API is bug-free.
For example I noticed that under windows 10 an open file can only be read once.
It is therefore necessary to close the file and then reopen it to be able to read it again.
like this:

Code: Select all

ButtonPlay:
MCI_close( hMedia )
hMedia:=MCI_Open( name )
MCI_Play(hMedia)
return
robodesign wrote:
21 Oct 2019, 04:02
I only need play/pause/stop, no seeking.
If you just need a few commands, just open the library and copy and paste all the functions you need directly into your script, then you won't need the whole MCI library anymore.
Don't forget then to remove the line with #include Mci.ahk

Cheers,
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

21 Oct 2019, 11:54

Okay, thanks very much for the answers.

I find the b64 usage as.... cumbersome, in sharing ahk files. Perhaps, in other cases is a good idea.

I will implement this new feature in the next release of Quick Picto Viewer . Right now, I am adding color depth conversion, ... it still needs some love ;-).

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

24 Oct 2019, 14:05

Hello, guys!

I just released the new version of Quick Picto Viewer . Feedback and comments welcome.

- v3.8.5 (2019-10-24)
- [new] option to play associated sound files; MP3, WAV and WMA supported; slideshow speed based on audios duration; many thanks to SpeedMaster and burque505
- [new] option to display the alpha channel
- [new] option to simulate 2/4/6/8/16 bits display mode for images; option to have this rendered with dithering or not
- implemented Black/White dithering display mode through GDI+, not through FreeImage, as it previously was
- renamed option "no semi-transparent pixels" to "remove alpha channel"

I love the new audio/sounds feature! Thank you very much @SpeedMaster and @burque505 .

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
SpeedMaster
Posts: 397
Joined: 12 Nov 2016, 16:09

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

25 Oct 2019, 08:54

robodesign wrote:
24 Oct 2019, 14:05
I just released the new version of Quick Picto Viewer . Feedback and comments welcome.
I briefly tested the application on win 7 and 10 and it works very well. :bravo:
burque505
Posts: 1396
Joined: 22 Jan 2017, 19:37

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

25 Oct 2019, 11:37

And I tested it just on Win7 so far, nice job! :bravo:
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

26 Oct 2019, 05:04

Hey, guys!

Thank you very much for the feedback! If you find bugs, let me know .

A new release:

- v3.8.6 (2019-10-26)
- [new] option to associate with image file formats [works with Windows 10 ]; option only available if the script is compiled;
- on Windows 10, this makes use of SetUserFTA.exe developed by Christoph Kolbicz from http://kolbi.cz/blog/2017/10/25/setuserfta-userchoice-hash-defeated-set-file-type-associations-per-user/

On Windows 10 , setting file associations is no longer an easy feat. The mentioned application does the job, but one needs to properly set registry entries first... To learn more about this, see https://www.autohotkey.com/boards/viewtopic.php?f=6&t=55638&p=298273#p298273

PS. I released v3.8.7. The previous version had bugs [silly typos] that rendered the file association feature unusable... Sorry...

Edit2. Version 3.8.8 with additional bug fixes.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

28 Oct 2019, 13:11

Hello, guys!

A new version is here:

- v3.8.9 (2019-10-28)
- [new] the option to «Open with external application» now shows a list of applications associated with the image file format
- [new] Quick Picto Viewer now prevents rapid spawning of instances of itself; for example when opening dozens/hundreds of files by mistake

Feedback and comments, as always, welcomed!

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

01 Nov 2019, 08:08

And another version:

- v3.9.0 (2019-11-01)
- [new] added option to highlight image borders
- [new] created an application icon ;-)
- various small changes to improve usability; additional visual cues to indicate what is going on
- bug fixes

Ideas and suggestions are welcomed...

A file explorer? image editing/simple drawing? or... ?

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

21 Nov 2019, 12:30

Hello, guys!

Here's a new release:

- v3.9.8 (2019-11-21)
- [new] advanced auto-crop image option; applicable on multiple images at once
- [new] option to have smooth fading transitions from one image to another in slideshows
- [new] panel to decide action to perform on deleting multiple entries from the list
- [new] convert file format panel; allows to quickly convert to a specified image format a single image or multiple ones
- [new] added shortcut for changing gamma; Alt + ] / [. Also available with Ctrl for Saturation and Shift for Contrast.
- [new] sort images by similarity with the selected image
- [new] sort images by image width or height, aspect ratio and resolution
- [new] sort images by their luminance histogram average or median
- [new] support for copy/paste images with alpha channel
- [new] panel to precisely define the length of the slideshow; the speed of the slides is calculated based on the user defined total play time and amount images loaded
- [new] support for processing [crop, rotation, rescaling] high-dynamic range images: JXR, EXR, HDR, TIFF and PFM formats. High-color depths preserved.
- all the potentially long operations are now interruptible with a mouse click or tap on the UI, or with Escape

What follows next is multi-threading with AHK_H, for batch image processing. I will abandon AHK_L. I will also investigate ways to implement an algorithm to identify image duplicates...

So, enjoy the last AHK_L - based version of this script. :-)

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
robodesign
Posts: 714
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: [Script] Quick Picto Viewer and Fast Slideshow creator

11 Mar 2020, 15:13

Hello, guys!

I am back with a teaser for Quick Picto Viewer v4, currently alpha/beta stage.

Editing features:
Image

List view mode (newly introduced)
Image

It comes with multicore batch processing of images, image editing features and many optimisations. SQLite slideshow databases as well .

The User interface is now in a different thread and... thumbnails are generated on multiple threads.

I will post more «teasers» in a few days. The final version is still sometime away.... I have to finish the quick shortcuts bar, sqlite database... add undo/redo options, and various other details.

PS. The alpha version is available on my GitHub.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: mcl and 16 guests