Sign in to follow this  
Followers 0
was2

HotKeySet Problem

6 posts in this topic

Hey everyone.

I got a problem with some HotKeySet Functions in combination with checkboxes. I'll only post one of the Functions because they are all pretty similar and the code is about 600 Lines long.

Func _HKoff()
    GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox3, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox4, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox5, $GUI_UNCHECKED)
    GUICtrlSetData($l1," ")
    GUICtrlSetData($l2," ")
    GUICtrlSetData($l3," ")
    GUICtrlSetData($l4," ")
    GUICtrlSetData($l5," ")
EndFunc


HotKeySet("{F6}",_HKoff())

It doesn't uncheck the Boxes and doesn't seem to be working at all. Is there a mistake in the code or am i just too stupid? :D

Share this post


Link to post
Share on other sites



Well, the way to make it work should be enclosing the function name in "" like this

HotKeySet("{F6}","_HKoff")



			
		

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

It should work as is, as long as those variables referring to the controls are global variables.

Totally missed the missing quotes.

Edited by BrewManNH

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

 

Well, the way to make it work should be enclosing the function name in "" like this

HotKeySet("{F6}","_HKoff")

I also tried out that one, it doesn't work either, or is there no visua effect on the checkboxes if i uncheck them in a function?

Share this post


Link to post
Share on other sites

You need to declare your HotKeySet at the top of the script. This works just fine (guessed at some of your variables since the code wasn't complete).

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{F6}", "_HKoff")
Local $msg

GUICreate("Test", 300, 300)
$l1 = GUICtrlCreateInput("Test", 1, 10, 50, 30)
$l2 = GUICtrlCreateInput("Test", 1, 50, 50, 30)
$l3 = GUICtrlCreateInput("Test", 1, 90, 50, 30)
$l4 = GUICtrlCreateInput("Test", 1, 130, 50, 30)
$l5 = GUICtrlCreateInput("Test", 1, 170, 50, 30)
$checkbox1 = GUICtrlCreateCheckbox("Test", 60, 10, 50, 30)
$checkbox2 = GUICtrlCreateCheckbox("Test", 60, 50, 50, 30)
$checkbox3 = GUICtrlCreateCheckbox("Test", 60, 90, 50, 30)
$checkbox4 = GUICtrlCreateCheckbox("Test", 60, 130, 50, 30)
$checkbox5 = GUICtrlCreateCheckbox("Test", 60, 170, 50, 30)
GUISetState(@SW_SHOW)

    While 1
        $msg = GUIGetMsg()
            Select
                Case $msg = $GUI_EVENT_CLOSE
                    ExitLoop
            EndSelect
    WEnd

GUIDelete()


Func _HKoff()
    GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox3, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox4, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox5, $GUI_UNCHECKED)
    GUICtrlSetData($l1," ")
    GUICtrlSetData($l2," ")
    GUICtrlSetData($l3," ")
    GUICtrlSetData($l4," ")
    GUICtrlSetData($l5," ")
EndFunc

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

 

You need to declare your HotKeySet at the top of the script. This works just fine (guessed at some of your variables since the code wasn't complete).

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{F6}", "_HKoff")
Local $msg

GUICreate("Test", 300, 300)
$l1 = GUICtrlCreateInput("Test", 1, 10, 50, 30)
$l2 = GUICtrlCreateInput("Test", 1, 50, 50, 30)
$l3 = GUICtrlCreateInput("Test", 1, 90, 50, 30)
$l4 = GUICtrlCreateInput("Test", 1, 130, 50, 30)
$l5 = GUICtrlCreateInput("Test", 1, 170, 50, 30)
$checkbox1 = GUICtrlCreateCheckbox("Test", 60, 10, 50, 30)
$checkbox2 = GUICtrlCreateCheckbox("Test", 60, 50, 50, 30)
$checkbox3 = GUICtrlCreateCheckbox("Test", 60, 90, 50, 30)
$checkbox4 = GUICtrlCreateCheckbox("Test", 60, 130, 50, 30)
$checkbox5 = GUICtrlCreateCheckbox("Test", 60, 170, 50, 30)
GUISetState(@SW_SHOW)

    While 1
        $msg = GUIGetMsg()
            Select
                Case $msg = $GUI_EVENT_CLOSE
                    ExitLoop
            EndSelect
    WEnd

GUIDelete()


Func _HKoff()
    GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox2, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox3, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox4, $GUI_UNCHECKED)
    GUICtrlSetState($Checkbox5, $GUI_UNCHECKED)
    GUICtrlSetData($l1," ")
    GUICtrlSetData($l2," ")
    GUICtrlSetData($l3," ")
    GUICtrlSetData($l4," ")
    GUICtrlSetData($l5," ")
EndFunc

I love you

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  
Followers 0