I want to have a script that works with a specific program open when I open that program with the program's shortcut icon. I have tried pasting the path into the target line in the icon's properties, but that didn't work. What do I need to do?
I think that I read that you want to create an icon that looks like the original application launch icon, which will, when clicked, indeed launch the original application AND run some extra ahk code. You can create a Shortcut or Link to a ahk script that will launch your app (run, c:\path\yourapp.exe) and perform other tasks (WinWaitActive, your app) etc.. In the link to the ahk script (does not work on the real ahk script, ONLY with the lnk file) you can select the properties (right click) and change the icon to whatever you want (often you can use the icon of the original application, by pointing to the .exe (instead of selecting icons from the the standard shell32.dll). So by selecting the new icon to e.g. c:/program files/officexx/word.exe , your AHK script will get the icon as if it is the word launch icon. Hope that answers your question.
At the beginning of the script, but ater you execute the run command, you place the timer
Run, abc.exe
SetTitleMatchMode, 2
Sleep, 1000 ; Give the app some time to run before you start the test
SetTimer, CloseScript, 1000
Return
CloseScript:
IfWinExist, place the windows title here....
Return
ExitApp
This is one of the first things that I did with AutoHotKey. I wanted a 'wrapper' script for a program that I regularly used that lets me to chose different program options with a script GUI form when I press the F4 key while clicking the link. Just clicking the link starts the program normally. Eat your heart out Microsoft.
In the link's Start-In property I put the actual program's directory and my script gets the program name and other details from the script's command line arguments in the link's target property.
Related
I have a script in msword which can print the current page when clicked on button created in toolbar, and also a keyboard shortcut ctrl+o to print.
The ahk script code which contains ctrl+0 shortcut works just fine. But I have to open manually word documents each time to do that, and I have hundreds documents to print every day.
I wanted to add a script or keyboard shortcut using ahk in right click context menu in windows, so that when I right click on my word files in folder it can do the same without opening the word files.
I tried adding the ahk script in regedit...HKEY_CLASSES_ROOT*\shellex\ContextMenuHandlers. But it gives me an error : This app can't run on your pc.
Any idea how can i do that ?
I have two queries that needs to be resolved.
How can I resize Windows Powershell to a considerable size in Windows 10? I have already tried using the Properties options and via ** Layout**.
But the moment I re-launch it, the window size goes to an in-proportionate size. (Please check the image attached for this query)
P.S - I also browsed Stack-overflow and found this link - [https://superuser.com/questions/68013/how-can-i-set-the-powershell-default-window-size-in-windows-7] but wasn't able to eliminate the issue. :(
Image - 1: In-proportionate size of Windows Powershell
Other than query #1, I also want to know - when I try to open cmd window in a particular folder, I am not able to see the option reading open cmd window here in the context sensitive menu. For quick reference, I am also attaching one image for this query.
Image - 2: No option to open Command Prompt via context-sensitive menu.
P.S: I am getting the option to open Windows Powershell in the above image
I earnestly request the experts here to guide me on these two queries so that I can use both Windows Powershell and Command Prompt without worrying about the size of the window every time.
I look forward to some quick guidance.
Regards.
You can set it in the properties on Powershell window.
After,
When you reopen Powershell, these settings will be saved. Tune Window Position values as well as needed.
For your 2nd issue, read on this link - https://fossbytes.com/powershell-replaces-command-prompt-windows/
If you aren’t ready to accept this change and ditch Command Prompt,
you can opt out of the WIN+X change. To do this, open Settings >
Personalization > Taskbar. Now, turn the “Replace Command Prompt with
Windows PowerShell in the menu when I right-click the Start button or
press Windows key+X” option to “Off”.
As for this...
open cmd window here in the context sensitive
Option:
You can just select any directory and click the Explorer search bar and type cmd or powershell or pwsh (v6 if you have it installed) and it will start in that directory; As long as you don't have directory configured in you PowerShell profile.
You can add thing to the context menu using the Registry editor
See instructions here:
Add the Command Prompt to the Windows Explorer Right-Click Menu
A hidden functionality in Windows allows you to right click on a directory, and select “Command Prompt Here” from the menu.
https://www.howtogeek.com/howto/windows/add-the-command-prompt-to-the-windows-explorer-right-click-menu
Just as you can for PowerShell
Add PowerShell to Windows Explorer Context Menu in Windows 10
Ever since the days of Windows Vista, it was possible to use Windows Explorer’s context menu to quickly open a command prompt window to a specific location by holding the shift key and right-clicking a folder. The “Open Command Prompt Here” appeared, allowing you to open the command prompt in the folder of your choice.
https://www.petri.com/add-powershell-windows-explorer-context-menu-windows-10
BTW, you can add anything you wish to your SendTo menu as well, just by copying the short cut there, and then that too will show up in the explore context menu for use.
As far as your PowerShell Window being overly large/small. Of course the is not the default and something / someone did that. I seen that, but never had it happen to me.
Have you made a lot of customizations?
Is this only happen in your logged on session, vs other users of the system?
So, are you saying also, you cannot resize the Window using your mouse to another size?
Try this first.
Exit the console host.
Open the PowerShell_ISE
Reset the defaults there using these commands
$PSise.Options.RestoreDefaults()
$PSise.Options.RestoreDefaultConsoleTokenColors()
$PSise.Options.RestoreDefaultTokenColors()
$PSise.Options.RestoreDefaultXMLTokenColors()
Next start the console host from the ISE by clicking the console host icon in the toolbar.
Try and work the properties from there, then close and reopen the console host form the ISE to see if the settings stayed.
Then open the console host from whatever shortcut you normally use and see if the changes remained.
If that does not reposition / resize the console windows then this is Windows proper causing this. Similar to a Window being off screen that you can't get to.
Then right click an open space on the taskbar and select Cascade windows.
If that does not work use the move option from the Taskbar.
Use Shift+Tab to select the console Windows.
Shift+RightClick the taskbar icon of the Window and select move.
The close and check again.
Lastly, if you have not done a lot of customizations, you can grab the default PowerShell regkey from another user / profile and import that into your registry.
If you don't have another default logon to use, just create one, check PowerShell state and the get that regkey to use.
Last thing, I meant to add, if none of the above works and you don't want to take the RegKey route. Create a PowerShell console profile and add this code to it. This of course will run each time you start you console using your profile. Of course adjust as needed,
$ConsoleSettings = (Get-Host).ui.rawui
$ScreenBufferSettings = $ConsoleSettings.buffersize
$ScreenBufferSettings.height = 50
$ScreenBufferSettings.width = 120
# $ConsoleSettings.buffersize = $ScreenBufferSettings
$ScreenSizeSettings = $ConsoleSettings.windowsize
$ScreenSizeSettings.height = 50
$ScreenSizeSettings.width = 120
$ConsoleSettings.windowsize = $ScreenSizeSettings
I'm using notepad++ (v6.5.3) and I constantly have to change the size of the tab for viewing some results. Not that it's taking me a lot of time to do it manually everytime, but it would be great if I could optimize that.
Is there a way to do so? Would a macro be the solution, or are they just for typing stuff?
Thanks a lot!
Ok, there's an easy way how you can achieve this - I have tested it right now:
Install AutoHotKey (or start portable version which runs without installation)
In Windows 7 and above, ensure you launched AutoHotKey as Administrator (otherwise you get inconsistencies in its behavior) - if not sure, exit it and restart it as administrator
Right click Autohotkey tray icon and select Edit This Script
Import the macro below this list at the end of the AutoHotKey script file and save the file
Right click Autohotkey tray icon and select Reload This Script.
–– This was end of general steps, now let's go with your macro: ––
In N++, display Preferences window and press its Close button1 at the bottom (NOT at the top-right corner)
Now you can use shortcuts Win+F2 and Win+F3 to switch different tab sizes instantly
SendMode Input
DetectHiddenWindows, On
SetTitleMatchMode, RegEx
;--------------------------------- Hotkeys for Notepad++ only
#IfWinActive ahk_class Notepad\+\+
#F2::Send {F10}{Right 6}{Down}{Enter}{Tab 2}{Space}16{Enter}{Tab 3}{Space}
#F3::Send {F10}{Right 6}{Down}{Enter}{Tab 2}{Space}4{Enter}{Tab 3}{Space}
#IfWinActive
1) Important: N++ user experience provided in dialog boxes is absolutely terrible. There are no anchors where you can fix focus when using keyboard. Thus you always need to perform step 4 manually when leaving Preferences dialog box otherwise the macros would send keys into incorect window page OR at correct page but incorrect control. Preferences dialog window remembers selected page and control. Macros I created for you therefore assume that correct page is already listed and button Close was recently focused.
Good news is Notepad++ windows with this weird behavior are rare exception from general user experience. In other places in N++ (or in other apps) where user interface components (menus, dialogs etc.) always start from the same point you do not need any special precautions like the one in step 4.
Adjust the macros as you like:
you can create more of them
you can adjust the numbers "16" and "4" typed into tab size input box
you can change shortcut keys to something else
you can replace sending keys with sending mouse clicks at desired screen/window positions
you can achieve many other useful shortcuts in N++ and in all other apps – check AHK deeper!
I have made an AHK script that will take file names from an Excel spreadsheet, open the file in a different program, then export that file to two different formats.
It's working pretty well, except sometimes, the file has some little tweak that needs to be done with it (wrong orientation, hidden layers, etc) that create a popup.
I've tried to program around that by using ifwinexist conditions, so that if I know when a window is SUPPOSED to pop up, the script can deal with it.
The problem I have is that the popup windows can happen at times that I do NOT expect.
So, is there a way to run a thread until the window pops up, closes the window, but then will continue to look for the window?
Thank you
You are looking for SetTimer, which spawns another thread. The following code checks for the window with partial name Notepad every second (1000ms), and closes it if found.
SetTitleMatchMode, 2
SetTimer, CheckWin, 1000
CheckWin:
IfWinExist, Notepad
WinClose, Notepad
Return
what name can I use for the Logitech button that appears on their keyboard that I'm using. I want to reprogram it in Autohotkey. I see it opens the calculator if you did not install the the proprietary software. Thanks!
e.g.
Calculator:: ;then some commands
Logitech:: ;then some commands
Here is how I set my Calc key to launch Google Chrome with AHK:
Launch_App2::
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
You can use the keyboard hook along with viewing the keyboard history.
The process for finding these keys is specified in the documentation.