is there a way to suspend the script while typing?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
TheBeginner
Posts: 91
Joined: 19 Oct 2018, 12:05

is there a way to suspend the script while typing?

31 Oct 2018, 05:00

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?
User avatar
Sabestian Caine
Posts: 528
Joined: 12 Apr 2015, 03:53

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

31 Oct 2018, 09:30

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
I don't normally code as I don't code normally.
TheBeginner
Posts: 91
Joined: 19 Oct 2018, 12:05

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

31 Oct 2018, 12:22

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
aifritz
Posts: 301
Joined: 29 Jul 2018, 11:30
Location: Germany

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

31 Oct 2018, 15:54

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
TheBeginner
Posts: 91
Joined: 19 Oct 2018, 12:05

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

31 Oct 2018, 16:51

thanks for the reply, I'll play around with the first approach tomorrow, I think it's more what I need
TheBeginner
Posts: 91
Joined: 19 Oct 2018, 12:05

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

04 Nov 2018, 05:18

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

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: RandomBoy, scriptor2016 and 355 guests