Sign in to follow this  
Followers 0
Hyflex

Toggle Hotkey?

4 posts in this topic

Hey

I have the following code below, I'm trying to get a normal toggle function working so the same hotkey will minimise and the same hotkey will restore (also i don't know why traytips aren't working for me)

HotKeySet("{END}", "Terminate")
HotKeySet("{F10}", "Minimise")
Global $p

While 1
Sleep(50)
WEnd

Func Terminate()
Exit 0
EndFunc

Func Minimise()
    $p= NOT $p
    While $p
WinSetState("[CLASS:tSkMainForm]", "", @SW_MINIMIZE)
Sleep(100)
    WEnd
WinSetState("[CLASS:tSkMainForm]", "", @SW_RESTORE)
Sleep(100)
EndFunc

Share this post


Link to post
Share on other sites



Try it this way:

HotKeySet("{END}", "Terminate")
HotKeySet("{F10}", "Minimise")
Global $p = False

While 1
    Sleep(50)
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func Minimise()
    $p = Not $p
    If $p Then
        WinSetState("[CLASS:tSkMainForm]", "", @SW_MINIMIZE)
    Else
        WinSetState("[CLASS:tSkMainForm]", "", @SW_RESTORE)
    EndIf
EndFunc   ;==>Minimise

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

Hello XxXGoD,

As for Tray tips, I don't see anything in your code that would create them. They are not automatically supplied.

I took a moment to rewrite your script so that your window toggle function would do as you wish.

Hope it helps.

HotKeySet("{END}", "Terminate")
HotKeySet("{F10}", "Window_Toggle")
Global $WinState

$state = WinGetState( "[CLASS:tSkMainForm]", "" )
If BitAND( $state, 16 ) Then
   $WinState = True
Else
   $WinState = False
EndIf

While 1
   Sleep(50)
WEnd

Func Terminate()
   Exit 0
EndFunc

Func Window_Toggle()
   $WinState= NOT $WinState
   If $WinState Then
      WinSetState("[CLASS:tSkMainForm]", "", @SW_MINIMIZE)
   Else
      WinSetState("[CLASS:tSkMainForm]", "", @SW_RESTORE)
   EndIf 
      Sleep(100)
EndFunc

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.  

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Just another showing that there really IS more than one way to skin a cat, I use the following code in a script of mine.There is a HotKeySet at the top of this script that calls this function, and the HIDE and SHOW could be changed to MINIMIZE and RESTORE. The flag that WinGetState uses might need to be changed.. Of course, the title of the app should be changed too..

Func ToggleHide()
    If BitAND(WinGetState("X-Lorem Ipsum", ""), 2) Then
        WinSetState("X-Lorem Ipsum", "", @SW_HIDE)
    Else
        WinSetState("X-Lorem Ipsum", "", @SW_SHOW)
    EndIf
EndFunc   ;==>ToggleHide
Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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