AutoHotkey Community

It is currently May 27th, 2012, 8:48 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: July 15th, 2006, 5:12 am 
Offline

Joined: February 22nd, 2006, 1:36 pm
Posts: 28
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 15th, 2006, 4:25 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Works OK. If you like it shorter, try this
Code:
#IfWinActive ahk_class IrfanView
space::^m

#IfWinActive ahk_class FullViewClass
space::^m


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 16th, 2006, 1:24 am 
Offline

Joined: February 22nd, 2006, 1:36 pm
Posts: 28
Hi Laszlo,

Much better! Thanks for posting this!

Much warmth,

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 16th, 2006, 8:19 am 
Offline
User avatar

Joined: December 20th, 2004, 12:19 pm
Posts: 798
Location: LooseChange911.com Ask Questions, Demand Answers █ The WTC bldgs █ shouldn't have fallen █ that fast
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...?

_________________
AutoHotkey-Hotstring.ahk - Helping the world spell "AutoHotkey" correctly! (btw, it's a lowercase k!)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 16th, 2006, 12:28 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], tomoe_uehara, Xx7 and 9 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group