Jump to content

[HELP]I Can'nt press keystroke


nopee427
 Share

Recommended Posts

Your question has been asked & answered NUMEROUS times.  Why don't you try using the search box and type in: keystroke AND background

Link to comment
Share on other sites

HotKeySet('{F1}', '_heyNotepad')
HotKeySet('{ESC}', '_Exit')

Local $_CLASS_TITLE_NOTEPAD = '[CLASS:Notepad]'
; Run Notepad with the window maximized.
Run("notepad.exe")
; Wait 5 seconds for the Notepad window to appear.
WinWait($_CLASS_TITLE_NOTEPAD, '', 5)

While Sleep(10)
WEnd

Func _heyNotepad()
    If WinActive($_CLASS_TITLE_NOTEPAD) Then
        Send('{HOME}'&'computer: got fetch my keyboard!'& @CRLF)
    Else
        MsgBox(0, @ScriptLineNumber&': error', 'notepad is not focus')
    EndIf
EndFunc
Func _Exit()
  Exit
EndFunc

 

Link to comment
Share on other sites

On 9/26/2020 at 2:28 AM, TheXman said:

Your question has been asked & answered NUMEROUS times.  Why don't you try using the search box and type in: keystroke AND background

On 9/26/2020 at 2:44 AM, Danp2 said:

Your question is also very vague. If you want help from the forum, I suggest that you provide more details, ie --

  • What keystroke do you need to send?
  • What application are you trying to automate?
  • Etc

 

 

On 9/26/2020 at 3:49 AM, zeenmakr said:
HotKeySet('{F1}', '_heyNotepad')
HotKeySet('{ESC}', '_Exit')

Local $_CLASS_TITLE_NOTEPAD = '[CLASS:Notepad]'
; Run Notepad with the window maximized.
Run("notepad.exe")
; Wait 5 seconds for the Notepad window to appear.
WinWait($_CLASS_TITLE_NOTEPAD, '', 5)

While Sleep(10)
WEnd

Func _heyNotepad()
    If WinActive($_CLASS_TITLE_NOTEPAD) Then
        Send('{HOME}'&'computer: got fetch my keyboard!'& @CRLF)
    Else
        MsgBox(0, @ScriptLineNumber&': error', 'notepad is not focus')
    EndIf
EndFunc
Func _Exit()
  Exit
EndFunc

 

I tried to do it with autohotkey, but they said that it is not possible, we cannot use sendevent and controlsend at the same time, so I discovered autoit and can I do this logic here?

*** Algorithm 🧠> My goal is to just send the three keys to a app window and I want it to be still doing keystrokes when I hide the application.

NOTE : You can see that I have my attempts in the comment line!

I will be waiting for your help, thanks! PEACE! ❤️

My Code : 

#MaxThreadsPerHotkey, 2         ; aynı tuş işlemi aynı anda kaç tane çalışabilsin
#SingleInstance, Force          ; aynı anda scriptin tek kopyası çalışsın
DetectHiddenWindows, On         ; gizli pencerelerle işlem yapabilme
#Warn                           ; uyarılar, scriptteki hatalarla ilgili ayrıntı dönme
#NoEnv                          ; gelecekteki AutoHotkey sürümleriyle uyumluluk için
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
if not A_IsAdmin
    Run *RunAs "%A_ScriptFullPath%" ; (A_AhkPath is usually optional if the script has the .ahk extension.) You would typically check  first.

;a = SendEvent, {SPACE down}
;b = SendEvent, {F1 down}{F1 up}
;c = SendEvent, {z down}{z up}


Loop 99999999999999999
{
    ;ControlSend, {F1 Down}{F1 Up}, ahk_exe app.exe
    
    if (true)
    {
        SetKeyDelay 200
        SendEvent, {F1 down}{F1 up}
        SetKeyDelay 100
        SendEvent, {SPACE down}
        SetKeyDelay 100
        SendEvent, {z down}{z up}
        SetKeyDelay 100
        
        ;WinActivate, ahk_pid 4652, SendEvent {F1 down}{F1 up}
        ;WinActivate, ahk_exe metin2.exe, SendEvent, {SPACE down}
        ;ControlSend, ahk_exe metin2.exe, %a%
        ;ControlSend, ahk_exe metin2.exe, %b%
        ;ControlSend, ahk_exe metin2.exe, %c%
    }
    sleep 100
}
Home::
  ExitApp


 

Edited by nopee427
Link to comment
Share on other sites

9 minutes ago, nopee427 said:

My goal is to just send the three keys to a game window and I want it to be still doing keystrokes when I hide the game.

you might want to convert your ahk code into autoit for better assistance.

use 'autoit window info' tool and get info of the game window and send a screenshot of that in.  (is metin2.exe your game?)

HotKeySet('{F4}', '_GameHotkeys') ;press F4 key on your keyboard to to execute F1 then SPACEBAR then z in the game
HotKeySet('{ESC}', '_Exit')

Global $_CLASS_TITLE_GAME = '[CLASS:MyXGame; TITLE:Game X Title]' ; <--- use 'autoit windows info' to get class and title of your game

While Sleep(10)
WEnd

Func _GameHotkeys()
    Switch @HotKeyPressed
      Case "{F4}"
          ; from ahk
          ; SetKeyDelay 200
          ; SendEvent, {F1 down}{F1 up}
          ; SetKeyDelay 100
          ; SendEvent, {SPACE down}
          ; SetKeyDelay 100
          ; SendEvent, {z down}{z up}
          ; SetKeyDelay 100
        
          If _IsGameActive() Then
              ;to autoit
              Sleep(200) ;time in miliseconds
              Send('{F1}')
              Sleep(100)
              Send('{SPACE}')
              Sleep(100)
              Send('z')
              Sleep(100)
          EndIf
    EndSwitch
EndFunc

Func _IsGameActive()
    If WinExists($_CLASS_TITLE_GAME) Then
        If Not WinActive($_CLASS_TITLE_GAME) Then
            WinActivate($_CLASS_TITLE_GAME)
            WinWaitActive($_CLASS_TITLE_GAME, 10)
        EndIf
        Return 1
    Else
        Return 0
    EndIf
EndFunc

Func _Exit()
  Exit
EndFunc

 

Link to comment
Share on other sites

1 hour ago, zeenmakr said:

you might want to convert your ahk code into autoit for better assistance.

use 'autoit window info' tool and get info of the game window and send a screenshot of that in.  (is metin2.exe your game?)

HotKeySet('{F4}', '_GameHotkeys') ;press F4 key on your keyboard to to execute F1 then SPACEBAR then z in the game
HotKeySet('{ESC}', '_Exit')

Global $_CLASS_TITLE_GAME = '[CLASS:MyXGame; TITLE:Game X Title]' ; <--- use 'autoit windows info' to get class and title of your game

While Sleep(10)
WEnd

Func _GameHotkeys()
    Switch @HotKeyPressed
      Case "{F4}"
          ; from ahk
          ; SetKeyDelay 200
          ; SendEvent, {F1 down}{F1 up}
          ; SetKeyDelay 100
          ; SendEvent, {SPACE down}
          ; SetKeyDelay 100
          ; SendEvent, {z down}{z up}
          ; SetKeyDelay 100
        
          If _IsGameActive() Then
              ;to autoit
              Sleep(200) ;time in miliseconds
              Send('{F1}')
              Sleep(100)
              Send('{SPACE}')
              Sleep(100)
              Send('z')
              Sleep(100)
          EndIf
    EndSwitch
EndFunc

Func _IsGameActive()
    If WinExists($_CLASS_TITLE_GAME) Then
        If Not WinActive($_CLASS_TITLE_GAME) Then
            WinActivate($_CLASS_TITLE_GAME)
            WinWaitActive($_CLASS_TITLE_GAME, 10)
        EndIf
        Return 1
    Else
        Return 0
    EndIf
EndFunc

Func _Exit()
  Exit
EndFunc

 

Bro thx. But.. Application title always change.. can we do it with application pid?
add me and let me show the status on live.. 
Discord : Razzere#8325

Edited by nopee427
Link to comment
Share on other sites

8 dakika önce zeenmakr şunları söyledi:

'otomatik pencere bilgisi' aracını kullanın ve oyun penceresi hakkında bilgi alın ve bunun bir ekran sayımı içeri gönderin. (metin2.exe sizin oyununuz mu?)

 


; <--- oyununuzun sınıfını ve adını almak için 'otomatik bilgi bilgi' kullanın

ok bro u Özel mesaj

Edited by nopee427
Link to comment
Share on other sites

  • Moderators
4 hours ago, nopee427 said:

You are very rude, you can be understanding bro..I'm just trying to learn that's all

Same old, tired excuse we hear all the time. Sad that botters can't even come up with new excuses.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...