Jump to content

icuurd12b42

Active Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by icuurd12b42

  1. Thanks. The term was used with my co workers often in my days. It is still a valid term but maybe obsolete? I dont know but good find on wikipedia.
  2. Where? Where did I say you need to run as admin to show a tool tip? Where? Quote me! Are you trying to play with my head here? Thanks,
  3. Like the code in the onclick function in the main post? Yeah, that does not work. Any idea why? Never said you need to run as admin to show a ToolTip in the gui, just that the idea to bypass the problem via launching an app was not reasonable. Yep, I actually had that code too, not working as well as your video though, the label often got clipped, half drawn. Did you have to add extra flags to the label window?
  4. Thanks. I just reformatted the code in the main post. the format was ruined when I edited it last time
  5. Neat. Thanks for the info. I like the file scope vars. that is useful
  6. That's not the reason... Actually, a tool tip is a window like everything you see in windows, your GUI, your controls.... You can have as many as you want. In fact AutoIT has 3 tool tip windows active, one for ToolTip(), one for GUICtrlSetTip() and one for _GUICtrlEdit_ShowBalloonTip() All of those can be up at the same time. A tool tip window can manage many controls or you can have one tip window per control. in this case they could co-exists, just like all 3 pre-canned tool tips can co exist. I proper fix would be to go the _WinApi way to create multiple tool tip windows and control their text and existence individually. There are a few example code on the site but none of them work Anyway, the worst thing about ToolTip is it goes on top of everything instead of on top the window that called it. Meaning you get nasty messages from an application you are not using while in Word for example and that confuses the user. See my tooltip replacement Launching another app is a bad idea. You get UAC window popping or the dreaded "This publisher cannot be verified" message. I can deal with that message launching the app, but not every time I need to pop up a tip to the user.
  7. always use local to define the variables in a function or you will have troubles in the long run, for example for $i loops with undefined scope defaults to global for $i so 2 functions using a for $i loop will interfere with each other (if the seconds function is called in the loop of the first) as for the the code, you never declared your variables so they are all global. I am curious about the working example Local $Count = 1 Test() $Count = 1 Test2() Func Test() Local $Test=1 ConsoleWrite("Running function Test - $Test = " & $Test & @CRLF) $Count += 1 If $Count = 10 Then Return $Test += 1 Test() EndFunc Func Test2() Local Static $Test=1 ConsoleWrite("Running function Test2 - $Test = " & $Test & @CRLF) $Count += 1 If $Count = 10 Then Return $Test += 1 Test2() EndFunc Why can Test and Test2 see $Count... $Count is local...
  8. The preferred method is ShellExecute ( "http://www.google.com" ,"" ,"", "open");
  9. I'd stick to 32 bits. I just compiled my app to 64bit and some part dont work. mainly the rich edit hyperlink clicking
  10. My final implementation loads the record sets in a global string one (256byte) record at a time, bypassing the fileread maximum. I also have 8 arrays of 1000 in size to keep the records in memory (name, text, date, etc). Then I pass the string to the Rich Edit, making sure to re-adjust the rich edit data size maximum (default 32k) to match the final string size. I did limit the number of records to 1000 items (* 256 for size), as showing more than that in the rich edit is really not needed (too large a document), the rich edit formats the records in a click-able list fashion. I can safely load 1000 records of 256 byte in arrays, stuff the array in a formatted rtf buffer and send it to the rich edit. total memory size ~1000k (arrays + buffer+copy of buffer in rich edit)
  11. I had a ton of problems with ToolTip. Mainly it showed tips on top of everything. when my application was behind or minimised the tips would show tip on the desktop over another app, confusing people. This alternative uses a stub edit box's tool tip to replace ToolTip, It will stick to the main window, not go on top of everything and not display if the window is minimized or invisible. I also added message importance, along with a control variable so you can tone down how many messges you generate for informing the user. the required control variables global $control_MaxMsgLevel = 3; what level of messages allowed to show global $control_ShowTrayMsg = 1; display in tray if minimised global $control_TimeOutFac = 1; a time multiplication factor so message stick longer or shorter global $control_LogMsg = 0; for logging, logging code not included global $hMainWnd; set to your GUI the function global $stube = -1; func OnHideTip() _GUICtrlEdit_HideBalloonTip(GUICtrlGetHandle($stube)); AdlibUnRegister("OnHideTip"); EndFunc Func Tip($x,$y,$title,$message,$icon,$level,$ctrl = 0,$timeoutS = 1,$delay = 0) if($level>$control_MaxMsgLevel) then return 0; local $lx = $x; local $ly = $y; if($ctrl) Then local $pos = _WinAPI_GetWindowPlacement($hMainWnd); local $wx = DllStructGetData($pos, "rcNormalPosition",1) local $wy = DllStructGetData($pos, "rcNormalPosition",2) local $tRect = _WinAPI_GetWindowRect(GUICtrlGetHandle($ctrl)); $lx += (DllStructGetData($tRect, "Left") + DllStructGetData($tRect, "Right"))/2 -$wx; $ly += (DllStructGetData($tRect, "Top") + DllStructGetData($tRect, "Bottom"))/2 -$wy-28; EndIf if($stube = -1) Then $stube = GUICtrlCreateEdit("",$lx,$ly,0,0); _WinAPI_ShowWindow(GUICtrlGetHandle($stube), @SW_HIDE); EndIf GUICtrlSetPos($stube,$lx,$ly); _GUICtrlEdit_ShowBalloonTip(GUICtrlGetHandle($stube), $title,$message,$icon); AdlibUnRegister("OnHideTip"); AdlibRegister("OnHideTip",$timeoutS*$control_TimeOutFac * 1000); if($control_ShowTrayMsg and IsMinimized()) then TrayTip($title,$message,$timeoutS*$control_TimeOutFac,$icon); if($control_LogMsg) then LogMessage($title, $message) if($delay) sleep($timeoutS*$control_TimeOutFac * 1000); EndFunc func IsMinimized() return ((WinActive("[ACTIVE]") = 16) or (_WinAPI_IsWindowVisible($hMainWnd) = 0)); EndFunc to call Level 0, message always show if control_MaxMsgLevel is 0 or higher Tip(0,0,"Error","There was a problem",$TTI_ERROR,0,$ctrl_UserDD) Level 2 will only show if the options are set to display message of that high verbose level control_MaxMsgLevel = 2 or higher Tip(0,0,"Tip","Did you know you can lower the tip level so this does not show anymore",$TTI_INFO,2,$ctrl_UserDD)
  12. After looking far and wide on the site for playing sounds at volume on all platforms, I figured they is not solution but to take control of the sound system as you would in a game.... Not to rely on the OS GUI to setup the volume as in the app volume in WIN:8, but in the application itself, like most games on Windows.. I decided to use my fmod experience for overcoming the SoundPlay and SoundSetWaveVolume limitation in AutoIT. As you may have found out loooking in the docs, SoundSetWaveVolume sets the volume of the wav mixer in older window's OS. it means you change the wav out (for every app) to the volume specified. In short, you screwed up the user's settings. So the user will be wondering why his app or game sound is lower than usuall because your app screwed with his setttings... ,confusion. The best thing to do is to control the volume of each sound your app plays. I have writen a fmod wrapper for gamemaker so I figure I would insight you into using fmod for this type of need. You need to make a fmod wrapper dll and you need fmod. fmod plays all types of sounds on all windows platforms. And the licensing is interesting if you play your cards right... Basic dumb ass setup for AutoIT and FMOD: FMOD: get FMOD at http://fmod.org/fmod-downloads.html download the API and install it. Copy the fmod dll in your autoit project... AutoIT code func myplaysound($filename, $vol) ;filename is the full path and name.ext ;vol is a 0 to 1 value return DllCall(@ScriptDir & "\myFMODwrap.DLL", "int:cdecl", "myplaysound", "str", $filename, "float",$vol) EndFunc create a wrapper dll myFMODwrap with code::blocks or ms dev studio with this file: new dll project: myFMODwrap main.cpp code. #include "main.h" #include <windows.h> #include <fmod.h> #include <fmod_errors.h> #include <string> #include <stdio.h> #define MYEXPORT __declspec (dllexport) int ERRCHECK(FMOD_RESULT result) { if (result != FMOD_OK) { MessageBoxA(NULL, FMOD_ErrorString(result), MB_IConerror); return 0; } return 1; } extern "C" { // a sample exported function DLL_EXPORT int myplaysound(LPCSTR filename, float vol) { FMOD_SYSTEM *system; FMOD_SOUND *sound1; FMOD_CHANNEL *channel = 0; FMOD_RESULT result; unsigned int version; int playing = 0; //MessageBoxA(NULL,"Debug", "1", MB_IConerror); //char *filename = strtok((lpszArgument),",\""); //MessageBoxA(NULL, filename,"myPlaySound", MB_IConerror); // std::string msg = "Hello"; // char msg2[20]; // float my_float = 10.0f; // sprintf((char*)msg2, "%f", vol); // msg = msg + msg2;// + ftoa(my_float); // MessageBox(NULL,"In the dll", msg2,0); result = FMOD_System_Create(&system); //MessageBoxA(NULL,"Play Called", "FMOD_System_Create", MB_IConerror); if(ERRCHECK(result)) { result = FMOD_System_GetVersion(system, &version); if(ERRCHECK(result)) { if (version == FMOD_VERSION) { result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL); //MessageBoxA(NULL,"gpPlaySound - by Gilles Page", "FMOD_System_Init", MB_IConerror); if(ERRCHECK(result)) { result = FMOD_System_CreateSound(system, filename, FMOD_HARDWARE | FMOD_LOOP_OFF, 0, &sound1); //MessageBoxA(NULL,"gpPlaySound - by Gilles Page", "FMOD_System_CreateSound", MB_IConerror); if(ERRCHECK(result)) { result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, 0, &channel); //MessageBoxA(NULL,"gpPlaySound - by Gilles Page", "FMOD_System_PlaySound", MB_IConerror); if(ERRCHECK(result)) { result = FMOD_Channel_SetVolume(channel,vol); if(ERRCHECK(result)) { /// sprintf((char*)msg2, "%f", vol); /// msg = msg + msg2;// + ftoa(my_float); /// MessageBox(NULL,"In the playing", msg2,0); do { result = FMOD_Channel_IsPlaying(channel, &playing); FMOD_System_Update(system); Sleep(10); } while (playing); } } FMOD_Sound_Release(sound1); } result = FMOD_System_Close(system); } } } FMOD_System_Release(system); } return 1; } } //EXTERN "C" extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: // attach to process // return FALSE to fail DLL load break; case DLL_PROCESS_DETACH: // detach from process break; case DLL_THREAD_ATTACH: // attach to thread break; case DLL_THREAD_DETACH: // detach from thread break; } return TRUE; // succesful } 1) create a new dll project with ms dev studio or code::blocks 2) replace the generated main code with the suplied code 3) add fmod 's inc folder to your additional include in ms dev or code;;blocks 4) add fmodexp_vc.lib (ms studio) or fmodex.a (code::blocks) to your additional lib options 5) compile and copy the dll to your au3 directory, and also copy fmodex.dll to the same location I tried to acess fmod directly from the autoit script but it had trouble with the double ref **system. so a wrapper did the job for me. I have a method to play the sound, though locking the GUI... you can add the fmod update call to your api and call it from your main GUI loop for asynchronus playing... or in a timed function call... FMODUptate()....
  13. Right so I'm trying to have a bunch of tool tips appear on the screen, mainly to display entry error in input boxes when you hit a button. func OnOK() if(GetUserName() = "" ) then ShowTimedTip(ctrl_UserDD,1000,"Input Error", "User name is invalid",$TTI_ERROR) if(GetDestName() = "" ) then ShowTimedTip(ctrl_DestDD,1000,"Input Error","Destination name is invalid",$TTI_ERROR) if(GetMessage() = "" ) then ShowTimedTip(ctrl_MsgTB,1000,"Input Error","Please type a message",$TTI_ERROR) endfunc The problem is the ToolTip wont allow multiple tips with GUICtrlSetTip() you CANNOT trigger the tip to show... I added stub EditBoxes because I can trigger the tip of edit boxes $_POP_HWND[$_POP_AT] =GUICtrlCreateEdit("",$lx,$ly,0,0) GUICtrlSetTip($_POP_HWND[$_POP_AT], $message,$title,$icon,1); _WinAPI_ShowWindow(GUICtrlGetHandle($_POP_HWND[$_POP_AT]),@SW_HIDE) _GUICtrlEdit_ShowBalloonTip(GUICtrlGetHandle($_POP_HWND[$_POP_AT]), $title,$message,$icon) However it's useless because this tip TOO can only be a singleton. If I show one tip, it nukes the previous at the other location Finally I went and tried every example involving _CreateToolTip on the site and absolutely none of them work so I cant tell if I can show more than one. I assume you could if you call _CreateToolTip multiple times, that would create a tip window dedicated to a single control box this is the result test code func onclick() ;create stub ctrl, set the tip to it, and show the tip Global $idstub = GUICtrlCreateLabel("Stub", 50, 150, 120, 22) Global $hstub = GUICtrlGetHandle($idstub) Global $hTip = _GUIToolTip_Create($hMainWnd,BitOR($TTS_ALWAYSTIP,$TTS_BALLOON)) _GUIToolTip_AddTool($hTip, $hstub, "Button Two: This is the tooltip for Button2") _GUIToolTip_SetTitle($hstub,"Title",3) _GUIToolTip_Activate($hTip) endfunc but it's a dud like all the site sample codes I found on the forum. I must be doing something wrong... Has anyone ever been able to show multiple tool tips at the same time? I would like a function like ShowTimedTip($ctrl,$time_ms,$title,$text,$icon) that would create a non blocking, non replacing tip on screen which would self destruct after the time elapsed. I can handle the timed self destruct but I really need help on getting that darn _GUIToolTip to work.
  14. 25 Megs is still perfectly reasonable in some cases. I was just wondering if AutiIT had a limit of it's own for arrays. I'll check the faq. I changed my method to be more streamlined. I am paging by recordset right now, I would rather not to have to page the rtf document data (the record layout).
  15. Thanks for the code. which I have. My query is about memory limits of AutoIT for FileRead("test.txt") as per the help I want to know if I'm going to cap my file reading, Which I did, but what size is the size cap size??? How much can I allocate if I decided to hold records in memory? couljd I hold 100000 text messages in an array? 100000*256 bytes. In an array? Or even in the rtf richedit box? what are the limits? does anyone know? Each instances ov the program running would need 24MB allocated in a records[100000] array..
  16. I compiled a script that sends a file to a richedit the file content but the app simply exites silently when my file was just a few MB large. So I have a few questions about the things invoved that I used FileOpen Any mem/disk size limit?FileRead Same, Size limit? how about the variable that holds it? 2GB?local $txt =FileRead($hfile) - local $txt: Size limit for 32bit? Size limit for 64 bit?global $gtxt =FileRead($hfile) - local $gtxt: Size limit for 32bit? Size limit for 64 bit?richedit Size limit to add, to set, to insert, to whole content?local $arr[N] - N limit? arr[] limit (mem)?global $garr[N] - N limit? garr[] limit (mem)?Can Compile Script to exe compile to 64 bits? even if the compiler is 32 bits?To fix the crash I read the file line by line. but I cannot keep the whole file in memory, $filebuff += ReadLine()... crash at about 1.5 megs Thanks!
  17. To update on this, I managed to crash AutoIt with large files... 1.5 meg. actually that's not large at all... Not sure if it's the box, the api or even by entire rtf buffer, a global string variable.. So I ended up limiting the number of line in the box, meaning I also used less string space in the global string.
  18. Event more exact for what I needed to do. thanks
  19. Sorry to bump this but this is where google sent me looking for a "tray menu item bold" to find how to bold my app tray's first menu item. The sln is Global $trayaboutmnu = TrayCreateItem("MyApp! - About") TrayItemSetState($trayaboutmnu,512);
  20. I found out the rtf codes and figured out a streamline rtf format for the rich edit so I could go back to the original method of inverted insertion. local $File = FileOpen($filename, 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open message file") Else ;Name: and To; color is \cf1 in rtf local $NameHCol = "\red0\green0\blue0;" ;Name and to content color is \cf2 in rtf local $NameCol = "\red0\green0\blue164;" ;Data color is \cf3 in rtf local $DateCol = "\red0\green128\blue128;" ;Msg color is \cf4 in rtf local $MsgCol = "\red128\green0\blue128;" local $DocHeader = "{\rtf1\ansi\deff0{\colortbl;" & $NameHCol & $NameCol & $DateCol & $MsgCol &"}" local $DocFooter = "}" local $DocBody = ""; ;$DocBody = "\cf1Name: \cf2Gilles \cf1To: \cf2Daniel \cf3 \tab 2012/10.10 12:45:24\line\cf4 \tab \fs24 This is message1\line \fs16"; ;$DocBody = $DocBody & "\cf1Name: \cf2Gilles \cf1To: \cf2Daniel \cf3 \tab 2012/10.10 12:45:24\line\cf4 \tab \fs24 This is message2\line \fs16"; ;_GUICtrlRichEdit_SetText($RichEdit, $DocHeader & $DocBody & $DocFooter) _GUICtrlRichEdit_PauseRedraw($RichEdit) ;_GUICtrlRichEdit_SetText($RichEdit, "") local $ct = 0 local $bubble = "" local $from = "" $Line = FileReadLine ($file) local $reading = not (@error = -1) while ($reading) if $ct = 0 then $Bubble = $line ;AddText(@LF,$MsgCol,4) ;AddText($line & @LF ,$MsgCol,12) $DocBody = "\cf4 \tab \fs24 " & $line &"\line \fs16" & $DocBody elseif $ct = 1 then ;AddText($line & @LF, $DateCol,10) $DocBody = " \cf3 \tab " & $line &"\line" & $DocBody elseif $ct = 2 then ;AddText($line & ", ", $NameCol,10) ;AddText("To: ",$NameHCol,10) $DocBody = " \cf1To: \cf2" & $line & $DocBody elseif $ct = 3 then ;AddText($line & " ",$NameCol,10) ;AddText("From: ",$NameHCol,10) $DocBody = "\cf1Name: \cf2" & $line & $DocBody $from = $line EndIf $ct = $ct+1 if $ct= 4 then $ct = 0 EndIf $Line = FileReadLine ($file) $reading = not (@error = -1) wend ;_GuiCtrlRichEdit_Deselect($RichEdit) _GUICtrlRichEdit_SetText($RichEdit, $DocHeader & $DocBody & $DocFooter) _GUICtrlRichEdit_ResumeRedraw($RichEdit) FileClose($file); PlayAlert($Sound); GUISetState(@SW_RESTORE) ToolTip ( StringMultiLine($Bubble,60) ,$WindowX+100 ,$WindowY+150 ,$from, 1, 5) EndIf Sorry for the trouble!
  21. The only code missing the the creation of the richedit... Global $RichEdit = _GUICtrlRichEdit_Create($hWnd, "", 45, 6+25+25+25, $WindowW-45-6, $WindowH-6-25-25-25-6, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)); _GUICtrlRichEdit_SetUndoLimit($RichEdit, 0); _GUICtrlRichEdit_SetReadOnly($RichEdit, True); and the color variables local $col[3] $col[0] = 0 $col[1] = 0 $col[2] = 0 global $NameHCol = _ColorSetCOLORREF($col) $col[0] = 0 $col[1] = 0 $col[2] = 164 global $NameCol = _ColorSetCOLORREF($col) $col[0] = 0 $col[1] = 128 $col[2] = 128 global $DateCol = _ColorSetCOLORREF($col) $col[0] = 128 $col[1] = 0 $col[2] = 128 global $MsgCol = _ColorSetCOLORREF($col)
  22. hiya everyone. I just got AutoIT 4 days ago and I just completed my first business application. I really like AutoIT, it brings me back to my golden days as far as the GUI techniques are concerned. Anyway, I have a problem with sluggish code to format my Rich Edit box content and was wondering if there is a better way of dealing with this. I have a text file that I read like so: ... local $File = FileOpen($filename, 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open message file") Else _GUICtrlRichEdit_PauseRedraw($RichEdit) _GUICtrlRichEdit_SetText($RichEdit, "") local $txt = "" local $ct = 0 local $bubble = "" local $from = "" $Line = FileReadLine ($file) local $reading = not (@error = -1) while ($reading) if $ct = 0 then $Bubble = $line AddText(@LF,$MsgCol,4) AddText($line & @LF ,$MsgCol,12) elseif $ct = 1 then AddText($line & @LF, $DateCol,10) elseif $ct = 2 then AddText($line & ", ", $NameCol,10) AddText("To: ",$NameHCol,10) elseif $ct = 3 then AddText($line & " ",$NameCol,10) AddText("From: ",$NameHCol,10) $from = $line EndIf $ct = $ct+1 if $ct= 4 then $ct = 0 EndIf $Line = FileReadLine ($file) $reading = not (@error = -1) wend _GuiCtrlRichEdit_Deselect($RichEdit) _GUICtrlRichEdit_ResumeRedraw($RichEdit) FileClose($file); the problem I have is the content of the file, consisting of plain text lines, is reversed, and I have to show the end of the file first and the begining last. originally I was using a simple text box and simply did txt = line & txt in the loop, effectively reversing the stings order then I would add txt to the edit box in one shot But people did not like the yuky edit bot and wanted me to format the text, font wize and color wise Turned out the solution was possible with the rich edit box but the process is very slow. Here is the AddText function ; add text to the rich edit box, txt, color, fontsize func AddText($txt,$clr,$sz) _GUICtrlRichEdit_GotoCharPos($RichEdit, 0) _GUICtrlRichEdit_InsertText($RichEdit,$txt) _GUICtrlRichEdit_SetSel($RichEdit, 0, StringLen($txt)) _GuiCtrlRichEdit_SetCharColor($RichEdit, $clr) _GUICtrlRichEdit_SetFont($RichEdit, $sz) EndFunc I half expected some slow down, but not to the point it takes 10 seconds to format 200 lines It there a faster way? I'm thinking rtf... where I could put back my original concept and sent the entore content, rtf formated, in one shot to the control... Sorry, the forum nuked my code formating...
×
×
  • Create New...