Skip to content

Instantly share code, notes, and snippets.

@nimdahk
nimdahk / gist:4964554
Last active December 13, 2015 19:39
Quick code post
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.DriverStationLCD;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.camera.AxisCamera;
import edu.wpi.first.wpilibj.camera.AxisCameraException;
import edu.wpi.first.wpilibj.image.*;
import edu.wpi.first.wpilibj.image.NIVision.MeasurementType;
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.templates;
Joystick stick;
Jaguar wheel1;
Jaguar wheel2;
double wheel1Speed;
double wheel2Speed;
boolean b2, b3, b4, b5;
final double INC1 = 0.03;
final double INC2 = 0.03;
public void robotInit() {
@nimdahk
nimdahk / ExpandEnvironmentStrings.ahk
Created April 21, 2012 01:08
ExpandEnvironmentStrings wrapper for AutoHotkey - expands %var% references when var is part of the environment
ExpandEnvironmentStrings(string){
; Find length of dest string:
nSize := DllCall("ExpandEnvironmentStrings", "Str", string, "Str", NULL, "UInt", 0, "UInt")
,VarSetCapacity(Dest, size := (nSize * (1 << !!A_IsUnicode)) + !A_IsUnicode) ; allocate dest string
,DllCall("ExpandEnvironmentStrings", "Str", string, "Str", Dest, "UInt", size, "UInt") ; fill dest string
return Dest
}
@nimdahk
nimdahk / MessageBox class.ahk
Created April 12, 2012 18:01
Provides a MessageBox with a Parent and Timeout. By just me.
#NoEnv
Run, Notepad.exe
WinWaitActive, ahk_exe Notepad.exe
HWND := WinExist()
MsgBox, % MessageBox.Show("Hello world!", 2 + 64, "Notepad", 3000, HWND)
ExitApp
Class MessageBox {
Static ID := {1: "OK", 2: "Cancel", 3: "Abort", 4: "Retry", 5: "Ignore", 6: "Yes", 7: "No"
, 10: "TryAgain", 11: "Continue"}
@nimdahk
nimdahk / Select.ahk
Created April 11, 2012 02:36
Change AutoIT Selects into AutoHotkey if/else if
changeSelect(var){
Select := 0
Loop Parse, var, `n, `r
{
if Trim(A_LoopField) = "Select"
Select++
else if RegExMatch(A_LoopField, "i)(\s*)Case\s*else(.*)", $) ;and Select > 0
{
Case%Select%++
out .= $1 (Case%Select% > 1 ? "}" : "") . "else{" . $2
@nimdahk
nimdahk / Switch.ahk
Created April 11, 2012 01:56
Convert AutoIT Switch statements to AHK
var =
(
Switch $me
Case "a"
MsgBox()
case 2 to 3
Die()
case 4 to 5, 9 to 10, 15, 17 to 20
Switch $you
case 14, 90, 100 to 1000
@nimdahk
nimdahk / AU3.ahk
Created April 10, 2012 22:51
Command-functions
HotkeySet(Hotkey, FunctionName=""){
Global HotkeySet := Object()
if !FunctionName
{
Try Hotkey, %Hotkey%, Off
return 1 ; Not specified in docs, and hell if I'm installing AU3
}
Try Hotkey, %Hotkey%, HotkeySet, On
@nimdahk
nimdahk / AU3toAHK.ahk
Created April 10, 2012 22:48
Convert AutoIT to AutoHotkey_L
#NoEnv
SetWorkingDir %A_ScriptDir%
If 0 > 0 ; incoming cmdline parameters
fileName = %1%
else
FileSelectFile, fileName
FileRead, file, %fileName%
@nimdahk
nimdahk / HotkeySet.ahk
Created April 10, 2012 00:26
HotkeySet() in AutoHotkey for use by AU3 to AHK_L converters
HotkeySet(Hotkey, FunctionName=""){
Global HotkeySet := Object()
if !FunctionName
{
Try Hotkey, %Hotkey%, Off
return 1 ; Not specified in docs, and hell if I'm installing AU3
}
Try Hotkey, %Hotkey%, HotkeySet, On