Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // MOSAID / 2015
- // c++ headers
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <sstream>
- #include <vector>
- #include <stdio.h>
- #include <conio.h>
- #include <iomanip>
- #include <ctime>
- //winapi headers
- #include <windows.h>
- #include <tchar.h>
- #include <strsafe.h>
- #include <Shellapi.h>
- #include <Shlwapi.h>
- #include <shlobj.h>
- #include <commctrl.h>
- #include <Objbase.h>
- #include <TlHelp32.h>
- #pragma comment(lib,"user32.lib")
- #pragma comment(lib,"Shell32.lib")
- #pragma comment(lib,"Gdi32.lib")
- #pragma comment(lib,"Advapi32.lib")
- #pragma comment(lib,"Comdlg32.lib")
- #pragma comment(lib,"Comctl32.lib")
- #pragma comment(lib,"Shlwapi.lib")
- #pragma comment(lib,"Ole32.lib")
- #include "LimitSingleInstance.h"
- CLimitSingleInstance g_SingleInstanceObj(TEXT("Global\\{9DA0BEED-7248-450a-B27C-C0409BDC377D}"));
- using namespace std;
- struct Vv{
- string name;
- string index;
- string path;
- string command;
- string password;
- };
- vector<Vv> myVec;
- char buffer[7];
- const HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);
- const string findex[]={"10","12","13","14","15","16","17","18","19","21","23","24","25","26","27","28","29","30","31","32"};
- const string aindex[]={"00","11","22","33","44","55","66","77","88","99","01","02","03","04","05","06","07","08","09"};
- INPUT_RECORD irInBuf[128];
- MOUSE_EVENT_RECORD ir;
- DWORD cNumRead;
- string str;
- bool password();
- void gotoxy(int x, int y);
- void InitiateConsole(int x, int y, bool bb);
- bool WINAPI SetConsoleIcon();
- void color(DWORD);
- void parse(string& arg);
- void cls();
- void design();
- void choices();
- void initIniFile();
- void ReadIniFile();
- void DisplayError(LPCSTR lpszFunction);
- void handleInputEvents();
- int main()
- {
- if (g_SingleInstanceObj.IsAnotherInstanceRunning())
- {
- return 0;
- }
- SetWindowPos(GetConsoleWindow(),HWND_TOP,400,180,0,0,SWP_NOSIZE);
- InitiateConsole(60,30,true);
- SetConsoleIcon();
- EXECUTION_STATE PrevES = SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS );
- DWORD oldConsoleMod,ConsoleMod;
- HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
- GetConsoleMode(hStdin, &oldConsoleMod);
- ConsoleMod = ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT;
- SetConsoleMode(hStdin, ConsoleMod);
- cls();
- design();
- initIniFile();
- ReadIniFile();
- choices();
- while(true)
- {
- gotoxy(44,2);
- cout<<" ";
- gotoxy(44,2);
- handleInputEvents();
- }
- SetThreadExecutionState(PrevES);
- SetConsoleMode(hStdin, oldConsoleMod);
- return 0;
- }
- void translateMouseDBClick(int x, int y)
- {
- string str("mm");
- if( x>=30 && y>=10 && y<29) str =aindex[y-10];
- if( x<30 && y>=4 && y<24) str =findex[y-4];
- if( x<10 && y==26) str ="xx";
- if( x>11 && x<30 && y==26) str ="ss";
- if( x<=9 && y==28) str ="pp";
- if( x>=10 && x<18 && y==28) str ="rr";
- if( x>=18 && x<30 && y==28) str ="aa";
- parse(str);
- }
- void handleInputEvents()
- {
- char c;
- HANDLE hStdin= GetStdHandle(STD_INPUT_HANDLE);
- if (! ReadConsoleInput(hStdin,irInBuf,128,&cNumRead) )
- DisplayError("ReadConsoleInput");
- for (int i = 0; i < cNumRead; i++)
- {
- if(irInBuf[i].EventType == MOUSE_EVENT )
- {
- ir = irInBuf[i].Event.MouseEvent;
- if(ir.dwEventFlags == DOUBLE_CLICK )
- {
- translateMouseDBClick(ir.dwMousePosition.X,ir.dwMousePosition.Y);
- }
- }
- if(irInBuf[i].EventType == KEY_EVENT )
- {
- if(irInBuf[i].Event.KeyEvent.bKeyDown)
- {
- c = irInBuf[i].Event.KeyEvent.uChar.AsciiChar;
- str = c;
- putchar(c);
- c =getch();
- str+=c;
- putchar(c);
- parse(str);
- gotoxy(46,4);
- cout<<" ";
- gotoxy(38,5);
- cout<<" ";
- }
- if (! ReadConsoleInput(hStdin,irInBuf,128,&cNumRead) )
- DisplayError("ReadConsoleInput");
- }
- }
- }
- void choices()
- {
- color(12);
- gotoxy(2,26);
- cout<<"xx: exit ss: settings";
- gotoxy(2,28);
- cout<<"pp: pass rr: run aa: about";
- color(11);
- gotoxy(2,1);
- cout<<"Folders :";
- gotoxy(32,8);
- cout<<"Apps :";
- color(244);
- for(int i=0;i<20;i++)
- {
- gotoxy(1,4+i);
- cout<<findex[i]<<":";
- for(int k=0;k<myVec.size();k++)
- {
- if(myVec[k].index.compare(findex[i])==0)
- {
- gotoxy(5,4+i);
- cout<<myVec[k].name;
- }
- }
- }
- color(10);
- for(int i=0;i<19;i++)
- {
- gotoxy(32,10+i);
- cout<<aindex[i]<<":";
- for(int k=0;k<myVec.size();k++)
- {
- if(myVec[k].index.compare(aindex[i])==0)
- {
- gotoxy(36,10+i);
- cout<<myVec[k].name;
- }
- }
- }
- }
- void design()
- {
- color(240);
- int k=0;
- gotoxy(0,3);
- for(int i=1;i<=638;i++){
- cout<<" ";
- if(i%29==0){k++;gotoxy(0,3+k);}
- }
- color(11);
- gotoxy(30,9);
- cout<<"\xDA";
- for(int i=0;i<=15;i++)cout<<"\xC4";
- for(int i=0;i<=18;i++){
- gotoxy(30,10+i);
- cout<<"\xB3";
- }
- gotoxy(35,7);
- color(14);
- for(int i=0;i<25;i++)cout<<(char)223;
- gotoxy(35,1);
- for(int i=0;i<12;i++)cout<<(char)223;
- for(int i=0;i<=5;i++)
- {
- gotoxy(35,6-i);
- cout<<(char)219;
- }
- color(0);
- color(11);
- gotoxy(37,2);
- cout<<"choice:";
- gotoxy(37,4);
- cout<<"password:";
- color(14);
- char mosaid[]="MOSAID";
- for(int i=0;i<6;i++)
- {
- gotoxy(32,1+i);
- cout<<char(186)<<mosaid[i]<<char(186);//182
- }
- gotoxy(32,7);
- cout<<char(223)<<char(223)<<char(223);
- }
- void gotoxy(int x, int y)
- {
- COORD coord = {x,y};
- SetConsoleCursorPosition(handle,coord);
- }
- void InitiateConsole(int x, int y, bool bb)
- {
- if(bb) InitiateConsole(x-10,y-10,false);
- COORD coord ={x,y};
- SMALL_RECT rect = {0,0,x-1,y-1};
- SetConsoleScreenBufferSize(handle,coord);
- SetConsoleWindowInfo(handle,true,&rect);
- SetConsoleTitle("Execute 1.0.15");
- HWND hwnd = GetConsoleWindow();
- LONG style = GetWindowLong(hwnd , GWL_STYLE);
- style = style & ~(WS_THICKFRAME);
- style = style & ~(WS_MAXIMIZEBOX);
- style = style & ~(WS_SYSMENU);
- SetWindowLong(hwnd, GWL_STYLE, style);
- HMENU hmenu = GetSystemMenu(hwnd, FALSE);
- DeleteMenu(hmenu, SC_CLOSE, MF_BYCOMMAND);
- }
- bool WINAPI SetConsoleIcon()
- {
- HMODULE hMainMod = GetModuleHandle(0);
- HICON hIcon =(HICON)LoadImage(hMainMod,"execute-1.0.15.ico",IMAGE_ICON,
- 0,0,LR_LOADFROMFILE|LR_DEFAULTSIZE);
- typedef bool (WINAPI *PSetConsoleIcon)(HICON);
- static PSetConsoleIcon pSetConsoleIcon = NULL;
- if(pSetConsoleIcon == NULL)
- pSetConsoleIcon = (PSetConsoleIcon)GetProcAddress(GetModuleHandle(_T("kernel32")), "SetConsoleIcon");
- if(pSetConsoleIcon == NULL)
- return false;
- return pSetConsoleIcon(hIcon);
- }
- void ReadIniFile()
- {
- ifstream ifs;
- string line;
- Vv tVv;
- int i=0;
- ifs.open("TrSettings.ini",ios::in);
- if(!ifs.is_open())
- {
- DisplayError("ReadIniFile");
- return;
- }
- while ( getline (ifs,line) )
- {
- if(line[0]=='[' && line[line.size()-1]==']')
- {
- tVv.name.assign(line.begin()+1,line.end()-1);
- i++;
- }
- if(line.compare(0,6,"index=")==0)
- {
- tVv.index.assign(line.begin()+6,line.end());
- i++;
- }
- if(line.compare(0,5,"path=")==0)
- {
- tVv.path.assign(line.begin()+5,line.end());
- i++;
- }
- if(line.compare(0,8,"command=")==0)
- {
- tVv.command.assign(line.begin()+8,line.end());
- i++;
- }
- if(line.compare(0,9,"password=")==0)
- {
- tVv.password.assign(line.begin()+9,line.end());
- i++;
- }
- if(i==5)
- {
- myVec.push_back(tVv);
- i=0;
- }
- }
- ifs.close();
- SetFileAttributes("TrSettings.ini",FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM );
- }
- bool NotEmptyFile(LPCSTR filename)
- {
- LARGE_INTEGER Size;
- HANDLE Hfile;
- bool result=false;
- Hfile = CreateFile(filename,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
- if(Hfile!=INVALID_HANDLE_VALUE)
- {
- GetFileSizeEx(Hfile,&Size);
- if(Size.LowPart)result=true;
- }
- CloseHandle(Hfile);
- return result;
- }
- void initIniFile()
- {
- if(NotEmptyFile("TrSettings.ini"))return;
- HANDLE hFile;
- DWORD dwWritten=0;
- ostringstream ofs;
- char data[MAX_PATH];
- bool result=false;
- GetWindowsDirectory(data,MAX_PATH);
- ofs<<"[command Prompt (cmd)]"<<endl;
- ofs<<"index=00"<<endl;
- ofs<<"path=cmd.exe"<<endl;
- ofs<<"command=/s /k pushd "<<data[0]<<":\\"<<endl;
- ofs<<"password=0"<<endl<<endl;
- ofs<<"[My Computer]"<<endl;
- ofs<<"index=10"<<endl;
- ofs<<"path=";
- GetWindowsDirectory(data,MAX_PATH);
- ofs<<data;
- ofs<<"\\Explorer.exe"<<endl;
- ofs<<"command=/E,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"<<endl;
- ofs<<"password=0"<<endl<<endl;
- ofs<<"[My Documents]"<<endl;
- ofs<<"index=12"<<endl;
- ofs<<"path=Explorer.exe"<<endl;
- ofs<<"command=/N,::{450D8FBA-AD25-11D0-98A8-0800361B1103}"<<endl;
- ofs<<"password=0"<<endl<<endl;
- ofs<<"[Control Panel]"<<endl;
- ofs<<"index=13"<<endl;
- ofs<<"path=";
- GetWindowsDirectory(data,MAX_PATH);
- ofs<<data;
- ofs<<"\\explorer.exe"<<endl;
- ofs<<"command=/N,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}";
- ofs<<"\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"<<endl;
- ofs<<"password=0"<<endl<<endl;
- ofs<<"[Recycle Bin]"<<endl;
- ofs<<"index=14"<<endl;
- ofs<<"path=Explorer"<<endl;
- ofs<<"command=/N,::{645FF040-5081-101B-9F08-00AA002F954E}"<<endl;
- ofs<<"password=0"<<endl<<endl;
- ofs<<"[google (google chrome)]"<<endl;
- ofs<<"index=11"<<endl;
- ofs<<"path=";
- SHGetSpecialFolderPath(0,data,CSIDL_PROGRAM_FILES,FALSE );
- ofs<<data;
- ofs<<"\\Google\\Chrome\\Application\\chrome.exe"<<endl;
- ofs<<"command=-incognito www.google.com www.youtube.com"<<endl;
- ofs<<"password=1"<<endl<<endl;
- hFile = CreateFile("TrSettings.ini",GENERIC_WRITE,0, NULL, CREATE_NEW , 0, NULL);
- if (hFile == INVALID_HANDLE_VALUE )
- {
- DisplayError("initIniFile Create");
- CloseHandle(hFile);
- return;
- }
- result = WriteFile(hFile,ofs.str().c_str(),ofs.str().size(),&dwWritten,NULL);
- if(!result)
- {
- DisplayError("initIniFile Write");
- }
- CloseHandle(hFile);
- SetFileAttributes("TrSettings.ini",FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM );
- }
- void handleCBBSel(HWND hwnd,LPSTR arg)
- {
- for(int k=0;k<myVec.size();k++)
- {
- if(myVec[k].index.compare(arg)==0)
- {
- SendMessage(GetDlgItem(hwnd,116),WM_SETTEXT,0,reinterpret_cast<LPARAM>(myVec[k].name.c_str()));
- SendMessage(GetDlgItem(hwnd,118),WM_SETTEXT,0,reinterpret_cast<LPARAM>(myVec[k].path.c_str()));
- SendMessage(GetDlgItem(hwnd,120),WM_SETTEXT,0,reinterpret_cast<LPARAM>(myVec[k].command.c_str()));
- if(myVec[k].password.compare("1")==0)
- SendMessage(GetDlgItem(hwnd,121),BM_SETCHECK ,BST_CHECKED,0);
- else SendMessage(GetDlgItem(hwnd,121),BM_SETCHECK ,BST_UNCHECKED,0);
- return;
- }
- }
- SendMessage(GetDlgItem(hwnd,116),WM_SETTEXT,0,0);
- SendMessage(GetDlgItem(hwnd,118),WM_SETTEXT,0,0);
- SendMessage(GetDlgItem(hwnd,120),WM_SETTEXT,0,0);
- SendMessage(GetDlgItem(hwnd,121),BM_SETCHECK ,BST_UNCHECKED,0);
- }
- void onClickConfirm(HWND hwnd)
- {
- char data[MAX_PATH];
- int inddex;
- Vv tmpVv;
- int iselected =SendMessage(GetDlgItem(hwnd,113), CB_GETCURSEL , 0,0);
- SendMessage(GetDlgItem(hwnd,113), CB_GETLBTEXT , iselected,reinterpret_cast<LPARAM>(buffer));
- SendMessage(GetDlgItem(hwnd,116),WM_GETTEXT,MAX_PATH,reinterpret_cast<LPARAM>(data));
- tmpVv.name=data;
- tmpVv.index=buffer;
- SendMessage(GetDlgItem(hwnd,118),WM_GETTEXT,MAX_PATH,reinterpret_cast<LPARAM>(data));
- tmpVv.path=data;
- SendMessage(GetDlgItem(hwnd,120),WM_GETTEXT,MAX_PATH,reinterpret_cast<LPARAM>(data));
- tmpVv.command=data;
- if(BST_CHECKED==SendMessage(GetDlgItem(hwnd,121),BM_GETCHECK ,0,0))
- tmpVv.password="1";
- else tmpVv.password="0";
- for(int k=0;k<myVec.size();k++)
- {
- if(myVec[k].index.compare(tmpVv.index)==0)
- {
- myVec.erase(myVec.begin()+k);
- }
- }
- if(!tmpVv.name.size() && !tmpVv.path.size() && !tmpVv.command.size())
- {
- MessageBox(hwnd,"Deleted !","Settings",MB_OK);
- }
- else
- {
- myVec.push_back(tmpVv);
- MessageBox(hwnd,"Done !","Settings",MB_OK);
- }
- }
- void onClickApply()
- {
- HANDLE hFile;
- DWORD dwWritten=0;
- ostringstream oss;
- hFile = CreateFile("TrSettings.ini",GENERIC_WRITE,0, NULL, TRUNCATE_EXISTING , 0, NULL);
- if (hFile!= INVALID_HANDLE_VALUE)
- {
- for(int k=0;k<myVec.size();k++)
- {
- oss<<"["<< myVec[k].name <<"]"<<endl;
- oss<<"index="<< myVec[k].index <<endl;
- oss<<"path="<< myVec[k].path <<endl;
- oss<<"command="<< myVec[k].command <<endl;
- oss<<"password="<< myVec[k].password <<endl<<endl;
- WriteFile(hFile,oss.str().c_str(),oss.str().size(),&dwWritten,NULL);
- oss.clear();
- oss.str(string());
- }
- CloseHandle(hFile);
- }
- SetFileAttributes("TrSettings.ini",FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM );
- cls();
- design();
- choices();
- }
- void GetMyPath(HWND hwnd)
- {
- char currDir[MAX_PATH];
- GetCurrentDirectory(MAX_PATH,currDir);
- OPENFILENAME ofn;
- char szFileName[MAX_PATH];
- string str;
- ZeroMemory(&ofn, sizeof(ofn));
- szFileName[0] = 0;
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = hwnd;
- ofn.lpstrTitle="Open file";
- ofn.lpstrFilter ="All Files\0*.*\0";
- ofn.nMaxFile = MAX_PATH;
- ofn.lpstrFile=szFileName;
- ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST ;
- if( GetOpenFileName(&ofn))
- {
- str.assign(ofn.lpstrFile);
- int pos=str.find_last_of("\\");
- if(pos!=string::npos) str.erase(str.begin(),str.begin() + pos+1);
- SendMessage(GetDlgItem(hwnd,116),WM_SETTEXT,0,reinterpret_cast<LPARAM>(str.c_str()));
- str.assign(ofn.lpstrFile);
- pos=str.find_last_of("\\");
- if(pos!=string::npos) str.erase(str.begin()+ pos,str.end());
- SendMessage(GetDlgItem(hwnd,118),WM_SETTEXT,0,reinterpret_cast<LPARAM>(ofn.lpstrFile));
- SendMessage(GetDlgItem(hwnd,120),WM_SETTEXT,0,reinterpret_cast<LPARAM>(str.c_str()));
- }
- SetCurrentDirectory(currDir);
- }
- LRESULT CALLBACK DialogProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
- {
- int iselected;
- switch(msg)
- {
- case WM_COMMAND:
- switch(LOWORD(wParam))
- {
- case 111 :
- onClickConfirm(hwnd);
- SetFocus(GetDlgItem(hwnd,113));
- break;
- case 112 :
- onClickApply();
- SendMessage(hwnd,WM_CLOSE,0,0);
- break;
- case 122 :
- GetMyPath(hwnd);
- break;
- case 1122 :
- SendMessage(hwnd,WM_CLOSE,0,0);
- break;
- case 113:
- switch (HIWORD(wParam))
- {
- case CBN_SELCHANGE :
- iselected =SendMessage(GetDlgItem(hwnd,113), CB_GETCURSEL , 0,0);
- SendMessage(GetDlgItem(hwnd,113), CB_GETLBTEXT , iselected,reinterpret_cast<LPARAM>(buffer));
- if(BST_UNCHECKED==SendMessage(GetDlgItem(hwnd,1222),BM_GETCHECK ,0,0))
- handleCBBSel(hwnd,buffer);
- break;
- }
- break;
- case 121 :
- if(BST_CHECKED==SendMessage(GetDlgItem(hwnd,121),BM_GETCHECK ,0,0))
- SendMessage(GetDlgItem(hwnd,121),BM_SETCHECK ,BST_UNCHECKED,0);
- else SendMessage(GetDlgItem(hwnd,121),BM_SETCHECK ,BST_CHECKED,0);
- break;
- case 1222 :
- if(BST_CHECKED==SendMessage(GetDlgItem(hwnd,1222),BM_GETCHECK ,0,0))
- SendMessage(GetDlgItem(hwnd,1222),BM_SETCHECK ,BST_UNCHECKED,0);
- else SendMessage(GetDlgItem(hwnd,1222),BM_SETCHECK ,BST_CHECKED,0);
- SetFocus(GetDlgItem(hwnd,113));
- break;
- }
- break;
- case WM_CLOSE:
- PostQuitMessage(0);
- break;
- }
- return DefWindowProc(hwnd,msg,wParam,lParam);
- }
- HWND CreateToolTip(int toolID, HWND hDlg, LPSTR pszText)
- {
- if (!toolID || !hDlg || !pszText)
- {
- return FALSE;
- }
- // Get the window of the tool.
- HWND hwndTool = GetDlgItem(hDlg, toolID);
- // Create the tooltip.
- HWND hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL,
- WS_POPUP |TTS_ALWAYSTIP | TTS_BALLOON,
- CW_USEDEFAULT, CW_USEDEFAULT,
- CW_USEDEFAULT, CW_USEDEFAULT,
- hDlg, NULL,
- NULL, NULL);
- if (!hwndTool || !hwndTip)
- {
- return (HWND)NULL;
- }
- // Associate the tooltip with the tool.
- TOOLINFO toolInfo = { 0 };
- toolInfo.cbSize = sizeof(toolInfo);
- toolInfo.hwnd = hDlg;
- toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
- toolInfo.uId = (UINT_PTR)hwndTool;
- toolInfo.lpszText = pszText;
- SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
- SendMessageW(hwndTip, TTM_SETMAXTIPWIDTH,0, (LPARAM)350);
- return hwndTip;
- }
- void CreateDialogBox()
- {
- HINSTANCE inst = GetModuleHandle(NULL);
- HWND hwnd = GetConsoleWindow();
- CoInitialize(NULL);
- WNDCLASSEX wc = {0};
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.lpfnWndProc = DialogProc;
- wc.hInstance = inst;
- wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
- wc.hCursor = LoadCursor(NULL,IDC_ARROW);
- wc.lpszClassName = TEXT("DialogClass");
- RegisterClassEx(&wc);
- RECT rect;
- GetWindowRect(hwnd,&rect);
- HWND hdialog = CreateWindowEx(WS_EX_DLGMODALFRAME,"DialogClass","Settings",
- WS_VISIBLE | WS_SYSMENU | WS_CAPTION , rect.left+100,
- rect.top+70, 500, 200,NULL, NULL, inst, NULL);
- CreateWindow("button","Confirm",WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_BORDER ,90, 130, 90, 25,
- hdialog, (HMENU) 111, NULL, NULL);
- CreateWindow("button","Apply Settings",WS_VISIBLE | WS_CHILD | WS_BORDER,190, 130, 120, 25,
- hdialog, (HMENU) 112, NULL, NULL);
- CreateWindow("button","Cancel",WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_BORDER,320, 130, 90, 25,
- hdialog, (HMENU) 1122, NULL, NULL);
- CreateWindow("COMBOBOX","Index",WS_VISIBLE | WS_CHILD | WS_TABSTOP | CBS_DROPDOWNLIST
- | WS_VSCROLL | WS_TABSTOP | WS_EX_LEFTSCROLLBAR,
- 90, 5, 100,150,hdialog, (HMENU) 113, NULL, NULL);
- CreateWindow("static","Index :",WS_VISIBLE | WS_CHILD,5, 7, 50, 25,
- hdialog, (HMENU) 114, NULL, NULL);
- CreateWindow("static","Title :",WS_VISIBLE | WS_CHILD,5, 36, 50, 25,
- hdialog, (HMENU) 115, NULL, NULL);
- CreateWindow("edit","",WS_VISIBLE | WS_CHILD |WS_BORDER | WS_TABSTOP ,90, 34, 160, 20,
- hdialog, (HMENU) 116, NULL, NULL);
- CreateWindow("static","Path :",WS_VISIBLE | WS_CHILD,5, 61, 50, 25,
- hdialog, (HMENU) 117, NULL, NULL);
- CreateWindow("button","...",WS_VISIBLE | WS_CHILD,445, 60, 25, 20,
- hdialog, (HMENU) 122, NULL, NULL);
- CreateWindow("edit","",WS_VISIBLE | WS_CHILD |ES_AUTOHSCROLL |WS_BORDER | WS_TABSTOP ,90, 60, 350, 20,
- hdialog, (HMENU) 118, NULL, NULL);
- CreateWindow("static","Command :",WS_VISIBLE | WS_CHILD,5, 81, 80, 25,
- hdialog, (HMENU) 119, NULL, NULL);
- CreateWindow("edit","",WS_VISIBLE | WS_CHILD |ES_AUTOHSCROLL |WS_BORDER | WS_TABSTOP ,90, 84, 350, 20,
- hdialog, (HMENU) 120, NULL, NULL);
- CreateWindow("button","Password :",WS_VISIBLE | WS_CHILD | BS_CHECKBOX | BS_LEFTTEXT,
- 5, 104, 100, 25,hdialog, (HMENU) 121, NULL, NULL);
- CreateWindow("button","change Index",WS_VISIBLE | WS_CHILD | BS_CHECKBOX ,
- 195, 5, 110, 25,hdialog, (HMENU) 1222, NULL, NULL);
- LPSTR pszText ="Any Title you chose";
- CreateToolTip(116,hdialog,pszText);
- pszText ="path to executable, for system executabes :\r\n explorer.exe \
- is the same as c:\\windows\\explorer.exe";
- CreateToolTip(118,hdialog,pszText);
- pszText ="Command line specific for each executabe.\
- \r\n explorer.exe takes the Folder Path as command line";
- CreateToolTip(120,hdialog,pszText);
- pszText ="change index without changing text in Title, Path And Command\
- Text Fields, Hit confirm To associate the new index.";
- CreateToolTip(1222,hdialog,pszText);
- pszText ="To Delete an index Entry, Hit Confirm with\n\
- Title, Path And Command Text Fields all empty.";
- CreateToolTip(113,hdialog,pszText);
- SendMessage(GetDlgItem(hdialog,113), CB_RESETCONTENT,0,0);
- for(int i=0;i<19;i++)
- SendMessage(GetDlgItem(hdialog,113), CB_ADDSTRING, 0,reinterpret_cast<LPARAM>(aindex[i].c_str()) );
- for(int i=0;i<20;i++)
- SendMessage(GetDlgItem(hdialog,113), CB_ADDSTRING, 0,reinterpret_cast<LPARAM>(findex[i].c_str()) );
- SendMessage(GetDlgItem(hdialog,113), CB_SETCURSEL,0,0);
- SendMessage(hdialog,WM_COMMAND,MAKEWPARAM(113,CBN_SELCHANGE),(LPARAM)GetDlgItem(hdialog,113));
- SetFocus(GetDlgItem(hdialog,113));
- HFONT SmallFont = CreateFont(14,0,0,0,FW_BOLD,FALSE,FALSE,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS,TEXT("Arial"));
- SendMessage (GetDlgItem(hdialog,116), WM_SETFONT, WPARAM (SmallFont), TRUE);
- SendMessage (GetDlgItem(hdialog,118), WM_SETFONT, WPARAM (SmallFont), TRUE);
- SendMessage (GetDlgItem(hdialog,120), WM_SETFONT, WPARAM (SmallFont), TRUE);
- SHAutoComplete(GetDlgItem(hdialog,118),SHACF_DEFAULT);
- SHAutoComplete(GetDlgItem(hdialog,120),SHACF_DEFAULT);
- EnableWindow(hwnd, FALSE);
- SetForegroundWindow(hdialog);
- MSG Msg;
- while(GetMessage(&Msg, NULL, 0, 0))
- {
- if(!IsDialogMessage(hdialog, &Msg))
- {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
- }
- EnableWindow(hwnd,TRUE);
- DestroyWindow(hdialog);
- SetForegroundWindow(hwnd);
- }
- WNDPROC wpOrigEditProc;
- LRESULT APIENTRY EditProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
- {
- switch(msg)
- {
- case WM_GETDLGCODE:
- if(wParam == VK_RETURN ) return DLGC_WANTALLKEYS;
- case WM_KEYDOWN:
- if(wParam == VK_RETURN )SendMessage(GetParent(hwnd),WM_CLOSE,0,0);
- }
- return CallWindowProc(wpOrigEditProc, hwnd, msg,wParam, lParam);
- }
- char data1[MAX_PATH];
- char data2[MAX_PATH];
- LRESULT CALLBACK DialogRunProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
- {
- switch(msg)
- {
- case WM_CREATE:
- break;
- case WM_GETDLGCODE:
- if(wParam==VK_RETURN) return DLGC_WANTALLKEYS;
- break;
- case WM_KEYDOWN:
- if(wParam == VK_RETURN)
- SendMessage(hwnd,WM_CLOSE,0,0);
- break;
- case WM_CLOSE:
- SendMessage(GetDlgItem(hwnd,118),WM_GETTEXT,MAX_PATH,reinterpret_cast<LPARAM>(data1));
- SendMessage(GetDlgItem(hwnd,120),WM_GETTEXT,MAX_PATH,reinterpret_cast<LPARAM>(data2));
- if(strlen(data1) || strlen(data2)) ShellExecute(0,NULL,data1,data2,NULL,1);
- PostQuitMessage(0);
- break;
- }
- return DefWindowProc(hwnd,msg,wParam,lParam);
- }
- void CreateRunDialogBox()
- {
- HINSTANCE inst = GetModuleHandle(NULL);
- HWND hwnd = GetConsoleWindow();
- CoInitialize(NULL);
- WNDCLASSEX wc = {0};
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.lpfnWndProc = DialogRunProc;
- wc.hInstance = inst;
- wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
- wc.hCursor = LoadCursor(NULL,IDC_ARROW);
- wc.lpszClassName = TEXT("DialogRunClass");
- RegisterClassEx(&wc);
- RECT rect;
- GetWindowRect(hwnd,&rect);
- HWND hdialog = CreateWindowEx(WS_EX_DLGMODALFRAME,"DialogRunClass","Execute",
- WS_VISIBLE, rect.left+40,rect.top+130, 500, 100,NULL, NULL, inst, NULL);
- CreateWindow("static","Executable :",WS_VISIBLE | WS_CHILD,2, 10, 90, 25,
- hdialog, (HMENU) 117, NULL, NULL);
- CreateWindow("edit","",WS_VISIBLE | WS_CHILD |ES_AUTOHSCROLL |WS_BORDER | WS_TABSTOP ,95, 10, 350, 20,
- hdialog, (HMENU) 118, NULL, NULL);
- CreateWindow("static","Command :",WS_VISIBLE | WS_CHILD,2, 33, 90, 25,
- hdialog, (HMENU) 119, NULL, NULL);
- CreateWindow("edit","",WS_VISIBLE | WS_CHILD |ES_AUTOHSCROLL |WS_BORDER | WS_TABSTOP ,95, 35, 350, 20,
- hdialog, (HMENU) 120, NULL, NULL);
- HFONT SmallFont = CreateFont(14,0,0,0,FW_BOLD,FALSE,FALSE,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS,TEXT("Arial"));
- SendMessage (GetDlgItem(hdialog,118), WM_SETFONT, WPARAM (SmallFont), TRUE);
- SendMessage (GetDlgItem(hdialog,120), WM_SETFONT, WPARAM (SmallFont), TRUE);
- SHAutoComplete(GetDlgItem(hdialog,118),SHACF_DEFAULT);
- SHAutoComplete(GetDlgItem(hdialog,120),SHACF_DEFAULT);
- wpOrigEditProc = (WNDPROC) SetWindowLong(GetDlgItem(hdialog,118),GWL_WNDPROC, (LONG) EditProc);
- wpOrigEditProc = (WNDPROC) SetWindowLong(GetDlgItem(hdialog,120),GWL_WNDPROC, (LONG) EditProc);
- EnableWindow(hwnd, FALSE);
- SetForegroundWindow(hdialog);
- SetFocus(GetDlgItem(hdialog,118));
- MSG Msg;
- while(GetMessage(&Msg, NULL, 0, 0))
- {
- if(!IsDialogMessage(hdialog, &Msg))
- {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
- }
- EnableWindow(hwnd,TRUE);
- DestroyWindow(hdialog);
- SetForegroundWindow(hwnd);
- }
- void color(DWORD d)
- {
- SetConsoleTextAttribute(handle,d);
- // 10 = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
- // 11 = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
- // 12 = red
- // 14 = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY
- // 240 = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
- // 249 = blue bk white
- }
- bool setPass(LPSTR password,bool changePass)
- {
- char tmp[35];
- char pass1[15];
- char pass2[15];
- int i=0;
- DWORD lResult,Dwsize=33;
- HKEY hkey;
- lResult=RegOpenKeyEx(HKEY_CURRENT_USER,TEXT("SOFTWARE"),0,KEY_READ,&hkey);
- if(ERROR_SUCCESS==lResult)
- lResult=RegGetValue(hkey,TEXT("MOSAIDTERMINAL"),TEXT("TerminalPass"),RRF_RT_REG_SZ,NULL,tmp,&Dwsize);
- RegCloseKey(hkey);
- if(ERROR_SUCCESS==lResult)
- {
- if(changePass)
- {
- cls();
- color(14);
- cout<<"Enter old pass:";
- i=0;
- while( (pass2[i]=getch())!='\r'&& i<14 )
- {
- putchar('*');
- i++;
- }
- pass2[i]='\0';
- if( strcmp(tmp,pass2)==0 ) goto askpass;
- else
- {
- color(12);
- cout<<"\nwrong pass!";
- color(14);
- cout<<"\nContinue...";
- getch();
- return false;
- }
- }
- else
- {
- memcpy(password,tmp,13);
- return true;
- }
- }
- else
- {
- if(!changePass)return false;
- askpass:
- i=0;
- cls();
- color(14);
- cout<<"Enter new pass:";
- while( (pass1[i]=getch())!='\r'&& i<14 )
- {
- putchar('*');
- i++;
- }
- pass1[i]='\0';
- i=0;
- cout<<"\nConfirm new pass:";
- while( (pass2[i]=getch())!='\r'&& i<14 )
- {
- putchar('*');
- i++;
- }
- pass2[i]='\0';
- if( strcmp(pass1,pass2)==0 )
- {
- HKEY hkey;
- DWORD lResult,Dwsize=13;
- lResult=RegCreateKeyEx(HKEY_CURRENT_USER,TEXT("SOFTWARE\\MOSAIDTERMINAL"),
- 0,NULL,0,KEY_ALL_ACCESS,NULL,&hkey,NULL);
- lResult=RegSetValueEx(hkey,TEXT("TerminalPass"),0,REG_SZ,(BYTE*)pass1,13);
- RegCloseKey(hkey);
- if(ERROR_SUCCESS==lResult)
- {
- color(10);
- cout<<"\nSuccess...";
- memcpy(password,pass1,13);
- color(14);
- cout<<"\nContinue...";
- getch();
- return true;
- }
- }
- else goto askpass;
- }
- return false;
- }
- bool fpassword(LPSTR password)
- {
- gotoxy(46,4);
- color(12);
- bool b=0;
- char pass[15];
- int i=0;
- while( (pass[i]=getch())!='\r'&& i<14 )
- {
- putchar('*');
- i++;
- }
- pass[i]='\0';
- if( strcmp(pass,password)==0 )b=1;
- else{
- gotoxy(38,5);
- cout<<"wrong password.";
- getch();
- }
- return b;
- }
- int mdays(int m,int y)
- {
- if(m==2)
- if(y%4==0 && y%100!=0 || y%400==0) return 29;
- else return 28;
- else
- if(m%2==0 && m<=7 || m%2!=0 && m>7) return 30;
- else return 31;
- }
- int st(int m_day,int day_i)
- {
- while(m_day>1)
- {
- m_day--;
- day_i--;
- if(day_i<0) day_i=6;
- }
- return day_i;
- }
- void printDate(void)
- {
- time_t t = time(0);
- struct tm * now_t = localtime(&t);
- char buf[80];
- strftime(buf, sizeof(buf), "%Y/%m/%d %X",now_t);
- int year = now_t->tm_year;
- int month = now_t->tm_mon+1;
- int day_m = now_t->tm_mday;
- int day_i = now_t->tm_wday;
- int m_days = mdays(month,year);
- day_i = st(day_m,day_i);
- gotoxy(35,18);
- cout<<buf;
- int a =1;
- gotoxy(30,20);
- color(14);
- printf(" Su Mo Tu We Th Fr Sa ");
- color(11);
- for(int i=0;i<=5;i++)
- {
- gotoxy(30,22 + i);
- for(int j=0;j<7;j++)
- {
- if(i==0 && j<day_i) printf(" ");
- else
- {
- if(a == day_m)
- {
- color(12);
- printf("%4d",a);
- color(11);
- }
- if(a<=m_days && a != day_m)printf("%4d",a);
- a++;
- }
- }
- }
- }
- void parse(string& arg)
- {
- if(arg.compare("ss")==0 || arg.compare("SS")==0)
- {
- CreateDialogBox();
- return;
- }
- if(arg.compare("rr")==0 || arg.compare("RR")==0)
- {
- CreateRunDialogBox();
- return;
- }
- if(arg.compare("xx")==0 || arg.compare("XX")==0)
- {
- exit(0);
- return;
- }
- if(arg.compare("aa")==0 || arg.compare("AA")==0)
- {
- cls();
- color(10);
- cout<<"\n "<<char(4)<<" FEATUTRES:\n\n";
- color(11);
- cout<<" "<<char(16)<<" Quick access to Files and Folders.\n";
- cout<<" "<<char(16)<<" Quick access to play-lists and videos.\n";
- cout<<" "<<char(16)<<" Quick access to Anything you want.\n";
- cout<<" "<<char(16)<<" Windows's Run Command.\n";
- cout<<" "<<char(16)<<" Prevent screen saver and display off.\n";
- cout<<" "<<char(16)<<" Mouse Double Click to execute .\n\n";
- color(10);
- cout<<"\n "<<char(4)<<" ABOUT:\n\n";
- color(11);
- cout<<" E-Mail : mosaid_radouan@yahoo.fr \n";
- cout<<" C 2015 By MOSAID.\n\n";
- printDate();
- gotoxy(0,16);
- color(12);
- cout<<" "<<char(4)<<" Continue...";
- getch();
- cls();
- design();
- choices();
- return;
- }
- if(arg.compare("pp")==0 || arg.compare("PP")==0)
- {
- char password[15];
- char cara;
- cls();
- color(14);
- cout<<"Change pass ? (y/n):";
- cara=getch();
- if(cara =='y' || cara == 'Y' )setPass(password,true);
- cls();
- design();
- choices();
- return;
- }
- if(arg.compare("mm")==0 || arg.compare("MM")==0)
- {
- HWND hwnd = GetConsoleWindow();
- ShowWindow(hwnd,SW_MINIMIZE);
- return;
- }
- for(int k=0;k<myVec.size();k++)
- {
- if(myVec[k].index.compare(arg)==0)
- {
- if(myVec[k].password.compare("1")==0)
- {
- char passwd[15];
- if(!setPass(passwd,false))
- {
- gotoxy(38,5);
- color(12);
- cout<<"password not set.";
- getch();
- return;
- }
- if(!fpassword(passwd)) return;
- }
- ShellExecute(0,NULL,myVec[k].path.c_str(),myVec[k].command.c_str(),NULL,1);
- return;
- }
- }
- }
- void cls()
- {
- color(0);
- HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE );
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- DWORD dwConSize;
- GetConsoleScreenBufferInfo( hConsole, &csbi );
- dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
- gotoxy(0,0);
- for( int i=0;i<dwConSize;i++)cout<<' ';
- gotoxy(0,0);
- }
- void DisplayError(LPCSTR lpszFunction)
- {
- // Retrieve the system error message for the last-error code
- LPVOID lpMsgBuf;
- LPVOID lpDisplayBuf;
- DWORD dw = GetLastError();
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- dw,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0, NULL );
- // Display the error message and exit the process
- lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
- (lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)lpszFunction) + 40) * sizeof(TCHAR));
- StringCchPrintf((LPTSTR)lpDisplayBuf,
- LocalSize(lpDisplayBuf) / sizeof(TCHAR),
- TEXT("%s failed with error %d: %s"),
- lpszFunction, dw, lpMsgBuf);
- MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK);
- LocalFree(lpMsgBuf);
- LocalFree(lpDisplayBuf);
- }
- int BringWToTop(void)
- {
- PROCESSENTRY32 entry;
- entry.dwSize = sizeof(PROCESSENTRY32);
- HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
- if (Process32First(snapshot, &entry) == TRUE)
- {
- while (Process32Next(snapshot, &entry) == TRUE)
- {
- if (stricmp(entry.szExeFile, "target.exe") == 0)
- {
- HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
- //SetForegroundWindow(
- CloseHandle(hProcess);
- }
- }
- }
- CloseHandle(snapshot);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement