Autohotkey only replace text in URL field - autohotkey

I'm trying to set up AHK only when I'm typing it in to the URL portion of a browser. That way I can continue to use my keyword other places.
Is this possible? I've been trying to mess around some with `ifWinActive("ahk_exe chrome.exe") which almost works, however when I try to type it not in the URL it simply deletes the text (and also will still make the replacement even if I'm typing in to a separate text box in the browser, not the URL box.)

You are on the right track. Once the command is limited to chrome, you have to do a conditional test to see if you are in the address bar or not. If not, simply "return" without doing anything.
For chrome, window spy however does not indicate the "focused Control" that you could use with "ControlGet" and its related commands:
https://www.autohotkey.com/docs/commands/ControlGet.htm
Oh well, so in your hotkey result, you may have to first do a quick copy all from your current caret position to clipboard and then see if the clipboard result is text only and starts with "http" and has a "://" and at least one "." and is otherwise a fully formed url address, and if so, then go ahead and run your hotkey result because now you can be pretty sure you actually are in the address bar.
Klugey, but certainly possible.

Related

What is hotkey to manually check a C function api in vscode?

Sometimes when I write the function name, the api is shown above its name automatically, but sometimes it doesn't work and I have to rewrite the function name to get that, so is there a shortcut key for it?
(I know man function_name but I used to CTRL+Q in NetBeans to get the same thing quickly but I can't find one for vscode.)
ALT+F12 seems to do the job. It's called "peek definition" which is available in the right click options too.
Also note that the opened window doesn't go away by clicking somewhere else outside of it, however, instead you can still use the ESC from keyboard.

Notepad++: disable auto-complete in comments

I'm using Notepad++ for C coding.
The auto-complete functionality in NP++ seems really naive. No matter where I am in a file, it always tries to give me a list of auto-complete suggestions (most of which are just random words, rather than function or variable names).
It becomes really annoying when I'm trying to write a long multi-line comment, and I keep having to hit escape at the end of lines because the auto-complete pop-up wants to change what I'm typing.
Is there a way to disable auto-complete inside comments?
Alternatively,
Is there a way to disable keyboard interactions with auto-complete? The time it saves by filling in text for me is negligible compared to the time it saves me from having to go and confirm that I'm spelling function or variable names correctly. So, it would be just about as useful if it always made suggestions, but where the arrow keys and enter interacted with the text, rather than the pop-up.
You can go Settings →Preferences → Auto-Completion and from this point you can set whether you have auto-completion on words, functions or both.
At this point, I don't believe there is a way to disable auto-completion within comments.
A workaround is to turn off auto-completion using Ctrl+Enter for your code, and Ctrl+Space for your comments.

ControlClick is not working

My script is supposed to press a button somewhere in my window, upper left. It is not working as it should be. I tried this:
ControlClick ClassNN ThunderRT6UserControlDC29, ahk_class ThunderRT6FormDC
Yet it doesn't work.
I tried the manual option:
Controlclick x160 y60, ....
But that doesn't work as well.
Eventually I resorted to a mere:
Click 160, 60 and that does work.
I was wondering why it is behaving like that? Also, is there a way for merely the button to get pressed without the mouse actually going all the way over there. I looks stupid and it is slow.
The main reason for me asking this question is because it is closely related to another question I posed:
How to obtain textual contents from a window
The common denominator is that anything with classNN and ahk_class seems to be problematic.
Try running script as a administrator (if you're on Windows 7 or Vista)
I finally found my own solution after skimming the documentation more thoroughly:
https://autohotkey.com/docs/commands/ControlClick.htm#Reliability
You can specify NA as the sixth parameter to wait for the mouse button to lift.
I found that when firing Control, Check, ,Button1 prior to ControlClick the click didn't work, but adding the NA to the end somehow magically fixed it. I suppose a click was being simulated and had not yet lifted.
First, make sure you have the capitalization correct. controlclick is case and space sensitive - everything in the name has to be correct.
Second, for your mouse-moving issue - first save the position of your mouse, then controlclick, and then put your mouse back where you found it. The mouse will only be out of place for the duration of either the click or the timeout. 160ms is not noticeable.
You might also try using ahk to activate the window, bringing it the front, and then seeing if you can tab through the controls to the one you want, and then push it by sending keys like space or return to the window in the forefront (which you have activated). This avoids using controlclick altogether. Some windows can be tricky.
Controlclick x160 y60,A,,Left,1, NA
Manual option like that should work,at least in my case it worked.
Left = your mouse button pressed
1 = number of clicks
A = Active Window
Also options to retrieve contents from the games or retrieve variables from other autohotkey parts for ControlClicks or SendMessage/PostMessage seem to not work yet.

How can I make the Home key put me at position 1 in Eclipse?

I'm using Eclipse Galileo, with a plugin for PHP development. I use the same editor at work and at home for my personal projects (at work, I do not use PHP or the PHP plugin, however).
One thing about using it is driving me crazy, though, and though I've spent a couple of hours digging through all the different options under Window->Preferences (as well as searching around the Internet), I can't find out how to do this one thing. Maybe someone here can help me?
Here's what's happening. I've got a line of code:
<?php
echo "Hello world"; // <-- I'm talking about this line
?>
and my cursor is on the 'w' in 'world'.
I hit the 'Home' key on my keyboard. In my key mappings, it claims this is supposed to take me to the beginning of the line ('Line Start', to be exact). To me, 'start' means 'there is nothing to the left of this position', aka position 1. As in, no tabs, no spaces, no nothing, and if I hit the 'Left arrow' key on my keyboard, I should then move to the end of the previous line. You know, how your browser works inside of a textarea, and how Word, Notepad, Excel, and almost every other program works.
Instead, when I hit 'Home', my cursor moves to position 5, the very beginning of the word 'echo'. This, in case it's not clear, is NOT the start of the line. It's the start of the non-whitespace content on the line, but that's not the way I expect this key to function. If I hit 'Home' again, I get to the REAL start of the line - position 1. Hit it again, and I'm back to 5.
It's possible that it's not a matter of the 'Home' key at all, but potentially a side-effect of the 'Smart Indenting' function. I also can't figure out how to turn that off (I've seen a few posts here that indicate that it can't be done), and it frequently messes up my formatting which causes me to waste my time fixing it, as I'm particular about how my code looks when I'm coding. For example, when I copy/paste a line, the indenting gets all messed up (the pasted line tabs in to where Eclipse thinks it should be, in spite of all of the preceding whitespace I've copied along with the text on the line). This may be related to the operation of the 'Home' key, or to Eclipse's conception of what the 'start' of the line really means.
I realize that people out there who don't code like I do will have an initial reaction of 'change the way you type', or 'ignore the messed-up formatting and let Eclipse auto-fix it later' or something similar. That's possible, but will take quite a bit of time, and is actively hindered by the fact that I'd be changing the way I work on this one app (in this one setting, as it doesn't do this at work), while all the others will continue to operate as I expect them to. So for me, that sort of suggestion is not a very viable option.
Thanks in advance for any help, advice or assistance you can offer.
PS. If you know of a way for me to keep 'Auto-indenting' on but turn off 'Smart Indenting', please let me know that too.
Untick General > Editors > Text Editors > Smart caret positioning at line start and end. Note that this will apply to all Eclipse editors, not just the PHP editor.

Using FileChooserButton in GTK+

I'm trying hard to find out how to use the file chooser button properly. Reading the reference manual on GtkFileChooserButton, GtkFileChooserDialog and GtkFileChooser didn't help so far. I've tried connecting to the undocumented signal file-set of GtkFileChooserButton and calling get\_filename() from here, but it seems to behave quite unreliably. When the user clicks the button and selects a file, it works fine so far.
But, if after clicking on the same button (which already has a filename set), the user changes his mind and closes the "open file" dialog, get\_filename() returns None (a Python type, i write it using pygtk) while the file remains set. Even more weird, if i call get_filename() on that button later from within another signal handler, the filename returns to what it previously had been set by the user. By the way, only closing the dialog box seems to cause the problem, pressing "cancel" works just fine.
Unclear question:
if you mean how to distinct between a valid chosen file:
if you call Run you will get a reponse:
Gtk::RESPONSE_ACCEPT if the user selected a file and accepted this file (clicked ok)
So only get the filename when the file is accepted.
if you mean how to reset filepath:
see gtk FileChooser -> set_ current_folder(filename) (without the space)