Jump to content

I HATE HotkeySet!


Recommended Posts

I am getting really frustrated with this.. here is my code:

Global Const $ubuntuHotkey = IniRead($iniPath, "Settings", "ubuntuhotkey", "^!a")
Global Const $winHotkey = IniRead($iniPath, "Settings", "winhotkey", "^!d")

HotKeySet($ubuntuHotkey, "ShowUbuntu")
HotKeySet($winHotkey, "ShowWindows")

Func ShowUbuntu()
    Local $cWin = WinExists($vmxName)
    If $cWin = 0 Then
        MsgBox(0, "Uh-oh!", "Ubuntu is not running!")
        Return 0
    Else
        WinSetState($vmxName, "", @SW_SHOW)
        Sleep(50)
        Send("^g")
        Return 1
    EndIf
EndFunc

Func ShowWindows()
    Local $cWin = WinActive($vmxName)
    If $cWin = 0 Then
        MsgBox(0, "Uh-oh!", "Ubuntu is not the active window!")
        Return 0
    Else
        Send("^!")
        Sleep(50)
        WinSetState($vmxName, "", @SW_MINIMIZE)
    EndIf
EndFunc
I have already tried using variables and normal text for HotKeySet.. neither work.

When the keys are pressed, as you can see by the function, it will do SOMETHING. But even if I press these keys a billion times, NOTHING happens.

I have tried both with the windows active and inactive. Oh God, I feel like the guy in my avatar :D

Hopefully this won't be one of my stupid questions again. :)

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Link to comment
Share on other sites

sorry to say it, but i think you need a break sandman, rather basic mistake.

your script opens, then closes. throw in a loop with a sleep, and bob is your mothers brother.

... try this:

Global Const $ubuntuHotkey = IniRead($iniPath, "Settings", "ubuntuhotkey", "^!a")
Global Const $winHotkey = IniRead($iniPath, "Settings", "winhotkey", "^!d")

HotKeySet($ubuntuHotkey, "ShowUbuntu")
HotKeySet($winHotkey, "ShowWindows")

while 1
    Sleep(250)
WEnd

Func ShowUbuntu()
    Local $cWin = WinExists($vmxName)
    If $cWin = 0 Then
        MsgBox(0, "Uh-oh!", "Ubuntu is not running!")
        Return 0
    Else
        WinSetState($vmxName, "", @SW_SHOW)
        Sleep(50)
        Send("^g")
        Return 1
    EndIf
EndFunc

Func ShowWindows()
    Local $cWin = WinActive($vmxName)
    If $cWin = 0 Then
        MsgBox(0, "Uh-oh!", "Ubuntu is not the active window!")
        Return 0
    Else
        Send("^!")
        Sleep(50)
        WinSetState($vmxName, "", @SW_MINIMIZE)
    EndIf
EndFunc
Edited by tAKTelapis
Link to comment
Share on other sites

Yes, I already have that, sorry to not post it :)

What I posted was only a portion of my code. That is included in my full script, but it doesn't work.

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Link to comment
Share on other sites

hmm, well, i created an ini file:

c:\test.ini

and specified it as $inipath (for testing)

and over-wrote your chosen default values with A and S.

as such:

[settings]

ubuntuhotkey=a

winhotkey=s

and when i hit A or S, i get an error, but it does activate the function like it is meant to..

perhaps if you removed the default values, and juts ran with what is in the ini file.

Link to comment
Share on other sites

Hm, that's weird, it works now.. I should report that then. That's WEIRD..

Okay, well, thanks!

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Link to comment
Share on other sites

Hm, that's weird, it works now.. I should report that then. That's WEIRD..

Okay, well, thanks!

Can't follow what's been said here.

I don't see any problem with the "^!a" or "^!d" in the defaults or in the ini file, change either and what's in the ini file works.

Remove the setting from the ini file and the default setting works. No errors.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...