Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Simple script: remap IrfanView's space bar to select random


  • Please log in to reply
6 replies to this topic
planetthoughtful
  • Members
  • 28 posts
  • Last active: Nov 24 2012 07:16 AM
  • Joined: 22 Feb 2006
A simple script to remap IrfanView's space bar (which normally selects the next image in the directory) to select a random image from the directory, while allowing normal operation of the space bar in other applications.

This is simply a preference of mine from the way other image applications work (e.g., ACDSee), since IrfanView's Ctrl-M key combination to select a random image seems a little counter-intuitive.

Works both in IrfanView's windowed and Full Screen views.

space::
{
	myvar:=false
	IfWinActive ahk_class IrfanView
	{
		myvar:=true
	} else {
		IfWinActive ahk_class FullViewClass
		{
			myvar:=true
		} else {
			myvar:=false
		}
	}
	if (myvar = true){
		#space::^m
	} else {
		space::space
	}
}
return

Note: I'm by no means a skilled AutoHotkey script developer. The script above might have problems I haven't yet detected, or might (in fact, probably can) be put together much more efficiently.

If anyone has any ways in which this script can be improved, please let me know.

Much warmth,

planetthoughtful
---
"lost in thought"
http://www.planetthoughtful.org

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
Works OK. If you like it shorter, try this
#IfWinActive ahk_class IrfanView

space::^m



#IfWinActive ahk_class FullViewClass

space::^m


planetthoughtful
  • Members
  • 28 posts
  • Last active: Nov 24 2012 07:16 AM
  • Joined: 22 Feb 2006
Hi Laszlo,

Much better! Thanks for posting this!

Much warmth,

planetthoughtful
---
"lost in thought"
http://www.planetthoughtful.org

JSLover
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004
Hehe...

GroupAdd, IrfanView, ahk_class IrfanView
GroupAdd, IrfanView, ahk_class FullViewClass

#IfWinActive ahk_group IrfanView
space::^m
...Note: I don't have IrfanView or a new enough AHK to test this...but...it should work. Chris...since #IfWinActive is a directive & GroupAdd is a command...how does #IfWinActive see the group before it's created?...I wasn't sure it would work because of this, but the online (new) help (my help file is old) says it should...btw...

if (myvar = true){
		#space::^m
	} else {
		space::space
	}
...I don't know how your version even works, because you shouldn't put :: hotkey definitions as if they were a command...if's shouldn't affect them (unless I'm projecting directive rules onto :: hotkey definitions...just checked the help & it don't mention not to use them like this)...so how does it even work...?
Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

since #IfWinActive is a directive & GroupAdd is a command...how does #IfWinActive see the group before it's created?

At the time the script is launched, #IfWinActive merely stores the specified WinTitle text; it doesn't attempt to interpret the text. Later, when the time comes for a hotkey or hotstring to check its associated #IfWin criteria, it interprets the WinTitle and discovers that the group now exists.

simonesch
  • Members
  • 1 posts
  • Last active: Oct 13 2014 12:37 PM
  • Joined: 13 Oct 2014

In Windows mode, the scripts work fine, in full screen mode, they don't. Any idea?
(Windows 7 SP 1, 64-Bit, German version)

 

BR Simon

 



floodindahood
  • Members
  • 383 posts
  • Last active: Apr 20 2018 01:45 PM
  • Joined: 21 Oct 2011

The "problem" is that the fullscreen's ahk_class is "FullScreenClass" so you'll need to check for both irfanview and fullscreenclass.

 

e.g,

$space::send, % (WinActive("ahk_class IrfanView") || WinActive("ahk_class FullScreenClass")) ? "^m" : "{space}"