AutoHotkey Community

It is currently May 27th, 2012, 1:28 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: September 24th, 2008, 1:46 am 
Offline

Joined: September 16th, 2008, 7:53 pm
Posts: 77
Greetings, Gurus.

I'm trying to create a Hotstring that will insert the current date, (in MM/DD format), into a line of text.

I know I can Hotstring the date if like this:
Code:
::dts::
Send, %A_MM%/%A_DD%
Exit


I've tried to enter my string like this, but it just types it as entered:
Code:
::ed::Edit %A_MM%/%A_DD% by Jerry H.


Do I need to put some universal characters or somehting in there?

Thanks in advance.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 24th, 2008, 2:00 am 
Offline

Joined: September 16th, 2008, 7:53 pm
Posts: 77
Never mind. I got it. I just had to split it up.

Code:
::ed::
Send, Edit %A_MM%/%A_DD% by Jerry H. 
Exit


Have a good one.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2008, 1:15 pm 
Offline

Joined: March 18th, 2008, 12:31 am
Posts: 63
Location: Barcelona, Catalonia
hi, I found this topic when finding out how to do a similar thing.

In my case I want to write the date on the second press of the key Home when it's done on the "Save Image" window of Firefox, the class of that window is #32770.

Code:
#IfWinActive ahk_class 32770
Home::Send, Edit %A_MM%/%A_DD% by Jerry H.
#IfWinActive


I don't know how to activate it on the second key press, but even on the first it doesn't do anything.

I do know that the original post is doing a hotstring and I am doing a hotkey. Thanks to those who help :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2008, 5:56 pm 
Offline

Joined: July 21st, 2008, 4:16 pm
Posts: 726
Location: Calgary, AB, Canada
Code:
Count = 0
#IfWinActive, ahk_class 32770 ; This may not work adequately for you... Too many windows use this same class. Add the name of the window in as well.  E.g.) Post a reply ahk_class IEFrame
Home::
    Count++
    If Count >= 2
    {
        Send, Edit %A_MM%/%A_DD% by Jerry H.
        Count = 0
    }
Return
#IfWinActive


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 4th, 2008, 3:37 pm 
Offline

Joined: March 18th, 2008, 12:31 am
Posts: 63
Location: Barcelona, Catalonia
perfect, thanks Sivvy :)

here's the final code if someone else is searching:

Code:
Count = 0
#IfWinActive Save Image ahk_class #32770
~Home::
    Count++
    If Count >= 2
    {
        Send,%A_YYYY%-%A_MM%-%A_DD% -{Space}
        Count = 0
    }
Return
#IfWinActive


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2009, 12:17 am 
Offline

Joined: March 18th, 2008, 12:31 am
Posts: 63
Location: Barcelona, Catalonia
I have a problem with the script above. It just writes the date in *every* second Home keypress no matter if I press something else in-between.

What I need is to type the date if the key is pressed two times very fast.

Something like "if this keypress is Home and the last one was aswell and the time between is less than 500ms", but I don't know how to do it :oops:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2009, 12:26 am 
Offline

Joined: January 12th, 2009, 11:38 pm
Posts: 55
Location: Southern Ca, USA
I think all you would need to add is a timer which resets the count to 0 if 500ms go by.

Code:
Count = 0
#IfWinActive Save Image ahk_class #32770
~Home::
    SetTimer, reset, -500
    Count++
    If Count >= 2
    {
        Send,%A_YYYY%-%A_MM%-%A_DD% -{Space}
        Count = 0
    }
Return
reset:
     Count = 0
return
#IfWinActive


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2009, 9:04 pm 
Offline

Joined: February 17th, 2008, 8:52 pm
Posts: 314
Here is another way of doing what you want.

Code:
;--Double click home key to enter date
;--Single click performs normal key function
#IfWinActive Save Image ahk_class #32770
$Home::
  If (A_PriorHotKey = "$Home" AND A_TimeSincePriorHotkey < 500)
    {
      Send,%A_YYYY%-%A_MM%-%A_DD% -{Space}
    }
  Else
    {
      Send {Home}
    }
#IfWinActive
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 13th, 2009, 12:11 am 
Offline

Joined: March 18th, 2008, 12:31 am
Posts: 63
Location: Barcelona, Catalonia
thank you very much. I will experience with these suggestions, and learn from them ;)

thanks again :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 12:50 am 
Offline

Joined: March 18th, 2008, 12:31 am
Posts: 63
Location: Barcelona, Catalonia
hi, I have a problem with this "#ifwinactive"

as you can see I want to set that shortkey just when uising the "add new torrent" window in utorrent, but that "The title or partial title of the target window" is not working. The full title of that window is "bla bla bla - Add New Torrent".

anybody can help?


Code:
#IfWinActive Add New Torrent ahk_class #32770
$Left::
  If (A_PriorHotKey = "$Left" AND A_TimeSincePriorHotkey < 500)
    {
      Send,{Home}{Right}{Right}{Right}{Right}{Right}{Right}{Space}-{Space}what.cd\
    }
  Else
    {
      Send {Left}
    }
#IfWinActive
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 2:18 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
Try SetTitleMatchMode, 2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 2:43 pm 
Offline

Joined: March 18th, 2008, 12:31 am
Posts: 63
Location: Barcelona, Catalonia
thanks, I will try :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2009, 3:42 am 
Offline

Joined: March 18th, 2008, 12:31 am
Posts: 63
Location: Barcelona, Catalonia
I am having some problems with this and the other comand CoordMode.

Code:
CoordMode, Mouse, Screen

SetTitleMatchMode, 2


The problem is that I understand that they need to be on top of the script, but what happens if I need "CoordMode, Mouse, Relative" or "SetTitleMatchMode, 1" in another part of the script?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2009, 5:08 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
They only need to be at the top (auto-execute section) if you want the settings to be global. That's the gist of this comment in the Remarks section for both of those commands.
AHK Help File wrote:
Every newly launched thread (such as a hotkey, custom menu item, or timed subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).

You can choose to set each of those commands in each subroutine if you want different settings in different places.

Example:
Code:
^z::
CoordMode, Mouse, Screen
MouseGetPos, x, y
MsgBox, Screen:`n %x%`t%y%
return

!z::
CoordMode, Mouse, Relative
MouseGetPos, x, y
MsgBox, Relative:`n %x%`t%y%
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2009, 2:38 am 
Offline

Joined: March 18th, 2008, 12:31 am
Posts: 63
Location: Barcelona, Catalonia
ok, thanks. I was puting the CoordMode just before the ^z:: and not inside. :roll:


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: iDrug, Ohnitiel, Yahoo [Bot] and 25 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:
Powered by phpBB® Forum Software © phpBB Group