Global (system-wide) hotkey with Powershell

 
Hi, i have a winform which is minimized/or hidden and would like to make it appear with a global (system wide) hotkey. (see bogus "new-hotkey"-cmdlet below)
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$form1 = New-Object 'System.Windows.Forms.Form'
$form1.ClientSize = '300, 250'
$form1.windowstate = "minimized"
# -- bogus(!) code --
$hk = new-hotkey -scope Global -keys "Ctrl,Shift,Z" -action ({$form1.windowstate = "normal" })
$form1.ShowDialog()
I searched the web intensively but only found C# solutions, which i could not translate into powershell (v3). I tried but it did not work:
http://stackoverflow.com/questions/23855928/acessing-c-sharp-code-in-powershell
The trouble is: even if i manage to use some C# code in my script, because i do not understand C#, i can't debug it.
I tried a few third-party tools, like WASP, Pseventing, Autohotkey, but they all have disadvantages or did not work correctly, so using C# in Powershell is seemingly the way to go.
I'm sorry, cause i know its not appreciated, but i need a working solution, not just tips how the get started.
thanks a lot, Rob

http://www.fluxbytes.com/csharp/how-to-register-a-global-hotkey-for-your-application-in-c/ shows the basics of how to accomplish this, by using the Win32
API RegisterHotKey function (which you've already found, by the looks of your StackOverflow post.)  Converting this to run PowerShell code in response to the hotkey might be a bit complicated, and also unnecessary in your case (since you seem to just
want to change the value of a property on the form, you could do that right in the C# WndProc method, or whatever it calls in response to your hotkey.
To make something more generic which can cause PowerShell code to execute, I'd probably have the form raise an event in response to the Windows message.  Then PowerShell scripts can use Register-ObjectEvent to respond to it, and you don't have to worry
about problems with threads or runspaces (since the PowerShell engine already takes care of that for you when you use Register-ObjectEvent.)

Similar Messages

  • ITunes 10.7 crashes all apps on Mountain Lion including Force Quit. First system wide prob with an apple computer since OSX introduced. Any ideas?

    updated to iTunes 10.7  from app Store last night. After the update, iTunes opens then stalls with the "spinning pizza wheel". Force Quit is unresponsive and will not shut it down. If I then open other applications say Safari for example, the problem migrates over to Safari and it similarly stalls and becomes unresponsive. The only way to solve the problem is to manually shut the computer down. This is the most significant problem I have experienced on an apple computer since OSX was introduced because it impacts on Force Quit which means that you have to shut the whole deal down. There are obvious problems for use of Apple TV and apple store etc. ! I am running mountain lion 10.8.1 on a 27" iMac with 2T Time Capsule connected wirelessly. How do I downgrade iTunes back to 10.6? I had no problems with Mountain Lion or iTunes up to that point.

    this is the exact same problem i've been dealing with for the past 2 days. after i installed itunes 10.7 for my iphone5 it would crash my mbp's lion system wide. i tried every solution i could find on google and i've actually had to reinstall lion & time machine my backups because of it. right now i'm too scared to redownload itunes 10.7. i actually feel like waiting for the "new itunes" that comes out in october.

  • Bad system wide crash with chrome canary

    Chrome Canary will lock up the entire system on cnn.com videos that load up on a black background.  I find this really amazing - that a browser (even if it's some kind of beta) can take down the entire computer.  The only way out once you've clicked one of those doomed links is to hit the power button.
    System:  MacBook Pro Retina
    OS:  Mountain Lion, freshly installed
    Not looking for help.  Just raising the alarm that a piece of software can totally destroy stability to the point where you have to hit the power button.  Chrome Canary is a workaround for us Chrome lovers who have Retina displays.  So just be warned:  Don't click any CNN videos for now.

    Yeah I just went and looked again and found ad block.  There does not appear to be a decent working script blocker, though.  Also, I had a good laugh when I noticed that Chrome Canary renders better.  I am really looking forward to the fix.  I will probably stick to Chrome Canary, except when I want to watch videos. 

  • HT4314 Is there a system-wide issue with the Game Center.  I cannot get past the spinning dots/loading part, my game says I'm not signed in, and I am connected to the Internet.

    I have been using the Game Center to track my wins for some time (months).  Suddenly, my game tells me I'm not signed in and I cannot get the Game Center to open.

    I have two yahoo accounts and I know as they 'improved' their servers I had periodic outages. It'd work fine on my webmail on  my computer, webmail on the iPad, but not via the mail app. And it was stuff on their end. It may be a case of wait and see and you may need to eventually remove/readd the account on your iPhone.
    When the issue is on their end, unfortunately there's not much for users to do beyond wait it out or find work arounds.

  • System wide spelling

    For some reason system wide spelling has been disabled...
    i have enabled it again in safari and text edit, but is there a way to enable system wide spelling with one option instead of enabling it tediously in each app???
    thanks

    http://discussions.apple.com/thread.jspa?threadID=1085614&tstart=500
    http://discussions.apple.com/thread.jspa?threadID=1081773&tstart=500
    http://discussions.apple.com/thread.jspa?threadID=1074142&tstart=550
    Those are a few for a start. The problem is not as rare as one might think if one saunters around the other threads.
    I will try your suggestion of making another user account to see if it works. However, even if it does, it is far from an ideal solution as I only want one account from which to work in.
    Thanks.

  • Capture system-wide keypresses in c/c++, what library to use?

    I want to be able to capture system-wide keypresses with a JAVA application in OSX. As this is not possible using pure java, I need to write a C/C++ app that does the listening, and combine that with my java app using JNI.
    But that is not my problem
    I was looking at this great tutorial:
    http://ubuntuforums.org/showthread.php?t=864566
    It does what I want, but for linux, and uses the X11 library's for the actual keypressdetection.
    As I don't know much about C/C++ for OSX specificly, my question is, what would be a good library for replacing X11 with (preferably something that everyone already has, like X11 in linux). I know I could use SDL or something for this, but isn't there anything a little closer to the system that everybody has by default?
    Thanks
    Reinout

    It would be best if you post this question on the Real Time forums since you are working with RT.
    Applications Engineer
    National Instruments

  • System-wide Transparent Proxy With URL Patterns

    Internet censorship -where I live- has almost turned web unusable so  I decided to setup a transparent proxy using Tor for my home network.
    Since Tor is so slow -here- proxying all traffic through Tor would slow my connection to a crawl.  Therefore I need a mechanism to selectively proxy the traffic.
    I know a bit of 'iptables' and it looks to me like the solution to my problem.  However there's a trick.  As most of the websites I need to access through Tor (like Google+, Facebook and such) use several IP addresses for their entry points, it's almost impossible for me to add 'iptables' rules for all of those IP addresses.  I need a mechanism to proxy the traffic based on URL patterns.  For example I need to be able to proxy access to '*.facebook.com' through Tor.
    So the question boils down to:  how can I setup a system-wide transparent proxy using URL patterns?
    Any idea/hint is much appreciated.  TIA,
    Bahman
    Last edited by bahman (2012-01-04 07:48:44)

    Use privoxy with socks5 forwarding:
    http://www.privoxy.org/user-manual/config.html#SOCKS
    http://www.privoxy.org/user-manual/acti … F-PATTERNS

  • Restoring one system-wide dictionary (issue with spell checking)

    Hello all,
    For some reason, spell checking is behaving badly: it won't spell check German correctly anymore, even though it is set on “Multilingual”. English is alright, so I suspect my German dictionary got corrupt.
    My questions are:
    1- Will installing the 10.5.7 update resolve the issue?
    2- Where can I find the system-wide dictionaries used for spell-checking by OS X?
    3- Where can I download these dictionaries?
    I hope a clean install is not required just to get one dictionary/spellcheck file back…
    Thanks very much all!

    it won't spell check German correctly anymore, even though it is set on “Multilingual”.
    How about when you set it to Deutsch?
    2- Where can I find the system-wide dictionaries used for spell-checking by OS X?
    3- Where can I download these dictionaries?
    You can't find them or download them.
    I hope a clean install is not required just to get one dictionary/spellcheck file back…
    Maybe. You could also install CocoAspell and add a German dictionary from its selection.
    http://cocoaspell.leuski.net/

  • File Type Associations Do Not Stick System-Wide CS4

    When I set File Type Associations for PSD, Tiff, DNG and Jpeg fles in Bridge CS4 so that my files will open in PS CS3 (and insure that the same file associations apply in Bridge CS3), this works as it should from within CS4 and CS3, but it is impossible to introduce a system-wide change in Mac OS 10.5.5 via File-Info. It always reverts to CS4 for these file types, if I try to 'modify all'. The same thing happened when I upgraded from CS2 to CS3.

    If File Type Associations are set properly in the Bridge preferences, the default setting can be made to open files in PS CS3, with CS4 installed. This works from within CS3 and CS4. However, it sometimes happens that one is in the Finder, and the default remains PS CS4, however much one tries (via File-Get Info) to modify the default system-wide settings so that these files open in CS3. In any event, a bit invasive. Of course, if I could get comfortable with the Adjustment Layer Panels, all this would be unnecessary, but for the moment, there appear to be too many clicks, and it is going to take some time, so I don't want to burn bridges. Perhaps there is also some ambiguity in my mind as to what the pointing finger in the new Curves dialogue box, much like a tolling bell, is trying to tell me.
    But thanks, once again Anne, for your good-natured help.

  • System-wide spell check will not work

    Hi,
    I can't get the system-wide spell check to work on my MacBook Pro with the Command + Shift + ; (semicolon) keys. Does anyone know of a solution to this problem? The Spell-Check on the Fly will work.
    Thank You,
    Guy

    I was able to zap the pram and that solved the problem.
    Guy

  • Setting ALSA sound card system wide (rather than just in KDE)

    Hi,
    I've got an HTPC with an ATI Radeon HD 4350 graphics card running Arch x86. It has its own integrated sound card for outputting audio via HDMI, which is detected by ALSA as a separate device. I've managed to set it as the default audio device in KDE 4 (via System Settings). This allows applications such as Amarok and SMPlayer to properly output audio to the HD 4350's integrated sound card, but software such as Flash and MPlayer (from the command line) are still outputting audio to the motherboard's built-in sound card. How can I change this setting on a system-wide level? I've tried running alsaconf as root and adding
    pcm.!default {
    type hw
    card 2
    device 3
    to ~/.asoundrc; I got the card and device numbers from aplay:
    [htpc@exia ~]$ aplay -l
    **** List of PLAYBACK Hardware Devices ****
    card 0: Intel [HDA Intel], device 0: HDA Generic [HDA Generic]
    Subdevices: 1/1
    Subdevice #0: subdevice #0
    card 1: HDMI [HDA ATI HDMI], device 3: ATI HDMI [ATI HDMI]
    Subdevices: 1/1
    Subdevice #0: subdevice #0
    Here is the output from MPlayer when I try to play a video, complete with errors regarding audio:
    MPlayer UNKNOWN-4.4.0 (C) 2000-2009 MPlayer Team
    137 audio & 296 video codecs
    mplayer: could not connect to socket
    mplayer: No such file or directory
    Failed to open LIRC support. You will not be able to use your remote control.
    Playing /tmp/FlashmvWXPy.
    libavformat file format detected.
    [flv @ 0xac7d250]skipping flv packet: type 18, size 294, flags 0
    [lavf] Video stream found, -vid 0
    [lavf] Audio stream found, -aid 1
    VIDEO: [H264] 854x480 0bpp 29.970 fps 0.0 kbps ( 0.0 kbyte/s)
    ==========================================================================
    Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
    Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
    ==========================================================================
    ==========================================================================
    Opening audio decoder: [faad] AAC (MPEG2/4 Advanced Audio Coding)
    FAAD: compressed input bitrate missing, assuming 128kbit/s!
    AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
    Selected audio codec: [faad] afm: faad (FAAD AAC (MPEG-2/MPEG-4 Audio))
    ==========================================================================
    [AO OSS] audio_setup: Can't open audio device /dev/dsp: Device or resource busy
    [AO_ALSA] alsa-lib: confmisc.c:768:(parse_card) cannot find card '2'
    [AO_ALSA] alsa-lib: conf.c:3513:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    [AO_ALSA] alsa-lib: confmisc.c:392:(snd_func_concat) error evaluating strings
    [AO_ALSA] alsa-lib: conf.c:3513:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    [AO_ALSA] alsa-lib: confmisc.c:1251:(snd_func_refer) error evaluating name
    [AO_ALSA] alsa-lib: conf.c:3513:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    [AO_ALSA] alsa-lib: conf.c:3985:(snd_config_expand) Evaluate error: No such file or directory
    [AO_ALSA] alsa-lib: pcm.c:2211:(snd_pcm_open_noupdate) Unknown PCM default
    [AO_ALSA] Playback open error: No such file or directory
    [JACK] cannot open server
    [AO SDL] Samplerate: 44100Hz Channels: Stereo Format s16le
    [AO_ALSA] alsa-lib: confmisc.c:768:(parse_card) cannot find card '2'
    [AO_ALSA] alsa-lib: conf.c:3513:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    [AO_ALSA] alsa-lib: confmisc.c:392:(snd_func_concat) error evaluating strings
    [AO_ALSA] alsa-lib: conf.c:3513:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    [AO_ALSA] alsa-lib: confmisc.c:1251:(snd_func_refer) error evaluating name
    [AO_ALSA] alsa-lib: conf.c:3513:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    [AO_ALSA] alsa-lib: conf.c:3985:(snd_config_expand) Evaluate error: No such file or directory
    [AO_ALSA] alsa-lib: pcm.c:2211:(snd_pcm_open_noupdate) Unknown PCM default
    [AO SDL] Unable to open audio: No available audio device
    DVB card number must be between 1 and 4
    AO: [null] 44100Hz 2ch s16le (2 bytes per sample)
    Starting playback...
    VDec: vo config request - 854 x 480 (preferred colorspace: Planar YV12)
    VDec: using Planar YV12 as output csp (no 0)
    Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
    VO: [xv] 854x480 => 854x480 Planar YV12
    Thanks!
    Last edited by w1ntermute (2009-06-28 18:40:03)

    whoops wrote:Do you use the motherboard sound-card?
    No.
    whoops wrote:If not - did you try just turning it off in bios (or blacklisting the driver)?
    No, I haven't tried that. I'll give it a shot. Thanks for the tip!
    Last edited by w1ntermute (2009-07-02 18:11:53)

  • Non-system wide DNS Lookups on RBL  (i.e. logical groups supported)

    Sun Java System Messaging Server documetation seems to state that RBL filtering can only exist in one of three files that are used for filtering based off of inbound connection IP address. My question is, can conditional execution occur for a section of one of these files based of destination e-mail address?
    I'd like to have multipule levels of e-mail filtering using RBL and allow users to be assinged to the level of filtering they desire by joining a logical group which will enable a level of RBL filtering for that logical group.
    Any help is greatly appreciated, as far as I can see, I can only have one system wide filtering set, so I can't possibly have one set of e-mail ids using 10 RBL (remote black lists) and another group e-mail ids using a smaller set of RBLs.
    ======= From the documentation =======
    MAIL_ACCESS : Used to block incoming connections based on combined information found in SEND_ACCESS and PORT_ACCESS tables: that is, the channel and address information found in SEND_ACCESS combined with the IP address and port number information found in PORT_ACCESS.
    ORIG_MAIL_ACCESS : Used to block incoming connections based on combined information found in ORIG_SEND_ACCESS and PORT_ACCESS tables: that is, the channel and address information found in ORIG_SEND_ACCESS combined with the IP address and port number information found in PORT_ACCESS.
    PORT_ACCESS : Used to block incoming connections based on IP number.
    ====================================

    Alas, the RBL stuff is done before iMS even knows who the message is addressd to. That stuff is done at the initial connection phase, as our philosophy is to reject a message just as soon as possible . . .
    After the message is accepted, then you can opt-in/out for things like spamassassin, brightmail, etc.

  • FDM System-wide

    I tried using FDM and i love it. However, I did a thorough Google search and this forum for a solution to my issue but could not find any answer. I hope someone will be able to assist me with a solution.
    Am wondering if it is possible for FDM to fetch mails from an ISP Domain box (multidrop/catchall mailbox) that holds mails for several users , and then hand them to Postfix that has Dovecot LDA delivery configured. The mails will then be delivered (by Dovecot's LDA) to respective users. I use Fetchmail (that is able to do this), but there are some issues with it, (like sometimes it gets stuck on large mails, etc).
    Here I illustrate my current Fetchmail System-wide setup's /etc/fetchmailrc file:
    # /etc/fetchmailrc
    set postmaster [email protected]
    set no bouncemail
    set daemon 300
    set logfile =  "/var/log/fetchmail.log"
    poll isp.domain.com proto pop3
    localdomains abc.net
    no dns
    no envelope
    user domain_mbox_username
    pass domain_mbox_passwd
    is * here
    In the above fetchmailrc, "is * here*,  * is aliased to our catchall account in our local postfix server. The ISP domain mailbox is configured as a catch-all domain and it holds our users emails (several different email addresses but all "@abc.net")
    I couldnt find a way to do this with FDM since I am limited to delivering to mbox/maildir directly, and the way I understand it is that I would have to create individual inbox references. This would be tedious if we have some hundreds pop3  local mailboxes, ( I might be wrong in my assumption).
    With my current setup, aliasing to the catchall account automatically distributes to respective mailboxes by reading the mail headers. (and also am not very good in coding, please treat me like a newbie )
    Looking forward to your assistance.
    Thanks and regards,
    Clemo
    Last edited by wclemo (2013-07-24 17:28:45)

    Hi, this post is for 10g, bu I don't think much have changed (except the file location: \MWHOME\instances\instance1\bifoundation\OracleBIPresentationServicesComponent\coreapplication_obips1\catalog\YOUR_CATALOG\root\system\metadata)
    http://oraclebi.blog.com/tip-of-the-day-data-format-file-in-obiee/
    I didn't test it myself.

  • W2K8 & Win7 - Setting system-wide Trusted file locations not working

    Win 2008 Network, Win 7 workstations.
    RE: Setting system-wide trusted file locations
    I have an application using Flash stored on a network location that accesses other files in the same location.  This causes the security warning "The following local application... is trying to communicate with this internet-enabled..."  I can add the location to the trusted sites in the Setting Manager and the warning goes away.  It is not practical however to do this on every machine on the network.  I have tried the FlashPlayerTrust directory and mms.cfg file and neither of these seem to work.  Is there a trick to getting the FlashPlayerTrust directory to work properly.  If I could get this working, I could create a script that copies this file to all machines on the network. 
    Any help you be greatly appreciated. 

    Hi Todd,
    Can you please provide just a little more detail?
    * When you say "accessess", what API is being used?  Are the paths to the other files relative, file: URI http: URI, other?
    * In the FlashPlayerTrust directory, are you using the same path notation as appears in the Settings Manager?  What's a sample {filename}.{ext} being used?
    Thanks!
    -Erica

  • System wide PDF presets location is not working in CC

    On both Mac and PC, the system wide location for PDF settings (.joboptions) does not work anymore.
    /Library/Application Support/Adobe/Adobe PDF/Settings (on a Mac)
    It is illogical to remove this feature. Even if that folder does not store the main default presets, which are now stored in each application, it still needs to be looked at and loaded from. It's actually illogical to store the same preset in multiple locations (i.e. each application). If there is a preset that is only for a certain application (e.g. Illustrator Default), this could be put in the application folder, but all others like High Quality, Prepress, PDF/X should be in a central location, i.e. where they used to be.
    I know that each user can manually load into their own PDF presets, which then do appear in all suite apps, but this has to be done every time a new user logs into a computer.
    The central location meant that all suite apps would see a custom set of presets automatically across the entire suite and across multiple versions of the suite. The other advantage to the central location is that the presets would appear in square brackets, in other words read only, so they cannot be changed by the user without saving as a new file.
    Having users manually load and be able to change the presets kind of defeats the purpose of having a preset, certainly in our environment, where we need these settings to be consistent across all apps, all computers and all users.
    Please put this feature back or at least honour the central location that used to be used.

    Hi,
    As per the description, I understand that your Office 2013 cannot open files through a network share directly.
    I would like to know that how many clients/users are affected by this in your environment. It could be some specific user account settings, that the Office applications are being affected by.
    I'd first suggest you try with a new Windows user profile, then verify result.
    Regards,
    Ethan Hua
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

Maybe you are looking for

  • All my e-mails are going to my deleted box and not my inbox, what do I do?

    Since last Saturday any messages sent to me are going straight to my deleted box. Nothing is appearing in my inbox.

  • Timed out repeatedly

    I've been getting the 'the network connection timed out' message repeatedly for the last day. I recently downloaded and made firefox my default browser . At ~ the same time I upgraded itunes from 7.3 to 7.3.1. Is itunes down? Is it firefox? Is it fir

  • Can I combine still slides and video clips in a presentation?

    I have just returned from a safari and have a lot of pictures and videos from the trip.  I would like to create a presentation/slide show that will show the slides and also videos in the same slide show and allow me to manually pace the show.  I know

  • EPMA/Planning custom dimension member attributes question

    I have a custom dimension associated to an attribute dimension that I am setting via dataloader. Can I query on members with missing values of an attribute? For example, Dimension: Product Attribute: Color Members: Red, Green, Blue, Yellow Should it

  • Do I need to keep mobile applications on my Mac?

    I have 34 GB of mobile applications from iTunes on my Mac. They are taking up toomuch space. I am not able to use my Mac daily because it is filled up with all of these apps. Do I need to keeps these on my computer for game data? If so, how would I s