AutoHotkey Community

It is currently May 27th, 2012, 12:51 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: July 28th, 2011, 4:51 pm 
Offline

Joined: October 24th, 2009, 7:04 pm
Posts: 17
I have two monitors and love playing RPG games, but I'm quite forgetful so I like to take notes with my second monitor. The problem is, I always have to alt+tab, type notes, and restore the game. Sometimes several times.

I wanted to keep notepad open on my second monitor, have a toggle button that will switch between sending all the keystrokes from the game, to the background notepad window, and then turn it off.

I've found suspend works great for this, but the problem I am having after that is finding out how to send keys to Notepad, without having to make 100+ individual hot keys!


So is there a way to cause every key press trigger this and send the key that was pressed to Notepad? Thanks!

Here is an example and it works great so far:

Code:
#s::Suspend

a::
{
   ControlSend, Scintilla1, {enter}, ahk_class Notepad++
   Return
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2011, 4:58 pm 
Offline

Joined: April 11th, 2011, 10:12 am
Posts: 393
Location: West Yorkshire, England
Maybe you need Anykey . . . !!

Perhaps . . . ??

_________________
Image

Hope this helps / Thanks <-------- (Delete Appropriate)

Chris


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2011, 5:29 pm 
Offline
User avatar

Joined: September 5th, 2009, 2:06 pm
Posts: 1718
Location: Somewhere near you
Code:
Start:
Input, SingleKey, L1
ControlSend, Edit1, %singlekey%, ahk_class Notepad
Goto Start

Pause::Pause

_________________
Image
The quick onyx goblin jumps over the lazy dwarf


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2011, 6:57 pm 
tomoe_uehara wrote:
Code:
Start:
Input, SingleKey, L1
ControlSend, Edit1, %singlekey%, ahk_class Notepad
Goto Start

Pause::Pause


This didn't do anything.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2011, 7:00 pm 
Offline
User avatar

Joined: September 5th, 2009, 2:06 pm
Posts: 1718
Location: Somewhere near you
Be sure to run notepad, and activate another window, and start typing, press Pause button to set this thing on & off

Tested on Win 7 x64 - AHK Basic

_________________
Image
The quick onyx goblin jumps over the lazy dwarf


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

Joined: October 24th, 2009, 7:04 pm
Posts: 17
tomoe_uehara wrote:
Be sure to run notepad, and activate another window, and start typing, press Pause button to set this thing on & off

Tested on Win 7 x64 - AHK Basic


Tried it again and it worked this time, the problem is that that code has to be the first thing in the script. The next problem is while it captures text keys, it doesn't capture enter, return, arrows, I can't backspace or navigate to edit the text. Second, I can't trigger the pause because it's outside of the loop?

Better, but still not functional.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2011, 7:28 pm 
Offline
User avatar

Joined: September 5th, 2009, 2:06 pm
Posts: 1718
Location: Somewhere near you
Code:
Start:
Input, SingleKey, L1
ControlSend, Edit1, %singlekey%, ahk_class Notepad
Goto Start

Left::ControlSend, Edit1, {left}, ahk_class Notepad
Right::ControlSend, Edit1, {right}, ahk_class Notepad
Pause::Pause

You can't trigger the pause? I don't know, but it works on my PC

_________________
Image
The quick onyx goblin jumps over the lazy dwarf


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2011, 7:38 pm 
Offline
User avatar

Joined: May 18th, 2010, 3:10 pm
Posts: 1179
Location: Sweden
I had something started for something like this, a long time ago. However, I noticed I didn't really get far... but it works!

Code:
Window := "ahk_class gdkWindowToplevel" ; Replace with a window of your choice. I am using it with Pidgin.

#s::
SoundPlay, %A_WinDir%\Media\Speech On.wav ; Optional sound
Input, String,, {Enter} ; Type a string
ControlSend,, %String%, %Window% ; Send the string
ControlSend,, {Enter}, %Window% ; "Send" the chat message (adding "Enter")
SoundPlay, %A_WinDir%\Media\Speech Off.wav ; Optional sound
return


I had planned to basically add a GUI where you could set up the "target windows", any more ideas?

_________________
~sumon Appifyer AHK Nova halted Recommended: AHK_L (Why?)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2011, 7:47 pm 
Offline

Joined: October 24th, 2009, 7:04 pm
Posts: 17
Yeah, for some reason the Pause key on my keyboard isn't triggering it, but when I changed it to another key it worked. The arrow keys work great, so that is just a mater of adding the extra function keys.

Now the problem is the suspension of the hot keys.

The script works perfect, but only if the first lines of code are:

Code:
Start:
Input, SingleKey, L1
ControlSend, Scintilla1, %singlekey%, ahk_class Notepad++
Goto Start


When paused, all the keys return to the game and work normally. However, the function hot keys, (Left, Right, Etc) continue to be captured and sent to Notepad instead of the game making them unusable. The fix is toggling suspend and pause together, but suspend can only be toggled if it's the first line of code and if Suspend is the first line of code no keystrokes are captured. If Start: is first, keystrokes are captured, but suspend can only be toggled off and never on again.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2011, 7:54 pm 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Look at the docs for suspend. You can allow that hotkey to trigger regardless of the suspend state.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2011, 9:39 pm 
Offline
User avatar

Joined: September 5th, 2009, 2:06 pm
Posts: 1718
Location: Somewhere near you
How about two separate scripts? Place them in a same folder..
Code:
; #1 - Launcher.ahk
#Persistent
F1::Run, %A_ScriptDir%\Capture.ahk,,, varPID
F2::Process, Close, %varPID%


Code:
; #2 - Capture.ahk
Start:
Input, SingleKey, L1
ControlSend, Edit1, %singlekey%, ahk_class Notepad
Goto Start

Left::ControlSend, Edit1, {left}, ahk_class Notepad
Right::ControlSend, Edit1, {right}, ahk_class Notepad

Run the Launcher first, and then press F1 to capture and F2 to stop..

_________________
Image
The quick onyx goblin jumps over the lazy dwarf


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2011, 11:15 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Please, please, please don't use Goto to form loops. That's what Loop is for.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 29th, 2011, 1:36 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
[offtopic]

Lexikos wrote:
Please, please, please don't use Goto to form loops. That's what Loop is for.
I wouldn't use it as an example, but for quick one-time-use scripts I have no problem with it. In this case it doesn't make much difference, and in my opinion: it looks better.


[/offtopic]

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 29th, 2011, 4:45 pm 
Offline
User avatar

Joined: September 5th, 2009, 2:06 pm
Posts: 1718
Location: Somewhere near you
Code:
; Ok then, I'll use Loop instead of goto
; #2 - Capture.ahk
Loop
{
Input, SingleKey, L1
ControlSend, Edit1, %singlekey%, ahk_class Notepad
}

Left::ControlSend, Edit1, {left}, ahk_class Notepad
Right::ControlSend, Edit1, {right}, ahk_class Notepad
:oops:

_________________
Image
The quick onyx goblin jumps over the lazy dwarf


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, chaosad, jrav, MSN [Bot] and 19 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