Hi all,
Is it possible to make a program only be able to run while a particular text box inside a particular window is focused/cursor placement? If so, could some one point me to the documentation or tut on that info.
Thanks,
Jason
Easy scripting question for the pros and cons
-
- Posts: 1
- Joined: 16 Jun 2018, 04:39
Re: Easy scripting question for the pros and cons
Code: Select all
IfWinActive
Re: Easy scripting question for the pros and cons
I suggest you try doing an #if context sensitive following this example2 from the docs:
https://autohotkey.com/docs/commands/_If.htm
I have one script using this example which allows me.to create a really custom.behabior for any focused control.
You can even have dynamic control names like edit_1 edit_2 etc in a GUI. You can check the dynamic names with RegExmatch() or InStr() at the return of the function
Can become this
Basically the #if will be where you input your conditions and actions
But the #if is made true or false with the function that is bellow. Without the function the #if wont work because it will not be able to validate if its true or false. So dont miss that important part. The if is dependant on the fonction's return of true or false related to those things you want to validate
Code: Select all
; Example 2: Simple word-delete shortcuts for all Edit controls.
#If ActiveControlIsOfClass("Edit") ;this is a function call looking for "Edit"
^BS::Send ^+{Left}{Del}
^Del::Send ^+{Right}{Del}
ActiveControlIsOfClass(Class) { ;this is the function being called and the following check ups happen
ControlGetFocus, FocusedControl, A
ControlGet, FocusedControlHwnd, Hwnd,, %FocusedControl%, A
WinGetClass, FocusedControlClass, ahk_id %FocusedControlHwnd%
return (FocusedControlClass=Class)
}
I have one script using this example which allows me.to create a really custom.behabior for any focused control.
You can even have dynamic control names like edit_1 edit_2 etc in a GUI. You can check the dynamic names with RegExmatch() or InStr() at the return of the function
Code: Select all
return (FocusedControlClass=Class)
Code: Select all
return (FocusedControlClass ~= Class)
But the #if is made true or false with the function that is bellow. Without the function the #if wont work because it will not be able to validate if its true or false. So dont miss that important part. The if is dependant on the fonction's return of true or false related to those things you want to validate
Who is online
Users browsing this forum: Descolada and 298 guests