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 

Hot string backspacing

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
moorpipe



Joined: 04 Oct 2006
Posts: 19

PostPosted: Wed Oct 11, 2006 1:37 am    Post subject: Hot string backspacing Reply with quote

Please don't take offence when I'm using the term "hot string", but that's what it's called, I'm afraid. Embarassed
I'm using the hotstring "]d" to display the date occasionally. To prevent paging back in Internet Explorer I added an exception (see code). At some time I was reading an HTML Help file (CHM) when I typed "]d". You know what happened then. So I added another exception. More recently I did it while reading blogs in FeedDemon... you get the drift!
Is there a more elegant way of excluding the backspace in certain applications rather than adding an exception code for each application where the backspace is functional? I would be most grateful.
Code:
#IfWinActive ahk_class IEFrame
{
    :B0*:]d::  ; This hotstring shows the current date and time via the commands below.
    FormatTime, CurrentDateTime,, dd MMMM yyyy HH:mm
    MsgBox ,, Huidige Datum en Tijd, %CurrentDateTime%
    return
}
#IfWinActive ahk_class HH Parent
{
    :B0*:]d::  ; This hotstring shows the current date and time via the commands below.
    FormatTime, CurrentDateTime,, dd MMMM yyyy HH:mm
    MsgBox ,, Huidige Datum en Tijd, %CurrentDateTime%
    return
}
#IfWinActive
{
    :B*:]d::  ; This hotstring shows the current date and time via the commands below.
    FormatTime, CurrentDateTime,, dd MMMM yyyy HH:mm
    MsgBox ,, Huidige Datum en Tijd, %CurrentDateTime%
    return
}
Back to top
View user's profile Send private message
silveredge78



Joined: 25 Jul 2006
Posts: 387
Location: Midwest, USA

PostPosted: Wed Oct 11, 2006 2:16 am    Post subject: Reply with quote

Try something like this:

Code:
#IfWinNotActive ahk_class IEFrame
:B0*:]d::
#IfWinNotActive ahk_class HH Parent
:B0*:]d::  ; This hotstring shows the current date and time via the commands below.
    FormatTime, CurrentDateTime,, dd MMMM yyyy HH:mm
    MsgBox ,, Huidige Datum en Tijd, %CurrentDateTime%
Return
 
#IfWinNotActive

This should make it that when it is NOT IE and NOT Parent whatever that is, that this hotkey works. Smile At least based on what Ive read in the help docs.

Note, I did not use brackets under the #IfWin commands, as I do not think that is the proper structure.
_________________
SilverEdge78
Back to top
View user's profile Send private message
moorpipe



Joined: 04 Oct 2006
Posts: 19

PostPosted: Wed Oct 11, 2006 3:00 am    Post subject: Reply with quote

Thanks for trying to help me. I should have mentioned that my code is working, that is not the issue. Let me try to revise my question.

Some applications use back space as a shortcut to go to the previous page as in Internet Explorer, HTML Help and FeedDemon.
Of course I do not want this to happen when I just want to display a message box with the current date and time. But the back space should be turned on when I'm in some kind of text editor to delete the "]d".
That is what your code and mine is doing.

Now, my example applications use all different classes, resp. IEFrame, HH parent and TfFDMain.UnicodeClass. And maybe I have some more, not yet discovered applications, using the back space as a shortcut.
I would like to know if there is an easy way of adding exceptions without repeating the same code (except for the class name) over and over again.
E.g. something like:
IfWinActive app1 or app2 or app3 or app4 ....
do this
else
do that
Back to top
View user's profile Send private message
silveredge78



Joined: 25 Jul 2006
Posts: 387
Location: Midwest, USA

PostPosted: Wed Oct 11, 2006 3:08 am    Post subject: Reply with quote

What bout something like this? I am bout to head out, so no time to test this, sorry.

Code:
#IfWinActive ahk_class IEFrame
    :B0*:]d::DateBox() ; This hotstring shows the current date and time via the commands below.
#IfWinActive ahk_class HH Parent
    :B0*:]d::DateBox()  ; This hotstring shows the current date and time via the commands below.
#IfWinActive
    :B*:]d::DateBox()  ; This hotstring shows the current date and time via the commands below.

DateBox()
{
    FormatTime, CurrentDateTime,, dd MMMM yyyy HH:mm
    MsgBox ,, Huidige Datum en Tijd, %CurrentDateTime%
}

_________________
SilverEdge78
Back to top
View user's profile Send private message
moorpipe



Joined: 04 Oct 2006
Posts: 19

PostPosted: Wed Oct 11, 2006 4:00 am    Post subject: Reply with quote

Well, the code doesn't work (e.g. commands s/b on the second line), but you've warned me for that. More important is, that I understand what you mean. I made some adjustments and it's working now. I must admit I was hoping for something more advanced but this will do.
Thanks.
Back to top
View user's profile Send private message
silveredge78



Joined: 25 Jul 2006
Posts: 387
Location: Midwest, USA

PostPosted: Wed Oct 11, 2006 6:38 am    Post subject: Reply with quote

My apologies if this is not what you were wanting exactly. I was limited on time and couldnt test it out myself. I am still rather new at all of this too. Sorry that its not more advanced (if its possible).
_________________
SilverEdge78
Back to top
View user's profile Send private message
JSLover



Joined: 20 Dec 2004
Posts: 542
Location: LooseChange911.com... the WTC attacks were done by the US Gov't... the official story is a lie...

PostPosted: Wed Oct 11, 2006 8:19 am    Post subject: Re: Hot string backspacing Reply with quote

Not tested...

Code:
GroupAdd, BackspaceGroup, ahk_class IEFrame
GroupAdd, BackspaceGroup, ahk_class HH Parent
GroupAdd, BackspaceGroup, <umm put FeedDemon here>

#IfWinActive ahk_group BackspaceGroup
:B0*:]d::
   ;//Debug...
   not:="not "
#IfWinActive
:B*:]d::
   ;//For debugging...
   msgbox, I will %not%send Backspace...
   not=
;//FormatTime, Date,, dd MMMM yyyy HH:mm
;//...better date/time format...
FormatTime, Date, , ddd, MMM d, yyyy --- M/d/yy h:mm:sstt
;//MsgBox ,, Huidige Datum en Tijd, %Date%
;//...um, yeah, english...
MsgBox, , Date, %Date%
return

_________________

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



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Wed Oct 11, 2006 10:50 am    Post subject: Reply with quote

That's why I advise not to use hotstrings outside edit fields... A simple hotkey is probably better for this use. There are ways to make combo hotkey combinations too. Otherwise, spot some edit field (address bar, form field, index search...), put the focus there and type your hotstring.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
silveredge78



Joined: 25 Jul 2006
Posts: 387
Location: Midwest, USA

PostPosted: Wed Oct 11, 2006 2:11 pm    Post subject: Reply with quote

Would this FormatDateTime script do kind of what you might want?
_________________
SilverEdge78
Back to top
View user's profile Send private message
moorpipe



Joined: 04 Oct 2006
Posts: 19

PostPosted: Wed Oct 11, 2006 2:18 pm    Post subject: Reply with quote

silveredge78 wrote:
My apologies if this is not what you were wanting exactly. I was limited on time and couldnt test it out myself. I am still rather new at all of this too. Sorry that its not more advanced (if its possible).

Please, don't be sorry. I'm a newbie myself, and you made me revise my concept of hotstrings.
JSLover wrote:
Not tested...

Code:
GroupAdd, BackspaceGroup, ahk_class IEFrame
GroupAdd, BackspaceGroup, ahk_class HH Parent
GroupAdd, BackspaceGroup, <umm put FeedDemon here>

#IfWinActive ahk_group BackspaceGroup
:B0*:]d::
   ;//Debug...
   not:="not "
#IfWinActive
:B*:]d::
   ;//For debugging...
   msgbox, I will %not%send Backspace...
   not=
;//FormatTime, Date,, dd MMMM yyyy HH:mm
;//...better date/time format...
FormatTime, Date, , ddd, MMM d, yyyy --- M/d/yy h:mm:sstt
;//MsgBox ,, Huidige Datum en Tijd, %Date%
;//...um, yeah, english...
MsgBox, , Date, %Date%
return

wow, very nice. Just deleted the debug code (after testing of course) and put back in the dutch text and format.
PhiLho wrote:
That's why I advise not to use hotstrings outside edit fields... A simple hotkey is probably better for this use. There are ways to make combo hotkey combinations too. Otherwise, spot some edit field (address bar, form field, index search...), put the focus there and type your hotstring.

Thanks for the advice. I agree a hotkey would be better in this case.

Case closed. Thanks all.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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