Need help on sending keystrokes into a game window

04/14/2016 01:18 Kuraiko#1
Hello everyone,

I'm in need for some help with a script I'm coding right now. Pretty simple one, but I have one big problem.

The game i'm planning this to use in is Blade & Soul.
The use of the macro is to simply send repeatedly an F keystroke with 100ms pause between every keystroke.
When testing the macro by just sending F via "Send, F" in Notepad the macro works just fine.
Sending the key to Notepad via ControlSend also works fine. The notepad windows doesn't even need to be active this way.

So here's the code I have so far.
Code:
SetTitleMatchMode, 3				;3: A window's title must exactly match WinTitle to be a match.

^q::						; This hotkey stops the loop below and asks for continuation.
	BreakLoop = 1
	MsgBox, 4, Mine Farmer, The script will now be stopped.`nAre you sure?
	IfMsgBox, Yes
		ExitApp
	Else
		BreakLoop = 0
Return

!f::
	Loop 
		{
		Sleep, 100
		ControlSend, , f, ahk_class LaunchUnrealUWindowsClient	;This line totally works fine if I use "Notepad"
		If BreakLoop = 1					;as the ahk_class, but seems to do nothing in the
			Break						;game window when using the games ahk_class
		If BreakLoop = 0
			Continue
		}
Return
And my questions are:
Is it even possible to get my idea working via AHK in Blade & Soul?
If yes, what else could I try? Which other commands for example.

I'll totally read any documation that leads me to a solution as well!

Regards,
Kuraiko
04/15/2016 19:42 Kuraiko#2
Tiny Push

Little Push
04/16/2016 16:37 mlukac89#3
I dont know in AHK but in autoit u need to get window name or window handle.

Here is example in autoit :

Run it and press F9 to check if window exists u will get message.


Code:
#RequireAdmin


HotKeySet("{F1}", "_sendFkey")      ; key that start/pause bot
HotKeyset("{F9}", "_check_window")  ; key that check if window exists


Global $pause = False
Global $window = "window name" ; name of the window if this fail comment it and uncoment second $window variable
;~ Global $window = WinGetHandle("window name") ; this is second option if first fail uncoment this variable and comment first $window variable


While 1
    Sleep(100)
WEnd


; main function
Func _sendFkey()


    $pause = Not $pause


        While $pause


            ControlSend($window, "", "", "{F}") ; key
            Sleep(1000) ; pause, 1000 = 1 second


        WEnd
EndFunc ; => main function


Func _check_window()


    If WinExists($window) Then
        MsgBox(0, "Message", "Window exists.")
    Else
        MsgBox(0, "Error", "Window dont exists.")
    EndIf


EndFunc ; => check if window exists
04/17/2016 02:44 Kuraiko#4
Hey mlukac89,

thanks for your answer.
Right now it says 02:43 on my clock, so I just flew over your code. I'll check it out at day time and let you know what I experience.

'Till then
Kuraiko

----------
Edit

Ha, totally forgot about this :O Sorry!
I got your solution to work, mlukac89. Thanks for your affort :)

Regards
Kuraiko