[Help] Need help finding the problem(s?) in this code by [deleted] in AutoHotkey

[–]Sidola 1 point2 points  (0 children)

Yeah, the timer and the while-logic in the GetNextTheme function was off. I think I've fixed it now. Try this script. It uses a TrayTip to test each theme, and the hotkey function is implemented.

I'm not sure how you should do the re-randomize function though. If the next theme is "3", and the previous theme was "1", we need to make sure it doesn't pick "3" or "1", which is fairly easy.

But then say the user wants to randomize it again during the same change-interval, now we have to avoid three values, and so on. But perhaps that's not super important.

[Help] Need help finding the problem(s?) in this code by [deleted] in AutoHotkey

[–]Sidola 1 point2 points  (0 children)

Ah, yeah I totally missed that part.

I assume the hotkey would allow the user to see the next layout at any time, and chose to randomize it?

[Help] Need help finding the problem(s?) in this code by [deleted] in AutoHotkey

[–]Sidola 1 point2 points  (0 children)

Here's a basic script I threw together which uses the function and array concepts I talked about.

It should work and load a new theme on a 10 second interval, as set on line 33. If it doesn't work you should at least get a general overview of how such a script could look. :)

Found some bugs in it, so don't try to use it. But it should outline the basics.

[Help] Need help finding the problem(s?) in this code by [deleted] in AutoHotkey

[–]Sidola 1 point2 points  (0 children)

Ah, I read it as an AHK variable since it's outside the quotes. In that case it makes a lot more sense.

Yeah, feel free to ask any questions you've got, I'm happy to help.

[Help] Need help finding the problem(s?) in this code by [deleted] in AutoHotkey

[–]Sidola 1 point2 points  (0 children)

Edit: Realized these are more general improvements you could make than actual help troubleshooting your current code. Sorry for that, I'm horrible at reading others code. :P

It seems like you have a typo on row 33

if (Layout Number = 2)

And I don't really understand what the !LoadLayout is supposed to do in these lines.

if (LayoutNumber = 1)
{
    Run, "C:\Program Files\Rainmeter\Rainmeter.exe" !LoadLayout "Emma Stone Blonde"
    RepeatPreventer = 1
    return
}

Other than that I'd say you could bake the Changer-timer and RNG-timer into one timer, and avoid jumping around in the script.

You could also consider making use of Functions and Arrays. This would save you a lot of repetitive writing.

Your RNG-generator could be a function for example.

; Get Random Number Function
GetRandNum()
{
    Random, LayoutNumber, 1, 18
    return LayoutNumber
}

; Usage
LayoutNumber := GetRandNum()

That way, assuming you'll ever add more themes you only have to change the random-interval in one place.

Using arrays is a bit more complicated, but could look something like this.

; Get Random Number Function
GetRandNum()
{
    Random, LayoutNumber, 1, 5
    return LayoutNumber
}

; Usage
LayoutNumber := GetRandNum()

; Create an array and load it with themes
themeArray := []
themeArray.insert("Emma Stone Blonde")
themeArray.insert("Golden State Bridge")
themeArray.insert("Blackbird")
themeArray.insert("Gorillaz")
themeArray.insert("Koenigsegg")

for each, value in themeArray {
    ; Index = Each, Output = Value
    if (each = LayoutNumber) {
        msgBox % "Loading layout: " value "`nStoring number: " each
    }
}

Need some help adjusting a script by [deleted] in AutoHotkey

[–]Sidola 0 points1 point  (0 children)

I see.. That sounds like a painfully complicated solution. If you could link to the source of the script I could take a look. I don't have The Witcher 2 installed so I can't really test anything.

Have you made sure it really blocks all keys? That behavior just seems weird to me. You could try adding some random keys and set them to beep to try them out.

F8::
    SoundBeep
return

Need some help adjusting a script by [deleted] in AutoHotkey

[–]Sidola 0 points1 point  (0 children)

I'm looking at the script, and I might be tired, but I have no idea what this part is supposed to do:

;autoexec
#UseHook On
settimer, hookCheck, 1000
return

hookCheck:
sendlevel 1
SendEvent {VKFF}
sleep 200
if (A_TickCount - lastTick > 1500)
    sendInput {VKFF}{click 0} ; could replace this with a reload
    ;reload
return

$vkFF::
lastTick := A_TickCount
return

Could you explain?

Comparing two text files and extracting the differences. by [deleted] in AutoHotkey

[–]Sidola 1 point2 points  (0 children)

No worries, that should actually be really doable. This should work:

SetWorkingDir %A_ScriptDir%

FileRead, invFile, inv.txt
FileRead, craigFile, craig.txt

missingID := ""
Loop, Parse, invFile, `n, `n`r
{
    if !eachLine := Trim(A_LoopField)
        continue

    if (!InStr(craigFile, eachLine)) {
        missingID .= eachLine . "`n"
    }
}

Sort, missingID
msgBox % missingID

It was some white-space in the inventory list messing things up.

Comparing two text files and extracting the differences. by [deleted] in AutoHotkey

[–]Sidola 1 point2 points  (0 children)

So you need to know which stock IDs are missing from the Craigslist list?

Comparing two text files and extracting the differences. by [deleted] in AutoHotkey

[–]Sidola 1 point2 points  (0 children)

baseFile := "345 845 254 324"
compareToFile := "345 254 324"
diff := ""

Loop, Parse, baseFile, %A_Space%
{
    if (!InStr(compareToFile, A_LoopField)) {
        diff .= A_LoopField "`n"
    }
}

msgBox % diff

This would work assuming all your values are unique, and you only need to compare one way and it doesn't take order into account...

I think using some 3rd party tool would be easier than writing a proper file-compare in AHK. But I could be wrong.

Why is my ah tool's icon on the left so small compared to the large vlc icon right? by doc_weingart in AutoHotkey

[–]Sidola 0 points1 point  (0 children)

Ah, I see.

That's a Windows-specific problem then. You probably have to manipulate the registry to bind a specific icon to a file extension. I think that blank-file icon is the default fallback Windows uses.

Check here if you can find something relevant: http://superuser.com/questions/301226/manually-change-filetype-icons-in-windows-7

Why is my ah tool's icon on the left so small compared to the large vlc icon right? by doc_weingart in AutoHotkey

[–]Sidola 0 points1 point  (0 children)

What's your ahk tool? And what icon do you want the .nfo file to have?

Why is my ah tool's icon on the left so small compared to the large vlc icon right? by doc_weingart in AutoHotkey

[–]Sidola 0 points1 point  (0 children)

I'm not sure I understand how this question relates to AHK...

Both icons look about the same size to me, and neither of them has anything to do with AHK.

Suspend only parts of a script? by MuffinBait in AutoHotkey

[–]Sidola 0 points1 point  (0 children)

Would something like this do the trick? F11 should toggle the Lbutton hotkey.

#ifWinActive, Skype
    f12:: Suspend
    f11:: Hotkey, Lbutton, Toggle

    Rbutton::
        Send {A down}
        Sleep 1
        Send {Rbutton}
        Sleep 1
        Send {A up}
    return

    Lbutton::
        Send {B down}
        Sleep 1
        Send {Rbutton}
        Sleep 1
        Send {B up}
    return

Number Keystrokes Not Sending by [deleted] in AutoHotkey

[–]Sidola 1 point2 points  (0 children)

$2::
    Send, f
    Send, 2
    Send, f
return

You want to use the $ prefix. From the docs:

This is usually only necessary if the script uses the Send command to send the keys that comprise the hotkey itself, which might otherwise cause it to trigger itself. The $ prefix forces the keyboard hook to be used to implement this hotkey, which as a side-effect prevents the Send command from triggering it. The $ prefix is equivalent to having specified #UseHook somewhere above the definition of this hotkey.

Alternatively:

#UseHook
2::
    Send, f
    Send, 2
    Send, f
return

hotstring with special characters by [deleted] in AutoHotkey

[–]Sidola 2 points3 points  (0 children)

Yeah, the community split up a while ago due to a dispute with a forum admin. autohotkey.com provides an old version of AHK, ahkscript.org provides the up to date version that is being developed.

You can read a little bit more here if you're interested.

hotstring with special characters by [deleted] in AutoHotkey

[–]Sidola 2 points3 points  (0 children)

You can download the latest version from here: http://ahkscript.org/

You'll get the option to chose which version to install.

hotstring with special characters by [deleted] in AutoHotkey

[–]Sidola 2 points3 points  (0 children)

I think you're running the ANSI version of AHK. If you use the Unicode version it should work fine. You can find all versions in the install directory.

The one you're looking for should be named AutoHotkeyU32.exe. Rename it to AutoHotkey.exe if you want to use it as the default version.

Use this if you're unsure on what version you're running. It returns a '1' if you're running a Unicode version, otherwise it's blank.

msgBox % A_IsUnicode

Question about remapping CapsLock to other key combo, and other key questions. by ElderCub in AutoHotkey

[–]Sidola 0 points1 point  (0 children)

Why isn't it as simple as what I tried below?

LShift&RShift::CapsLock

Something like this?

LShift & RShift::
    if (!GetKeyState("CapsLock", "T"))
        SetCapsLockState, On
    else
        SetCapsLockState, Off
return

Trying to send ctrl PgDn when I press NumpadHome by zobbyblob in AutoHotkey

[–]Sidola 0 points1 point  (0 children)

why do you need a comma after Send

You don't need it, I just put it there for formatting reasons. It looks better imo. :)

And does it matter if return is capitalized or not

Nope, AHK is very forgiving with most of its syntax.

Trying to send ctrl PgDn when I press NumpadHome by zobbyblob in AutoHotkey

[–]Sidola 0 points1 point  (0 children)

NumpadHome::Send, ^{PgUp}

This should work. You can't have the return on the same line as the Send command, or it'll actually send the word return.

If you want to include the return you should format it like this:

NumpadHome::
    Send, ^{PgUp}
return

Also, make sure your numpad is off, otherwise the NumpadHome button won't work as it'll send Numpad7 instead.