Page 1 of 1

is there a way to suspend the script while typing?

Posted: 31 Oct 2018, 05:00
by TheBeginner
I'm trying to suspend a script while in an input field in a program, and haven't found a way to do that

I've tried to do

Code: Select all

#if (!A_CaretX)
the problem is that in this program it returns blank even if a caret exists, any solution for that, or an alternative approach?

Re: is there a way to suspend the script while typing?

Posted: 31 Oct 2018, 09:30
by Sabestian Caine
My view is that you should Explain your question/problem in full detail, if you wanna good answer...

secondly, i think you should use #ifwinactive directive for making hotkeys context sensitive...


Regards
SC

Re: is there a way to suspend the script while typing?

Posted: 31 Oct 2018, 12:22
by TheBeginner
thanks for the reply

Hope this would make what I want to accomplish clearer, I want all script hotkey to suspend when I enter any text field, so I can write without hotkeys being triggered

this is the code I used, works okay if the application sends the caret position (hence I am in a text field). unfortunately doesn't work in every program, I'm wondering if there's a better way

Code: Select all

#SingleInstance force

#If (!A_CaretX) 

d::

msgbox %A_CaretX%

return

Re: is there a way to suspend the script while typing?

Posted: 31 Oct 2018, 15:54
by aifritz
I think it would be easier, when you define another Hotkey e.g. ^d::msgbox %A_CaretX%
So you had to press Ctrl and d.

...otherwise you had define all Classnames for the controls where you don`t want to use this hotkey:
Here an example:

Code: Select all

#If Not ActiveControlClassMatch("(.*Edit.*|_WwG|.*Excel.*|XLDESK1|MozillaWindowClass)") ;_WwG => MS Word, .*Excel.*|XLDESK1 => MS Excel etc. 
  d::msgbox %A_CaretX%
#If

ActiveControlClassMatch(Class) {
 ControlGetFocus, FocusControl, A
 ControlGet, FocusControlHwnd, Hwnd,, %FocusControl%, A
 WinGetClass, FocusControlClass, ahk_id %FocusControlHwnd%
 ;msgbox |%FocusControlClass%|
 Return RegExMatch(FocusControlClass, Class)
}
As alternative you also could use the Windowstitles, which makes it a bit easier:

Code: Select all

SetTitleMatchMode, RegEx
return

#IfWinNotActive (PSPad|Word|Excel|Firefox)
  d::msgbox %A_CaretX%
#IfWinNotActive

Re: is there a way to suspend the script while typing?

Posted: 31 Oct 2018, 16:51
by TheBeginner
thanks for the reply, I'll play around with the first approach tomorrow, I think it's more what I need

Re: is there a way to suspend the script while typing?

Posted: 04 Nov 2018, 05:18
by TheBeginner
Couldn't make it work, same as A_CaretX, the ControlGet also returns blank, it doesn't identify If a field is in focus/what the field text or id is in that program.
Going to drop it for now, when I have time again I'll try Autohotkey v2 maybe it's detection and handling is better