Skip to content

Instantly share code, notes, and snippets.

@JonasSchubert
JonasSchubert / mousemove.ps1
Created December 4, 2023 09:50
mousemove.ps1
Add-Type -AssemblyName System.Windows.Forms
$Mouse=@'
[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
'@
$SendMouseClick = Add-Type -memberDefinition $Mouse -name "Win32MouseEventNew" -namespace Win32Functions -passThru
$moves = 0
@JonasSchubert
JonasSchubert / array-helper.ts
Created November 3, 2018 11:40
method to check if an array has any value (true) or is null or empty (false)
export function any(array: any[]): boolean {
return !!array && array.length > 0;
}
@JonasSchubert
JonasSchubert / services.mock.ts
Created October 9, 2018 20:07
Creating mock objects for jasmine tests can be a pain. This small function should help reduce it, by simply creating a mocked object by adding the class as the type parameter
declare var jasmine;
export default class MockServices {
static substitute<T>(type: { new(...x): T }): jasmine.SpyObj<T> {
const obj = type.prototype;
const objPropertyNames = Object.getOwnPropertyNames(obj);
const methods = objPropertyNames.filter(key => typeof obj[key] === "function");
return jasmine.createSpyObj(