AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
planetthoughtful



Joined: 22 Feb 2006
Posts: 28

PostPosted: Sat Jul 15, 2006 4:12 am    Post subject: Simple script: remap IrfanView's space bar to select random Reply with quote

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.

Code:

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
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4710
Location: Boulder, CO

PostPosted: Sat Jul 15, 2006 3:25 pm    Post subject: Reply with quote

Works OK. If you like it shorter, try this
Code:
#IfWinActive ahk_class IrfanView
space::^m

#IfWinActive ahk_class FullViewClass
space::^m
Back to top
View user's profile Send private message
planetthoughtful



Joined: 22 Feb 2006
Posts: 28

PostPosted: Sun Jul 16, 2006 12:24 am    Post subject: Reply with quote

Hi Laszlo,

Much better! Thanks for posting this!

Much warmth,

planetthoughtful
---
"lost in thought"
http://www.planetthoughtful.org
Back to top
View user's profile Send private message
JSLover



Joined: 20 Dec 2004
Posts: 634
Location: LooseChange911.com The WTC bldgs shouldn't have fallen that fast. The official story is a lie!

PostPosted: Sun Jul 16, 2006 7:19 am    Post subject: Reply with quote

Hehe...

Code:
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...

Code:
   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...?
_________________

Home • Click image! • Blog
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Sun Jul 16, 2006 11:28 am    Post subject: Reply with quote

JSLover wrote:
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.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group