Jump to content

Noob needs some help with Hotkeys


Kage
 Share

Recommended Posts

Hello.

im just a starter with Autoit, and i was hoping you guys could help me out here.

i wanted to make a Hotkey that triggers a case

like this:

Dim $AccelKeys[1][2]=[["!s", $start]] ;hotkey
        GUISetAccelerators($AccelKeys) ;hotkey!

The hotkey works and stuff, but only when the Autoit GUI is the active window

like when u are using Iexplore and press the hotkey nothing happened, i would need to first clikc the GUI and then the hotkey..

not very usefull like that

i know that the HotKeySet command works Always regardless of what windows you have active, but is it possible with HotKeySet to trigger a Case

(case as in this: )

While 1
     $msg = GUIGetMsg()
   Select
       Case $msg = $start
           do ;alot of stuff
           untill $counter = 1
   EndSelect
wend
Link to comment
Share on other sites

No need to use a Select/Case for something like that, just do whatever you want in a function that runs when you press the hotkey. You can use the function to do whatever you think you need to do inside your While/Wend loop.

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

Link to comment
Share on other sites

Well what i just showed you was an example, im trying to make one big gui with multiple buttons(that all do different things) as it why i choose for using Case's

And also if i would have made a seperate Func for it the Var's dont work in it right ?

for what i have tested it is not possible putting a func inside a func and making a seprate func cannot use the var's used in another func ?

Like i said in my first post im still a complete noob with AutoIt, so im most likely doing alot wrong, and misunderstanding you ;)

Thanks,

Kage

Edited by Kage
Link to comment
Share on other sites

If you need to use the values of the variables between the functions, make the variables global. The GUI buttons being read can stay inside the loop, it's just that hotkey functions don't need to be especially if you want them to be available regardless of which Window is open at the time.

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

Link to comment
Share on other sites

Hello Kage,

Welcome to the AutoIt Forums ;)

Why do you want that to trigger a case statement? Maybe a bit more information of what your attempting to do, and you might get more accurate help towards a solution.

When a hotkey is activated it will pause the script where it is at, run the hotkey function, and return back to where it was left off at, so in essence doing this:

HotKeySet("!s", "Start")

Func Start()
    Do
        ;alot of stuff
    Until $counter = 1
EndFunc

Should not call away from a While Statement, it should only pause it, then return to it once the function has completed.

Realm

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...