Jump to content
Sign in to follow this  
orestis125

Hotkeys not working on background

Recommended Posts

orestis125

Heya everyone,

I'm new to this forum so please forgive me if I'm posting this on the wrong place. I've just encountered a problem with my script which prevents functions, that are called by pressing a hotkey, to be executed.

I've tested a simple script which terminates itself when the letter "p" is pressed. Although this works perfectly when I'm working on the desktop, it doesn't work when I'm working on a full-screen/borderless program.

This is my script:

#Include <Misc.au3>;

HotkeySet("p","terminate");

While(true)

;Main Loop

WEnd

Func terminate()

Exit;

EndFunc

Is there anyway to get around this problem? I'm not sure but I believe that it was working before on another computer. I've tried running the script in x64 and x86 but there doesn't seem to be any difference regarding this problem.

Also I've got another small question. Is there a way to prevent the send() function from triggering hotkeys? For example, if I have a hotkey which is activated when "a" is pressed, and later in the program I'm calling send("a"), the hotkey would be activated.

I would appreciate it if someone could give me a solution or a hint,

Thank you very much,

Orestis

Edit: By the way my code appeared messy when I put it inside an AutoIt element so I just used a quote. I hope that's ok ;)

Edited by orestis125

Share this post


Link to post
Share on other sites
JohnOne

Your "full-screen/borderless program" is most likely eating the hotkey, or actively preventing

automation.

As for other problem.

Func _Send($s)
    HotKeySet($s,"")
    Send($s)
    HotKeySet($s","_Func")
EndFunc
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
Exit

;#include <Misc.au3>;

$rc = HotKeySet("p", "terminate");

If Not $rc Then Exit MsgBox(262144,"",@lf & "Hotkeyset Error " & $rc & @lf,0)

While 1

Sleep(2000) ; wait 2 secobnds

Beep(440,200) ; and beep to show "beeing alive"

;Main Loop

WEnd

Func terminate()

HotKeySet("p") ; cancel hotkey

MsgBox(262144, "", @LF & " Hotkey disabled " & @LF, 2)

Exit;

EndFunc ;==>terminate


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
Melba23

orestis125,

I'm working on a full-screen/borderless program

Would you care to let us know what the particular full screen/borderless program is? The more information you give, the more focused the help you are likely to get. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
woody0

I might be having the same problem here, and I'm not sure how to get around it. I'm trying to use this to do some automated user interface testing to click around on the Microsoft windows mobile device emulator. I'm really just trying to implement a simple exit key to stop the script from executing.

The script below works, and the start, stop and exit functions all work up until the TestCustomer() function is entered. once that starts, there's no stopping it until the loop reaches the counter value. One that function starts, none of the hot keys fire anymore. I'm thinking that once the device emulator window has focus that all keyboard input gets sent to the emulator and bypasses the script. Any ideas how to get around this?

HotKeySet("{F2}", "_start")
HotKeySet("{F8}", "_stop")
HotKeySet("{ESC}", "_exit")

$stop = False
$started = False
$exit = False
$sleepDefault = 500
$sleepOffset = 2000
$i = 0

While 1
   if $i > 1 or $exit then ExitLoop ; Need this to get out eventually
   if $started Then
      TestCustomer()
 $i = $i + 1
   EndIf
   sleep (100)
WEnd

Func TestCustomer()
   MouseClick("left",117,152,1) ; Customer
   sleep($sleepDefault + $sleepOffset)
   MouseClick("left",183,270,2) ; Double Click customer
   sleep ($sleepDefault)
   MouseClick("left",94,414,1) ; Back
   sleep ($sleepDefault)
   MouseClick("left",94,414,1) ; Home
   sleep ($sleepDefault)
EndFunc

Func _start()
   Consolewrite("Started")
$stop = False
$started = True
EndFunc

Func _stop()
   ConsoleWrite("stop")
$stop = True
$started = False
EndFunc

Func _exit()
   ConsoleWrite("Exit")
   $exit = True
Exit
EndFunc

Share this post


Link to post
Share on other sites
BrewManNH

Does it work with other windows active? If it does, then it's the program that you're trying to click into.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×