How it Work?
This function activate and minimize targeted window, while sending keys between those. To avoid flickering screen, the window will be moved away from your screen, but still be activated. (This script targeted to be used for ppl that using the same screen for automating something (with only keyboard keys) while doing something else (ex: watching video).)
Code: Select all
; ControlProcessLibrary
; A "fake" ControlSend
;===
; This simple library contains function and
; acts like ControlSend but, for program/window
; that doesn't accept normal ControlSend.
;===
; How it work :
; This functions activate and minimize
; window you want, and send keys
; between those. To avoid flickering
; screen, the window will moved
; away from your screen, while still
; activating the window.
;===
; How to use :
; For _ControlSend
; _ControlSend("Keys", "WinTitle")
; > Keys = Any valid keyboard keys
; > WinTitle = Targeted Window Title
;
; For _WinRestore
; _WinRestore("WinTitle")
; > WinTitle = Targeted Window Title
;===
; Example Usage :
; #Include ControlProcessLib.ahk
;
; ^/:: ; ctrl+/
; _ControlSend("Hello{!}, You can send any key here. Even {enter} work, and {q 10}`nWork too :D", "ahk_exe Notepad.exe")
; return
;
; Esc::
; _WinRestore("ahk_class Notepad")
; ExitApp
;===
_ControlSend(cp_key,cp_wintitle){
BlockInput, On
WinActivate, %cp_wintitle%
cp_height:=A_ScreenHeight+1000
cp_width:=A_ScreenWidth+1000
WinMove, %cp_wintitle%,, %cp_height%, %cp_width%
SendInput, %cp_key%
WinMinimize, %cp_wintitle%
BlockInput, Off
}
_WinRestore(cp_wintitle){
WinActivate, %cp_wintitle%
WinMove, %cp_wintitle%,, 0, 0
WinMinimize, %cp_wintitle%
BlockInput, Off
}
Code: Select all
#Include ControlProcessLib.ahk
^/:: ; ctrl+/
_ControlSend("Hello{!}, You can send any key here. Even {enter} work, and {q 10}`nWork too :D", "ahk_exe Notepad.exe")
return
Esc::
_WinRestore("ahk_class Notepad") ; putting these before ExitApp to make sure the moved window will be restored before the script goes off
ExitApp