AutoHotkey Community

It is currently May 26th, 2012, 11:06 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: macro help needed
PostPosted: November 3rd, 2009, 5:30 pm 
Not sure if this is possible but i have been trying to figure out a macro that can do the following keystrokes

3 every 15 seconds
5 every 10 seconds
4 every 12 seconds
contine to hit 0 if none of the timers are up


Does anyone know if this is possible


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2009, 6:20 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Try:
Code:
#Persistent
SetTimer, Send0,100
SetTimer, Send3, 15000
SetTimer, Send5, 10000
SetTimer, Send4, 12000
Return
Send0:
Send3:
Send4:
Send5:
Thread,NoTimers
;SendInput % "{" . SubStr(A_ThisLabel,0) . "}"
ToolTip % "Sending " . SubStr(_ .= SubStr(A_ThisLabel,0),-100)
Return
Escape::ExitApp

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2009, 7:42 pm 
That seems to be very close

Im not sure what this does

Thread,NoTimers
;SendInput % "{" . SubStr(A_ThisLabel,0) . "}"
ToolTip % "Sending " . SubStr(_ .= SubStr(A_ThisLabel,0),-100)
Return

i just need it to send the key strokes in whatever program i am in
notepad for example


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2009, 7:50 pm 
Offline

Joined: December 24th, 2008, 3:25 am
Posts: 1401
Location: :noitacoL
rotti wrote:
Thread,NoTimers
WinActivate, your_window_name_here (use WindpwSpy)
SendInput % "{" . SubStr(A_ThisLabel,0) . "}" ;uncomment this
;ToolTip % "Sending " . SubStr(_ .= SubStr(A_ThisLabel,0),-100) ;comment this out
Return

i just need it to send the key strokes in whatever program i am in
notepad for example


Tell it to activate your window, and use the 'send input' as opposed to the 'tool tip' in the example which was a test/demonstration.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2009, 8:15 pm 
Tried this using 2 as my hotkey but doesn't seem to work

2::
while GetKeyState("2", "P")
SetTimer, Send0,100
SetTimer, Send3, 15000
SetTimer, Send5, 10000
SetTimer, Send4, 12000
Return
Send0:
Send3:
Send4:
Send5:
Thread,NoTimers
WinActivate, New Text Document.txt - Notepad,
Return
Escape::ExitApp


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 3rd, 2009, 8:54 pm 
Offline

Joined: February 17th, 2008, 7:09 am
Posts: 536
I suggest you surround your code in blocks.

First, your while doesn't have brackets {} so the surrounding code isn't blocked together, rather the line IMMEDIATELY following will be looped, not the whole thing. I think where you placed your while block is probably wrong.

Second, if it were to include the whole thing, it only activates the Notepad, nothing else. Tooltip was a good idea as it would let you see the timing

Why does WinActivate have an comma at the end?
Lastly i suggest you read from the helpfile what the commands do, it's very well documented. We can assist if you don't understand.

The first posted suggestion looks great in my opinion, uncomment the sendinput and add a IfWinActive check.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], JSLover, Kirtman, Miguel, XstatyK and 57 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