Anyone got a clue how to make a vbscript popup-message/box "spawn" on top of everything and not in the background...?
This is my script: :)
Set objShell = WScript.CreateObject("WScript.Shell")
Const wshYes = 6
Const wshNo = 7
Const wshYesNoDialog = 4
Const wshQuestionMark = 32
intReturn = objShell.Popup("Vil du annulere shutdown?", _
20, "Shutdown om 5 minutter!", wshYesNoDialog + wshQuestionMark)
If intReturn = wshYes Then
Wscript.Echo "Shutdown annuleret."
objShell.Run "C:\ProgramData\AutoShutdown\Annuler.bat"
End If
I am very bad at vbscript, I am just using this little part for my Batch program. Any help appreciated!
It was simply by adding vbSystemModal
120, "Shutdown om 5 minutter!", wshYesNoDialog + vbSystemModal + wshQuestionMark)
The are wrappers around the API messagebox function. Just pass the numbers. Most msgbox functions just pass the numbers on so they don't need to understand them.
So use &h1000, &h2000, or &h40000
/*
* MessageBox() Flags
*/
#define MB_OK 0x00000000L
#define MB_OKCANCEL 0x00000001L
#define MB_ABORTRETRYIGNORE 0x00000002L
#define MB_YESNOCANCEL 0x00000003L
#define MB_YESNO 0x00000004L
#define MB_RETRYCANCEL 0x00000005L
#if(WINVER >= 0x0500)
#define MB_CANCELTRYCONTINUE 0x00000006L
#endif /* WINVER >= 0x0500 */
#define MB_ICONHAND 0x00000010L
#define MB_ICONQUESTION 0x00000020L
#define MB_ICONEXCLAMATION 0x00000030L
#define MB_ICONASTERISK 0x00000040L
#if(WINVER >= 0x0400)
#define MB_USERICON 0x00000080L
#define MB_ICONWARNING MB_ICONEXCLAMATION
#define MB_ICONERROR MB_ICONHAND
#endif /* WINVER >= 0x0400 */
#define MB_ICONINFORMATION MB_ICONASTERISK
#define MB_ICONSTOP MB_ICONHAND
#define MB_DEFBUTTON1 0x00000000L
#define MB_DEFBUTTON2 0x00000100L
#define MB_DEFBUTTON3 0x00000200L
#if(WINVER >= 0x0400)
#define MB_DEFBUTTON4 0x00000300L
#endif /* WINVER >= 0x0400 */
#define MB_APPLMODAL 0x00000000L
#define MB_SYSTEMMODAL 0x00001000L
#define MB_TASKMODAL 0x00002000L
#if(WINVER >= 0x0400)
#define MB_HELP 0x00004000L // Help Button
#endif /* WINVER >= 0x0400 */
#define MB_NOFOCUS 0x00008000L
#define MB_SETFOREGROUND 0x00010000L
#define MB_DEFAULT_DESKTOP_ONLY 0x00020000L
#if(WINVER >= 0x0400)
#define MB_TOPMOST 0x00040000L
#define MB_RIGHT 0x00080000L
#define MB_RTLREADING 0x00100000L
#endif /* WINVER >= 0x0400 */
#ifdef _WIN32_WINNT
#if (_WIN32_WINNT >= 0x0400)
#define MB_SERVICE_NOTIFICATION 0x00200000L
#else
#define MB_SERVICE_NOTIFICATION 0x00040000L
#endif
#define MB_SERVICE_NOTIFICATION_NT3X 0x00040000L
#endif
#define MB_TYPEMASK 0x0000000FL
#define MB_ICONMASK 0x000000F0L
#define MB_DEFMASK 0x00000F00L
#define MB_MODEMASK 0x00003000L
#define MB_MISCMASK 0x0000C000L
Adding + 4096 to your code will also work
20, "Shutdown om 5 minutter!", wshYesNoDialog + wshQuestionMark + 4096)
Here's google search link for objShell.Popup modal 4096
Related
I'm migrating a project from VC6 to VS2019. As far as I know, _far _near are for the segmented memory model access, and _cdel _ pascal are for calling convention. All of them seem only existed in VC6 and older versions. For migration, is it safe to remove them like the #else block? Thanks!
Code:
/* 関数タイプ コンパイラ依存 */
#ifdef MSDOS
#ifdef _MSC_VER /* MS-C Ver.6.0以上 */
#define FAR _far
#define NEAR _near
#define CDECL _cdecl
#define LeafFunc _fastcall _near /* nearコール */
#define NearFunc _pascal _near /* nearコール */
#define FarLeafFunc _fastcall _far /* farコール */
#define FarFunc _pascal _far /* farコール */
#define register /* register宣言は無視 */
#else /* その他 */
#define FAR
#define NEAR
#define CDECL
#define LeafFunc
#define NearFunc
#define FarLeafFunc
#define FarFunc
#endif
NareFunc is used like the following code:
void NearFunc mmInit PT0() {
//...
}
EDIT: Thanks to 9dan. I've corrected _far and _near in the post.
so I'm using 1 solution for multiple products and I need to make some kind of 'product id system' so i know what product people are using.
HEre is my attempt:
#ifdef _WIN64
#if defined(_DEBUG)
#if defined(PFW_APP_D3D_TEST)
#define PFW_PRODUCT_ID 1
#elif defined(PFW_APP_LOADER)
#define PFW_PRODUCT_ID 24
#endif
#else
#if defined(PFW_APP_D3D_TEST)
#define PFW_PRODUCT_ID 25
#elif defined(PFW_APP_LOADER)
#define PFW_PRODUCT_ID 48
//Then some nested #if here
#endif
#endif
#else
#if defined(_DEBUG)
#if defined(PFW_APP_D3D_TEST)
#define PFW_PRODUCT_ID 49
#elif defined(PFW_APP_LOADER)
#define PFW_PRODUCT_ID 72
#endif
#else
#if defined(PFW_APP_D3D_TEST)
#define PFW_PRODUCT_ID 73
#elif defined(PFW_APP_LOADER)
#define PFW_PRODUCT_ID 96
#endif
#endif
#endif
but it doesn't compile D: (no clue how to properly use this # system
so my question is, how can i fix the syntax error and is there a automated way i can generate product id's?
problem fixed...
changed from
#elif defined(PFW_APP_BF1)
#if defined(PFW_GAME_BF4)
#define PFW_PRODUCT_ID 51
#elif defined(PFW_GAME_BF1)
#define PFW_PRODUCT_ID 52
to
#elif defined(PFW_APP_BF1)
#elif defined(PFW_GAME_BF4)
#define PFW_PRODUCT_ID 51
#elif defined(PFW_GAME_BF1)
#define PFW_PRODUCT_ID 52
but sad that i couldn't use #if :D
In my c++ class, I want use WIN API GetFileSizeEx() function. When I compile my code, the compilator said:
"error: 'GetFileSizeEx' was not declared in this scope".
However, others functions like CreateFile() or WriteFile() work perfectly.
In my class header, I declare this :
#if defined(WINVER) && WINVER==0x0602 /* windows 8 */
#define WINVER 0x0602
#define _WIN32_WINNT 0x0602
#elif defined(WINVER) && WINVER==0x0601 /* windows 7 */
#define WINVER 0x0601
#define _WIN32_WINNT 0x0601
#elif defined(WINVER) && WINVER==0x0600 /* windows vista and server 2008 */
#define WINVER 0x0600
#define _WIN32_WINNT 0x0600
#elif defined(WINVER) && WINVER==0x0502 /* server 2003 */
#define WINVER 0x0502
#define _WIN32_WINNT 0x0502
#elif defined(WINVER) && WINVER==0x0501 /* windows xp */
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#endif
#include <windows.h>
#include <winbase.h>
#include <string>
In my .cpp class:
Test::Test()
{
hFile = CreateFile(TEXT("conf/configure_tool.txt"),
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
canAcces = false;
}else
{
if(GetFileSizeEx(hFile,&sized) != 0)
{
canAcces = true;
}
}
}
Have you an idea to resolve my problem ?
From the documentation:
Minimum supported client Windows XP [desktop apps only]
So you need to ensure that you have defined WINVER to be 0x0501 or greater.
If that doesn't solve the problem then the likely cause is that you are using a deficient SDK. Perhaps from an old version of a non-MS compiler. Make sure that you have an up-to-date SDK.
It must be said that the conditional code in the question that attempts to define _WIN32_WINNT is a little odd. Why don't you define _WIN32_WINNT at the same time as you define WINVER?
I find the following post very useful to do a project of my own. Here's the newbie question then: what must I include for this to work?
Link:
How to accurately measure mouse movement in inches or centimetres for a mouse with a known DPI
Content:
The following code registers the RAWINPUTDEVICE so it can be used in WM_INPUT.
RAWINPUTDEVICE Rid[1];
Rid[0].usUsagePage = HID_USAGE_PAGE_GENERIC;
Rid[0].usUsage = HID_USAGE_GENERIC_MOUSE;
Rid[0].dwFlags = RIDEV_INPUTSINK;
Rid[0].hwndTarget = hWnd;
RegisterRawInputDevices(Rid, 1, sizeof(Rid[0]);
The following code acutally uses the Rid variable two determine how many pixels the mouse has moved since the last time WM_INPUT was initiated.
case WM_INPUT:
{
UINT dwSize = 40;
static BYTE lpb[40];
GetRawInputData((HRAWINPUT)lParam, RID_INPUT,
lpb, &dwSize, sizeof(RAWINPUTHEADER));
RAWINPUT* raw = (RAWINPUT*)lpb;
if (raw->header.dwType == RIM_TYPEMOUSE)
{
int xPosRelative = raw->data.mouse.lLastX; // Could be 1, or could be more than 1
int yPosRelative = raw->data.mouse.lLastY; // Could be 1, or could be more than 1!
}
break;
}
I just found it.
#include "hidusage.h"
here's some definitions it has
#define HID_USAGE_GENERIC_POINTER ((USAGE) 0x01)
#define HID_USAGE_GENERIC_MOUSE ((USAGE) 0x02)
#define HID_USAGE_GENERIC_JOYSTICK ((USAGE) 0x04)
#define HID_USAGE_GENERIC_GAMEPAD ((USAGE) 0x05)
#define HID_USAGE_GENERIC_KEYBOARD ((USAGE) 0x06)
#define HID_USAGE_GENERIC_KEYPAD ((USAGE) 0x07)
#define HID_USAGE_GENERIC_SYSTEM_CTL ((USAGE) 0x80)
typedef USHORT USAGE,*PUSAGE;
You need to include windows.h
...also the HID_USAGE_PAGE_GENERIC and HID_USAGE_GENERIC_MOUSE must be defined.
See MSDN..
#ifndef HID_USAGE_PAGE_GENERIC
#define HID_USAGE_PAGE_GENERIC ((USHORT) 0x01)
#endif
#ifndef HID_USAGE_GENERIC_MOUSE
#define HID_USAGE_GENERIC_MOUSE ((USHORT) 0x02)
#endif
http://msdn.microsoft.com/en-gb/library/windows/desktop/ee418864%28v=vs.85%29.aspx
Right now i can get these tags from an audio file:
#define kAFInfoDictionary_Artist "artist"
#define kAFInfoDictionary_Album "album"
#define kAFInfoDictionary_Tempo "tempo"
#define kAFInfoDictionary_KeySignature "key signature"
#define kAFInfoDictionary_TimeSignature "time signature"
#define kAFInfoDictionary_TrackNumber "track number"
#define kAFInfoDictionary_Year "year"
#define kAFInfoDictionary_Composer "composer"
#define kAFInfoDictionary_Lyricist "lyricist"
#define kAFInfoDictionary_Genre "genre"
#define kAFInfoDictionary_Title "title"
#define kAFInfoDictionary_RecordedDate "recorded date"
#define kAFInfoDictionary_Comments "comments"
#define kAFInfoDictionary_Copyright "copyright"
#define kAFInfoDictionary_SourceEncoder "source encoder"
#define kAFInfoDictionary_EncodingApplication "encoding application"
#define kAFInfoDictionary_NominalBitRate "nominal bit rate"
#define kAFInfoDictionary_ChannelLayout "channel layout"
#define kAFInfoDictionary_ApproximateDurationInSeconds "approximate duration in seconds"
#define kAFInfoDictionary_SourceBitDepth "source bit depth"
#define kAFInfoDictionary_ISRC "ISRC" // International Standard Recording Code
#define kAFInfoDictionary_SubTitle "subtitle"
So how can i get the Disc Number tag? Thanks!
You can try to use TagLib: http://taglib.github.io/
It's free and powerful.