I'm trying to run Juniper Network's Junos Pulse using AHK. It works when I use Windows' Run App, but not in my AHK script. There is no error - nothing happens:
#j::
Run, C:\Program Files (x86)\Common Files\Juniper Networks\JamUI\Pulse.exe
Return
Things I have tried:
Run, Pulse.exe, %Path%
Run, '%Path%Pulse.exe'
Run, "%Path%Pulse.exe"
Run %Path%Pulse.exe
Also, when I add a MsgBox to open within the command, it opens fine - no issue, but Pulse doesn't open, and no error occurs.
UPDATE: Since the previous line didn't work with Pulse and your answer demands specific screen coordinates and position in taskbar, I made this workaround that may work on every PC regardles of it's resolution/taskbar:
#j::
Send #r
Sleep, 1
clipboard:="C:\Program Files (x86)\Common Files\Juniper Networks\JamUI\Pulse.exe"
Send ^v
Sleep, 1
ControlClick, OK, Run
return
Alternatively, if you want to preserve the 'Clipboard' and use 'Enter' instead of 'ControlClick':
#j::
Send #r
Sleep, 1
Send C:\Program Files (x86)\Common Files\Juniper Networks\JamUI\Pulse.exe
Sleep, 1
Send {Enter}
return
ps: increase the 'Sleep' time to get safer results on slow computers.
Try to run the script as administrator (context menu),
or add this to the auto-execute section (top of the script, before the first return or hotkey):
if not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
TL;DR:
Pulse's GUI Implementation disregards standard AHK input. You need to use more indirect input to interact with Pulse. Try this script, changing the click coords to match your own screen:
#CommentFlag ;//
;// Run Junos Pulse
#j::
Send, {LWinDown}4{LWinUp} ;// If Pulse is pinned to your taskbar in the 4th position
Sleep 100
Click 568,315 ;// the position of the Connect button on my screen
Sleep 7000
Click 641,32 ;// the position of the Minimize button
Return
Details
Custom GUI Implementations
Some Apps use a custom GUI implementation. This is typically because they want more control over what the OS can access and how it can access it.
A good example is Google's Chrome, which acts like this in Windows. They probably don't want to share your data with Windows, because it's worth more to them that way.
Junos Pulse is also a special GUI implementation for one to a few of the following reasons: 1) They want to work across as many platforms as possible. 2) They want to add security by limiting the number of ways Windows can access it. 3) It's a poorly written application. 4) It was written for Windows 8, and never actually updated for Windows 10.
Because they use custom implementations instead of the standard MS implementations, they knowingly or accidentally disallow seemingly innocuous functions.
Because Chrome works semi-well with AHK, it's probably less restrictive on how it can be accessed as an application, and more restrictive on how Windows can access the data it stores. This is also part of the reason it's damn near impossible to completely remove your Chrome data from a computer.
Junos Pulse, on the other hand, probably lumps AHK in with intrusive or unsafe malware.
But, there is Hope
Pulse still responds to indirect interactivity such as the mouse and keyboard. So that is what you have to use.
Remember:
You can open programs by adding them to the taskbar and pressing win + number - corresponding to the order of apps pinned to the task bar.
Junos Pulse is the 4th Program on my taskbar:
So I can use win+4 to open it. I send that and some mouse clicks to automate signing in, then minimize the window. Keep in mind, this is specific to my screen (MS Surface Pro), and the placement of the Pulse window when it opens):
#CommentFlag ;//
;// Run Junos Pulse
#j::
Send, {LWinDown}4{LWinUp}
Sleep 100
Click 568,315 ;// the position of the Connect button on my screen
Sleep 7000
Click 641,32 ;// the position of the Minimize button
Return
Use WindowSpy (a tool in SciTE4AutoHotkey) to get the exact mouse coordinates for the Click commands.
Related
I am trying to setup a remote to work with an IR reciever that I recently purchased using my raspberry pi, I've installed LIRC according to the following tutorial
https://www.digikey.com/en/maker/blogs/2021/how-to-send-and-receive-ir-signals-with-a-raspberry-pi
now the problem arises when I try and record to setup a specific remote, it saves all the values as 0x0,
here is the console output when setting up the remote that doesn't work
Running as regular user pi
Using driver default on device /dev/lirc0
irrecord: could not open logfile "/home/pi/.cache/irrecord.log"
irrecord: Permission denied
irrecord - application for recording IR-codes for usage with lirc
Copyright (C) 1998,1999 Christoph Bartelmus(lirc#bartelmus.de)
This program will record the signals from your remote control
and create a config file for lircd.
A proper config file for lircd is maybe the most vital part of this
package, so you should invest some time to create a working config
file. Although I put a good deal of effort in this program it is often
not possible to automatically recognize all features of a remote
control. Often short-comings of the receiver hardware make it nearly
impossible. If you have problems to create a config file READ THE
DOCUMENTATION at https://sf.net/p/lirc-remotes/wiki
If there already is a remote control of the same brand available at
http://sf.net/p/lirc-remotes you might want to try using such a
remote as a template. The config files already contains all
parameters of the protocol used by remotes of a certain brand and
knowing these parameters makes the job of this program much
easier. There are also template files for the most common protocols
available. Templates can be downloaded using irdb-get(1). You use a
template file by providing the path of the file as a command line
parameter.
Please take the time to finish the file as described in
https://sourceforge.net/p/lirc-remotes/wiki/Checklist/ an send it
to <lirc#bartelmus.de> so it can be made available to others.
Press RETURN to continue.
Checking for ambient light creating too much disturbances.
Please don't press any buttons, just wait a few seconds...
No significant noise (received 0 bytes)
Enter name of remote (only ascii, no spaces) :notworking
Using notworking.lircd.conf as output filename
Now start pressing buttons on your remote control.
It is very important that you press many different buttons randomly
and hold them down for approximately one second. Each button should
generate at least one dot but never more than ten dots of output.
Don't stop pressing buttons until two lines of dots (2x80) have
been generated.
Press RETURN now to start recording.
................................................................................
Got gap (108172 us)}
Please keep on pressing buttons like described above.
.....................................................................................................................................................Cannot find any gap, using an arbitrary 50 ms one. If you have a
regular remote for e. g., a TV or such this is probably a point
where you hit control-C. However, technical hardware like air
condition gear often works without any gap. If you think it's
reasonable that your remote lacks gap you can proceed.
Press RETURN to continue.
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_UP
Now hold down button "KEY_UP".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_DOWN
Now hold down button "KEY_DOWN".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_LEFT
Now hold down button "KEY_LEFT".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_RIGHT
Now hold down button "KEY_RIGHT".
Please enter the name for the next button (press <ENTER> to finish recording)
KEY_OK
Now hold down button "KEY_OK".
Please enter the name for the next button (press <ENTER> to finish recording)
Checking for toggle bit mask.
Please press an arbitrary button repeatedly as fast as possible.
Make sure you keep pressing the SAME button and that you DON'T HOLD
the button down!.
If you can't see any dots appear, wait a bit between button presses.
Press RETURN to continue.
...Cannot find any toggle mask.
Successfully written config file notworking.lircd.conf
Here is what the config file that's generated looks like
Now, if I setup another remote I have laying around I get a correct config file
Here is a picture of the two remotes sitting side by side, the remote on the left is the one that is not working
I've tried using this tutorial too to no avail
https://www.raspberrypi.org/forums/viewtopic.php?t=235256
does anyone know what's going on here?
To give you an intro, I am not a programmer but a biologist who is learning a bit of programming.
Now I use OneNote a lot and continuously switch between typing and touch-based inking.
Now OneNote UWP does not have a shortcut for selecting a pen.
But I found out that by pressing Alt+d and then down and then continuously pressing right six times and then pressing enter, one can switch to pen via keyboard.
Now I want to automate the above process and link it to Numpad 1.
So I tried AutoHotkey and tried to learn making a script of the above command but still no success.
This is what I tried (3-4 different ways):
Numpad1::
!d
Down
Right
Right
Right
Right
Right
Right
Right
Enter
I know this script is wrong but I can't find the correct way to do it.
You're off to a good start! In order to send the keystrokes, you'll need to use one of the variations of the Send command. In addition, we can also make it so that it only work when OneNote is the active window using the #If directive. (It makes hotkeys context-sensitive.)
I don't have OneNote on my machine, but please verify that the title contains "OneNote" for the following script to work.
SetTitleMatchMode , 2
#If WinActive("OneNote")
Numpad1::Send , !d{down}{right 6}{enter}
#If
Edit: I installed OneNote to try it out. It appears to run too quickly. I added a key delay of 75ms and changed Send to SendEvent, which obeys the key delay. This worked fine for me:
SetTitleMatchMode , 2
SetKeyDelay , 75
#If WinActive("OneNote")
Numpad1::SendEvent , !d{down}{right 6}{enter}
#If
I'm running a script on a PC (windows 7) with dual monitors, and every time when I open a new on-line window, Matlab freezes (not responding to mouse or keyboard inputs, only to calling windows task manager and switching tasks).
For what I've checked, only Screen('Openwindow') has this problem; other screen functions work fine. This failure never happens in single monitor situation.
Here's my script:
screeninfo.pos = get(0,'MonitorPositions');
if size(screeninfo.pos,1)<2
fprintf('cannot find two monitors! \n');
return;
end
[screeninfo.window, screeninfo.rect] = Screen('OpenWindow',0, [900 900 1000],screeninfo.pos(2,:));
Anyone has a clue?
Psychtoolbox 3.0.10 is ancient. You should update to the latest and greatest.
More importantly, when you open a window, any input (keyboard/mouse) goes to the opened screen, not matlab, unless you specifically focus matlab with alt-tab. cntr+C is an exception that makes matlab stop execution of the script, also when a PTB window is open.
If your matlab is on another screen than where the PTB window is opened, things should work normally. But if you start interacting with the matlab interface which a PTB window is open, all guarantees of proper timing of the PTB window are gone.
I'm trying to multi-cast audio do a number of channels. The software requires that I click and hold a button to broadcast. So, I wrote this little script to do the job.
After running several copies of the software, the loop is supposto cycle through the windows and click and hold all of the broadcast buttons. However, only the first button sticks but the other buttons do not appear to click or hold.
The encouraging thing is, I can run the script and as the first button is being held (by the script's action), I can manually click and hold down a second button in another window. The programs work as intended sending voice down all channels. Perhaps there is an issue in the auto-hot-key program.
Here is the code:
#enter::
Loop 3 {
SetTitleMatchMode, Slow
IfWinExist, Virtual Base Station, USER_%a_index%
{
WinActivate
WinWaitActive
Click down 400,60
}
}
Update: I have a work around. The multi-cast program allows the space key as a short cut too. Send {Space down} does function on multiple windows. All windows think the space bar is being held down.
I have created an autohotkey scripts which automates a manual process by launching an application and clicking on the script mentioned icons. The script is working fine on one computer which having higher resoultion but fails to execute on other computer with different resoultion. Do you have any suggestions to workout in other way. This app doesn't have any keyboard shortcuts and only executes on mouse clicks. I hope there will be an anwer.
Most Apps Have Alt Shortcuts, have you tried them? also you may try re-adjusting mouse click x,y as per resoulution
::: Explaining the problem ::: Please read to understand the problem.
Lets start off simple you create the autohotkey script on COMPUTER_A, you print_screen/capture all your images & resize them on COMPUTER_A, however when you transfer your files to COMPUTER_B image_search does not find matchs as well or at all, why is this ?
Well COMPUTER_A and COMPUTER_B are two totally different computers, the problem comes cause with two different computers each have different COLOR TEMPLATES installed on them, if you copy the color template from COMPUTER_A onto COMPUTER_B or any computer. Overall problem is different color templates does not allow image_search to find a match pixel by pixel cause the varying difference between the two different computers. Thats why its best to copy color template from computer_A to another computer to allow image search to work properly.
::: Finding the COLOR Template :::
On Win7 --> Control Panel --> Color Management --> Mine was easy to find cause it is the color template that came with my computer monitor, however yours might take a little more work in finding. ICC profiles are generally printers, ICM profiles are display drivers/color templates for you computer screen. Once you find your display profile currently in use on COMPUTER_A find it on your computer storage & copy it to your autohotkey direction for easy access in the future so it can be copied with your autohotkey script to computer_B or computer_Z later. Right Click on the ICM once copied to computer_B and click install & its possible you may need to restart the computer for all changes to take affect.
::: Results :::
Once the color template from computer_A is installed on another computer image_search should work exactly how it does on computer_A, i've personally tested the results on 6 different computers from XP, Vista & Win7, always had a 100% success rate which i believe makes this a universal solution/fix to the image_search problem with other computers.
I do caution those few people who have trouble with this to have patience & do you fair share of research into "windows color profiles" to make this solution work for you, i just foresee someone accidently finding/copying the wrong ICM/ICC profile. Also to be warned if someone installs photography software/development software like adobe photoshop/multimedia/development software sometimes they come with their own ICM/ICC profiles and could overright the existing ones causing image_search to again become a problem. Just reinstall the default ICC/ICM profile again to fix that problem.
::: CONCLUSION :::
I hope this was helpful to someone, sorry for all the writing but i thought it best to share my complete findings with you all since it can get complicated.
Here is how I once solved it.. In the beginning I ask the user to capture the mouse position of each icon, and store these coordinates for later use.
Hotkey, LButton, off ; Make sure that the Left Mouse button inactivator is turned Off
Lbutton:: ; Disable the Left Mouse Button
SplashImage , %A_ScriptDir%/Images/YourScreenShot.jpg,,, Screen shot, Icons ; Show Screenshot of what the user needs to do
SoundBeep 1000, 300 ; wake up user
SplashTextOn, 200, 100, Script Preparations, Please Click on Icon1. ; Show new instructions to the user
WinMove, Script Preparations,, (A_ScreenWidth/2)-150, (A_ScreenHeight/2)-200 ; Move the text instructions window with the name "Script Preparations" 150 pixels right of the center of the screen and 200 pixels up
SoundBeep 600, 300 ; Wake up user
; Here the left mouse button will temporarily be disabled (to prevent actions)
Hotkey, LButton, on ; Turn Left Mouse Button OFF, to capture the Mouse click
KeyWait, LButton, D ; Wait for LeftMouseButton click Down
MouseGetPos, xpos1 ,ypos1 ; Store the position where the mouse was clicked (Icon1)
Repeat this for all icons used.
Then if you want to click on icon1 use:
MouseClick, left, %xpos1% ,%ypos1% ; Perform the mouse click on the captured mouse location