Travis Heeter
Travis Heeter

Reputation: 14054

A program runs in Windows' Run, but not with AHK's Run

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:

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.

Upvotes: 0

Views: 1281

Answers (3)

L777
L777

Reputation: 8457

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.

Upvotes: 4

Travis Heeter
Travis Heeter

Reputation: 14054

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:

My Taskbar with numbers corresponding to the applications pinned there.

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.

Upvotes: 0

Relax
Relax

Reputation: 10543

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
}

Upvotes: 1

Related Questions